:root, [data-theme="calm"] {
  --bg: #f5f4f0; --glass: rgba(245,244,240,.82); --card: #ffffff; --ink: #142229; --muted: #64727a; --line: #e9e6df;
  --brand: #1f4356; --brand-ink: #ffffff; --accent: #f2a93b; --soft: #eef2f4;
  --danger: #c8322a; --danger-soft: #fdeceb; --ok: #2e7d4f; --miss: #c0612b;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 20px rgba(16,24,40,.06);
}
[data-theme="warm"] {
  --bg: #faf4ec; --glass: rgba(250,244,236,.85); --card: #fffaf4; --ink: #3a2a1f; --muted: #7a6656; --line: #eedfcd;
  --brand: #9a4d2e; --brand-ink: #fff; --accent: #e8a33d; --soft: #f6e8da; --danger-soft: #fbe7e2;
}
[data-theme="night"] {
  --bg: #0e1418; --glass: rgba(14,20,24,.8); --card: #182127; --ink: #e8eef1; --muted: #93a2aa; --line: #26333b;
  --brand: #7fb3cc; --brand-ink: #0d1316; --accent: #f2a93b; --soft: #1f2c34;
  --danger: #ef6b62; --danger-soft: #3a1f1d; --ok: #5cc28a; --miss: #e8925c;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}
[data-theme="bold"] {
  --bg: #ffffff; --glass: rgba(255,255,255,.92); --card: #ffffff; --ink: #000000; --muted: #333333; --line: #000000;
  --brand: #0038a8; --brand-ink: #ffffff; --accent: #ffcc00; --soft: #eef3ff; --danger-soft: #ffe5e5;
  --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; min-height: 100vh;
}
a { color: var(--brand); }
.muted { color: var(--muted); font-size: 14px; }

/* header: light, translucent, logo + two pills */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--glass); color: var(--ink);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-weight: 750; font-size: 19px; letter-spacing: -.03em; }
.brand img { border-radius: 9px; box-shadow: 0 2px 6px rgba(16,31,40,.25); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-988, .top-help { font-weight: 700; text-decoration: none; border-radius: 999px; padding: 7px 13px; font-size: 14px; white-space: nowrap; }
.top-988 { background: var(--danger); color: #fff; box-shadow: 0 2px 8px rgba(200,50,42,.3); }
.top-help { background: var(--soft); color: var(--ink); }
.top-help.on { background: var(--brand); color: var(--brand-ink); }

main { padding: 18px 16px; outline: none; }
h1 { font-size: 27px; font-weight: 800; letter-spacing: -.03em; margin: 2px 0 14px; line-height: 1.15; }
h2 { font-size: 18px; font-weight: 750; letter-spacing: -.015em; margin: 20px 0 8px; }

/* bottom bar: line icons with a soft pill on the active tab */
.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 5;
  display: flex; background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 2px; font-size: 11px; font-weight: 600;
  color: var(--muted); text-decoration: none; }
.tabs a .ico { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; transition: background .15s; }
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--brand); }
.tabs a.on .ico { background: var(--soft); }

/* Help Now */
.sos { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--danger); color: #fff; font-weight: 750; border-radius: 16px;
  padding: 15px; text-decoration: none; margin-bottom: 16px; box-shadow: 0 6px 18px rgba(200,50,42,.28); font-size: 16px; }
.sos svg { width: 20px; height: 20px; }
.tiles { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.tile { display: flex; align-items: center; gap: 13px; background: var(--card); padding: 13px 14px; text-decoration: none; color: var(--ink);
  font-weight: 650; font-size: 15.5px; line-height: 1.3; border-bottom: 1px solid var(--line); margin: 0; border-radius: 0; }
.tiles .tile:last-child { border-bottom: 0; }
.tile > span.t { flex: 1; min-width: 0; }
.tile small { display: block; color: var(--muted); font-weight: 400; font-size: 13.5px; margin-top: 2px; }
.tile .ti { flex: 0 0 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--soft); color: var(--brand); }
.tile .ti svg { width: 21px; height: 21px; }
.tile.urgent .ti { background: var(--danger-soft); color: var(--danger); }
.tile.decide .ti { background: #fdf3e1; color: #b9741a; }
.tile .chev { color: var(--muted); opacity: .6; flex: 0 0 auto; }
.tile.other { color: var(--ink); }
a.tile:not(.tiles .tile) { border-radius: 18px; box-shadow: var(--shadow); border: 0; margin-bottom: 12px; }

.back { display: inline-block; margin-bottom: 8px; text-decoration: none; }
.intro { background: var(--soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.step { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--brand); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; }
.step h3 { margin: 0 0 4px; font-size: 16px; }
.step h3 .n { color: var(--brand); margin-right: 6px; }
.step p { margin: 4px 0; }
.say { background: var(--soft); border-radius: 8px; padding: 8px 10px; font-style: italic; margin: 8px 0 4px; }
.note { color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; padding: 10px 16px;
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; background: var(--soft); color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }

.sources { font-size: 14px; color: var(--muted); }
.sources ul { padding-left: 18px; margin: 6px 0; }

.ask { display: flex; gap: 8px; margin-top: 16px; position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); }
.ask input, .ask textarea, .field { flex: 1; font: inherit; border: 1px solid var(--line); border-radius: 22px; padding: 10px 14px;
  background: var(--card); color: var(--ink); }
.ask textarea { resize: none; min-height: 44px; max-height: 140px; }

.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; border-radius: 16px; padding: 10px 13px; white-space: normal; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin: 0; }
.bubble ol, .bubble ul { margin: 4px 0 8px; padding-left: 20px; }
.bubble.typing { color: var(--muted); font-style: italic; }
.alert { background: var(--danger); color: #fff; border-radius: 12px; padding: 12px 14px; }
.alert a { color: #fff; font-weight: 700; }
.alert a.btn { color: #1f2a30; background: #fff; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.agree { border-bottom: 1px solid var(--line); padding: 10px 0; }
.agree:last-child { border-bottom: 0; }
.agree-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.agree-top b { font-weight: 650; }
.days { display: flex; gap: 6px; margin-top: 8px; }
.day { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 8px; padding: 6px 0;
  font: inherit; font-size: 12px; cursor: pointer; text-align: center; }
.day.kept { background: var(--ok); border-color: var(--ok); color: #fff; }
.day.missed { background: var(--miss); border-color: var(--miss); color: #fff; }
.day.future { opacity: .4; cursor: default; }
.weekbar { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.weekbar .lbl { width: 76px; color: var(--muted); }
.weekbar .bar { flex: 1; height: 12px; background: var(--soft); border-radius: 6px; overflow: hidden; }
.weekbar .bar i { display: block; height: 100%; background: var(--ok); }
.weekbar .pct { width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; }
.x { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
select.field { border-radius: 10px; flex: 0 0 auto; }

.res { display: block; text-decoration: none; color: var(--ink); padding: 10px 0; border-bottom: 1px solid var(--line); }
.res:last-child { border-bottom: 0; }
.res b { color: var(--brand); }
.res .row { margin-top: 6px; }

.why { display: inline-block; background: var(--accent); color: #1f2a30; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.card.now { border: 2px solid var(--brand); }
.always { flex-wrap: wrap; margin-bottom: 12px; }
details.group summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary::after { content: '›'; color: var(--muted); transform: rotate(90deg); }
details.group[open] summary { margin-bottom: 6px; }
.evi { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.dq { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dq:last-of-type { border-bottom: 0; }
.dq .muted { font-size: 13px; }
.verdict { margin-top: 14px; border-radius: 12px; padding: 14px; background: var(--soft); border-left: 6px solid var(--brand); }
.verdict h3 { margin: 0 0 6px; font-size: 18px; }
.verdict ul { padding-left: 20px; margin: 4px 0 8px; }
.verdict .notes { color: var(--muted); font-size: 14px; }
.v-support { border-left-color: var(--ok); }
.v-different { border-left-color: var(--accent); }
.v-hold { border-left-color: var(--miss); }
.v-safety { border-left-color: var(--danger); }
details.dc { border-bottom: 1px solid var(--line); padding: 10px 0; }
details.dc:last-child { border-bottom: 0; }
details.dc summary { cursor: pointer; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.verdict-chip { flex: 0 0 auto; font-size: 12px; background: var(--soft); border-radius: 999px; padding: 2px 8px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { background: var(--soft); border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.seg { display: flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--ink); font: inherit; font-size: 14px; padding: 7px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); font-weight: 650; }

.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme { border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; background: var(--card); color: var(--ink); font: inherit; text-align: left; }
.theme.on { border-color: var(--brand); }
.theme .sw { display: flex; gap: 4px; margin-top: 6px; }
.theme .sw i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.switch input { width: 22px; height: 22px; }
textarea.field { border-radius: 12px; width: 100%; min-height: 90px; }

dialog { border: 0; border-radius: 16px; padding: 20px; max-width: 420px; width: calc(100% - 32px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin-top: 0; }

/* ---------------------------------------------------------------- Resources (compact rows, topics) */
.rsearch { width: 100%; border-radius: 12px; margin: 2px 0 4px; }
.sec-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 22px 0 8px; }
.sec-h h2 { margin: 0; font-size: 17px; }
.sec-h span, .sec-h a { font-size: 13px; color: var(--muted); text-align: right; }
.sec-h a { color: var(--brand); text-decoration: none; font-weight: 600; }

.now-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nb { display: flex; flex-direction: column; gap: 1px; padding: 12px 14px; border-radius: 14px; text-decoration: none; background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.nb b { font-size: 17px; }
.nb small { color: var(--muted); font-size: 12.5px; }
.nb.red { background: var(--danger); border-color: var(--danger); color: #fff; }
.nb.red small { color: rgba(255,255,255,.85); }

.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.rr { border-bottom: 1px solid var(--line); }
.rr:last-child { border-bottom: 0; }
.rr summary { list-style: none; display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; }
.rr summary::-webkit-details-marker { display: none; }
.rr-ic { flex: 0 0 38px; height: 38px; border-radius: 11px; background: var(--soft); display: grid; place-items: center; font-size: 19px; }
.rr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rr-main b { font-size: 15px; line-height: 1.3; }
.rr-desc { color: var(--muted); font-size: 13.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rr[open] .rr-desc { display: block; }
.rr-why { font-size: 12px; color: var(--brand); font-weight: 650; margin-top: 3px; }
.rr-act { flex: 0 0 auto; display: inline-block; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; background: var(--brand); color: var(--brand-ink); text-decoration: none; white-space: nowrap; }
.rr-act.ghost { background: var(--soft); color: var(--ink); }
.rr-act.red { background: var(--danger); color: #fff; }
.rr-more { padding: 0 14px 14px 64px; font-size: 14px; }
.rr-more .meta { color: var(--ink); font-size: 13px; font-weight: 600; }
.rr-more .evi { margin-top: 4px; font-style: normal; font-size: 13px; }
.nr-act { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.linkbtn { background: none; border: 0; color: var(--brand); font: inherit; font-weight: 650; font-size: 14px; padding: 10px 2px; cursor: pointer; }
.empty-now { color: var(--muted); font-size: 14px; margin: 0; }

.card.near { padding: 14px; }
.near-h { display: flex; flex-direction: column; margin-bottom: 10px; }
.near-h b { font-size: 16px; }
.near-h .muted { font-size: 12.5px; }
.near-in { display: flex; gap: 8px; margin-top: 10px; }
.near-in form { display: flex; gap: 6px; flex: 1; min-width: 0; }
.near-in .field { flex: 1; min-width: 0; width: 100%; padding: 8px 12px; }
.near-status { font-size: 12.5px; margin: 8px 0; }
.near .list { margin-top: 4px; }
.nr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.nr:last-child { border-bottom: 0; }
.nr-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.nr-top b { font-size: 15px; line-height: 1.3; }
.mi { flex: 0 0 auto; font-size: 12px; color: var(--muted); font-weight: 600; }

.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tp { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); font-weight: 650; font-size: 14px; line-height: 1.25; }
.tp .ic { font-size: 22px; flex: 0 0 auto; }
.tp small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 1px; }
.fine { font-size: 12.5px; margin-top: 18px; }
.sec-h.stack { flex-direction: column; align-items: flex-start; gap: 2px; }
.sec-h.stack span { text-align: left; }
.rr[open] summary { align-items: flex-start; }
.rr[open] summary .rr-act { display: none; }

/* ---------------------------------------------------------------- modern surfaces: soft shadows instead of borders */
.card, .list, .step, .nb, .tp, details.dc, .verdict { border-radius: 18px; }
.card, .list, .nb, .tp { border: 0; box-shadow: var(--shadow); }
.step { border: 0; border-left: 4px solid var(--brand); box-shadow: var(--shadow); border-radius: 14px; padding: 14px 16px; }
.step h3 .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--soft); color: var(--brand); font-size: 13px; margin-right: 8px; }
.intro { border-radius: 16px; padding: 14px 16px; line-height: 1.5; }
.say { border-radius: 12px; padding: 10px 12px; }
.nb.red { box-shadow: 0 6px 18px rgba(200,50,42,.28); }
.field, .rsearch { border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 11px 14px; }
.rsearch { box-shadow: var(--shadow); border-color: transparent; }
.btn { font-weight: 700; }
.btn.primary { box-shadow: 0 2px 8px rgba(31,67,86,.22); }
.bubble.assistant { border: 0; box-shadow: var(--shadow); }
.bubble { border-radius: 18px; }
.chip { border: 0; box-shadow: var(--shadow); }
.seg { padding: 4px; }
.back { font-weight: 600; font-size: 15px; }
.alert { border-radius: 16px; box-shadow: 0 6px 18px rgba(200,50,42,.28); }
dialog { border-radius: 22px; }
.welcome-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.welcome-brand img { border-radius: 14px; box-shadow: 0 4px 12px rgba(16,31,40,.25); }
.welcome-brand b { display: block; font-size: 22px; letter-spacing: -.03em; }
.welcome-brand span { display: block; color: var(--muted); font-size: 14px; }
.brand img { box-shadow: 0 2px 6px rgba(16,31,40,.2); border-radius: 8px; }
