:root {
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #ccfbf1;
  --bg: #f6f7f9; --panel: #ffffff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --hot: #dc2626; --warm: #d97706; --cold: #64748b;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2dd4bf; --brand-ink: #042f2e; --brand-soft: #134e4a;
    --bg: #0b0f14; --panel: #131920; --ink: #e5e7eb; --muted: #9ca3af; --line: #253040;
    --ok: #4ade80; --ok-soft: #14301f; --warn: #fbbf24; --warn-soft: #3a2a0a; --bad: #f87171; --bad-soft: #3b1414;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #2dd4bf; --brand-ink: #042f2e; --brand-soft: #134e4a;
  --bg: #0b0f14; --panel: #131920; --ink: #e5e7eb; --muted: #9ca3af; --line: #253040;
  --ok: #4ade80; --ok-soft: #14301f; --warn: #fbbf24; --warn-soft: #3a2a0a; --bad: #f87171; --bad-soft: #3b1414;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* App shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 1rem; position: sticky; top: 0; height: 100vh; }
.logo { font-weight: 800; font-size: 1.05rem; display: flex; gap: .5rem; align-items: center; margin-bottom: 1.25rem; }
.logo .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: .9rem; }
.nav a { display: block; padding: .5rem .7rem; border-radius: 8px; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.main { padding: 1.5rem 2rem 4rem; max-width: 1200px; width: 100%; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: .6rem 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .logo { margin-bottom: .5rem; }
  .nav { display: flex; overflow-x: auto; gap: 2px; }
  .nav a { white-space: nowrap; }
  .main { padding: 1rem 16px 4rem; }
}

/* Components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.stat .n { font-size: 1.8rem; font-weight: 800; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: .55rem .9rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; gap: .4rem; align-items: center; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.big { padding: .8rem 1.3rem; font-size: 1.05rem; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.ghost { background: transparent; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.hot { background: var(--bad-soft); color: var(--hot); border-color: transparent; }
.badge.warm { background: var(--warn-soft); color: var(--warm); border-color: transparent; }
.badge.cold { color: var(--cold); }
.badge.clear { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.caution { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.refer { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.flag { padding: .6rem .8rem; border-radius: 9px; margin: .4rem 0; border-left: 4px solid; }
.flag.caution { background: var(--warn-soft); border-color: var(--warn); }
.flag.refer { background: var(--bad-soft); border-color: var(--bad); }
.flag.clear { background: var(--ok-soft); border-color: var(--ok); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: .55rem .7rem; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
label.f { display: block; margin: .7rem 0 .25rem; font-weight: 600; font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: .45rem .85rem; cursor: pointer; user-select: none; background: var(--panel); }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.choice { display: block; border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; margin: .4rem 0; cursor: pointer; background: var(--panel); }
.choice.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.yn { display: flex; gap: .4rem; flex-shrink: 0; }
.yn button { min-width: 56px; }
.yn button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.qrow { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
td input, td select { padding: .3rem .4rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: .6rem .8rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--brand); }
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.col { background: var(--bg); border: 1px dashed var(--line); border-radius: var(--radius); padding: .6rem; min-height: 200px; }
.col h3 { font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; display: flex; justify-content: space-between; }
.lead { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .5rem; cursor: pointer; }
.lead:hover { border-color: var(--brand); }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.bar.low > span { background: var(--warn); } .bar.high > span { background: var(--bad); }
.cite { font-size: .8rem; color: var(--muted); }
.cite a { color: var(--muted); }
.ev { border-left: 3px solid var(--brand); padding: .2rem 0 .2rem .7rem; margin: .5rem 0; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 9px; z-index: 50; }
.copybox { display: flex; gap: .5rem; }
.copybox input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.md h1, .md h2, .md h3 { margin-top: 1rem; } .md ul { padding-left: 1.2rem; }
.empty { text-align: center; padding: 2rem; color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill-ai { background: linear-gradient(90deg, #7c3aed, #0f766e); color: #fff; border: 0; }

/* Funnel / plan (public pages) */
.public { max-width: 640px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.public header { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .5rem 0 1.25rem; }
.progress span { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.step h2 { font-size: 1.4rem; }
.nav-btns { display: flex; justify-content: space-between; margin-top: 1.5rem; gap: .5rem; }
.ex { border: 1px solid var(--line); border-radius: 10px; padding: .75rem; margin: .5rem 0; background: var(--panel); }
.ex .sets { display: grid; grid-template-columns: 2.2rem 1fr 1fr 1fr; gap: .35rem; margin-top: .5rem; align-items: center; }
.ex .sets input { padding: .4rem; text-align: center; }
.hero { background: var(--brand); color: var(--brand-ink); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.hero h1 { color: inherit; }
.grid > .card + .card { margin-top: 0; }
.ex .sets { grid-template-columns: 2rem repeat(3, minmax(0, 1fr)); }
.ex .sets input { min-width: 0; }
.hero h1 { overflow-wrap: anywhere; }
.main { min-width: 0; }

/* v0.2 */
.chart { width: 100%; max-width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; }
.chart .dot { fill: var(--brand); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .end { fill: var(--ink); font-weight: 700; }
.nb { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; margin-left: .35rem; border-radius: 99px; background: var(--hot); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; }
.thread { display: flex; flex-direction: column; gap: .5rem; max-height: 420px; overflow-y: auto; padding: .25rem; }
.msg { max-width: 80%; padding: .55rem .8rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .t { display: block; font-size: .7rem; opacity: .7; margin-top: .2rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.photos figure { margin: 0; } .photos img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.photos figcaption { font-size: .75rem; color: var(--muted); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.compare img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.macros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.macros div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; }
.macros b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .macros { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.login { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
.pkg { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; background: var(--panel); display: flex; flex-direction: column; gap: .35rem; }
.pkg .price { font-size: 1.3rem; font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; font-size: .9rem; }
.grid + .card, .card + .grid { margin-top: 1rem; }

/* v0.3 */
.task { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px; padding: .6rem .75rem; margin: .5rem 0; background: var(--panel); }
.task.pain { border-left-color: var(--bad); } .task.reply { border-left-color: var(--hot); } .task.inactive, .task.checkin { border-left-color: var(--warn); }
.task .acts { margin-top: .5rem; flex-wrap: wrap; gap: .4rem; }
.task details { margin-top: .35rem; } .task textarea { width: 100%; min-height: 90px; margin-top: .35rem; }
.install { border-color: var(--brand); }
