/* Cockpit — the one stylesheet.
 *
 * Tokens first, components after. Dark is the primary appearance: a blue-black
 * ground (#030712) with slate surfaces, blue accent, 12px radii, Inter as the
 * face — bundled, so the cockpit makes no request outside its own origin.
 * Light is derived from the same tokens. Nothing here is specific to a module —
 * a module gets a card, and a card looks like every other card.
 */

@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/InterVariable.woff2") format("woff2");
}

:root {
  --bg: #030712;
  --surface: #0b1220;
  --surface-2: #111a2e;
  --line: #1e293b;
  --ink: #f1f5f9;
  --ink-2: #94a3b8;
  --ink-3: #64748b;
  --accent: #3b82f6;
  --accent-soft: #60a5fa;
  --accent-ink: #ffffff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
  --radius-s: 8px;
  --pill: 999px;
  --gap: 16px;
  --font: "Inter", ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --line: #e2e8f0;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --shadow: 0 1px 2px rgba(15,23,42,.06);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f8fafc; --surface: #ffffff; --surface-2: #f1f5f9; --line: #e2e8f0;
    --ink: #0f172a; --ink-2: #475569; --ink-3: #94a3b8; --shadow: 0 1px 2px rgba(15,23,42,.06);
  }
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { color-scheme: dark light; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* -------------------------------------------------------------- layout */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.brand h1 em { font-style: normal; color: var(--accent-soft); }
.brand .tag { color: var(--ink-3); font-size: 13px; }
.controls { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.controls select, .controls button {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--pill); padding: 5px 12px; cursor: pointer;
}
main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.stamp { color: var(--ink-3); font-size: 12px; margin: 0 0 18px; }

.grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

/* ---------------------------------------------------------------- card */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
  position: relative; min-height: 220px; transition: border-color .15s ease;
}
.card:hover { border-color: var(--ink-3); }
.card::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 3px; background: var(--ink-3);
}
.card[data-state="ok"]::before        { background: var(--ok); }
.card[data-state="attention"]::before { background: var(--warn); }
.card[data-state="blocked"]::before   { background: var(--bad); }
.card[data-state="stale"]::before,
.card[data-state="denied"]::before,
.card[data-state="error"]::before,
.card[data-state="invalid"]::before   { background: var(--ink-3); }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head h2 { font-size: 15px; }
.card-head .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }

.headline { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 2px; }
.headline .num { font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.headline .unit { color: var(--ink-2); font-size: 13px; }

.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.lines li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.lines .label { color: var(--ink-2); }
.lines .value { font-variant-numeric: tabular-nums; font-weight: 600; }
.lines .value.warn  { color: var(--warn); }
.lines .value.ok    { color: var(--ok); }
.lines .value.muted { color: var(--ink-3); font-weight: 500; }

.card-foot {
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px;
}
.card-foot .src { color: var(--ink-3); font-family: var(--mono); font-size: 11px;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hint { color: var(--ink-2); font-size: 13px; margin: 0; }

/* -------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--pill); font-size: 11px;
  font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink-2); background: var(--surface-2);
}
.badge.running    { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge.draft      { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.planned    { color: var(--ink-2); }
.badge.assumption { color: var(--ink-3); border-style: dashed; }
.badge.state-ok        { color: var(--ok); }
.badge.state-attention { color: var(--warn); }
.badge.state-blocked   { color: var(--bad); }

/* ------------------------------------------------------------- module page */
.module-page h2 { font-size: 22px; margin-bottom: 4px; }
.module-page .back { display: inline-block; margin-bottom: 18px; font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
pre.raw {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; overflow: auto; font-size: 12px; line-height: 1.45;
}

@media (max-width: 640px) {
  .top { padding: 12px 16px; flex-wrap: wrap; }
  main { padding: 16px; }
  .headline .num { font-size: 34px; }
}

/* ------------------------------------------------------------- figures */
.fig { margin: 2px 0 4px; }
.fig svg { display: block; width: 100%; height: auto; }
.fig-bar svg { height: 10px; }
.legend { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px;
          font-size: 11px; color: var(--ink-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend b { color: var(--ink); font-weight: 600; margin-left: 3px; }
.fig-ring { display: flex; align-items: center; gap: 14px; }
.fig-ring svg { width: 76px; height: 76px; flex: none; }
.ring-label { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fig-flow svg { max-height: 74px; }
.flow-ends { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-3); margin-top: 2px; }
.fig-route svg { max-height: 120px; }

/* ------------------------------------------------------------- actions */
.two { display: grid; grid-template-columns: minmax(300px, 520px) minmax(300px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.actions h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 0 0 12px; }
.action {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px;
}
.action h4 { margin: 0; font-size: 14px; }
.action label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.action input, .action select, .action textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 10px;
}
.action button {
  align-self: flex-start; font: inherit; font-weight: 600; color: var(--accent-ink);
  background: var(--accent); border: 0; border-radius: var(--pill); padding: 8px 16px; cursor: pointer;
}
.action button:hover { filter: brightness(1.1); }
.outcome { border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: var(--radius);
           background: var(--surface); padding: 12px 14px; margin-bottom: 14px; font-size: 13px; }
.outcome.bad { border-left-color: var(--bad); }
.outcome-head { margin-bottom: 6px; }
.outcome pre { margin: 0; white-space: pre-wrap; font-size: 12px; color: var(--ink-2); }
.outcome .argv { margin-top: 8px; font-size: 11px; color: var(--ink-3); }

/* -------------------------------------------------------------- blocks */
.block { margin-top: 28px; }
.block h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 12px; }
/* a titled block folds: the heading is the handle, the state lives in the browser */
.block details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.block details.fold > summary::-webkit-details-marker { display: none; }
.block details.fold > summary::before { content: "▸"; font-size: 11px; color: var(--ink-3); transition: transform .15s; }
.block details.fold[open] > summary::before { transform: rotate(90deg); }
.block details.fold > summary h3 { margin: 0; }
.block details.fold:not([open]) > summary { margin-bottom: 0; }
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { flex: 0 0 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.kcol h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2);
           display: flex; justify-content: space-between; }
.kcol[data-tone="warn"] h4 { color: var(--warn); }
.kcol[data-tone="ok"] h4 { color: var(--ok); }
.kcard { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; transition: border-color .15s ease; }
.kcard:hover { border-color: var(--accent); }
.ktag { display: inline-block; font: 700 10px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--accent-soft);
        background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: var(--pill); padding: 2px 8px; margin-bottom: 4px; }
.ktitle { font-size: 13px; font-weight: 600; margin: 2px 0 4px; line-height: 1.35; }
.kmeta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--ink-3); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.badge.tone-ok { color: var(--ok); } .badge.tone-warn { color: var(--warn); } .badge.tone-bad { color: var(--bad); }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px;
       font-size: 14px; line-height: 1.6; max-width: 900px; }
.doc h1 { font-size: 20px; margin: 0 0 12px; } .doc h2 { font-size: 16px; margin: 22px 0 8px; } .doc h3 { font-size: 14px; margin: 16px 0 6px; }
.doc table { font-size: 12.5px; margin: 10px 0; } .doc code { background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.doc pre { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-s); overflow: auto; font-size: 12px; }
.doc blockquote { margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--line); color: var(--ink-2); }
.doc-page { max-width: 960px; }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.links li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 12px; font-size: 14px; }
.links .note { color: var(--ink-3); font-size: 12px; margin-left: 8px; }
.rawbox { margin-top: 24px; font-size: 13px; color: var(--ink-2); } .rawbox summary { cursor: pointer; }

/* ---------------------------------------------------------------- apps */
.applink { display: flex; align-items: center; gap: 14px; margin: 0 0 20px; }
.button { display: inline-block; font-weight: 600; color: var(--accent-ink); background: var(--accent);
          border-radius: var(--pill); padding: 9px 18px; }
.button:hover { text-decoration: none; filter: brightness(1.1); }

/* ------------------------------------------------------------ intro */
.intro-body, .login-body { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%), var(--bg); }
.intro { width: min(720px, 92vw); position: relative; cursor: pointer; }
.intro-svg { width: 100%; height: auto; display: block; }
.intro .grid line { opacity: 0; animation: fade .8s ease forwards; }
.intro .grid line:nth-child(odd) { animation-delay: .1s; } .intro .grid line:nth-child(even) { animation-delay: .25s; }
.intro .n { opacity: 0; transform: translateY(6px); animation: rise .5s cubic-bezier(.2,.8,.2,1) forwards; }
.intro .n1 { animation-delay: .5s; } .intro .n2 { animation-delay: .65s; } .intro .n3 { animation-delay: .8s; }
.intro .n4 { animation-delay: .95s; } .intro .n5 { animation-delay: 1.1s; }
.intro .l { stroke-dasharray: 220; stroke-dashoffset: 220; animation: draw 1s ease-out forwards; }
.intro .l1 { animation-delay: 1.3s; } .intro .l2 { animation-delay: 1.4s; } .intro .l3 { animation-delay: 1.5s; }
.intro .l4 { animation-delay: 1.6s; } .intro .l5 { animation-delay: 1.7s; }
.intro .gate { opacity: 0; transform-origin: 240px 150px; transform: scale(.6); animation: pop .6s cubic-bezier(.2,.9,.3,1.3) 2.2s forwards; }
.intro .check { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .5s ease-out 2.7s forwards; }
.intro .title, .intro .tag { opacity: 0; animation: fade .7s ease 3.1s forwards; }
.intro .tag { animation-delay: 3.35s; }
.intro .skip { position: absolute; right: 0; bottom: -34px; font-size: 12px; color: var(--ink-3); opacity: 0; animation: fade .6s ease 1.5s forwards; }
@keyframes fade { to { opacity: 1; } }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop  { to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .intro * { animation-duration: .01s !important; animation-delay: 0s !important; } }

/* ------------------------------------------------------------ login */
.login { width: min(420px, 92vw); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 34px 34px 24px;
              box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: rise .5s cubic-bezier(.2,.8,.2,1); }
.login-mark { margin-bottom: 14px; }
.login-card h1 { font-size: 22px; }
.login-card .tag { color: var(--ink-2); margin: 4px 0 22px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); }
.login-form input { font: inherit; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
                    border-radius: var(--radius-s); padding: 10px 12px; }
.login-form input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); border-color: var(--accent); }
.login-form button { margin-top: 6px; font: inherit; font-weight: 600; font-size: 15px; color: var(--accent-ink);
                     background: linear-gradient(135deg, var(--accent), #2f6fd8); border: 0; border-radius: var(--radius-s);
                     padding: 11px 14px; cursor: pointer; }
.login-error { color: var(--bad); font-size: 13px; margin: 0; }
.login-foot { display: flex; justify-content: space-between; margin-top: 18px; font-size: 12px; color: var(--ink-3); }
.login-foot a { color: var(--ink-3); } .login-foot a.on { color: var(--ink); font-weight: 600; }

/* ----------------------------------------------------- header: user */
.who { display: flex; align-items: center; gap: 8px; }
.who .avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700;
               color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--ok)); }
.who a { color: var(--ink-3); font-size: 12px; }

/* -------------------------------------------------------------- setup */
.setuplink { font-size: 13px; color: var(--ink-2); }
.tabs { display: flex; gap: 14px; margin: 0 0 6px; font-size: 13px; }
.tabs a { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.setup .block { margin-top: 26px; }
.schema { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.schema > summary { cursor: pointer; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.schema .tablewrap { margin: 10px 0; border: 0; }
.schema .defhead { background: var(--surface-2); font-family: var(--mono); font-size: 11px; text-transform: none; letter-spacing: 0; }
.action .row { display: flex; gap: 10px; flex-wrap: wrap; } .action .row label { flex: 1; min-width: 140px; }
.action label.check { flex-direction: row; align-items: center; gap: 8px; }
.doc-two { grid-template-columns: minmax(320px, 1fr) minmax(300px, 420px); }
.doc.proposal { border-left: 3px solid var(--warn); }
.action textarea[name="body"] { font-family: var(--mono); font-size: 12px; line-height: 1.45; }

/* files in a container: tiles (thumbnail or type icon, name below) or a plain list */
.view-toggle { float: right; display: inline-flex; gap: 2px; }
.view-toggle button { font-size: 11px; padding: 3px 9px; background: transparent; border: 1px solid var(--line); color: var(--ink-2); cursor: pointer; }
.view-toggle button.on { background: var(--surface-2, var(--line)); color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--surface); min-width: 0; }
.tile:hover { border-color: var(--accent); }
.tile .thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--bg-2, #111); display: flex; align-items: center; justify-content: center; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile svg { width: 46%; height: 46%; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tile svg .ln { stroke: var(--accent); }
.tile svg text { fill: var(--ink-2); stroke: none; font-size: 11px; font-weight: 700; font-family: inherit; }
.tile-review svg { stroke: var(--warn); }
.tile .play { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-40%, -50%); border-left: 16px solid #fff; border-top: 10px solid transparent; border-bottom: 10px solid transparent; opacity: .85; filter: drop-shadow(0 0 4px rgba(0,0,0,.6)); }
.tile .fname { font-size: 12px; font-family: var(--mono, ui-monospace, monospace); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .fmeta { font-size: 11px; color: var(--ink-2); }
.filelist { width: 100%; border-collapse: collapse; font-size: 13px; }
.filelist th, .filelist td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
input[type=file] { font-size: 13px; }

/* board filters: one select per value list in the data's schema */
.kfilters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; margin: 0 0 12px; }
.kfilters label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.kfilters select { font-size: 13px; min-width: 130px; }
.kfilters button { align-self: end; font-size: 12px; padding: 5px 10px; }
.kcard[hidden] { display: none; }

/* the right column: action forms, then the blocks that belong next to them */
.col-right { min-width: 0; }
.aside-blocks { margin-top: 18px; }
.aside-blocks .block { margin-top: 0; }

/* covers: a piece's poster, drawn from its meta — on the board card and at the top of its page */
.kcard.has-cover { display: flex; gap: 10px; align-items: flex-start; }
.kcover { flex: 0 0 auto; display: block; line-height: 0; }
.kcover svg { width: 56px; height: auto; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.4); display: block; }
.kbody { min-width: 0; flex: 1; }
.doc-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 8px; }
.doc-cover svg { width: 120px; height: auto; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.45); display: block; }
.kcol[data-tone="warn"] { border-color: var(--warn); }

/* the hidden attribute wins over every display rule above */
[hidden] { display: none !important; }

/* a collapsed column (the archive): narrow, cards behind a summary */
.kcol.collapsed { flex-basis: 150px; }
.kcol.collapsed summary { cursor: pointer; font-size: 12px; color: var(--ink-2); padding: 6px 0; }
.kcol.collapsed details[open] { flex-basis: 240px; }

/* ------------------------------------------------------------ the rail */
body.has-rail { padding-left: 64px; }
.rail {
  position: fixed; left: 0; top: 0; bottom: 0; width: 64px; z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0;
  background: var(--surface); border-right: 1px solid var(--line);
}
.rail a { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; color: var(--ink-3); }
.rail a:hover { background: var(--surface-2); color: var(--m, var(--ink)); text-decoration: none; }
.rail a.on { background: var(--surface-2); color: var(--m, var(--ink)); box-shadow: inset 0 0 0 1px var(--line); }
.rail .rail-home { margin-bottom: 8px; color: var(--ink-2); }
.rail .rail-setup { margin-top: auto; }
.glyph { display: block; }

/* card head: glyph in the plugin's colour, then title and subtitle */
.card-head { align-items: flex-start; }
.card-glyph { color: var(--m, var(--accent)); display: inline-flex; align-items: center; justify-content: center;
              width: 34px; height: 34px; border-radius: 9px; background: color-mix(in srgb, var(--m, var(--accent)) 14%, transparent); flex: 0 0 auto; }
.card-title { flex: 1; min-width: 0; }
.card-head .badge { margin-left: auto; }
h2.with-glyph { display: flex; align-items: center; gap: 10px; }

/* the greeting */
.hello { margin: 4px 0 22px; }
.hello h2 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.hello-line { margin: 6px 0 4px; font-size: 15px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.hello .stamp { margin: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ink-3); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* ------------------------------------------------------------ calendar */
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; overflow-x: auto; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 6px; margin-bottom: 6px; }
.cal-day { min-height: 76px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 8px; background: var(--bg); display: flex; flex-direction: column; gap: 4px; }
.cal-day.slot { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.cal-day.slot.busy { border-style: solid; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-date { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cal-date span:first-child { font-weight: 700; color: var(--ink-2); }
.cal-day.today .cal-date span:first-child { color: var(--accent-soft); }
.cal-piece { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink); text-decoration: none; border-left: 3px solid var(--accent); padding-left: 6px; }
.cal-piece.published { border-left-color: var(--ok); }
.cal-piece .ktag { margin: 0; align-self: flex-start; }
.cal-piece .cal-title { line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cal-piece:hover { text-decoration: none; color: var(--accent-soft); }
.cal-foot { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 12px; color: var(--ink-2); padding: 6px 4px 0; }
.cal-foot b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.cal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; background: var(--accent); }
.cal-legend i.published { background: var(--ok); }
.cal-legend i.slot { background: transparent; border: 1px dashed color-mix(in srgb, var(--accent) 60%, var(--line)); }

/* ------------------------------------------------------------------ the desk
 * The creator's view: pieces by what is next, one button each; a piece page with
 * head, files in words, notes as a thread, helpers. Same tokens as everything else. */
.desk { max-width: 1180px; margin: 0 auto; }
.desk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.desk-head h2 { font-size: 24px; }
.desk .stamp { margin-bottom: 6px; }
.button.small { padding: 6px 14px; font-size: 13px; border-radius: var(--pill); }
.button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button.ghost:hover { border-color: var(--ink-3); filter: none; }
.button.ok { background: var(--ok); }
form.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
form.inline input[type=date] { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 5px 8px; }
.flash { border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: var(--radius); background: var(--surface); padding: 10px 14px; margin: 10px 0 16px; font-size: 13px; white-space: pre-wrap; }
.flash.bad { border-left-color: var(--bad); }
.newidea { margin: 12px 0 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.newidea > summary { list-style: none; cursor: pointer; padding: 14px 18px; font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.newidea > summary::-webkit-details-marker { display: none; }
.newidea .plus { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.newidea .action { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); margin: 0; }
.dgroup { margin-top: 26px; }
.dgroup h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.dgroup h3 .count { font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--pill); padding: 0 8px; font-size: 11px; }
.dgroup-you h3 { color: var(--warn); }
.dcards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.dcard { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; transition: border-color .15s ease; }
.dcard:hover { border-color: var(--ink-3); }
.dgroup-you .dcard { border-left: 3px solid var(--warn); }
.dgroup-working .dcard { border-left: 3px solid var(--accent); }
.dcover { grid-row: 1 / span 2; display: block; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; }
.dcover svg { width: 56px; height: 56px; display: block; }
.dformat { font: 600 11px var(--font); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.dtitle { font-size: 15px; font-weight: 650; line-height: 1.3; }
.dtitle a { color: var(--ink); }
.dstate { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.dact { grid-column: 2; margin-top: 4px; }
.dcard:not(:has(.dcover)) .dact { grid-column: 1 / -1; }
/* the piece page */
.piece .back { font-size: 13px; }
.phead { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; margin: 18px 0 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.pcover svg { width: 120px; height: 120px; display: block; border-radius: 10px; }
.phead h2 { font-size: 24px; margin: 4px 0 6px; }
.psub { margin: 0 0 6px; color: var(--ink-2); }
.pstate { margin: 0; font-size: 13px; }
.pact { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.pgrid { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(320px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .pgrid, .phead { grid-template-columns: 1fr; } .pact { align-items: flex-start; } }
.pfiles h3, .pnotes h3, .phelpers h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 12px; }
.tile .flabel { font-size: 13px; font-weight: 600; line-height: 1.25; }
.tile .fver { font-weight: 500; color: var(--ink-2); font-size: 11px; }
.pupload { margin-top: 14px; font-size: 13px; } .pupload summary { cursor: pointer; color: var(--accent); }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.note-forme { border-left: 3px solid var(--warn); }
.note-done { opacity: .75; }
.note-approved { border-left: 3px solid var(--ok); }
.nhead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-2); }
.nhead .nid { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.ntitle { font-weight: 650; margin: 6px 0 4px; }
.ntext { font-size: 13.5px; white-space: pre-wrap; line-height: 1.5; }
.nreply { margin-top: 8px; font-size: 13px; } .nreply summary { cursor: pointer; color: var(--accent); }
.nreply .action, .nnew { margin-top: 8px; }
.note form.inline { margin-top: 8px; }
.helpers { display: flex; flex-wrap: wrap; gap: 10px; }
.helper { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; font-size: 12px; color: var(--ink-2); }
.helper.dim-helper { opacity: .55; }
.phelpers { margin-top: 26px; }
.precord { margin: -8px 0 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.precord h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 10px; }
.precord .kv { font-size: 13px; } .precord .kv dt { font-family: var(--mono); font-size: 12px; } .precord .kv dd { word-break: break-word; }
.nask { border-left: 3px solid var(--accent); }
/* the matrix: artifacts down, stages across */
.matrixwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.matrix { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.matrix th, .matrix td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: center; }
.matrix th.mart, .matrix td.mart { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix th.mst { font-weight: 600; color: var(--ink-2); vertical-align: bottom; }
.matrix th.mst span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; max-height: 110px; overflow: hidden; text-overflow: ellipsis; }
.matrix th.mst small { display: block; color: var(--accent-soft); font-size: 10px; margin-top: 4px; }
.matrix th.current, .matrix td.current { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.matrix tr.due td.mart b { color: var(--warn); }
.matrix tr.later td { color: var(--ink-3); }
.matrix .dot { font-size: 14px; text-decoration: none; }
.matrix .dot.have { color: var(--ok); } .matrix .dot.due { color: var(--warn); } .matrix .dot.later, .matrix .dot.carry { color: var(--ink-3); }
.matrix .dot sup { font-size: 9px; margin-left: 1px; }
.artifacts { border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 10px 12px; margin: 0; }
.artifacts legend { font-size: 12px; color: var(--ink-2); padding: 0 6px; }
.artifacts label small { margin-left: 4px; font-family: var(--mono); font-size: 10px; }
