:root {
  --bg: #101315;
  --surface: #181d1f;
  --surface-2: #20272a;
  --text: #f3f5ef;
  --muted: #8e9999;
  --line: rgba(255, 255, 255, .09);
  --accent: #c8ff62;
  --accent-soft: rgba(200, 255, 98, .13);
  --orange: #ffad66;
  --danger: #ff7474;
  --shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 86% -10%, rgba(200,255,98,.11), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; padding-bottom: 100px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 20px 12px;
}
.brand-button { border: 0; padding: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.brand-button:active { transform: translateY(1px); }

.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .2em; }
h1 { margin: 0; font-family: Georgia, serif; font-size: 35px; font-weight: 500; letter-spacing: -.04em; }
.accent { color: var(--accent); }

.avatar {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2);
  color: var(--accent); font-weight: 800;
}
.export-button {
  min-height: 40px; border: 1px solid rgba(200,255,98,.28); border-radius: 12px;
  padding: 0 13px; background: var(--accent-soft); color: var(--accent);
  font-family: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
}
.export-button:disabled { opacity: .55; cursor: wait; }

.content { padding: 6px 16px 28px; }
.loading-state, .empty-state { min-height: 55vh; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); text-align: center; }
.loader { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.date-switcher { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; margin: 8px 0 18px; }
.date-switcher button, .icon-button { border: 1px solid var(--line); background: var(--surface); border-radius: 13px; min-height: 42px; cursor: pointer; }
.date-heading { text-align: center; }
.date-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.date-heading button { min-height: 0; padding: 3px 7px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-card { padding: 13px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.stat-card strong { display: block; font-size: 19px; letter-spacing: -.04em; }
.stat-card span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }

.composer, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 19px; box-shadow: var(--shadow); }
.composer { padding: 12px; margin-bottom: 20px; }
.composer textarea { width: 100%; min-height: 54px; max-height: 220px; resize: none; overflow-y: hidden; border: 0; outline: 0; color: var(--text); background: transparent; padding: 5px 4px; line-height: 1.45; transition: height .12s ease; }
.composer textarea::placeholder, input::placeholder { color: #657071; }
.composer-actions {
  --composer-control-height: 42px;
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(76px, .8fr);
  align-items: stretch; gap: 7px;
}
.composer-actions > .segmented, .date-field, .composer-actions > .primary-button {
  height: var(--composer-control-height); min-width: 0; margin: 0;
  border: 1px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: 11px; font-weight: 700; line-height: 1;
}
.composer-actions > .segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; }
.composer-actions > .segmented button {
  min-width: 0; height: 34px; padding: 0 4px;
  font: inherit; line-height: 1; letter-spacing: 0;
}
.date-field {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 5px;
  overflow: hidden; background: var(--surface-2); color: var(--text); cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.date-field span { white-space: nowrap; }
.date-field input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.composer-actions > .primary-button { padding: 0 8px; font-family: inherit; font-size: 11px; font-weight: 800; line-height: 1; }
.field-label select { width: 100%; min-width: 0; height: 40px; border: 0; border-radius: 11px; background: var(--surface-2); color: var(--text); padding: 7px 8px; outline: none; color-scheme: dark; }
.segmented { display: flex; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.segmented button { border: 0; border-radius: 8px; padding: 7px 10px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.segmented button.active { color: var(--text); background: #343d3f; }
.primary-button { border: 0; border-radius: 12px; padding: 10px 16px; background: var(--accent); color: #17200d; font-weight: 800; cursor: pointer; }
.primary-button:disabled { opacity: .5; }

.section-title { display: flex; align-items: end; justify-content: space-between; margin: 22px 2px 12px; }
.section-title h2 { margin: 0; font-size: 17px; }
.section-title span { color: var(--muted); font-size: 12px; }
.section-tools { display: flex; align-items: center; gap: 9px; }
.sort-button { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--accent); padding: 7px 9px; font-size: 11px; cursor: pointer; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 1px; background: var(--line); }
.entry { position: relative; display: grid; grid-template-columns: 56px 1fr auto; gap: 8px; align-items: start; padding: 0 0 17px; }
.entry::before { content: ""; position: absolute; left: -19px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--bg); }
.entry.note::before { background: var(--orange); }
.entry-time { padding-top: 2px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.entry-card { min-width: 0; }
.entry-card p { margin: 0; line-height: 1.42; overflow-wrap: anywhere; }
.entry-meta { margin-top: 5px; color: var(--muted); font-size: 11px; }
.entry-menu { border: 0; background: transparent; color: var(--muted); padding: 0 3px 8px; font-size: 20px; cursor: pointer; }
.entry-actions { grid-column: 2 / 4; display: none; gap: 7px; }
.entry.open .entry-actions { display: flex; }
.entry.editing .entry-actions { display: none; }
.small-button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 10px; color: var(--muted); font-size: 12px; cursor: pointer; }
.small-button.danger { color: var(--danger); }
.inline-edit-form { display: grid; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.inline-edit-form textarea { width: 100%; min-height: 62px; max-height: 220px; resize: none; overflow-y: hidden; border: 0; outline: 0; padding: 2px; background: transparent; color: var(--text); line-height: 1.45; }
.inline-edit-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px; }
.inline-edit-buttons { display: flex; gap: 7px; margin-left: auto; }
.segmented.compact button { padding: 6px 8px; font-size: 10px; }
.inline-edit-buttons .primary-button { padding: 8px 11px; font-size: 12px; }

.report-card { margin-top: 14px; overflow: hidden; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 15px 4px; }
.report-head h3 { display: inline; margin: 0 8px 0 0; font-size: 14px; }
.report-card summary { display: flex; cursor: pointer; justify-content: space-between; padding: 15px; font-weight: 700; list-style: none; }
.report-card summary::-webkit-details-marker { display: none; }
.report-text { margin: 0; padding: 0 15px 18px; color: #c9cfca; white-space: pre-wrap; line-height: 1.5; font-size: 13px; }
.report-status { display: inline-block; padding: 4px 7px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.report-status.stale { background: rgba(255,173,102,.1); color: var(--orange); }
.report-status.error { background: rgba(255,116,116,.08); color: var(--danger); }
.report-status.missing, .report-status.generating { background: var(--surface-2); color: var(--muted); }

.month-head { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 18px; }
.month-head h2 { margin: 0; text-transform: capitalize; font-size: 20px; }
.month-nav { display: flex; gap: 7px; }
.month-nav button { width: 38px; height: 38px; }
.calendar { padding: 14px 10px 10px; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays span { padding: 6px 0 10px; color: var(--muted); text-align: center; font-size: 10px; text-transform: uppercase; }
.day-cell { position: relative; min-height: 58px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); cursor: pointer; }
.day-cell.has-data { color: var(--text); background: rgba(255,255,255,.025); }
.day-cell.today { box-shadow: inset 0 0 0 1px var(--accent); }
.day-cell.selected { background: var(--accent-soft); color: var(--accent); }
.day-cell small { display: block; margin-top: 4px; font-size: 8px; color: var(--muted); }
.day-cell .report-dot { position: absolute; right: 8px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.day-cell .report-dot.stale { background: var(--orange); }
.day-cell .report-dot.error { background: var(--danger); }

.range-picker { display: flex; gap: 7px; margin: 12px 0 16px; }
.range-picker button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 9px; color: var(--muted); cursor: pointer; }
.range-picker button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.quality-banner { padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; background: rgba(255,173,102,.1); color: var(--orange); font-size: 12px; }
.category-list { padding: 14px; }
.category-row { margin-bottom: 14px; }
.category-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; }
.category-label span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; overflow: hidden; border-radius: 9px; background: var(--surface-2); }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #75dab0); }

.search-form { display: flex; gap: 8px; margin: 12px 0 18px; }
.search-form input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 12px 14px; outline: none; }
.search-result { width: 100%; display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 14px; margin-bottom: 8px; text-align: left; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); cursor: pointer; }
.search-result time { color: var(--muted); font-size: 11px; }
.search-result p { margin: 0; line-height: 1.35; }

.settings-section { padding: 15px; margin-bottom: 12px; }
.settings-section h3 { margin: 0 0 14px; font-size: 14px; }
.field-label { display: grid; gap: 6px; margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.settings-hint { margin: -6px 0 14px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.switch-row:first-of-type { border-top: 0; }
.switch-row > span { min-width: 0; }
.switch-row > span strong { display: block; font-size: 13px; }
.switch-row > span small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.switch-row > input { position: absolute; opacity: 0; }
.switch-row > i { position: relative; width: 46px; height: 26px; flex: none; border-radius: 20px; background: #343d3f; transition: .2s; }
.switch-row > i::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #aab2b0; transition: .2s; }
.switch-row > input:checked + i { background: var(--accent); }
.switch-row > input:checked + i::after { transform: translateX(20px); background: #17200d; }
.switch-copy strong { display: block; font-size: 13px; }
.switch-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: absolute; inset: 0; border-radius: 20px; background: #343d3f; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #aab2b0; transition: .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); background: #17200d; }
.settings-save { width: 100%; margin-top: 4px; padding: 13px; }
.schedule-grid { display: grid; grid-template-columns: 1fr auto; gap: 9px 14px; color: var(--muted); font-size: 12px; }
.schedule-grid strong { color: var(--text); font-weight: 600; }

.bottom-nav {
  position: fixed; z-index: 20; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 720px); display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 9px 12px max(9px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: rgba(16,19,21,.92); backdrop-filter: blur(18px);
}
.nav-item { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; gap: 3px; cursor: pointer; }
.nav-item span { font-size: 22px; line-height: 1; }
.nav-item small { font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.nav-item.active { color: var(--accent); }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 90px; transform: translate(-50%, 18px); max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 12px; background: #eef3eb; color: #192018; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.error-card { padding: 18px; margin-top: 20px; border: 1px solid rgba(255,116,116,.25); border-radius: 18px; background: rgba(255,116,116,.07); }
.error-card h2 { margin-top: 0; }
.error-card p { color: var(--muted); line-height: 1.5; }

@media (min-width: 600px) {
  .content { padding-inline: 24px; }
  .topbar { padding-inline: 28px; }
  .stats-grid { gap: 12px; }
}
