/* Typescale. Framed-sheet app style (taste skill, seed 89260143): one stone-tinted L frame holds the
   top bar and the settings column; the work sits on a white sheet inset 8px, 1px edge, 16px corners,
   no shadow. Face: the frame takes a paper-stone tint, and the one data hue (ink blue) marks the
   scale ladder's size bars and the active tab. */
:root {
  color-scheme: light;
  --ground: #f5f5f3;
  --surface: #ffffff;
  --raised: #f4f5f6;
  --active: #e9eaea;
  --border: #e6e7e8;
  --rule: #eff0f1;
  --control: #cdced1;
  --text: #131416;
  --muted: #5d5f60;
  --accent: #1f4fb4;
  --accent-soft: #e8eefa;
  --primary: #1d1f20;
  --on-primary: #ffffff;
  --pill-warning-bg: #fffbeb;
  --pill-warning-ink: #92400e;
  --pill-warning-edge: #fde68a;
  --pill-neutral-bg: #ebedee;
  --pill-neutral-ink: #353736;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-sheet: 16px;
  --sheet-inset: 8px;
  --gap: 24px;
  --pad: 24px;
  --control-height: 32px;
  --controls-width: 300px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --code: "IBM Plex Mono", ui-monospace, monospace; /* one job: code, clamp() strings and step ids. taste-skill-ignore */
  --fs-title: 22px;
  --fs-section: 16px;
  --fs-body: 14px;
  --fs-small: 12px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0b0b0b;
  --surface: #141414;
  --raised: #1c1c1c;
  --active: #262626;
  --border: #262626;
  --rule: #1f1f1f;
  --control: #444444;
  --text: #f4f4f4;
  --muted: #b4b4b4;
  --accent: #86a8f0;
  --accent-soft: #1b2436;
  --primary: #ffffff;
  --on-primary: #111111;
  --pill-warning-bg: #2a2110;
  --pill-warning-ink: #f5c26b;
  --pill-warning-edge: #4a3a17;
  --pill-neutral-bg: #262626;
  --pill-neutral-ink: #d6d6d6;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--text);
  font: 400 var(--fs-body) / 20px var(--font);
  display: grid;
  grid-template-rows: 48px 1fr;
  height: 100dvh;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num, output, input[type="number"] { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, pre, .code { font-family: var(--code); }

/* ---- top bar (part of the frame, no rule under it) ---- */
.top { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; flex: none; }
.mark { width: 20px; height: 20px; stroke: none; fill: var(--accent); }
.crumb { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb::before { content: "/"; margin-right: 12px; color: var(--control); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-height); padding: 0 12px; border-radius: var(--radius-control);
  background: var(--surface); border: 1px solid var(--control); cursor: pointer; white-space: nowrap;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 500; }
.btn.primary:hover { opacity: 0.88; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: var(--radius-control); cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--active); color: var(--text); }

.seg { display: inline-flex; background: var(--active); border-radius: var(--radius-control); padding: 2px; height: var(--control-height); }
.seg button { border: 0; background: none; padding: 0 10px; border-radius: 4px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 500; }

/* ---- the frame's left column: settings ---- */
.work { display: grid; grid-template-columns: var(--controls-width) minmax(0, 1fr); min-height: 0; }
.controls { overflow-y: auto; padding: 8px 16px 24px; min-height: 0; }
.group { padding: 16px 0; }
.group + .group { border-top: 1px solid var(--border); }
.group h2 { font-size: 13px; font-weight: 600; margin: 0 0 12px; line-height: 20px; }
.group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.group-head h2 { margin: 0; }
.hint { color: var(--muted); font-size: var(--fs-small); line-height: 16px; margin: 8px 0 0; }
.field { display: grid; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field > label, .vp-grid > label { font-size: var(--fs-small); color: var(--muted); display: flex; justify-content: space-between; }
.field > label output { color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 84px; gap: 8px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row3 .field { margin-bottom: 0; }

input[type="number"], input[type="text"], input[type="search"], select {
  height: var(--control-height); width: 100%; min-width: 0; padding: 0 8px;
  background: var(--surface); border: 1px solid var(--control); border-radius: var(--radius-control);
}
input:hover, select:hover { border-color: var(--muted); }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 30px; cursor: pointer; }
.select-wrap::after { content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.unit-in { position: relative; }
.unit-in input { padding-right: 28px; }
.unit-in span { position: absolute; right: 8px; top: 0; line-height: var(--control-height); color: var(--muted); font-size: var(--fs-small); pointer-events: none; }
.unit-out { height: var(--control-height); line-height: var(--control-height); padding: 0 8px; color: var(--muted); background: var(--raised); border-radius: var(--radius-control); white-space: nowrap; overflow: hidden; }
input[type="range"] { width: 100%; accent-color: var(--text); margin: 0; height: 20px; }

.vp-grid { display: grid; grid-template-columns: 52px 1fr 1fr; gap: 8px; align-items: center; margin-top: 12px; }
.vp-h { font-size: var(--fs-small); color: var(--muted); }
.vp-grid > label { line-height: var(--control-height); }
#fluidFields[hidden] { display: none; }

.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { width: 30px; height: 18px; border-radius: 9px; background: var(--control); position: relative; transition: background-color 150ms ease-out; }
.switch .track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: transform 150ms ease-out; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(12px); background: var(--on-primary); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* font picker */
.font-block { position: relative; margin-bottom: 16px; border-radius: var(--radius-card); }
.font-block.drop { outline: 2px dashed var(--accent); outline-offset: 4px; }
.font-block .fb-label { font-size: var(--fs-small); color: var(--muted); display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.fb-file { border: 0; background: none; color: var(--muted); font-size: var(--fs-small); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.fb-file:hover { color: var(--text); }
.combo { position: relative; }
.combo input { padding-right: 30px; }
.combo .local-tag { position: absolute; right: 8px; top: 7px; }
.listbox {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 4px; margin: 0; list-style: none;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); /* a floating listbox. taste-skill-ignore */
}
.listbox li { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 36px; padding: 0 8px; border-radius: 4px; cursor: pointer; }
.listbox li .fam { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listbox li .cat { color: var(--muted); font-size: var(--fs-small); flex: none; }
.listbox li[aria-selected="true"], .listbox li:hover { background: var(--active); }
.listbox .empty { color: var(--muted); cursor: default; }
.axes { display: grid; gap: 4px; margin-top: 10px; }
.axis { display: grid; grid-template-columns: 52px 1fr 44px; gap: 8px; align-items: center; font-size: var(--fs-small); color: var(--muted); }
.axis output { text-align: right; color: var(--text); }
.weight-row { margin-top: 8px; }

.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); flex: none; white-space: nowrap; }
.credit { color: var(--muted); font-size: var(--fs-small); line-height: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---- the sheet ---- */
.sheet {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet);
  margin: 0 var(--sheet-inset) var(--sheet-inset) 0; overflow-y: auto; min-height: 0; min-width: 0;
  padding: 20px var(--pad) 40px;
}
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.title-text { min-width: 0; }
h1 { font-size: var(--fs-title); line-height: 28px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 4px 0 0; }
.preview-at { display: grid; grid-template-columns: auto 180px 64px; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-small); flex: none; padding-top: 4px; }
.preview-at output { color: var(--text); text-align: right; font-size: var(--fs-body); }
.preview-at[hidden] { display: none; }
.notes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.notes:empty { display: none; }
.notes li { background: var(--pill-warning-bg); color: var(--pill-warning-ink); border: 1px solid var(--pill-warning-edge); border-radius: var(--radius-control); padding: 6px 10px; font-size: 13px; line-height: 18px; }
.notes li.ok { background: var(--raised); color: var(--muted); border-color: var(--border); }

.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin: 20px 0 24px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 0 0 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head h2 { font-size: var(--fs-section); font-weight: 600; margin: 0; line-height: 24px; }
.view-head .tools { display: flex; gap: 8px; align-items: center; }
.view-head input[type="text"] { width: 280px; }

/* Scale ladder: the screen's signature. One row per step, largest first. */
.ladder { width: 100%; border-collapse: collapse; }
.ladder th { font-size: var(--fs-small); font-weight: 400; color: var(--muted); text-align: left; padding: 0 12px 8px 0; white-space: nowrap; border-bottom: 1px solid var(--border); }
.ladder th.r, .ladder td.r { text-align: right; }
.ladder td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.ladder tr:last-child td { border-bottom: 0; }
.ladder .step { width: 64px; white-space: nowrap; }
.step-id { font-family: var(--code); font-size: 13px; }
.step-role { display: block; color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.ladder .sample-cell { max-width: 0; width: 100%; }
.bar { height: 3px; background: var(--accent); border-radius: 2px; margin-bottom: 8px; }
.sample { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.ladder .px { white-space: nowrap; width: 112px; }
.px .lo { color: var(--muted); }
.ladder .clampc { width: 1%; white-space: nowrap; }
.clamp-btn { font-family: var(--code); font-size: 12px; border: 0; background: var(--raised); border-radius: 4px; padding: 3px 6px; cursor: pointer; color: var(--muted); max-width: 290px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.clamp-btn:hover { color: var(--text); background: var(--active); }
.ladder .edit { width: 76px; min-width: 76px; }
.ladder .edit input { height: 28px; width: 68px; text-align: right; padding: 0 6px; }
.ladder .edit.changed input { border-color: var(--accent); }
.ladder .reset { width: 32px; padding-right: 0; }
.ladder .reset .icon-btn { width: 28px; height: 28px; }
.ladder .reset .icon-btn[hidden] { visibility: hidden; display: inline-grid; }
.ladder-foot { color: var(--muted); font-size: var(--fs-small); margin-top: 16px; }

/* specimen surfaces: set in the chosen fonts, sized from the scale at the preview width */
.spec { color: var(--text); }
.spec-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.spec-row:last-child { border-bottom: 0; }
.spec-meta { font-size: var(--fs-small); color: var(--muted); line-height: 16px; }
.spec-meta b { display: block; color: var(--text); font-weight: 500; font-size: 13px; }
.spec-text { margin: 0; overflow-wrap: break-word; min-width: 0; }

.article { margin: 0 auto; padding: 8px 0 24px; }
.article > * { margin: 0; }
.article .deck { color: var(--muted); }
.article blockquote { border-left: 3px solid var(--accent); padding-left: 1em; }
.article ul { padding-left: 1.2em; }
.article figcaption { color: var(--muted); }

.ui-sample { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.ui-card { border: 1px solid var(--border); border-radius: 12px; padding: 24px; min-width: 0; }
.ui-card .k { color: var(--muted); }
.ui-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ui-btn { border-radius: 8px; padding: 0.55em 1.1em; border: 1px solid var(--control); background: var(--surface); cursor: default; }
.ui-btn.fill { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.ui-input { display: grid; gap: 6px; }
.ui-input span { color: var(--muted); }
.ui-input div { border: 1px solid var(--control); border-radius: 8px; padding: 0.55em 0.75em; }
.ui-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.ui-tag { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); border-radius: 4px; padding: 0.15em 0.5em; }
.ui-nav { display: flex; gap: 1.2em; border-bottom: 1px solid var(--border); padding-bottom: 0.6em; }
.ui-nav span:first-child { font-weight: 600; }
.ui-list { display: grid; }
.ui-list div { display: flex; justify-content: space-between; padding: 0.6em 0; border-bottom: 1px solid var(--rule); }
.ui-list div:last-child { border-bottom: 0; }

.waterfall-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 0; }
.wf-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 16px; align-items: baseline; border-bottom: 1px solid var(--rule); }
.wf-row:last-child { border-bottom: 0; }

.glyph-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--gap); align-items: start; }
.glyphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.glyphs button { aspect-ratio: 1; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); font-size: 24px; cursor: pointer; color: var(--text); }
.glyphs button:hover { background: var(--raised); }
.glyphs button[aria-pressed="true"] { background: var(--accent-soft); }
.glyph-big { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; position: sticky; top: 0; }
.glyph-big .g { font-size: 160px; line-height: 1; text-align: center; padding: 24px 0; }
.glyph-big dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.glyph-big dt { color: var(--muted); }
.glyph-big dd { margin: 0; text-align: right; }

.pairs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.pair { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px; display: grid; gap: 10px; align-content: start; min-width: 0; background: var(--surface); cursor: pointer; text-align: left; }
.pair:hover { border-color: var(--control); }
.pair[aria-current="true"] { border-color: var(--text); outline: 1px solid var(--text); outline-offset: -2px; }
.pair .ph { font-size: 28px; line-height: 1.15; overflow-wrap: break-word; }
.pair .pb { font-size: 15px; line-height: 1.5; color: var(--text); }
.pair .pw { font-size: var(--fs-small); color: var(--muted); line-height: 16px; }
.pair .pn { font-size: var(--fs-small); color: var(--muted); }

.export-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.code { margin: 0; background: var(--raised); border-radius: var(--radius-card); padding: 16px; font-size: 12.5px; line-height: 19px; overflow: auto; max-height: 520px; white-space: pre; tab-size: 2; }
.share { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.share input { font-family: var(--code); font-size: 12px; color: var(--muted); }
.fmt-tabs { display: flex; gap: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: var(--radius-control); opacity: 0; pointer-events: none; transition: opacity 150ms ease-out, transform 150ms ease-out; font-size: 13px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.16); } /* a floating toast. taste-skill-ignore */
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.only-phone { display: none; }

/* ---- tablet and phone: the frame folds away, settings open as a sheet ---- */
@media (max-width: 1100px) {
  .pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ui-sample, .glyph-layout { grid-template-columns: minmax(0, 1fr); }
  .glyph-big { position: static; }
  .preview-at { grid-template-columns: auto 120px 64px; }
  .clampc { display: none; }
}
@media (max-width: 860px) {
  body { overflow: auto; height: auto; display: block; }
  .top { position: sticky; top: 0; z-index: 30; background: var(--ground); height: 48px; padding: 0 8px; gap: 4px; }
  .only-phone { display: inline-grid; }
  .crumb, #copyLink span, .seg { display: none; }
  #copyLink { width: 32px; padding: 0; }
  .work { display: block; }
  .controls { position: fixed; inset: 0; z-index: 40; background: var(--ground); padding: 0 16px 32px; transform: translateX(-100%); visibility: hidden; transition: transform 200ms ease-out, visibility 200ms; }
  .controls.open { transform: none; visibility: visible; }
  .controls-head { display: flex; align-items: center; justify-content: space-between; height: 48px; font-weight: 600; position: sticky; top: 0; background: var(--ground); z-index: 1; }
  .sheet { margin: 0; border-radius: 0; border: 0; padding: 16px 16px 40px; overflow: visible; }
  .title-row { flex-direction: column; gap: 12px; }
  .preview-at { width: 100%; grid-template-columns: auto minmax(0, 1fr) 64px; }
  .tabs { margin: 16px -16px 20px; padding: 0 16px; gap: 18px; }
  .tabs button { padding-bottom: 12px; min-height: 44px; }
  .view-head input[type="text"] { width: 100%; }
  .view-head .tools { width: 100%; }
  .pairs { grid-template-columns: minmax(0, 1fr); }
  .spec-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .wf-row { grid-template-columns: 56px minmax(0, 1fr); gap: 8px; }
  .ladder thead { display: none; }
  .ladder, .ladder tbody { display: block; }
  .ladder tr { display: grid; grid-template-columns: minmax(0, 1fr) 64px 64px 28px; grid-template-areas: "sample sample sample sample" "step lh ls reset"; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .ladder tr:last-child { border-bottom: 0; }
  .ladder td { padding: 0; border: 0; display: block; }
  .ladder .sample-cell { grid-area: sample; max-width: none; }
  .ladder .step { grid-area: step; width: auto; display: flex; gap: 8px; align-items: baseline; }
  .ladder .step .px-inline { display: inline; }
  .ladder .px, .ladder .clampc { display: none; }
  .ladder .edit { width: auto; }
  .ladder .edit.lh { grid-area: lh; }
  .ladder .edit.ls { grid-area: ls; }
  .ladder .reset { grid-area: reset; }
  .glyphs button { font-size: 20px; }
  .glyph-big .g { font-size: 120px; }
}
.px-inline { display: none; color: var(--muted); font-size: var(--fs-small); }

/* the chosen fonts, set through custom properties from app.js */
.fh { font-family: var(--fh); font-weight: var(--fhw); font-variation-settings: var(--fhv, normal); }
.fb { font-family: var(--fb); font-weight: var(--fbw); font-variation-settings: var(--fbv, normal); }
