:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #eeece6;
  --text: #1c1d21;
  --muted: #6b6d75;
  --line: #dddad2;
  --accent: #14213d;
  --accent-text: #ffffff;
  --gold: #c9a227;
  --danger: #b3261e;
  --user-bubble: #14213d;
  --user-text: #ffffff;
  --d-work: #2f6fde; --d-business: #7a4fd1; --d-family: #d9480f; --d-health: #2b8a3e;
  --d-travel: #0b7285; --d-finance: #a07900; --d-personal: #868e96;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216; --surface: #181b21; --surface-2: #22262e; --text: #eceef2; --muted: #9aa0ab;
    --line: #2c313a; --accent: #e3c15a; --accent-text: #15171b; --user-bubble: #2a3550; --user-text: #eceef2;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 22px; height: 22px; fill: currentColor; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Brand */
.error { color: var(--danger); }
.fatal { padding: 24px 16px; text-align: center; }
.brand-mark { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 700; letter-spacing: .5px; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 8px; font-size: .78rem; }

/* Shell */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"], .icon-btn.on { color: var(--gold); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }

/* Side panel */
.panel { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.panel-tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-tabs button { flex: 1 1 auto; border: 0; background: transparent; padding: 8px 4px; border-radius: 8px; color: var(--muted); font-size: .9rem; }
.panel-tabs button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px 16px 24px; }
.panel-body h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.panel-body h3:first-child { margin-top: 4px; }
.day-title { font-size: 1.15rem; font-weight: 650; margin: 4px 0 2px; }
.muted { color: var(--muted); font-size: .9rem; }

.item { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; padding-top: 1px; }
.item .title { font-weight: 550; }
.item .meta { color: var(--muted); font-size: .84rem; }
.tag { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); margin-right: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--d-personal); }
.dot.work { background: var(--d-work); } .dot.business { background: var(--d-business); } .dot.family { background: var(--d-family); }
.dot.health { background: var(--d-health); } .dot.travel { background: var(--d-travel); } .dot.finance { background: var(--d-finance); }
.check { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; display: grid; place-items: center; color: transparent; }
.check:hover { border-color: var(--accent); color: var(--accent); }
.check svg { width: 16px; height: 16px; }
.overdue .time { color: var(--danger); }

/* Chat */
.chat { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: min(680px, 88%); padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow); }
.msg.assistant { align-self: flex-start; background: var(--surface); border-top-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--user-bubble); color: var(--user-text); border-top-right-radius: 4px; }
.msg.error { background: transparent; box-shadow: none; color: var(--danger); font-size: .9rem; }
.msg .actions { margin-top: 6px; font-size: .78rem; color: var(--muted); }
.typing { align-self: flex-start; color: var(--muted); font-size: .9rem; padding: 4px 6px; }
.typing::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.empty { margin: auto; max-width: 520px; text-align: center; padding: 16px; }
.empty h2 { font-size: 1.6rem; margin: 0 0 8px; }
.empty p { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 99px; font-size: .9rem; }
.chip:hover { border-color: var(--accent); }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; max-height: 160px; padding: 11px 14px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--bg); line-height: 1.4;
}
.mic, .send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; }
.mic { background: var(--surface-2); color: var(--text); }
.mic[aria-pressed="true"] { background: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
.send { background: var(--accent); color: var(--accent-text); }
.send:disabled { opacity: .5; cursor: default; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(179 38 30 / 45%); } 70% { box-shadow: 0 0 0 12px rgb(179 38 30 / 0%); } 100% { box-shadow: 0 0 0 0 rgb(179 38 30 / 0%); } }

/* Status */
.badge { align-self: center; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-right: 4px; }
.offline-bar { background: var(--surface-2); color: var(--muted); font-size: .85rem; text-align: center; padding: 6px 16px; border-bottom: 1px solid var(--line); }

/* Settings */
.setting-row { display: flex; gap: 8px; }
.setting-row input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.small-btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 12px; border-radius: 10px; font-size: .88rem; }
.small-btn:hover { border-color: var(--accent); }
.small-btn.danger { color: var(--danger); }

.setting-toggle { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.setting-toggle input[type="time"] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.primary-btn { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.badge.pro { background: var(--gold); color: #1c1d21; }

/* Upsell and paywall */
.msg.upsell { border: 1px solid var(--gold); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
dialog#paywall { border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
dialog#paywall::backdrop { background: rgb(10 14 26 / 55%); }
.paywall { position: relative; padding: 28px 22px 20px; text-align: center; }
.paywall h2 { margin: 12px 0 4px; font-size: 1.35rem; }
.paywall .close { position: absolute; top: 10px; right: 10px; }
.paywall .reason { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; font-size: .92rem; }
.benefits { list-style: none; padding: 0; margin: 16px 0; text-align: left; display: grid; gap: 10px; }
.benefits li { display: grid; gap: 2px; padding-left: 26px; position: relative; }
.benefits li::before { content: "✓"; position: absolute; left: 4px; top: 0; color: var(--gold); font-weight: 700; }
.benefits span { color: var(--muted); font-size: .9rem; }
.plans { display: grid; gap: 10px; margin: 8px 0; }
.plan-btn { display: grid; gap: 2px; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); text-align: center; }
.plan-btn.best { border-color: var(--gold); }
.plan-btn span { color: var(--muted); font-size: .9rem; }
.link-btn { border: 0; background: transparent; color: var(--muted); text-decoration: underline; font-size: .85rem; }
.fine { color: var(--muted); font-size: .75rem; margin-top: 12px; }

/* Reminder banner */
.inbox { position: fixed; top: calc(env(safe-area-inset-top) + 64px); left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 32px)); z-index: 10; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--accent); color: var(--accent-text); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; }
.toast .body { flex: 1; }
.toast button { border: 0; border-radius: 8px; padding: 6px 10px; background: rgb(255 255 255 / 18%); color: inherit; font-size: .85rem; }

.bottom-nav { display: none; }

/* Mobile: one view at a time, bottom navigation */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .panel { border-right: 0; display: none; }
  .panel-tabs { display: none; }
  .app[data-view="panel"] .panel { display: flex; }
  .app[data-view="panel"] .chat { display: none; }
  .bottom-nav {
    display: flex; background: var(--surface); border-top: 1px solid var(--line);
    padding: 4px 8px calc(env(safe-area-inset-bottom) + 4px);
  }
  .bottom-nav button { flex: 1; border: 0; background: transparent; padding: 10px 4px; color: var(--muted); font-size: .85rem; border-radius: 8px; }
  .bottom-nav button.active { color: var(--text); font-weight: 650; }
  .app[data-view="chat"] .composer { padding-bottom: 10px; }
  .msg { max-width: 92%; }
  .brand span:last-child { display: none; }
}
