:root {
  --bg: #05080b;
  --fg: #e1ebef;
  --dim: #7a8f98;
  --line: rgba(216, 228, 234, 0.12);
  --line-strong: rgba(216, 228, 234, 0.3);
  --panel: rgba(7, 13, 18, 0.88);
  --hole: #5aa7ff;
  --fold: #ff5c5c;
  --str: #ffa733;
  --accent: #9fe3ff;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gut: clamp(12px, 2vw, 26px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
body { font-family: var(--mono); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }
.mono { font-family: var(--mono); }
.small { font-size: 12px; }
.tiny { font-size: 10.5px; line-height: 1.5; }
.dim { color: var(--dim); }
.sep { margin: 0 .6em; opacity: .5; }
.hud { position: fixed; z-index: 3; }
.tl { top: var(--gut); left: var(--gut); max-width: min(520px, calc(100vw - 2 * var(--gut))); pointer-events: none; }
.tl a { pointer-events: auto; }
.tr { z-index: 5; top: var(--gut); right: var(--gut); display: flex; gap: 8px; align-items: center; }
.bl { left: var(--gut); bottom: var(--gut); width: 300px; max-height: 52vh; }
/* One-screen viewer: the segment list is the one box that scrolls. The card grows to fit and never scrolls; on a
   window too short for it, its bottom is cut (NUMBERS folds it back), so its top stays on screen below the buttons. */
.br { right: var(--gut); bottom: var(--gut); width: 330px; max-height: calc(100vh - 2 * var(--gut) - 44px); overflow: hidden; overflow: clip; }
.kicker { font-size: 10.5px; letter-spacing: .14em; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 5vw, 54px); margin: .15em 0 .1em; line-height: 1; }
h1 em, h2 em { color: var(--accent); }
.lede { font-size: 12.5px; line-height: 1.55; color: #c3d2d8; max-width: 46ch; }
.c-hole { color: var(--hole); } .c-fold { color: var(--fold); } .c-str { color: var(--str); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; backdrop-filter: blur(8px); }
#picker { display: flex; flex-direction: column; gap: 8px; }
select, input[type=search] { background: #0a1217; color: var(--fg); border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 8px; font: inherit; width: 100%; }
.row { display: flex; gap: 6px; align-items: center; }
.list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 80px; border-top: 1px solid var(--line); }
.list li { padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.list li:hover, .list li:focus { background: rgba(159, 227, 255, .07); outline: none; }
.list li.on { background: rgba(159, 227, 255, .14); }
.list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .ar { color: var(--dim); text-align: right; }
.list .fl { grid-column: 1 / -1; font-size: 10.5px; color: var(--dim); }
.list .fl b { font-weight: 500; }
.chip, .tbtn, .lk { background: rgba(10, 18, 23, .85); color: var(--fg); border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; font: 12px var(--mono); cursor: pointer; text-decoration: none; }
.chip.on { background: var(--fg); color: var(--bg); }
.seg { display: flex; gap: 4px; }
h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: .2em 0 .4em; word-break: break-word; }
.more > summary { cursor: pointer; font-size: 10.5px; letter-spacing: .14em; margin: 0 0 6px; }
.nums { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 3px 10px; margin: 0 0 8px; }
.nums dt { color: var(--dim); }
.nums dd { margin: 0; text-align: right; white-space: nowrap; grid-column: span 2; }
.nums dd.v, .nums dd.u { grid-column: auto; }
.nums dd.u { color: var(--dim); }
.nums dd.wrap { white-space: normal; }
.nums .hd { color: var(--dim); font-size: 10.5px; padding-top: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 8px 0; }
.legend label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.sw.hole { background: var(--hole); } .sw.fold { background: var(--fold); } .sw.str { background: var(--str); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.sheet { position: fixed; inset: 0; z-index: 4; background: rgba(5, 8, 11, .97); padding: calc(var(--gut) + 56px) var(--gut) var(--gut); display: flex; flex-direction: column; }
.sheet-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
.sheet-head input { max-width: 320px; }
.tablewrap { overflow: auto; flex: 1; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #0a1217; cursor: pointer; color: var(--dim); font-weight: 500; }
th.sorted { color: var(--fg); }
td.n, th.n { text-align: right; }
tbody tr:hover { background: rgba(159, 227, 255, .06); }
tbody tr.go { cursor: pointer; }
.sheet-dialog { background: #0a1217; color: var(--fg); border: 1px solid var(--line-strong); border-radius: 12px; max-width: min(680px, calc(100vw - 32px)); padding: 18px 22px; line-height: 1.55; font-size: 13px; }
.sheet-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.sheet-dialog .x { float: right; background: none; color: var(--fg); border: 0; font-size: 22px; cursor: pointer; }
.sheet-dialog pre { background: #05080b; padding: 10px; border-radius: 6px; overflow-x: auto; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 6; background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; }
.loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; color: var(--dim); }
/* While the table or the guide is open it is the one box that scrolls: the panels under it step aside. */
html.covered .list { overflow: hidden; }
html.guide .tablewrap { overflow: hidden; }
@media (max-height: 640px) {
  .br h2 { font-size: 19px; }
  .nums { gap: 2px 10px; }
}
@media (max-width: 760px) {
  .tl .lede { display: none; }
  /* Stacked under the title: the picker, then the card. The card keeps its own height (app.js writes it to
     --card-h) up to what leaves the picker 225px, room for one row of the list; the picker takes what is left. */
  .bl { width: calc(100vw - 2 * var(--gut)); bottom: auto; top: calc(var(--gut) + 78px);
        max-height: max(225px, min(40vh, calc(100vh - 78px - 3 * var(--gut) - var(--card-h, 34vh)))); }
  .br { width: calc(100vw - 2 * var(--gut)); max-height: calc(100vh - 78px - 3 * var(--gut) - 225px); }
  .list { min-height: 56px; }
}
/* a phone: the view buttons take the top right, so the kicker keeps only the mesh count */
@media (max-width: 560px) { .k-src { display: none; } }
@media (max-width: 760px) and (max-height: 500px) {
  /* a phone on its side: the picker and the card side by side, as on a wide screen */
  .bl { top: auto; bottom: var(--gut); width: calc(50vw - 1.5 * var(--gut)); max-height: calc(100vh - 78px - 3 * var(--gut)); }
  .br { width: calc(50vw - 1.5 * var(--gut)); max-height: calc(100vh - 2 * var(--gut) - 44px); }
}
