:root {
  --bg: #f6f5f1; --panel: #ffffff; --side: #efede6; --line: #e2dfd6; --text: #1c1b18; --muted: #6b6860;
  --accent: #1d4ed8; --accent-soft: #e6ecfb; --good: #15803d; --good-soft: #e5f3ea; --warn: #b45309; --danger: #b91c1c;
  --radius: 10px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171c; --panel: #1e2027; --side: #1a1b21; --line: #2c2f38; --text: #ecebe6; --muted: #9a9ca5;
    --accent: #7aa2ff; --accent-soft: #1f2a44; --good: #5fc489; --good-soft: #1b3326; --warn: #f0a656; --danger: #f17b7b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }
.pad { padding: 24px; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 20px 14px; background: var(--side); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 0 8px; }
.dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
#nav a:hover { background: var(--line); }
#nav a[aria-current="page"] { background: var(--panel); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.me { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 0 8px; font-size: 13px; color: var(--muted); word-break: break-all; }
main { padding: 32px 40px 64px; min-width: 0; outline: none; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
section + section { margin-top: 40px; }

/* Controls */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; }
.icon { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; border-radius: 4px; }
.icon:hover { color: var(--danger); background: var(--line); }
input[type="text"], textarea, select { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; }
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Visual roadmap */
.track { display: flex; align-items: stretch; overflow-x: auto; padding: 4px 2px 16px; scroll-snap-type: x proximity; }
.phase { flex: 0 0 280px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.phase[data-status="active"] { border: 2px solid var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.phase[data-status="done"] { opacity: .78; }
.phase-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.pill { border: 0; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; cursor: pointer; background: var(--line); color: var(--muted); }
.pill[data-status="active"] { background: var(--accent-soft); color: var(--accent); }
.pill[data-status="done"] { background: var(--good-soft); color: var(--good); }
.summary { margin: 0; font-size: 13px; color: var(--muted); }
.progress { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--good); }
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.tasks li { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: start; }
.tasks li input { margin-top: 4px; }
.tasks li.done span { text-decoration: line-through; color: var(--muted); }
.tasks li .icon { visibility: hidden; }
.tasks li:hover .icon, .tasks li .icon:focus { visibility: visible; }
.add-task input { font-size: 13px; padding: 5px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 2px 8px; }
.phase-foot { margin-top: auto; display: flex; justify-content: flex-end; }
.gate { flex: 0 0 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; padding: 0 10px; position: relative; font-size: 12px; }
.gate::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed var(--line); z-index: 0; }
.gate > * { position: relative; z-index: 1; background: var(--bg); }
.diamond { width: 22px; height: 22px; transform: rotate(45deg); border: 2px solid var(--muted); border-radius: 3px; margin-bottom: 8px; }
.gate[data-passed="true"] .diamond { background: var(--good); border-color: var(--good); }
.gate strong { font-size: 13px; }
.gate .fail { color: var(--warn); }
.gate.plain { flex-basis: 32px; }
.new-phase { flex: 0 0 160px; margin-left: 32px; border: 2px dashed var(--line); background: none; border-radius: var(--radius); color: var(--muted); cursor: pointer; }
.new-phase:hover { color: var(--text); border-color: var(--muted); }

/* Ideas */
.ideas-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filter { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 12px; font-size: 13px; cursor: pointer; }
.filter[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.add-idea { display: grid; grid-template-columns: 1fr auto; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.add-idea textarea { grid-column: 1 / -1; min-height: 44px; }
.idea-list { display: flex; flex-direction: column; gap: 8px; }
.idea { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.idea[data-status="rejected"] { opacity: .6; }
.vote { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--line); background: none; border-radius: 8px; padding: 4px 0; cursor: pointer; font-weight: 600; }
.vote[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.vote small { font-size: 11px; font-weight: 400; }
.idea p { margin: 4px 0 0; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.idea-controls { display: flex; flex-direction: column; gap: 6px; width: 170px; }
.idea-controls select { font-size: 13px; padding: 4px 8px; }
.idea-controls .row { display: flex; gap: 12px; justify-content: flex-end; font-size: 13px; }
.empty { padding: 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Activity */
.activity { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.activity li { display: grid; grid-template-columns: 120px 140px 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.activity .ai { color: var(--accent); font-weight: 600; }

/* AI + links */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 820px; }
.card + .card { margin-top: 16px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; max-width: 900px; }
.links a { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); }
.links a:hover { border-color: var(--muted); }
.links small { display: block; color: var(--muted); }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
#dialog-form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
#dialog-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.dialog-actions .btn.danger { margin-right: auto; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 14px; z-index: 10; }

/* Phone */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  #nav { flex-direction: row; overflow-x: auto; }
  .me { margin: 0 0 0 auto; flex-direction: row; gap: 8px; }
  #me-name { display: none; }
  main { padding: 20px 16px 48px; }
  .phase { flex-basis: 250px; }
  .gate { flex-basis: 110px; }
  .idea { grid-template-columns: 44px 1fr; }
  .idea-controls { grid-column: 1 / -1; width: auto; flex-direction: row; flex-wrap: wrap; }
  .idea-controls select { flex: 1; min-width: 120px; }
  .activity li { grid-template-columns: 1fr; gap: 0; }
}

/* Login */
.locked .shell { display: block; }
.locked .side { display: none; }
.locked main { padding: 0; }
.mark { position: relative; display: inline-block; width: 26px; height: 26px; border-radius: 8px; background: #fff; overflow: hidden; flex: none; }
.mark span { position: absolute; left: -4px; right: -4px; height: 6px; border-radius: 6px; background: var(--accent); }
.mark span:first-child { top: 7px; transform: rotate(-8deg); }
.mark span:last-child { top: 14px; transform: rotate(6deg); opacity: .55; }

.auth-panel { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 48px 20px; background: var(--bg); }
.auth-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 18px; }
.auth-mobile-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 8px; }
.auth-mobile-brand .mark { background: var(--accent); }
.auth-mobile-brand .mark span { background: #fff; }
.auth-form h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.auth-lead { margin: -10px 0 6px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input { width: 100%; height: 44px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 0 14px; font-size: 15px; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: var(--muted); opacity: .7; }
.field input:hover { border-color: var(--muted); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.with-reveal { position: relative; }
.with-reveal input { padding-right: 64px; }
.reveal { position: absolute; right: 6px; top: 6px; height: 32px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.reveal:hover { color: var(--text); background: var(--line); }
.auth-error { margin: -6px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.auth-error:empty { display: none; }
.auth-submit { height: 46px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; transition: filter .15s, transform .05s; }
.auth-submit:hover { filter: brightness(1.08); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit:disabled { opacity: .7; cursor: progress; }
.auth-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-color-scheme: dark) { .auth-submit { color: #0b1430; } }
.auth-foot { margin: 4px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

@media (max-width: 600px) { .auth-panel { align-items: flex-start; padding-top: 12vh; } }

