:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --ink: #1c1c1a;
  --ink-2: #5c5b55;
  --ink-3: #8d8b83;
  --line: #e2dfd6;
  --brand: #1f3a34;
  --brand-ink: #ffffff;
  --accent: #d9a441;
  --danger: #b4412f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);

  /* status palette: bg / fg */
  --s-slate-bg: #ebeae5; --s-slate-fg: #4a4944;
  --s-blue-bg:  #e2ecf7; --s-blue-fg:  #23548a;
  --s-amber-bg: #fbefd6; --s-amber-fg: #8a5a0d;
  --s-violet-bg:#ece6f7; --s-violet-fg:#5b3e94;
  --s-green-bg: #e1f1e6; --s-green-fg: #23663b;
  --s-red-bg:   #f8e3df; --s-red-fg:   #9a3322;
  --s-gray-bg:  #eeeeee; --s-gray-fg:  #777777;

  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141614; --surface: #1d201d; --surface-2: #262a26;
    --ink: #ecebe6; --ink-2: #b4b2aa; --ink-3: #85837c; --line: #333733;
    --brand: #9ccdb9; --brand-ink: #10201b; --accent: #e6b65a; --danger: #ef8a77;
    --shadow: none;
    --s-slate-bg:#2c2f2c; --s-slate-fg:#c9c7c0;
    --s-blue-bg:#1d2d40;  --s-blue-fg:#9cc3ef;
    --s-amber-bg:#3b2f15; --s-amber-fg:#f0c66e;
    --s-violet-bg:#2d2540;--s-violet-fg:#c4adf0;
    --s-green-bg:#1b3324; --s-green-fg:#8fd6a6;
    --s-red-bg:#3e221c;   --s-red-fg:#f2a594;
    --s-gray-bg:#2a2a2a;  --s-gray-fg:#9a9a9a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.splash { display: grid; place-items: center; min-height: 100dvh; color: var(--ink-3); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.topbar .spacer { flex: 1; }
@media (max-width: 520px) { .who { display: none; } .brand span { display: none; } }
.who { font-size: 13px; color: var(--ink-2); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 880px; margin: 0 auto; padding: 20px 16px calc(env(safe-area-inset-bottom) + 96px); }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 4px 0 6px; line-height: 1.2; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 28px 0 10px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 9px 14px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: progress; }
.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 6;
  border-radius: 999px; padding: 14px 20px; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}

/* ---------- chips / filters ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 12px 0 16px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 4px; }

/* ---------- status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
select.pill { border: 0; appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
select.pill::before { display: none; }
.c-slate  { background-color: var(--s-slate-bg);  color: var(--s-slate-fg); }
.c-blue   { background-color: var(--s-blue-bg);   color: var(--s-blue-fg); }
.c-amber  { background-color: var(--s-amber-bg);  color: var(--s-amber-fg); }
.c-violet { background-color: var(--s-violet-bg); color: var(--s-violet-fg); }
.c-green  { background-color: var(--s-green-bg);  color: var(--s-green-fg); }
.c-red    { background-color: var(--s-red-bg);    color: var(--s-red-fg); }
.c-gray   { background-color: var(--s-gray-bg);   color: var(--s-gray-fg); }

/* ---------- proposal cards ---------- */
.cards { display: grid; gap: 12px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-decoration: none; box-shadow: var(--shadow); position: relative;
}
.card:hover { border-color: var(--ink-3); }
.card .row { display: flex; align-items: flex-start; gap: 12px; }
.card .title { font-weight: 700; font-size: 17px; line-height: 1.3; flex: 1; letter-spacing: -.01em; }
.card .issuer { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; font-size: 13px; }
.card.attention { border-left: 4px solid var(--accent); }

.due { font-weight: 600; }
.due.soon { color: var(--s-amber-fg); }
.due.late { color: var(--danger); }
.due.none { color: var(--ink-3); font-weight: 400; }

.progress { display: flex; align-items: center; gap: 8px; min-width: 140px; flex: 1; }
.bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.flag { font-size: 12px; font-weight: 700; color: var(--s-red-fg); }

.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); border: 1.5px dashed var(--line); border-radius: var(--radius); }

/* ---------- detail ---------- */
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 600; }
.head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; }
.head h1 { flex: 1 1 320px; }
.headactions { display: flex; gap: 8px; align-items: center; }
.deadline-box {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px;
}
.deadline-box .big { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.kv { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.kv .v { margin-top: 2px; overflow-wrap: anywhere; }
.summary { line-height: 1.55; margin-top: 14px; }
details.reqs { margin-top: 10px; }
details.reqs summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
details.reqs ul { margin: 8px 0 0; padding-left: 20px; line-height: 1.6; }

/* ---------- checkpoints ---------- */
.nodes-head { display: flex; align-items: center; gap: 12px; margin: 28px 0 10px; }
.nodes-head h2 { margin: 0; }
.nodes-head .progress { max-width: 260px; }
.nodes { list-style: none; margin: 0; padding: 0; position: relative; }
.node {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start;
  padding: 12px 12px 12px 4px; position: relative;
}
.node + .node { border-top: 1px solid var(--line); }
.nodes { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; margin: 4px auto 0; border: 2.5px solid currentColor; background: var(--surface); }
.dot.done { background: currentColor; }
.node .ntitle { font-weight: 650; cursor: pointer; }
.node.isdone .ntitle { color: var(--ink-3); text-decoration: line-through; }
.node .nmeta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.node .notes { font-size: 13px; color: var(--ink-2); margin-top: 6px; white-space: pre-wrap; }
.avatar {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); font-size: 10px; font-weight: 800; color: var(--ink-2); vertical-align: middle;
}

/* ---------- forms / dialogs ---------- */
dialog.sheet {
  border: 0; padding: 0; border-radius: 18px; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog.sheet::backdrop { background: rgba(10,14,12,.45); backdrop-filter: blur(2px); }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; }
}
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.dlg header { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dlg header h3 { margin: 0; flex: 1; font-size: 17px; }
.dlg .body { padding: 16px 18px; overflow-y: auto; }
.dlg footer { display: flex; gap: 8px; padding: 12px 18px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--line); }
.dlg footer .spacer { flex: 1; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; letter-spacing: .02em; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 15px;
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 0; border-color: var(--brand); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.45; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; } }

.ai-box { background: var(--surface-2); border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.ai-row { display: flex; gap: 8px; }
.ai-row .input { flex: 1; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: underline; font-size: 13px; }
.notice { font-size: 13px; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.notice.warn { background: var(--s-amber-bg); color: var(--s-amber-fg); }
.notice.err { background: var(--s-red-bg); color: var(--s-red-fg); }
.notice.ok { background: var(--s-green-bg); color: var(--s-green-fg); }

.checks { display: grid; gap: 6px; }
.checks label { display: flex; gap: 10px; align-items: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 14px; cursor: pointer; }
.checks input { margin-top: 3px; }

.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .box { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.login img { width: 56px; height: 56px; border-radius: 14px; }
.login h1 { margin-top: 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- alerts ---------- */
.iconbtn { position: relative; padding: 8px 10px; }
.offdot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.panel.tight { margin-top: 0; padding: 4px 14px 12px; }
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.panel fieldset:disabled { opacity: .45; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; cursor: pointer; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-row .hint { display: block; margin-top: 2px; font-weight: 400; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chipcheck input { position: absolute; opacity: 0; pointer-events: none; }
.chipcheck span { display: inline-block; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chipcheck input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chipcheck input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.rems { list-style: none; margin: 6px 0 0; padding: 0; }
.rem { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rem .remtime { font-weight: 700; white-space: nowrap; }
.rem.sent { color: var(--ink-3); }
@media (max-width: 480px) { .rem { grid-template-columns: 1fr auto; } .rem .remmsg { grid-column: 1; } }
.banner { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 8px 8px 8px 12px; margin-top: 12px; font-size: 14px; font-weight: 600; }
.banner span { flex: 1; }
