:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --border: #dde1e7; --border-strong: #c3c9d2;
  --text: #1b1f24; --muted: #5d6672; --accent: #2f5bd3; --accent-hover: #2449b3; --accent-soft: #e8eefc;
  --on-accent: #ffffff; --ok: #1d7a46; --ok-soft: #e5f4ea; --warn: #9a5b00; --warn-soft: #fdf1dc;
  --danger: #b3261e; --danger-soft: #fbe9e7; --band: #cfdaf7; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --radius: 10px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --surface: #1a1e24; --surface-2: #232830; --border: #2e353f; --border-strong: #434c58;
    --text: #e7eaee; --muted: #9aa4b1; --accent: #7a9cff; --accent-hover: #94b0ff; --accent-soft: #212c47;
    --on-accent: #0d1220; --ok: #5cc98a; --ok-soft: #17301f; --warn: #f0b555; --warn-soft: #34280f;
    --danger: #ff8a80; --danger-soft: #3a1c1a; --band: #2c3c66; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --surface: #1a1e24; --surface-2: #232830; --border: #2e353f; --border-strong: #434c58;
  --text: #e7eaee; --muted: #9aa4b1; --accent: #7a9cff; --accent-hover: #94b0ff; --accent-soft: #212c47;
  --on-accent: #0d1220; --ok: #5cc98a; --ok-soft: #17301f; --warn: #f0b555; --warn-soft: #34280f;
  --danger: #ff8a80; --danger-soft: #3a1c1a; --band: #2c3c66; --shadow: none; color-scheme: dark;
}
* { 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, sans-serif; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.25rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 620; }
p { margin: 0; }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 650; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; margin-right: auto; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 14px; }
main { max-width: 980px; margin: 0 auto; padding: 24px 16px 64px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.remove:hover { background: var(--danger-soft); color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small-text { font-size: .875rem; }

/* Home */
.hero { padding: 28px; display: grid; gap: 18px; }
.hero p.lead { font-size: 1.05rem; color: var(--muted); max-width: 62ch; }
.steps-overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps-overview li { counter-increment: s; display: flex; gap: 10px; align-items: baseline; font-size: .92rem; }
.steps-overview li::before { content: counter(s); flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 650; display: grid; place-items: center; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 32px 0 12px; }
.project-list { display: grid; gap: 10px; }
.project-row { padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.project-row .info { flex: 1 1 260px; min-width: 0; }
.project-row .title { font-weight: 620; overflow-wrap: anywhere; }
.project-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; vertical-align: 2px; margin-left: 6px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.draft { background: var(--surface-2); color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Wizard */
.wizard-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.save-state { font-size: .85rem; color: var(--muted); }
.save-state.dirty { color: var(--warn); }
.stepper { display: flex; gap: 4px; list-style: none; margin: 0 0 18px; padding: 0; }
.stepper li { flex: 1; min-width: 0; }
.stepper button { width: 100%; border: 0; background: none; padding: 8px 2px 0; cursor: pointer; text-align: left; color: var(--muted); font-size: .8rem; }
.stepper button::before { content: ""; display: block; height: 4px; border-radius: 4px; background: var(--border); margin-bottom: 6px; }
.stepper .done button::before { background: var(--band); }
.stepper .current button { color: var(--text); font-weight: 620; }
.stepper .current button::before { background: var(--accent); }
.stepper .label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-card { padding: 24px; }
.step-title { display: grid; gap: 4px; margin-bottom: 20px; }
.step-kicker { font-size: .8rem; font-weight: 650; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.step-foot { display: flex; gap: 8px; align-items: center; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.step-foot .spacer { flex: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 580; font-size: .92rem; }
.field .hint { font-size: .84rem; color: var(--muted); }
.field .req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); min-height: 40px; }
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: .84rem; }
.parsed { font-size: .84rem; color: var(--ok); }

/* Chips (integrations) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--border-strong); border-radius: 8px; min-height: 42px; background: var(--surface); }
.chips:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--accent-soft); color: var(--text); border-radius: 6px; padding: 2px 2px 2px 9px; font-size: .9rem; max-width: 100%; }
.chip span { overflow-wrap: anywhere; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); width: 22px; height: 22px; border-radius: 4px; }
.chip button:hover { color: var(--danger); }
.chips input { border: 0; flex: 1 1 160px; min-height: 28px; padding: 2px 4px; background: transparent; }
.chips input:focus { box-shadow: none; }

/* Feature entry */
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; }
.feature-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.feature-list li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.feature-list li .name { flex: 1; overflow-wrap: anywhere; }

/* Rank list */
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); position: relative; }
.rank-item.dragging { border-color: var(--accent); box-shadow: 0 6px 24px rgba(16,24,40,.18); z-index: 2; background: var(--surface); }
.handle { width: 32px; height: 40px; border: 0; background: none; cursor: grab; color: var(--muted); touch-action: none; display: grid; place-items: center; border-radius: 6px; flex: none; }
.handle:hover { color: var(--text); background: var(--surface-2); }
.dragging .handle { cursor: grabbing; }
.rank-num { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: .82rem; font-weight: 650; flex: none; font-variant-numeric: tabular-nums; }
.rank-item .name-input { flex: 1; min-width: 0; border-color: transparent; background: transparent; }
.rank-item .name-input:hover { border-color: var(--border); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--surface); padding: 0 12px; min-height: 32px; cursor: pointer; font-size: .85rem; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-checked="true"][data-p="high"] { background: var(--danger-soft); color: var(--danger); font-weight: 650; }
.seg button[aria-checked="true"][data-p="medium"] { background: var(--warn-soft); color: var(--warn); font-weight: 650; }
.seg button[aria-checked="true"][data-p="low"] { background: var(--ok-soft); color: var(--ok); font-weight: 650; }
.priority-summary { display: flex; gap: 14px; margin-top: 14px; font-size: .88rem; color: var(--muted); flex-wrap: wrap; }

/* Reality check */
.layout-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.reality { background: var(--surface-2); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.reality-head { display: flex; align-items: center; gap: 8px; }
.reality-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.metric { display: grid; gap: 6px; }
.metric-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.metric-top strong { font-variant-numeric: tabular-nums; }
.rangebar { position: relative; height: 10px; background: var(--border); border-radius: 99px; margin: 6px 0 18px; }
.rangebar .band { position: absolute; top: 0; bottom: 0; background: var(--band); border-radius: 99px; }
.rangebar .marker { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--text); }
.rangebar .marker-label { position: absolute; top: 18px; transform: translateX(-50%); font-size: .75rem; font-weight: 650; white-space: nowrap; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notes li { padding: 9px 12px; border-radius: 8px; font-size: .9rem; background: var(--surface); border-left: 3px solid var(--border-strong); }
.notes li.ok { border-left-color: var(--ok); }
.notes li.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.notes li.tip { border-left-color: var(--accent); }
.typical-stack { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.typical-stack div { background: var(--surface); border-radius: 8px; padding: 8px 10px; }
.typical-stack .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.typical-stack .v { font-weight: 620; font-size: .92rem; }
.tech-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.tech-row:first-child { padding-top: 0; }
.tech-row:last-child { border-bottom: 0; }

/* Review */
.review { display: grid; gap: 14px; }
.review section { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.review section header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.review dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.review dt { color: var(--muted); font-size: .88rem; }
.review dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.review ol { margin: 0; padding-left: 22px; }
.pill { font-size: .75rem; font-weight: 650; padding: 1px 8px; border-radius: 99px; margin-left: 6px; }
.pill.high { background: var(--danger-soft); color: var(--danger); }
.pill.medium { background: var(--warn-soft); color: var(--warn); }
.pill.low { background: var(--ok-soft); color: var(--ok); }
.callout { padding: 14px 16px; border-radius: var(--radius); background: var(--ok-soft); display: grid; gap: 6px; }
.callout.warn { background: var(--warn-soft); }
.callout ul { margin: 0; padding-left: 20px; }
.share-box { display: grid; gap: 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 16px; }

/* Toast & dialog */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: .92rem; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.error { background: var(--danger); color: #fff; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 22px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 480px) {
  .brand-text { display: none; }
  .topbar-inner { gap: 6px; }
}
@media (max-width: 760px) {
  .grid-2, .layout-split, .tech-row, .typical-stack { grid-template-columns: 1fr; }
  .step-card, .hero { padding: 18px; }
  .stepper .label { display: none; }
  .rank-item { flex-wrap: wrap; }
  .rank-item .name-input { flex: 1 1 calc(100% - 120px); }
  .rank-item .seg { margin-left: 72px; }
  .step-foot .btn { flex: 1 1 auto; }
  .step-foot .spacer { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .rank-item.settle { transition: transform .15s ease; }
}

/* Account pages */
.auth-wrap { max-width: 440px; margin: 32px auto; }
.auth-card { padding: 28px; display: grid; gap: 18px; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .btn.primary { width: 100%; min-height: 42px; }
.auth-foot { text-align: center; font-size: .92rem; color: var(--muted); }
.flash { padding: 10px 14px; border-radius: 8px; font-size: .92rem; margin-bottom: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.notice { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius); background: var(--warn-soft); margin-bottom: 18px; font-size: .92rem; }
.notice form { margin: 0; }
.usermenu { display: flex; align-items: center; gap: 6px; }
.usermenu form { margin: 0; }
.usermenu .who { font-size: .85rem; color: var(--muted); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.admin { background: var(--accent-soft); color: var(--accent); }
.danger-zone { border-color: var(--danger-soft); }
@media (max-width: 600px) { .usermenu .who, .hide-sm { display: none; } }
.auth-card form > .btn:not(.primary) { justify-self: start; }
