/* TRE Focus — one calm screen. Tokens first; nothing below hardcodes a color. */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #0e2431;
  --muted: #6b7680;
  --faint: #a3abb2;
  --line: #e6e2d9;
  --accent: #966e35;
  --accent-soft: #f1e9dc;
  --danger: #a33a2c;
  --ok: #2f6b4a;
  --shadow: 0 8px 30px rgba(14, 36, 49, 0.12);
  --toast-accent: #cab487;
  --radius: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1b24;
    --surface: #142733;
    --text: #ece8e0;
    --muted: #93a0a9;
    --faint: #5f6e78;
    --line: #213845;
    --accent: #cab487;
    --accent-soft: #1f3340;
    --danger: #e38878;
    --ok: #7fc39c;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    --toast-accent: #7a5a2b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1b24;
  --surface: #142733;
  --text: #ece8e0;
  --muted: #93a0a9;
  --faint: #5f6e78;
  --line: #213845;
  --accent: #cab487;
  --accent-soft: #1f3340;
  --danger: #e38878;
  --ok: #7fc39c;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --toast-accent: #7a5a2b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px 120px;
}

/* ── Header ── */
.top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
/* Hub link and menu sit together on the right at every width */
.top > a.icon-btn { margin-left: auto; margin-right: 4px; }
.date { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.checked { font-size: 13px; color: var(--faint); margin-top: 2px; min-height: 18px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); fill: currentColor; stroke: currentColor;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn svg rect, .icon-btn svg circle { stroke: none; }

/* ── Tabs ── */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.tabs button {
  padding: 8px 0 10px; margin-bottom: -1px;
  color: var(--muted); font-weight: 500; font-size: 15px;
  border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.count { color: var(--accent); font-weight: 600; margin-left: 2px; }
.count:empty { display: none; }

/* ── Problem banner (degraded source) ── */
.problem {
  background: var(--accent-soft); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 22px; font-size: 14px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.problem button { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ── Sections ── */
.label { font-size: 13px; font-weight: 500; color: var(--faint); margin: 0 0 10px; }
section + section { margin-top: 30px; }
.loading, .empty { color: var(--muted); padding: 30px 0; }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }

/* NOW: the one thing, set apart by size and a single accent line */
.now { border-left: 3px solid var(--accent); padding: 2px 0 2px 16px; }
.now-title { font-size: 21px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.now-why { color: var(--muted); margin-top: 6px; font-size: 15px; }
.now-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  height: 38px; padding: 0 16px; border-radius: 19px;
  font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-ghost { color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--faint); }

/* Item icon tile: shape carries the meaning, one soft tint keeps it calm */
.ico {
  flex: none; width: 30px; height: 30px; margin-top: -3px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tl-row.task { gap: 10px; }

/* Focus ring */
.focus-wrap { display: flex; gap: 18px; align-items: center; margin-top: 4px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--line); }
.ring .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text span { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ring-text small { font-size: 12px; color: var(--faint); }
.focus-body { min-width: 0; }
.focus .now-title { font-size: 19px; }
.focus.up .ring .track { stroke: var(--accent-soft); }
.focus.up .ring-text span { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .ring .prog { transition: none; } }

/* Timeline: time column, a thin rail, then the entry */
.now-slot { color: var(--accent); margin-left: 6px; }
.allday { font-size: 14px; color: var(--muted); }
.tl-head { display: block; text-align: left; }
.tl-row { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; position: relative; }
.tl-time { width: 50px; flex: none; text-align: right; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; line-height: 1.35; padding-top: 1px; }
.tl-time small { display: block; font-size: 12px; color: var(--faint); }
.tl-mark { width: 22px; flex: none; align-self: stretch; display: flex; justify-content: center; align-items: flex-start; padding-top: 1px; position: relative; }
.tl-mark::before { content: ''; position: absolute; top: -9px; bottom: -9px; left: 50%; width: 1px; background: var(--line); }
.tl-row:first-of-type .tl-mark::before { top: 12px; }
.tl-row:last-child .tl-mark::before { bottom: auto; height: 21px; }
.tl-mark .check, .tl-mark .dot { position: relative; z-index: 1; background: var(--bg); }
.tl-mark .dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 3px; background: var(--accent); }
.tl-body { flex: 1; min-width: 0; text-align: left; }
.tl-row.meeting .tl-body { color: var(--muted); padding-top: 1px; }
.tl-row.meeting .in { color: var(--accent); font-size: 13px; font-weight: 500; margin-left: 4px; }
.tl-row.past { opacity: 0.45; }
.tl-row.live .tl-body { color: var(--text); font-weight: 500; }
.tl-row.live .dot { box-shadow: 0 0 0 4px var(--accent-soft); }

/* Meetings */
.meeting { display: flex; gap: 14px; padding: 7px 0; align-items: baseline; }
.meeting .t { width: 58px; flex: none; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.meeting .m { flex: 1; min-width: 0; }
.meeting .in { color: var(--accent); font-size: 13px; font-weight: 500; white-space: nowrap; }
.meeting.past { opacity: 0.45; }
.meeting.live .t { color: var(--accent); font-weight: 600; }

/* Item rows */
.row { display: flex; gap: 14px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line); }
.label + .row { border-top: 0; }
.check {
  flex: none; width: 22px; height: 22px; margin-top: 1px;
  border: 1.5px solid var(--faint); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.check:hover { border-color: var(--accent); }
.check.done { background: var(--ok); border-color: var(--ok); }
.check.done::after { content: ''; width: 6px; height: 10px; border: solid var(--bg); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.row-body { flex: 1; min-width: 0; text-align: left; }
.row-title { display: block; }
.row-meta { display: block; font-size: 13px; color: var(--faint); margin-top: 2px; }
.row-meta .late { color: var(--danger); }
.more { color: var(--muted); font-size: 14px; padding: 10px 0; }
.more:hover { color: var(--text); }

/* ── Capture bar ── */
.capture {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex; justify-content: center;
  z-index: 5;
}
.capture input {
  width: 100%; max-width: 528px; height: 48px;
  padding: 0 52px 0 18px; border-radius: 24px;
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); outline: none;
}
.capture input:focus { border-color: var(--accent); }
.capture .icon-btn { margin-left: -46px; align-self: center; }
.capture .icon-btn.listening { color: var(--danger); }

/* ── Sheet ── */
.scrim { position: fixed; inset: 0; background: rgba(8, 18, 24, 0.35); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 560px; margin: 0 auto; max-height: 85vh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 22px 20px calc(env(safe-area-inset-bottom) + 20px);
  box-shadow: var(--shadow);
}
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 12vh; border-radius: 18px; }
}
.sheet h2 { font-size: 19px; font-weight: 600; margin: 0 0 6px; line-height: 1.3; }
.sheet .why { color: var(--muted); margin: 0 0 4px; }
.sheet .meta { color: var(--faint); font-size: 13px; margin: 0 0 18px; }
.sheet .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet .quiet { display: flex; gap: 18px; margin-top: 18px; font-size: 14px; }
.sheet .quiet button, .sheet .quiet a { color: var(--muted); text-decoration: none; }
.sheet .quiet .danger { color: var(--danger); }
.sheet input.edit {
  width: 100%; font-size: 17px; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.sheet textarea.profile { width: 100%; font: inherit; font-size: 15px; line-height: 1.5; padding: 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); resize: vertical; }
.row.archived { align-items: center; opacity: 0.75; }
.setting { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); gap: 12px; }
h2 + .setting, .why + .setting { border-top: 0; }
.setting .state { font-size: 13px; color: var(--faint); }
.setting .state.bad { color: var(--danger); }
.setting .state.good { color: var(--ok); }
.setting button, .setting a { color: var(--accent); font-weight: 500; font-size: 14px; text-decoration: none; white-space: nowrap; }

/* ── Ask ── */
.ask { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.ask .q { align-self: flex-end; max-width: 85%; background: var(--accent-soft); padding: 9px 14px; border-radius: 16px 16px 4px 16px; }
.ask .a { line-height: 1.5; }
.ask .a p { margin: 0 0 8px; }
.ask .a ul { margin: 0 0 8px; padding-left: 20px; }
.ask .a li { margin-bottom: 4px; }
.ask .a a { color: var(--accent); }
.ask .a.error { color: var(--danger); }
.ask .a.thinking { color: var(--muted); }
.ask .did { font-size: 13px; color: var(--ok); margin-top: 4px; }
.ask-form { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
.ask-form input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; outline: none; }
.ask-form input:focus { border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .ask .a.thinking::after { content: '...'; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
  @keyframes dots { from { width: 0; } to { width: 1.2em; } }
}

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 20px; font-size: 14px;
  display: flex; gap: 14px; align-items: center; z-index: 20; max-width: calc(100% - 32px);
}
.toast button { color: var(--toast-accent); font-weight: 600; }

@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: rise 0.18s ease-out; }
  @keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ── Tablet and wide screens ────────────────────────────────────────────── */
/* iPad portrait (and anything 700px up): same single column, more room */
@media (min-width: 700px) {
  .app { max-width: 680px; padding-left: 24px; padding-right: 24px; }
  .capture input { max-width: 640px; }
}

/* iPad landscape, iPad Pro, desktop: two columns, no tabs.
   Matches the WIDE media query in app.js. */
@media (min-width: 900px) and (min-height: 600px) {
  .app { max-width: 1120px; padding-left: 32px; padding-right: 32px; }
  body.wide .tabs { display: none; }
  body.wide .top { margin-bottom: 26px; }
  .split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 56px; align-items: start; }
  .col-side {
    position: sticky; top: calc(env(safe-area-inset-top) + 20px);
    max-height: calc(100vh - 160px); overflow-y: auto;
    padding-left: 32px; border-left: 1px solid var(--line);
  }
  .col-side section + section { margin-top: 26px; }
  .side-empty { color: var(--muted); margin: 0; font-size: 15px; }
  .side-toggle { font-weight: 500; color: var(--text); }
  .capture input { max-width: 720px; }
}

