:root {
  --bg: #fafbfd; --surface: #fff; --text: #1d2433; --muted: #5b6475;
  --accent: #5b6cff; --accent-soft: #eef0ff; --border: #e4e8f0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c; --surface: #1a1d29; --text: #e8eaf2; --muted: #9aa3b5;
    --accent: #7c89ff; --accent-soft: #23263c; --border: #2a2e40;
  }
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  max-width: 680px; margin: 0 auto; min-height: 100vh;
  padding-bottom: 76px;
}
@media (prefers-color-scheme: dark) and (min-width: 760px) {
  .app-shell { box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45); }
}

/* Login gate */
.gate {
  position: fixed; inset: 0; z-index: 100; overflow: auto;
  background:
    radial-gradient(700px 380px at 20% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: 0 18px 60px rgba(31, 41, 80, 0.12); padding: 32px 26px;
}
.gate-logo { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.gate-card h1 { font-size: 1.7rem; letter-spacing: -0.5px; margin-bottom: 6px; }
.gate-card input { margin-top: 12px; }
.gate-actions { display: flex; gap: 10px; margin: 12px 0 4px; }
.gate-actions .btn { flex: 1; }
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 8px; gap: 10px;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.header-auth { padding: 7px 16px; font-size: 0.88rem; }
.header-auth.hidden { display: none; }
.logo { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); display: inline-block; }
.pill { font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px; }
.pill.local { background: var(--accent-soft); color: var(--muted); }
.pill.synced { background: #163b2a; color: #4ade80; }
.pill.pending { background: #3b3016; color: #fbbf24; }
.pill.error { background: #3b1616; color: #f87171; }
@media (prefers-color-scheme: light) {
  .pill.synced { background: #e7f7ee; color: #15803d; }
  .pill.pending { background: #fdf3d7; color: #a16207; }
  .pill.error { background: #fdeaea; color: #b91c1c; }
}

.view { display: none; padding: 10px 18px; }
.view.active { display: block; }

textarea, input[type=search], input[type=email], input[type=password] {
  width: 100%; padding: 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
  margin-bottom: 10px; resize: vertical;
}
textarea:focus, input:focus { outline: none; border-color: var(--accent); }

.capture-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
select {
  padding: 10px 12px; font: inherit; border-radius: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.btn {
  padding: 10px 20px; border-radius: 10px; font: inherit; font-weight: 600;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.icon { padding: 10px 12px; }
.btn:active { transform: scale(0.98); }

.toast {
  background: var(--accent-soft); color: var(--accent); border-radius: 10px;
  padding: 10px 14px; font-size: 0.9rem; margin-bottom: 8px;
  transition: opacity 0.4s;
}
.hidden { display: none !important; }

.recent-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 18px 0 8px; }
.entry-list { list-style: none; padding: 0; }
.entry-list li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.entry-list li .text { white-space: pre-wrap; word-break: break-word; }
.entry-list li .meta { font-size: 0.78rem; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.entry-list li.archived { opacity: 0.55; }
.tagchip { background: var(--accent-soft); color: var(--accent); border-radius: 20px; padding: 0 8px; font-size: 0.72rem; font-weight: 600; }

.chips { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 20px; padding: 5px 14px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Review */
#review-card .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; margin-top: 8px;
}
#review-card .heading { font-weight: 600; font-size: 1.05rem; }
#review-card .sub { color: var(--muted); margin-top: 6px; white-space: pre-wrap; }
#review-card .prompt { color: var(--muted); font-size: 0.85rem; margin: 14px 0 8px; }
#review-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.review-empty { text-align: center; color: var(--muted); padding: 40px 0; }
.review-empty .big { font-size: 2.6rem; }
.review-tab-badge {
  display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 3px;
  background: var(--accent); color: #fff; border-radius: 20px; font-size: 0.7rem; line-height: 16px;
}

/* Today */
.today-glance {
  background: var(--accent-soft); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px;
}
.today-glance ul { list-style: none; padding: 0; }
.today-glance li { padding: 3px 0; color: var(--text); }
#today-sections h3 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin: 18px 0 8px;
}

/* Plan / billing */
.plan-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 12px 0;
}
.plan-card.premium { border-color: var(--accent); background: var(--accent-soft); }
.plan-card .plan-name { font-weight: 700; font-size: 1.05rem; }
.plan-card .plan-note { color: var(--muted); font-size: 0.88rem; margin: 4px 0 12px; }
.plan-card .plan-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.billing-banner {
  padding: 12px 16px; border-radius: 12px; margin: 10px 18px 0;
  font-size: 0.92rem; text-align: center;
}
.billing-banner.success { background: #163b2a; color: #4ade80; }
.billing-banner.cancel { background: #3b3016; color: #fbbf24; }
@media (prefers-color-scheme: light) {
  .billing-banner.success { background: #e7f7ee; color: #15803d; }
  .billing-banner.cancel { background: #fdf3d7; color: #a16207; }
}

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: #ef4444; font-size: 0.9rem; }
a { color: var(--accent); }

.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 30;
}
.sheet {
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 18px;
  width: 100%; max-width: 640px;
}

nav.bottom {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 680px; display: flex; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom button {
  flex: 1; padding: 8px 0 10px; border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 1.2rem; line-height: 1.1;
}
nav.bottom button span { display: block; font-size: 0.7rem; font-weight: 600; }
nav.bottom button.on { color: var(--accent); }

/* Desktop layout — MUST stay at end of file so it overrides the
   base mobile nav.bottom rule (equal specificity, later wins). */
/* On wide screens, present the app as a centered card with a left sidebar nav,
   instead of a sparse mobile column stranded on a big monitor. */
@media (min-width: 760px) {
  body {
    max-width: 1000px;
    margin: 28px auto 40px;
    padding-bottom: 0;
  }
  .app-shell {
    display: flex;
    min-height: calc(100vh - 68px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 18px 60px rgba(31, 41, 80, 0.10);
    overflow: hidden;
  }
  .main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  /* bottom nav → left sidebar rail */
  nav.bottom {
    position: static; transform: none; max-width: none; width: 216px;
    flex-direction: column; align-items: stretch;
    border-top: none; border-right: 1px solid var(--border);
    padding: 14px 10px; gap: 4px;
    background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface));
  }
  nav.bottom button {
    flex: none; flex-direction: row; justify-content: flex-start;
    gap: 12px; padding: 12px 16px; border-radius: 12px; font-size: 1.15rem;
  }
  nav.bottom button span { display: inline; font-size: 0.98rem; font-weight: 600; }
  nav.bottom button.on { background: var(--accent-soft); }
}
