/* Argon · Structurosophy — calm paper-and-ink palette; star badges in their traditional colours. */
:root {
  --bg: #f6f4ef; --panel: #fffdf9; --ink: #1f2328; --ink-2: #4b5159; --ink-3: #7b828b; --line: #e4dfd5; --line-2: #d6cfc2;
  --accent: #8a5a2b; --accent-ink: #fff; --ok: #2f7d4f; --warn: #b5532f; --focus: #c7893f;
  --gen: #2f8a57; --ctrl: #b2453b; --soft: #f1ede5; --shadow: 0 1px 2px rgba(31,35,40,.06), 0 6px 18px rgba(31,35,40,.05);
  --serif-cjk: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  .s2 .n, .n.s2 { border-color: #9097a0; } .graph .bs.s2 { stroke: #9097a0; }
  :root { --bg: #15171a; --panel: #1c1f23; --ink: #e9e6df; --ink-2: #c3beb4; --ink-3: #8e8a82; --line: #2c3036; --line-2: #3a3f46;
    --accent: #d39a5c; --accent-ink: #1a1307; --soft: #23272c; --gen: #5bbf86; --ctrl: #e07a6f; --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line-2); background: var(--panel); border-radius: 10px; padding: 7px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 10px; }
textarea { resize: vertical; }
.muted { color: var(--ink-3); }
.error { color: var(--warn); min-height: 1.4em; }

/* login */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-size: 22px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; }
.brand .logo { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
.brand b { display: block; line-height: 1.1; }
.brand small { color: var(--ink-3); font-size: 12px; letter-spacing: .04em; }
.sig { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sig .who { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-right: 2px; }
.sig .when { font-size: 12px; color: var(--ink-3); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-left: auto; }
.field { display: grid; gap: 2px; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.field select, .field input { text-transform: none; letter-spacing: 0; font-size: 14px; padding: 5px 8px; color: var(--ink); }
.subbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 8px 18px 0; color: var(--ink-2); font-size: 14px; }
.subbar .pill { border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--ink-2); background: var(--panel); }

/* star badges */
.star { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px 2px 3px; border: 1px solid transparent; font-size: 13px; white-space: nowrap; background: var(--soft); }
.star .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; border: 1px solid rgba(0,0,0,.15); }
.star .layer { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.s1 .n, .n.s1 { background: #f8fafc; color: #1d3a57; border-color: #5b8fbf; }
.s2 .n, .n.s2 { background: #262626; color: #fff; }
.s3 .n, .n.s3 { background: #1e8a83; color: #fff; }
.s4 .n, .n.s4 { background: #3d9a4b; color: #fff; }
.s5 .n, .n.s5 { background: #e3b52f; color: #2b2100; }
.s6 .n, .n.s6 { background: #f1f2f4; color: #3a4048; border-color: #9aa3ad; }
.s7 .n, .n.s7 { background: #c23b3b; color: #fff; }
.s8 .n, .n.s8 { background: #fbf6ea; color: #5b4417; border-color: #c4a465; }
.s9 .n, .n.s9 { background: #7a3e9d; color: #fff; }

/* panels */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 14px 18px 110px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px 18px; min-width: 0; display: flex; flex-direction: column; }
.panel > header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.panel h2 small { text-transform: none; letter-spacing: 0; color: var(--ink-3); font-weight: 400; margin-left: 6px; }
.scroll { overflow: auto; max-height: 640px; padding-right: 4px; }
@media (max-width: 1100px) { .grid { grid-template-columns: 1fr; } .scroll { max-height: none; } }

/* board */
.toggles { display: flex; flex-wrap: wrap; gap: 4px; }
.toggle { font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; aspect-ratio: 1 / 1; max-width: 560px; width: 100%; margin: 0 auto; }
.cell { position: relative; border: 1px solid var(--line-2); border-radius: 12px; padding: 8px; background: var(--soft); display: flex; flex-direction: column; gap: 6px; overflow: hidden; min-width: 0; }
.cell.center { background: color-mix(in srgb, var(--soft) 70%, #e3b52f 12%); }
.cell .head { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); letter-spacing: .04em; z-index: 1; }
.cell .head b { color: var(--ink-2); font-weight: 600; }
.cell .home { position: absolute; right: 8px; bottom: 2px; font-size: 52px; font-weight: 700; line-height: 1; color: var(--ink); opacity: .07; pointer-events: none; }
.cell .chips { display: flex; flex-wrap: wrap; gap: 4px; z-index: 1; }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-3); }
.chip .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; border: 1px solid rgba(0,0,0,.15); }
.chip.hit .n { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.marks { display: flex; flex-wrap: wrap; gap: 4px; z-index: 1; margin-top: auto; }
.mark { font-size: 10.5px; border: 1px dashed var(--accent); color: var(--accent); border-radius: 6px; padding: 0 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 12px; font-size: 12px; color: var(--ink-3); justify-content: center; }
.legend .star { font-size: 12px; }
.note { font-size: 12.5px; color: var(--ink-3); margin: 10px 0 0; }

/* graph */
.graph { width: 100%; max-width: 520px; margin: 0 auto; display: block; }
.graph .edge { fill: none; stroke: var(--line-2); stroke-width: 1.6; }
.graph .edge.gen.on { stroke: var(--gen); stroke-width: 3; }
.graph .edge.ctrl.on { stroke: var(--ctrl); stroke-width: 3; }
.graph .edge.back { stroke-dasharray: 6 5; }
.graph .node circle { fill: var(--panel); stroke: var(--line-2); stroke-width: 1.5; }
.graph .node.on circle { stroke: var(--ink-2); stroke-width: 2; }
.graph .node text.el { font-size: 13px; font-weight: 600; fill: var(--ink); text-anchor: middle; }
.graph .node text.zh { font-size: 12px; fill: var(--ink-3); text-anchor: middle; font-family: var(--serif-cjk); }
.graph .badge circle { stroke: rgba(0,0,0,.25); stroke-width: 1; }
.graph .badge.natal circle { stroke-width: 2.5; }
.graph .badge text { font-size: 11px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.graph-key { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 12px; color: var(--ink-3); margin: 6px 0 12px; }
.graph-key i { display: inline-block; width: 22px; height: 0; border-top: 3px solid var(--gen); vertical-align: middle; margin-right: 4px; }
.graph-key i.ctrl { border-color: var(--ctrl); }
.graph-key i.back { border-top-style: dashed; border-color: var(--ink-3); }
.graph-key .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; background: #e3b52f; border: 1px solid rgba(0,0,0,.25); }
.graph-key .dot.ring { background: transparent; border: 3px solid var(--accent); }
.pairs { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.pairs li { display: grid; grid-template-columns: auto auto auto 1fr; gap: 8px; align-items: center; font-size: 13.5px; padding: 6px 8px; border-radius: 10px; background: var(--soft); }
.pairs .op { font-weight: 700; width: 18px; text-align: center; }
.pairs .op.gen { color: var(--gen); } .pairs .op.ctrl { color: var(--ctrl); } .pairs .op.same { color: var(--accent); }
.pairs .why { color: var(--ink-2); }

/* summary */
.tabs { display: flex; gap: 4px; }
.headline { font-size: 17px; line-height: 1.45; margin: 0 0 14px; }
.cards { display: grid; gap: 12px; }
.group h3 { margin: 6px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.group.support h3 { color: var(--gen); } .group.pressure h3 { color: var(--ctrl); } .group.synthesis h3 { color: var(--accent); } .group.note h3 { color: var(--ink-3); }
.card { border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: 12px; padding: 12px 14px; background: var(--panel); }
.group.support .card { border-left-color: var(--gen); } .group.pressure .card { border-left-color: var(--ctrl); } .group.synthesis .card { border-left-color: var(--accent); }
.card h4 { margin: 0 0 6px; font-size: 15px; }
.card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--ink-2); }
.card li { line-height: 1.5; max-width: 62ch; }
.progress { display: flex; gap: 10px; align-items: center; color: var(--ink-3); font-size: 14px; padding: 8px 0; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* sources */
.source { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: var(--panel); }
.source h4 { margin: 0 0 8px; font-size: 14.5px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: 11px; border-radius: 6px; padding: 1px 7px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--soft); }
.tag.l1 { border-color: #3d7a5a; color: #2f6b4c; } .tag.l2 { border-color: #7b6a3a; color: #6b5a2a; } .tag.l3 { border-color: #8a4f7a; color: #7a3f6a; }
.zh { font-family: var(--serif-cjk); font-size: 19px; line-height: 1.7; margin: 4px 0 10px; letter-spacing: .02em; }
.dl { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 13.5px; }
.dl dt { color: var(--ink-3); text-transform: uppercase; font-size: 11px; letter-spacing: .06em; padding-top: 2px; }
.dl dd { margin: 0; color: var(--ink-2); }
.ref { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-3); word-break: break-all; }
.approval { border: 2px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; background: color-mix(in srgb, var(--panel) 90%, var(--accent) 10%); }
.approval h4 { margin: 0 0 4px; }
.approval pre { max-height: 260px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12.5px; white-space: pre-wrap; }
.approval .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.approval input { flex: 1 1 220px; }

/* ask bar and drawers */
.askbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; gap: 8px; align-items: end; padding: 12px 18px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.askbar textarea { flex: 1; min-height: 42px; max-height: 180px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); z-index: 40; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0,0,0,.12); display: flex; flex-direction: column; }
.drawer > header { display: flex; gap: 8px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer > header h2 { margin: 0 auto 0 0; font-size: 15px; }
.drawer .body { overflow: auto; padding: 14px 16px 24px; display: grid; gap: 12px; align-content: start; }
.msg { border-radius: 12px; padding: 10px 12px; line-height: 1.55; }
.msg.you { background: var(--soft); justify-self: end; max-width: 92%; white-space: pre-wrap; }
.msg.argon { border: 1px solid var(--line); }
.msg.argon p { margin: 0 0 8px; } .msg.argon ul { margin: 0 0 8px; padding-left: 18px; }
.msg .meta, .steps { font-size: 12px; color: var(--ink-3); }
.form { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.form .row { display: flex; flex-wrap: wrap; gap: 8px; }
.felt { display: flex; gap: 4px; flex-wrap: wrap; }
.felt button { font-size: 12px; padding: 4px 9px; border-radius: 999px; }
.felt button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.entry { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.entry .top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.entry .text { white-space: pre-wrap; color: var(--ink-2); }
.entry .actions { display: flex; gap: 6px; margin-top: 8px; }
.entry .actions button { font-size: 12px; padding: 3px 9px; }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); width: min(460px, calc(100% - 32px)); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); }
@media (max-width: 640px) { .topbar { position: static; } .topbar, .subbar, .grid, .askbar { padding-left: 16px; padding-right: 16px; } .controls { margin-left: 0; } .cell .home { font-size: 38px; } .dl { grid-template-columns: 1fr; } }

/* graph badges (SVG fills follow the star colours) and dialog layout */
.graph .bs.s1 { fill: #f8fafc; stroke: #5b8fbf; } .graph .bs.s2 { fill: #262626; } .graph .bs.s3 { fill: #1e8a83; } .graph .bs.s4 { fill: #3d9a4b; }
.graph .bs.s5 { fill: #e3b52f; } .graph .bs.s6 { fill: #f1f2f4; stroke: #9aa3ad; } .graph .bs.s7 { fill: #c23b3b; } .graph .bs.s8 { fill: #fbf6ea; stroke: #c4a465; } .graph .bs.s9 { fill: #7a3e9d; }
.graph .bt { fill: #fff; } .graph .bt.s1 { fill: #1d3a57; } .graph .bt.s5 { fill: #2b2100; } .graph .bt.s6 { fill: #3a4048; } .graph .bt.s8 { fill: #5b4417; }
.graph .badge.natal .bs { stroke: var(--accent); stroke-width: 3; }
.graph .bs.ring { fill: var(--panel); stroke: var(--accent); stroke-width: 3; }
.graph .graph-legend text { font-size: 12px; fill: var(--ink-3); }
.graph .mk-gen { fill: var(--gen); } .graph .mk-ctrl { fill: var(--ctrl); } .graph .mk-off { fill: var(--line-2); }
.dialog-title { margin: 0; }
.dialog-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.dialog-right { display: flex; gap: 8px; }
