/* Holm Desk — an instrument panel for how Holm is built. One monospace family
   (Martian Mono, variable weight and width) carries the hierarchy; panes are
   framed like a terminal's, with their names set into the border. */

@font-face {
  font-family: "Martian Mono";
  src: url("/vendor/martian-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #eef1f5;
  --panel: #f8fafc;
  --rule: #cfd8e3;
  --rule-strong: #a9b7c8;
  --ink: #0f1b2d;
  --ink-2: #45556b;
  --ink-3: #6e7d92;
  --signal: #b9770e;          /* commits: the pulse */
  --signal-soft: rgba(185, 119, 14, 0.14);
  --signal-glow: rgba(185, 119, 14, 0.35);
  --agent: #1d8a94;           /* AI agents */
  --agent-soft: rgba(29, 138, 148, 0.16);
  --s1: #2a78d6; --s2: #1baf7a; --s3: #6250d6; --s4: #eb6834; --s5: #8a96a8;
  --cell: #e3e9f0;
  --focus: #2a78d6;
  --shadow: 0 1px 0 rgba(15, 27, 45, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0b1422;
    --panel: #0f1a2c;
    --rule: #22334c;
    --rule-strong: #364b6a;
    --ink: #dbe5f1;
    --ink-2: #9cadc3;
    --ink-3: #6a7e98;
    --signal: #f2b33d;
    --signal-soft: rgba(242, 179, 61, 0.16);
    --signal-glow: rgba(242, 179, 61, 0.45);
    --agent: #5fc9d3;
    --agent-soft: rgba(95, 201, 211, 0.16);
    --s1: #3987e5; --s2: #199e70; --s3: #9085e9; --s4: #d95926; --s5: #6c7a8e;
    --cell: #16243a;
    --focus: #5fc9d3;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0b1422;
  --panel: #0f1a2c;
  --rule: #22334c;
  --rule-strong: #364b6a;
  --ink: #dbe5f1;
  --ink-2: #9cadc3;
  --ink-3: #6a7e98;
  --signal: #f2b33d;
  --signal-soft: rgba(242, 179, 61, 0.16);
  --signal-glow: rgba(242, 179, 61, 0.45);
  --agent: #5fc9d3;
  --agent-soft: rgba(95, 201, 211, 0.16);
  --s1: #3987e5; --s2: #199e70; --s3: #9085e9; --s4: #d95926; --s5: #6c7a8e;
  --cell: #16243a;
  --focus: #5fc9d3;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 13px/1.55 "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }
kbd { font: inherit; }

/* ---------- top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-weight: 650;
  font-stretch: 112.5%;
  letter-spacing: -0.01em;
  color: var(--signal);
}
.brand span { color: var(--ink); }
.spaces { display: flex; gap: 18px; font-stretch: 87.5%; }
.spaces a, .spaces span { text-decoration: none; color: var(--ink-3); padding: 2px 0; }
.spaces a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--signal); }
.spaces span[aria-disabled] { cursor: default; opacity: 0.7; }
.ranges[hidden] { display: none; }
.ranges { margin-left: auto; display: flex; gap: 2px; border: 1px solid var(--rule); border-radius: 7px; padding: 2px; }
.ranges button {
  border: 0; background: none; cursor: pointer;
  padding: 4px 10px; border-radius: 5px;
  font-stretch: 87.5%; color: var(--ink-2);
}
.ranges button kbd { color: var(--ink-3); margin-right: 6px; font-size: 11px; }
.ranges button[aria-checked="true"] { background: var(--signal-soft); color: var(--ink); }
.ranges button[aria-checked="true"] kbd { color: var(--signal); }
.account { position: relative; }
.ranges[hidden] + .account { margin-left: auto; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--rule-strong); background: var(--panel);
  padding: 0; overflow: hidden; cursor: pointer;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu {
  position: absolute; right: 0; top: 40px; z-index: 5;
  min-width: 240px; padding: 8px;
  background: var(--panel); border: 1px solid var(--rule-strong); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.menu .who { display: grid; padding: 6px 8px 10px; border-bottom: 1px solid var(--rule); margin-bottom: 6px; }
.menu .who span { color: var(--ink-3); font-size: 12px; }
.menu .item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 8px; border-radius: 5px; text-decoration: none; cursor: pointer; }
.menu .item:hover { background: var(--cell); }
.themes { border: 0; margin: 0 0 6px; padding: 4px 8px 8px; display: flex; gap: 12px; border-bottom: 1px solid var(--rule); }
.themes legend { padding: 0; color: var(--ink-3); font-size: 12px; margin-bottom: 4px; float: left; width: 100%; }
.themes label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; font-stretch: 87.5%; }

/* ---------- panes ---------- */
main { flex: 1; padding: 30px clamp(16px, 3vw, 36px) 12px; outline: none; }
.board {
  max-width: 1440px; margin: 0 auto;
  display: grid; gap: 30px 22px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}
.pane {
  position: relative;
  grid-column: span 12;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 26px 22px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.pane > h2 {
  position: absolute; top: -0.85em; left: 16px; margin: 0;
  padding: 0 8px;
  background: var(--ground);
  font-size: 12.5px; font-weight: 600; font-stretch: 112.5%;
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1.6;
}
.pane > h2::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px; background: var(--rule-strong); margin-right: 8px; vertical-align: 1px; }
.pane.signal > h2::before { background: var(--signal); }
.pane.agents > h2::before { background: var(--agent); }
.pane .aside { position: absolute; top: -0.85em; right: 16px; padding: 0 8px; background: var(--ground); color: var(--ink-3); font-size: 11.5px; font-stretch: 87.5%; line-height: 1.6; }
.half { grid-column: span 6; }
.third { grid-column: span 4; }
.two-thirds { grid-column: span 8; }

.lede { margin: 0 0 16px; color: var(--ink-2); font-stretch: 87.5%; max-width: 70ch; }
.lede b { color: var(--ink); font-weight: 600; }
.muted { color: var(--ink-3); }

/* ---------- pulse ---------- */
.pulse-pane { padding-top: 30px; }
.pulse-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 26px; margin-bottom: 18px; }
.pulse-head .big {
  font-size: clamp(34px, 5.4vw, 64px);
  line-height: 1;
  font-weight: 250;
  font-stretch: 112.5%;
  letter-spacing: -0.03em;
}
.pulse-head .big small { font-size: 0.42em; font-weight: 400; color: var(--ink-2); letter-spacing: 0; margin-left: 0.4em; }
.pulse-head .of { color: var(--ink-2); font-stretch: 87.5%; font-size: 14px; }
.trace-wrap { position: relative; height: clamp(200px, 26vw, 300px); margin: 0 -6px; touch-action: pan-y; }
.trace-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.trace-wrap canvas:focus-visible { outline-offset: -2px; }
.status {
  display: flex; flex-wrap: wrap; gap: 4px 26px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--rule-strong);
  font-stretch: 87.5%; color: var(--ink-2);
  min-height: 2.6em;
}
.status b { color: var(--ink); font-weight: 600; }
.status .when { color: var(--signal); font-weight: 600; min-width: 15ch; }
.status .tag { color: var(--agent); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; margin-top: 20px; }
.fact { border-left: 2px solid var(--rule); padding-left: 12px; }
.fact .v { font-size: 22px; font-weight: 400; font-stretch: 112.5%; letter-spacing: -0.02em; line-height: 1.2; }
.fact .k { color: var(--ink-3); font-size: 11.5px; font-stretch: 87.5%; }

/* ---------- svg charts ---------- */
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
/* Dense hour grids keep a readable size and scroll inside their pane. */
.scroll-x { overflow-x: auto; overscroll-behavior-x: contain; }
.scroll-x > svg.chart { min-width: 620px; }
svg.chart text { fill: var(--ink-3); font: 400 10.5px "Martian Mono", ui-monospace, monospace; font-stretch: 87.5%; }
svg.chart .axis { stroke: var(--rule); stroke-width: 1; }
svg.chart .grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; }
.cell-hit:hover { stroke: var(--ink); stroke-width: 1.5; }

/* code mix */
.mix { display: flex; gap: 2px; height: 26px; border-radius: 4px; overflow: hidden; margin: 6px 0 12px; }
.mix span { display: block; height: 100%; min-width: 2px; }
.mix-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 18px; margin: 0; padding: 0; list-style: none; }
.mix-legend li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: baseline; font-stretch: 87.5%; }
.mix-legend i { width: 10px; height: 10px; border-radius: 2px; align-self: center; }
.mix-legend .n { color: var(--ink-3); }
.tbl { width: 100%; border-collapse: collapse; font-stretch: 87.5%; margin-top: 16px; }
.tbl th { text-align: left; font-weight: 500; color: var(--ink-3); padding: 0 0 6px; border-bottom: 1px solid var(--rule); }
.tbl td { padding: 6px 0; border-bottom: 1px dashed var(--rule); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr:last-child td { border-bottom: 0; }

/* bars list */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bars li { display: grid; grid-template-columns: 11ch 1fr 6ch; gap: 10px; align-items: center; font-stretch: 87.5%; }
.bars .track { height: 9px; border-radius: 3px; background: var(--cell); overflow: hidden; }
.bars .fill { height: 100%; border-radius: 3px; background: var(--agent); }
.bars .n { text-align: right; color: var(--ink-2); }

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--ink); color: var(--panel);
  padding: 6px 9px; border-radius: 5px;
  font-size: 11.5px; font-stretch: 87.5%; line-height: 1.45;
  white-space: nowrap; transform: translate(-50%, calc(-100% - 10px));
}
.tip[hidden] { display: none; }

/* ---------- gate, boot, footer ---------- */
.booting { max-width: 1440px; margin: 18vh auto 0; color: var(--ink-3); text-align: center; font-stretch: 87.5%; }
.caret { display: inline-block; width: 0.6em; height: 1.1em; background: var(--signal); vertical-align: -0.2em; margin-left: 4px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.gate { max-width: 560px; margin: 14vh auto 0; }
.gate .pane { padding: 34px 28px 26px; }
.gate p { color: var(--ink-2); margin: 0 0 18px; }
.button { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--rule-strong); text-decoration: none; background: var(--panel); cursor: pointer; }
.button.primary { background: var(--signal); border-color: var(--signal); color: #1a1202; font-weight: 600; }
.foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px clamp(16px, 3vw, 36px) 26px;
  color: var(--ink-3); font-size: 11.5px; font-stretch: 87.5%;
}
.foot .made { text-decoration: none; }
.foot .made:hover { color: var(--ink); }

/* ---------- dialog, toast ---------- */
dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--rule-strong); border-radius: 10px;
  background: var(--panel); color: var(--ink);
  padding: 22px;
}
dialog::backdrop { background: rgba(5, 10, 18, 0.55); }
.dialog-head { display: flex; justify-content: space-between; align-items: baseline; }
.dialog-head h2 { margin: 0 0 8px; font-size: 15px; font-stretch: 112.5%; font-weight: 600; }
.link { background: none; border: 0; padding: 0; color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.access-list { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 6px; }
.access-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--rule); }
.invite label { display: block; margin-bottom: 6px; color: var(--ink-2); }
.invite-row { display: flex; gap: 8px; }
.invite-row input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--rule-strong); background: var(--ground); color: var(--ink); font: inherit; }
.invite-row button { padding: 8px 14px; border-radius: 6px; border: 0; background: var(--signal); color: #1a1202; font-weight: 600; cursor: pointer; }
.error { color: #d9534f; margin: 8px 0 0; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 9px 14px; border-radius: 6px; font-stretch: 87.5%; z-index: 30; }

/* ---------- small screens ---------- */
@media (max-width: 980px) {
  .half, .third, .two-thirds { grid-column: span 12; }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 10px 18px; }
  .spaces { order: 3; width: 100%; overflow-x: auto; }
  .ranges { order: 4; margin-left: 0; width: 100%; justify-content: space-between; }
  .ranges button { flex: 1; padding: 5px 4px; }
  .ranges button kbd { display: none; }
  .account { margin-left: auto; }
  .pane { padding: 24px 14px 16px; }
  .board { gap: 28px; }
  .bars li { grid-template-columns: 13ch 1fr 4ch; }
}

@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; }
}
