:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #1b2230;
  --muted: #697386;
  --line: #e3e6eb;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #e3f3f1;
  --warn: #b45309;
  --warn-soft: #fdf1df;
  --danger: #c2410c;
  --danger-soft: #fdebe3;
  --ok: #15803d;
  --ok-soft: #e5f5ea;
  --info: #1d4ed8;
  --info-soft: #e7eefe;
  --fire: #ea580c;
  --fire-soft: #fff1e6;
  --side: #10202d;
  --side-ink: #b9c4cf;
  --side-active: #1c3445;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b;
    --panel: #151d26;
    --panel-2: #1a2430;
    --text: #e4e8ee;
    --muted: #8e9aab;
    --line: #26323f;
    --primary: #2bb3a3;
    --primary-ink: #04201d;
    --primary-soft: #133430;
    --warn: #f0a24a;
    --warn-soft: #3a2a14;
    --danger: #f08a5d;
    --danger-soft: #3b2017;
    --ok: #4ccb7a;
    --ok-soft: #15301f;
    --info: #7aa2ff;
    --info-soft: #18243f;
    --fire: #ff8a4c;
    --fire-soft: #3a2115;
    --side: #0a1118;
    --side-active: #17242f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; margin-bottom: 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
p { margin: 0 0 10px; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 224px; flex-shrink: 0; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; font-size: 11px; color: var(--side-ink); }
.brand-dark { color: var(--text); padding: 0 0 16px; }
.brand-dark small { color: var(--muted); }
.logo {
  width: 32px; height: 32px; border-radius: 8px; background: #0f766e; color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
}
.side nav { display: flex; flex-direction: column; padding: 0 8px; flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f8091; padding: 14px 10px 4px; }
.side nav a {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--side-ink); padding: 7px 10px; border-radius: 7px; font-size: 13.5px;
}
.side nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.side nav a.active { background: var(--side-active); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #2bb3a3; }
.count { background: #2bb3a3; color: #04201d; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 7px; min-width: 20px; text-align: center; }
.count.c-warn { background: #f0a24a; }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-top: 1px solid #1d2f3d; }
.me-name { color: #fff; min-width: 0; }
.me-name b, .me-name small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-name small { color: var(--side-ink); font-size: 11px; }
.me .btn-ghost { color: var(--side-ink); border-color: #2a3e4e; }

.main { flex: 1; min-width: 0; padding: 20px 28px 48px; max-width: 1180px; }
.main.wide { max-width: 1480px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 36px; }
.top h1 { font-size: 21px; flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 18px; color: var(--text); cursor: pointer; }
.side-backdrop { display: none; }

@media (max-width: 900px) {
  .side { position: fixed; left: -240px; z-index: 30; transition: left .2s; }
  body.side-open .side { left: 0; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
  .menu-btn { display: block; }
  .main { padding: 14px 16px 40px; }
  .top h1 { font-size: 18px; }
}

/* building blocks */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card .pad { padding: 16px 18px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card-fire { border-color: var(--fire); background: linear-gradient(0deg, var(--panel), var(--panel)) padding-box; box-shadow: 0 0 0 3px var(--fire-soft); }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸ "; color: var(--muted); }
details.card[open] > summary::before { content: "▾ "; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.end-self { align-self: end; }
@media (max-width: 1100px) { .g-main { grid-template-columns: minmax(0, 1fr); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .span2, .span3 { grid-column: auto; } }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg > * + * { margin-top: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.gap-s { gap: 6px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 160px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.inline { display: inline; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.pre { white-space: pre-wrap; }
.req { color: var(--danger); }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.dim { opacity: .55; }

/* forms */
label { display: block; font-weight: 600; font-size: 13px; }
label > input, label > select, label > textarea { display: block; margin-top: 4px; }
label > .copy-row { margin-top: 4px; }
.hint { margin-left: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
label.check > input { margin-top: 0; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.inline-label > input { margin-top: 0; }
.inline-label { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.w-num { width: 90px; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; }
.row > input, .row > select { width: auto; }
fieldset.qa { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: grid; gap: 6px; }
fieldset.qa legend { font-weight: 600; padding: 0 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 13px; line-height: 1;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input[type="search"], .toolbar input[type="date"] { width: auto; min-width: 150px; }

.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; border: 1px solid; }
.f-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.f-error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.f-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

/* badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.b-muted { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-primary { background: var(--primary-soft); color: var(--primary); }
.b-fire { background: var(--fire-soft); color: var(--fire); }
.score { display: inline-grid; place-items: center; width: 30px; height: 26px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.s-ok { background: var(--ok-soft); color: var(--ok); }
.s-warn { background: var(--warn-soft); color: var(--warn); }
.s-danger { background: var(--danger-soft); color: var(--danger); }

/* tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap > .tbl { min-width: 680px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.card:not(.flush) .tbl th { background: transparent; }
.card:not(.flush) .tbl td, .card:not(.flush) .tbl th { padding-left: 6px; padding-right: 6px; }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl td.actions > * + * { margin-left: 4px; }
.w-hook { min-width: 280px; max-width: 520px; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 15px; color: var(--muted); font-weight: 600; }
.kpi-note { font-size: 12px; color: var(--muted); }
.kpi-note.warn { color: var(--warn); }
.kpi-note.ok { color: var(--ok); }
.kpi-fire { border-color: var(--fire); background: var(--fire-soft); }
.kpi-fire .kpi-value { color: var(--fire); }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; background: var(--primary); }

.list { list-style: none; margin: 0 0 10px; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.feed li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.steps { margin: 0 0 12px; padding-left: 20px; }

/* review */
.review-item { display: flex; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.review-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.review-actions { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.hook { font-weight: 600; font-size: 15px; }
@media (max-width: 760px) { .review-item { flex-direction: column; } .review-actions { width: 100%; } }

/* idea form */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
.form-side { border-left: 1px solid var(--line); padding-left: 20px; }
.form-side h3 { margin-top: 0; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } .form-side { border-left: 0; padding-left: 0; } }
.score-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; }
.seg { display: flex; gap: 4px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 6px 0; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 600; }
.seg input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }
.score-total { font-size: 16px; margin: 12px 0 4px; }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.kcol-head { display: flex; align-items: center; gap: 6px; padding: 2px 2px 4px; }
.kcard { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; color: var(--text); box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--primary); text-decoration: none; }
.k-can_sua .kcard { border-left: 3px solid var(--danger); }
.kempty { color: var(--muted); font-size: 12px; text-align: center; padding: 16px 0; }

/* post & metrics */
.post-item { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.post-item > div:first-child { flex: 1; min-width: 240px; }
.post-item form { flex: 1; min-width: 300px; justify-content: flex-end; }
.metrics { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.metric { width: 96px; font-size: 12px; font-weight: 600; color: var(--muted); }
.metric input { margin-top: 2px; }
.metric input { padding: 6px 8px; }
.metric.due input { border-color: var(--warn); background: var(--warn-soft); }

/* research */
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ref { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.ref-thumb { display: block; aspect-ratio: 16 / 9; background: var(--panel-2); overflow: hidden; }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ref-title { font-weight: 600; }
.ref-note { white-space: normal; background: var(--panel-2); border-radius: 6px; padding: 6px 8px; }
.ref-actions { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* reports */
.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.scorecard { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--panel-2); }
.sc-row { display: flex; justify-content: space-between; margin-top: 8px; }
.sc-row b { font-variant-numeric: tabular-nums; }
.sc-hint { margin-top: -2px; }

.setting-row > input { margin-top: 0; }
.setting-row { display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.setting-row small { display: block; font-size: 12px; font-weight: 400; }

/* auth */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.auth-box h1 { font-size: 20px; margin-bottom: 16px; }

/* AI analysis */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel-2);
  padding: 22px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus, .drop.over { border-color: var(--primary); background: var(--primary-soft); outline: none; }
.drop-hint { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.drop-hint b { color: var(--text); font-size: 15px; }
.drop-icon { font-size: 28px; }
.drop.has-files .drop-hint { display: none; }
.drop-previews { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.drop-previews:empty { display: none; }
.thumb { position: relative; }
.thumb img { height: 150px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.thumb button { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-weight: 700; cursor: pointer; line-height: 1; }
.thumb-add { height: 150px; width: 90px; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-size: 24px; }
.ai-idea { border-top: 1px solid var(--line); padding: 14px 0; display: flex; flex-direction: column; gap: 6px; }
.ai-idea p { margin: 0; }
.prompt-box { display: flex; flex-direction: column; gap: 6px; }
.prompt-box textarea { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); }
ul.tight { margin: 6px 0 0; padding-left: 18px; }
