/* TMS Brainstorming Portal — plain CSS, no external assets. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #17202e;
  --muted: #5d6778;
  --border: #e1e5eb;
  --border-strong: #cfd5de;
  --accent: #0f6e68;
  --accent-hover: #0b5853;
  --accent-soft: #e3f2f0;
  --focus: #2f80ed;
  --dir-a: #2457c5;   --dir-a-soft: #e7eefb;
  --dir-b: #7a3fc4;   --dir-b-soft: #f1e9fb;
  --dir-h: #a35a00;   --dir-h-soft: #fbf0e0;
  --dir-o: #4b5563;   --dir-o-soft: #eef0f3;
  --ok: #1d7a43;      --ok-soft: #e4f4ea;
  --warn: #9a5b00;    --warn-soft: #fdf1dc;
  --err: #b42318;     --err-soft: #fdeceb;
  --info: #1f5f99;    --info-soft: #e5f0fa;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 10px;
  --radius-sm: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --surface: #171e27; --surface-2: #1c2430; --text: #e6eaf0; --muted: #9aa5b5;
    --border: #2a3441; --border-strong: #364252; --accent: #3fb8ad; --accent-hover: #5fcbc1; --accent-soft: #15302e;
    --dir-a: #7da2f0; --dir-a-soft: #1b2740; --dir-b: #b994ea; --dir-b-soft: #2a2140; --dir-h: #e0a24f; --dir-h-soft: #33270f;
    --dir-o: #aab3c0; --dir-o-soft: #252c36; --ok: #5cc98a; --ok-soft: #15301f; --warn: #e8aa4a; --warn-soft: #33270f;
    --err: #f2877d; --err-soft: #3a1a18; --info: #78b4ea; --info-soft: #172a3d; --shadow: none;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { font: .85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: .05em .3em; border-radius: 4px; border: 1px solid var(--border); }
pre { overflow-x: auto; background: var(--surface-2); padding: .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border); }
pre code { border: 0; padding: 0; background: none; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- layout */
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 1.5rem; padding-bottom: 3rem; flex: 1; }
main.narrow { max-width: 860px; }
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom, 0px)); }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head p { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.crumbs { margin: 0 0 .25rem; font-size: .85rem; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.side-stack, .main-stack { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.section-title { margin: 1.75rem 0 .75rem; }
@media (max-width: 960px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  /* idea page on narrow screens: idea, then status/scores/AI, then discussion and AI notes */
  .detail-grid { display: flex; flex-direction: column; }
  .detail-grid > .main-stack { display: contents; }
  .order-1 { order: 1; } .order-2 { order: 2; } .order-3 { order: 3; } .order-4 { order: 4; }
}
@media (max-width: 720px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } h1 { font-size: 1.35rem; } }

/* ---------- top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 650; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; background: var(--accent); color: #fff; font-weight: 750; font-size: .72rem; letter-spacing: .04em; border-radius: 7px; padding: .3rem .4rem; }
.navmenu { flex: 1; min-width: 0; }
.nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.nav-toggle-label { display: none; }
.mainnav { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; }
.mainnav a { color: var(--muted); padding: .35rem .5rem; border-radius: var(--radius-sm); font-size: .92rem; white-space: nowrap; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-sep { width: 1px; height: 1.2rem; background: var(--border); margin: 0 .3rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; white-space: nowrap; }
.inbox { position: relative; color: var(--muted); display: inline-flex; padding: .3rem; border-radius: 50%; }
.inbox.has-unread { color: var(--accent); }
.inbox .count { position: absolute; top: -4px; right: -6px; background: var(--err); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 9px; padding: 0 .35rem; line-height: 1.35; }
.me { color: var(--text); font-weight: 550; font-size: .9rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: .9rem; padding: 0; }
.linkbtn:hover { color: var(--text); text-decoration: underline; }
@media (max-width: 1080px) {
  .topbar-inner { flex-wrap: wrap; gap: .5rem .75rem; }
  .navmenu { order: 3; flex-basis: 100%; }
  .nav-toggle-label { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; color: var(--muted); font-size: .9rem; font-weight: 500; padding: .25rem 0; }
  .nav-toggle:focus-visible + .nav-toggle-label { outline: 2px solid var(--focus); outline-offset: 2px; }
  .nav-toggle:not(:checked) ~ .mainnav { display: none; }
  .mainnav { padding: .25rem 0 .5rem; }
  .topbar-right { margin-left: auto; }
  .burger, .burger::before, .burger::after { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 1px; position: relative; }
  .burger::before, .burger::after { content: ""; position: absolute; left: 0; }
  .burger::before { top: -5px; } .burger::after { top: 5px; }
}
@media (min-width: 1081px) and (max-width: 1300px) { .brand-text { display: none; } }
@media (max-width: 480px) {
  .brand-text { display: none; }
  .mainnav { display: grid; grid-template-columns: 1fr 1fr; }
  .nav-sep { display: none; }
  .me { max-width: 8rem; }
}

/* ---------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: .45rem .85rem; border-radius: var(--radius-sm); font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; line-height: 1.2; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.btn-small { padding: .25rem .55rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-ai { width: 100%; justify-content: flex-start; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .5rem .6rem; }
textarea { resize: vertical; min-height: 2.6rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 55%, transparent); border-color: var(--focus); }
input:disabled { background: var(--surface-2); color: var(--muted); }
label, .fld { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 550; }
label.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 450; }
label.check input { width: 1rem; height: 1rem; margin: 0; flex: none; accent-color: var(--accent); }
label .muted { font-weight: 400; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.req { color: var(--err); }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
@media (max-width: 720px) { .row-2, .row-3 { grid-template-columns: minmax(0, 1fr); } }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.errors { background: var(--err-soft); color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); border-radius: var(--radius-sm); padding: .6rem .85rem; margin-bottom: 1rem; font-size: .9rem; }
.errors ul { margin: 0; padding-left: 1.1rem; }
.text-error { color: var(--err); }
.flashes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.flash { padding: .6rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: .92rem; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.flash-error { background: var(--err-soft); color: var(--err); border-color: transparent; }
.flash-info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* ---------- badges & chips */
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 650; padding: .14rem .5rem; border-radius: 999px; background: var(--dir-o-soft); color: var(--dir-o); white-space: nowrap; vertical-align: middle; letter-spacing: .01em; }
.dir-a { background: var(--dir-a-soft); color: var(--dir-a); }
.dir-b { background: var(--dir-b-soft); color: var(--dir-b); }
.dir-hybrid { background: var(--dir-h-soft); color: var(--dir-h); }
.dir-other { background: var(--dir-o-soft); color: var(--dir-o); }
.status { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.st-discussion { background: var(--info-soft); color: var(--info); border-color: transparent; }
.st-decided { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.st-parked { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st-rejected { background: var(--err-soft); color: var(--err); border-color: transparent; }
.proposal { background: transparent; color: var(--warn); border: 1px dashed currentColor; }
.hw-confirmed { background: var(--ok-soft); color: var(--ok); }
.hw-to_verify { background: var(--warn-soft); color: var(--warn); }
.hw-issue { background: var(--err-soft); color: var(--err); }
.hw-reference { background: var(--dir-o-soft); color: var(--dir-o); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.ai-label { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .25rem 0 .5rem; }
.chip { display: inline-block; font-size: .78rem; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.small-chips .chip { font-size: .72rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }

/* ---------- dashboard */
.callout { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.25rem; font-size: .92rem; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; color: var(--text); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat-num { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-num.warn { color: var(--warn); }
.stat-label { color: var(--muted); font-size: .82rem; }
@media (max-width: 720px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.feed { list-style: none; margin: .5rem 0 0; padding: 0; }
.feed-item { display: flex; gap: .7rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.feed-item:first-child { border-top: 0; }
.feed-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); margin-top: .45rem; flex: none; }
.kind-idea .feed-dot { background: var(--accent); } .kind-comment .feed-dot { background: var(--info); }
.kind-score .feed-dot { background: var(--dir-b); } .kind-decision .feed-dot { background: var(--ok); }
.kind-ai .feed-dot { background: var(--warn); } .kind-edit .feed-dot { background: var(--dir-a); }
.rank-list { margin: 0; padding-left: 1.2rem; }
.rank-list li { padding: .35rem 0; }
.rank-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .15rem; }
.status-bars { list-style: none; margin: 0; padding: 0; }
.status-bars li { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0; border-top: 1px solid var(--border); }
.status-bars li:first-child { border-top: 0; }
.status-count { font-weight: 650; }
.plain-list { margin: 0; padding-left: 1.1rem; }
.plain-list li { padding: .2rem 0; }
.mini-timeline { list-style: none; margin: 0; padding: 0; }
.mini-timeline li { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: .5rem; padding: .3rem 0; font-size: .88rem; border-top: 1px solid var(--border); }
.mini-timeline li:first-child { border-top: 0; }
.mini-timeline .when { color: var(--accent); font-weight: 600; }

/* ---------- idea board */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1.25rem; padding: .85rem 1rem; }
.filters label { min-width: 150px; flex: 0 1 190px; }
.filters label.grow { flex: 1 1 220px; }
.filter-actions { display: flex; gap: .4rem; }
.idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
@media (max-width: 400px) { .idea-grid { grid-template-columns: minmax(0, 1fr); } }
.idea-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--dir-o); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .5rem; box-shadow: var(--shadow); min-width: 0; }
.dir-edge-a { border-left-color: var(--dir-a); } .dir-edge-b { border-left-color: var(--dir-b); }
.dir-edge-hybrid { border-left-color: var(--dir-h); } .dir-edge-other { border-left-color: var(--dir-o); }
.idea-card-top { display: flex; flex-wrap: wrap; gap: .35rem; }
.idea-title { font-size: 1.04rem; margin: 0; }
.idea-title a { color: var(--text); }
.idea-rq { font-size: .88rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.idea-card-foot { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--border); }
.push { margin-left: auto; }
.score-pill { display: inline-flex; align-items: baseline; gap: .25rem; font-size: .85rem; }
.score-pill strong { font-size: 1rem; }
.score-pill.empty { color: var(--muted); font-size: .8rem; }
.disagree { color: var(--warn); font-weight: 800; margin-left: .2rem; }
.tag-todo { font-size: .75rem; font-weight: 650; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: .05rem .45rem; }
.equip-warn { font-size: .8rem; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); padding: .3rem .55rem; }
.warn-icon { display: inline-grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; background: var(--warn); color: #fff; font-size: .7rem; font-weight: 800; vertical-align: -.1em; }
.empty-state { text-align: center; padding: 2rem; }

/* ---------- idea detail */
.idea-head { margin-bottom: 1.25rem; }
.idea-badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .45rem; }
.idea-head h1 { margin-bottom: .25rem; }
.idea-head .actions { margin-top: .5rem; }
.note-proposal { margin: .75rem 0 0; font-size: .88rem; color: var(--warn); }
.prose { overflow-wrap: anywhere; }
.prose.lead { font-size: .98rem; margin-bottom: .75rem; }
.fields { margin: 0 0 .5rem; }
.fields dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; margin-top: .65rem; }
.fields dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.fields-grid { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: .1rem 1rem; }
.fields-grid dt { margin-top: .45rem; }
.fields-grid dd { margin-top: .4rem; }
@media (max-width: 560px) { .fields-grid { grid-template-columns: minmax(0, 1fr); } .fields-grid dd { margin-top: 0; } }
h3.sec { margin: 1.25rem 0 .4rem; padding-top: .9rem; border-top: 1px solid var(--border); font-size: .95rem; }
.empty-val { font-style: italic; font-size: .9rem; }
.equip-list { list-style: none; margin: 0; padding: 0; }
.equip-list > li { padding: .4rem .6rem; border-radius: var(--radius-sm); margin-bottom: .3rem; background: var(--surface-2); }
.equip-list > li.has-warn { background: var(--warn-soft); }
.warn-list { list-style: none; margin: .25rem 0 0; padding: 0; font-size: .82rem; color: var(--warn); }
.warn-list li { padding: .08rem 0; }
.comments { list-style: none; margin: 0 0 1rem; padding: 0; }
.comment { padding: .7rem 0; border-top: 1px solid var(--border); }
.comments > .comment:first-child { border-top: 0; }
.comment-head { margin-bottom: .2rem; }
.comment-body { overflow-wrap: anywhere; }
.replies { list-style: none; margin: .5rem 0 0 1.1rem; padding: 0 0 0 .85rem; border-left: 2px solid var(--border); }
.reply { padding: .45rem 0; }
.reply-box { margin-top: .35rem; }
.reply-box summary { cursor: pointer; font-size: .8rem; color: var(--accent); }
.reply-box form { margin-top: .5rem; }
.mention { color: var(--dir-b); font-weight: 600; }
.mention.known { background: var(--dir-b-soft); border-radius: 4px; padding: 0 .2rem; }
.comment-form { border-top: 1px solid var(--border); padding-top: 1rem; }
.log { list-style: none; margin: 0; padding: 0; }
.log li { padding: .45rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.log li:first-child { border-top: 0; }
.log-reason { background: var(--surface-2); border-left: 3px solid var(--accent); padding: .3rem .55rem; margin: .25rem 0; border-radius: 0 4px 4px 0; font-size: .86rem; }

/* scores */
.mini-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.mini-table th, .mini-table td { padding: .3rem .4rem; border-bottom: 1px solid var(--border); text-align: left; }
.mini-table th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.total-row td { font-weight: 700; border-bottom: 0; }
.disagree-row td, .disagree-cell { background: var(--warn-soft); }
.disagree-note { color: var(--warn); font-size: .85rem; margin: .5rem 0 0; }
.rationale td { color: var(--muted); font-style: italic; font-size: .8rem; border-bottom: 1px solid var(--border); }
.per-user { margin-top: .75rem; }
.per-user summary, .ai-articles summary, .ai-queries summary { cursor: pointer; font-size: .85rem; color: var(--accent); }
.score-form { display: flex; flex-direction: column; gap: .7rem; }
.rating { border: 0; margin: 0; padding: 0; }
.rating legend { font-size: .86rem; font-weight: 600; padding: 0; margin-bottom: .3rem; display: flex; flex-direction: column; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { display: block; position: relative; font-weight: 600; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: .4rem 0; border-left: 1px solid var(--border); background: var(--surface); }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }

/* AI */
.ai-buttons { display: flex; flex-direction: column; gap: .4rem; margin: .5rem 0; }
.ai-status { min-height: 1.4rem; font-size: .88rem; }
.spinner { display: inline-block; width: .9rem; height: .9rem; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -.15em; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.ai-note { border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1rem; background: var(--surface-2); }
.ai-note-head { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin-bottom: .5rem; }
.ai-warnings { margin: 0 0 .5rem; padding-left: 1.1rem; color: var(--warn); font-size: .85rem; }
.ai-body h3, .ai-body h4, .ai-body h5 { margin: .9rem 0 .35rem; font-size: .98rem; }
.ai-body ul, .ai-body ol { margin: .25rem 0 .6rem; padding-left: 1.3rem; }
.ai-body li.sub { margin-left: 1.1rem; list-style-type: circle; }
.ai-body p { margin-bottom: .55rem; }
.articles { margin: .5rem 0 0; padding-left: 1.3rem; font-size: .88rem; }
.articles li { margin-bottom: .45rem; }
.md-table { border-collapse: collapse; font-size: .85rem; margin: .5rem 0; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: .3rem .5rem; text-align: left; vertical-align: top; }

/* ---------- forms (idea) */
.idea-form { display: flex; flex-direction: column; gap: 1rem; }
.form-section { display: flex; flex-direction: column; gap: .85rem; }
.form-section h2 { margin-bottom: 0; }
.fld-check-wrap { display: flex; align-items: flex-end; padding-bottom: .5rem; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .45rem 1rem; }
.equip-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .85rem .75rem; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.equip-group legend { font-size: .82rem; font-weight: 650; color: var(--muted); padding: 0 .3rem; }
.equip-item { flex-wrap: wrap; }
.cat-label { margin-top: .4rem; font-weight: 650; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); padding: .75rem 0 calc(.75rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); }

/* ---------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rank-table, .log-table, .user-table, .diff-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rank-table th, .rank-table td, .log-table th, .log-table td, .user-table th, .user-table td, .diff-table th, .diff-table td { padding: .5rem .55rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.rank-table thead th, .log-table thead th, .user-table thead th, .diff-table thead th { font-size: .76rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; vertical-align: bottom; }
.rank-table td:nth-child(2) { min-width: 220px; }
.rank-table .sd { display: block; color: var(--muted); font-size: .72rem; }
.rank-table tr.unscored td { color: var(--muted); }
.cell-badges { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .2rem; }
.method { margin-top: .75rem; }
.per-idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
@media (max-width: 400px) { .per-idea-grid { grid-template-columns: minmax(0, 1fr); } }
.per-idea-grid h3 { font-size: .95rem; }
.seg-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.filter-links { margin-bottom: 1rem; }
.diff-table th[scope=row] { width: 11rem; color: var(--muted); font-weight: 600; }
.diff-table td.old { color: var(--muted); }
.diff del { background: var(--err-soft); color: var(--err); text-decoration: line-through; }
.diff ins { background: var(--ok-soft); color: var(--ok); text-decoration: none; }
.user-table tr.inactive td { color: var(--muted); }
.actions-cell { display: flex; flex-wrap: wrap; gap: .3rem; }
.outcome-list { list-style: none; margin: 0; padding: 0; }
.outcome-list li { padding: .55rem 0; border-top: 1px solid var(--border); }
.outcome-list li:first-child { border-top: 0; }
.rev-list { list-style: none; margin: 0; padding: 0; }
.rev-list li { padding: .6rem 0; border-top: 1px solid var(--border); }
.rev-list li:first-child { border-top: 0; }
.rev-card { margin-bottom: 1rem; }

/* ---------- reference pages */
.hw-section { margin-bottom: 1.25rem; }
.hw-list { list-style: none; margin: 0; padding: 0; }
.hw-list > li { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; padding: .7rem 0; border-top: 1px solid var(--border); }
.hw-list > li:first-child { border-top: 0; }
.hw-list > li.archived { opacity: .6; }
.hw-main { min-width: 0; }
.hw-name { font-weight: 600; }
.hw-notes { font-size: .88rem; color: var(--muted); margin-top: .15rem; }
.hw-actions { display: flex; gap: .5rem; align-items: center; flex: none; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist > li { display: flex; gap: .8rem; align-items: flex-start; padding: .75rem 0; border-top: 1px solid var(--border); }
.checklist > li:first-child { border-top: 0; }
.checklist > li.done .check-title { text-decoration: line-through; color: var(--muted); }
.check-body { flex: 1; min-width: 0; }
.check-title { font-weight: 600; color: var(--text); }
.checkbox-btn { display: inline-block; width: 1.2rem; height: 1.2rem; border: 2px solid var(--border-strong); border-radius: 5px; background: var(--surface); cursor: pointer; margin-top: .15rem; padding: 0; flex: none; }
span.checkbox-btn { cursor: default; }
.checkbox-btn.checked { background: var(--ok); border-color: var(--ok); position: relative; }
.checkbox-btn.checked::after { content: ""; position: absolute; left: .32rem; top: .1rem; width: .3rem; height: .6rem; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: 1rem; padding: .85rem 0; border-top: 1px solid var(--border); }
.tl-item:first-child { border-top: 0; }
.tl-when { font-weight: 700; color: var(--accent); }
.tl-item.tbd .tl-when { color: var(--warn); }
.tl-item.done .tl-title { color: var(--muted); }
.tl-title { font-weight: 600; }
.tl-links { margin-top: .2rem; }
@media (max-width: 560px) { .tl-item { grid-template-columns: minmax(0, 1fr); gap: .15rem; } }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
@media (max-width: 400px) { .people-grid { grid-template-columns: minmax(0, 1fr); } }
.person { display: flex; gap: 1rem; align-items: flex-start; }
.person h2 { margin-bottom: .2rem; }
.person .role { font-weight: 550; margin-bottom: .3rem; }
.avatar { width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; flex: none; }
.context ul { padding-left: 1.2rem; margin: 0; }
.context li { margin-bottom: .4rem; }
.dir-card { border-left: 4px solid var(--dir-o); }

/* ---------- auth & admin */
.auth-page { max-width: 460px !important; }
.auth-card { margin-top: 2.5rem; padding: 1.75rem; }
.auth-brand { display: flex; gap: .85rem; align-items: center; margin-bottom: 1.25rem; }
.auth-brand .brand-mark { font-size: .85rem; padding: .55rem .6rem; border-radius: 9px; }
.auth-brand h1 { font-size: 1.3rem; margin: 0; }
.auth-brand p { margin: 0; font-size: .88rem; }
.error-card { text-align: center; padding: 2.5rem 1.5rem; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--accent); margin: 0; }
.invite-result { border-color: var(--accent); background: var(--accent-soft); margin-bottom: 1.25rem; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.notif-list li:first-child { border-top: 0; }
.notif-list li.unread a { font-weight: 600; }
.notif-list li.unread::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); align-self: center; }
.notif-list li.unread { justify-content: flex-start; }
.notif-list li.unread .muted { margin-left: auto; }

/* ranked comparison: compact cards on phones instead of the wide table */
.rank-cards { display: none; list-style: none; margin: 0; padding: 0; }
@media (max-width: 640px) {
  .rank-table-wrap { display: none; }
  .rank-cards { display: block; }
}
.rank-cards > li { padding: .75rem 0; border-top: 1px solid var(--border); }
.rank-cards > li:first-child { border-top: 0; }
.rank-card-head { display: flex; gap: .6rem; align-items: baseline; }
.rank-no { font-weight: 800; color: var(--muted); min-width: 1.4rem; }
.rank-score { margin-left: auto; text-align: right; white-space: nowrap; }
.rank-crit { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .25rem; margin-top: .45rem; font-size: .78rem; text-align: center; }
.rank-crit div { background: var(--surface-2); border-radius: 4px; padding: .2rem .1rem; }
.rank-crit div.disagree-cell { background: var(--warn-soft); }
.rank-crit span { display: block; color: var(--muted); font-size: .68rem; }

.auth-card > p.small { margin-top: 1rem; margin-bottom: 0; }
/* decisions log: stacked rows on phones */
@media (max-width: 640px) {
  .log-table thead { display: none; }
  .log-table, .log-table tbody, .log-table tr, .log-table td { display: block; width: 100%; }
  .log-table tr { padding: .6rem 0; border-bottom: 1px solid var(--border); }
  .log-table td { border: 0; padding: .1rem 0; }
  .log-table td.nowrap { white-space: normal; }
  .log-table td:first-child { color: var(--muted); font-size: .8rem; }
}
