/* Typeshelf: framed-sheet app style after Facet. Warm paper frame, white sheet, Instrument Sans, vermilion accent. */
:root {
  --ground: #f5f3f1;
  --sheet: #ffffff;
  --raised: #f5f3f1;
  --active: #ebe7e3;
  --border: #e8e4e0;
  --rule: #f0edea;
  --control: #cdc7c1;
  --text: #171514;
  --muted: #615b56;
  --accent: #cc3328;
  --accent-soft: #fbe6e3;
  --radius-card: 10px;
  --radius-control: 6px;
  --radius-sheet: 16px;
  --inset: 8px;
  --side: 236px;
  --top: 52px;
  --pad: 32px;
  --font: 'Instrument Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace; /* taste-skill-ignore: only for the copied code in <pre> */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ground: #110f0e; --sheet: #1a1817; --raised: #221f1e; --active: #2c2927; --border: #2c2927; --rule: #242120;
    --control: #46413e; --text: #ededec; --muted: #aaa39d; --accent: #ff7a6b; --accent-soft: #46201b;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --ground: #110f0e; --sheet: #1a1817; --raised: #221f1e; --active: #2c2927; --border: #2c2927; --rule: #242120;
  --control: #46413e; --text: #ededec; --muted: #aaa39d; --accent: #ff7a6b; --accent-soft: #46201b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ground); color: var(--text); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pad { padding: var(--pad); }
.skip { position: fixed; left: 12px; top: -48px; z-index: 50; padding: 10px 14px; border-radius: var(--radius-control); background: var(--text); color: var(--sheet); text-decoration: none; }
.skip:focus { top: 12px; }
svg { display: block; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: var(--top) 1fr; height: 100vh; height: 100dvh; }
.side { grid-row: 1 / 3; display: flex; flex-direction: column; min-height: 0; padding: 12px 12px 16px; }
.top { grid-column: 2; display: flex; align-items: center; gap: 12px; padding-right: calc(var(--inset) + 12px); }
.sheet { grid-column: 2; position: relative; min-height: 0; min-width: 0; overflow: hidden; margin: 0 var(--inset) var(--inset) 0; background: var(--sheet); border: 1px solid var(--border); border-radius: var(--radius-sheet); }
.sheet:focus { outline: none; }
.work { height: 100%; overflow-y: auto; scrollbar-width: thin; }

/* ---------- sidebar ---------- */
.brand { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px; text-decoration: none; }
.brand-name { font-weight: 600; font-size: 16px; }
.brand-by { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav { flex: 1; overflow-y: auto; margin-top: 12px; scrollbar-width: thin; }
.nav-title { margin: 18px 10px 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.nav-item { display: flex; width: 100%; align-items: center; gap: 10px; height: 34px; margin-bottom: 2px; padding: 0 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 14px; text-decoration: none; }
.nav-item svg { flex: none; color: var(--muted); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .glyph { width: 20px; text-align: center; font-size: 15px; color: var(--muted); }
.nav-item:hover { background: var(--raised); }
.nav-item[aria-current='page'] { background: var(--active); font-weight: 500; }
.count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 400; }
.side-foot { padding-top: 8px; border-top: 1px solid var(--border); }
.side-link { display: flex; align-items: center; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 13px; text-align: left; }
.side-link:hover { color: var(--text); background: var(--raised); }

/* ---------- top bar ---------- */
.icon-btn { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--text); transition: background 0.12s ease, transform 0.08s ease; }
.icon-btn:hover { background: var(--active); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.small { width: 32px; height: 32px; }
.menu-btn { display: none; }
.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 560px; height: 38px; padding: 0 10px 0 36px; border: 1px solid var(--border); border-radius: 9px; background: var(--sheet); }
.search:focus-within { border-color: var(--control); }
.search-icon { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; }
.kbd { padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--muted); font: 500 11px/18px var(--font); }
#theme-btn { margin-left: auto; }

/* ---------- head and tools ---------- */
.head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 24px var(--pad) 8px; }
.head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.sub { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.tools { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px var(--pad); background: var(--sheet); border-bottom: 1px solid var(--rule); }
.sample { display: flex; align-items: center; flex: 1 1 200px; min-width: 200px; height: 38px; padding: 0 3px 0 12px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--sheet); }
.sample:focus-within { border-color: var(--control); }
.sample input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; }
.range { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.range input { width: 92px; accent-color: var(--accent); }
.range output { min-width: 66px; color: var(--text); font-variant-numeric: tabular-nums; }
.toggle { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--sheet); transition: background 0.12s ease, transform 0.08s ease; }
.toggle:hover { background: var(--raised); }
.toggle:active { transform: scale(0.96); }
.toggle[aria-pressed='true'] { background: var(--text); color: var(--sheet); border-color: var(--text); }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 8px; }
.seg button { display: inline-grid; place-items: center; min-width: 34px; height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 13px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--active); color: var(--text); font-weight: 500; }

/* ---------- font cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding: 20px var(--pad) 8px; }
.grid.list { grid-template-columns: 1fr; gap: 0; padding-top: 4px; }
.card { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 14px; min-height: 196px; padding: 18px 18px 20px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--sheet); cursor: pointer; transition: border-color 0.14s ease, transform 0.14s ease; }
.card:hover { border-color: var(--control); transform: translateY(-2px); }
.list .card { min-height: 0; border-width: 0 0 1px; border-radius: 0; padding: 18px 4px; }
.list .card:hover { transform: none; }
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-name { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; }
.card-name button { all: unset; cursor: pointer; }
.card-name button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.card-name button::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.card-meta { display: block; margin-top: 1px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.fav { position: relative; z-index: 1; margin: -6px -6px 0 0; color: var(--muted); opacity: 0; }
.card:hover .fav, .fav:focus-visible, .fav[aria-pressed='true'] { opacity: 1; }
.fav[aria-pressed='true'] { color: var(--accent); }
.fav[aria-pressed='true'] path { fill: currentColor; fill-opacity: 0.18; }
@media (hover: none) { .fav { opacity: 1; } }
.preview { margin: 0; color: var(--text); line-height: 1.15; overflow-wrap: anywhere; opacity: 0; transition: opacity 0.2s ease; }
.preview.ready { opacity: 1; }
.list .preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 500; line-height: 18px; vertical-align: 1px; }
.empty { padding: 48px var(--pad); color: var(--muted); }
.empty strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 16px; font-weight: 600; }
.more { height: 48px; }

/* ---------- pairings ---------- */
.tools.is-pairs .range:has(#weight), .tools.is-pairs #italic, .tools.is-pairs .seg:has([data-sort]) { display: none; }
.pairs-grid { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); }
.pairs-grid.list { grid-template-columns: 1fr; gap: 16px; padding-top: 20px; }
.pcard { cursor: default; gap: 12px; min-height: 0; padding: 24px; }
.pcard:hover { transform: none; }
.list .pcard { border-width: 1px; border-radius: var(--radius-card); padding: 24px; }
.p-head { line-height: 1.1; }
.p-body { margin: 0; font-size: 16px; line-height: 1.6; max-width: 62ch; }
.p-why { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.p-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--rule); }
.p-name { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 4px 10px 4px 0; border: 0; background: none; text-align: left; font-size: 13px; font-weight: 500; }
.p-name:hover span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.p-role { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.p-acts { display: flex; gap: 8px; margin-left: auto; }
@media (max-width: 860px) { .pairs-grid { grid-template-columns: 1fr; } .p-acts { margin-left: 0; width: 100%; } .p-name { min-height: 44px; } }

/* ---------- drawer ---------- */
.scrim { position: absolute; inset: 0; z-index: 8; background: rgb(0 0 0 / 0.16); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; z-index: 9; width: min(600px, 100%); overflow-y: auto; background: var(--sheet); border-left: 1px solid var(--border); scrollbar-width: thin; animation: slide 0.2s ease; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } .card, .preview, .icon-btn, .toggle { transition: none; } }
.d-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 14px 16px 14px 24px; background: var(--sheet); border-bottom: 1px solid var(--rule); }
.d-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-sec { padding: 20px 24px; border-bottom: 1px solid var(--rule); }
.d-sec h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; }
.d-sec h3 .count { margin-left: 6px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; color: var(--muted); font-size: 13px; }
.facts b { color: var(--text); font-weight: 500; }
.specimen { margin: 0 0 16px; font-size: 64px; line-height: 1.05; overflow-wrap: anywhere; outline: none; }
.specimen:focus-visible { outline: 1px dashed var(--control); outline-offset: 6px; }
.axes { display: grid; gap: 10px; }
.axis { display: grid; grid-template-columns: 112px 1fr 52px; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.axis input { width: 100%; accent-color: var(--accent); }
.axis output { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.styles { display: grid; gap: 2px; }
.style-row { display: flex; align-items: baseline; gap: 16px; padding: 8px 0; border-top: 1px solid var(--rule); }
.style-row:first-child { border-top: 0; }
.style-row span { flex: none; width: 128px; color: var(--muted); font-size: 12.5px; }
.style-row p { flex: 1; min-width: 0; margin: 0; font-size: 26px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glyphs { margin: 0; font-size: 28px; line-height: 1.5; letter-spacing: 0.06em; overflow-wrap: anywhere; }
.pairs { display: grid; gap: 10px; }
.pair { display: block; width: 100%; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-card); background: none; text-align: left; transition: border-color 0.14s ease, transform 0.14s ease; }
.pair:hover { border-color: var(--control); transform: translateY(-2px); }
.pair-h { display: block; font-size: 26px; line-height: 1.15; }
.pair-b { display: block; margin-top: 6px; font-size: 15px; line-height: 1.5; color: var(--muted); }
.pair-names { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 2px; margin-bottom: 10px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs button { height: 36px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 13px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }
.code { position: relative; }
.code pre { margin: 0; padding: 14px 16px; padding-right: 92px; border-radius: var(--radius-card); background: var(--raised); font: 12.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.code .btn { position: absolute; top: 8px; right: 8px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--sheet); font-size: 13px; font-weight: 500; text-decoration: none; transition: background 0.12s ease, transform 0.08s ease; }
.btn:hover { background: var(--raised); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--text); color: var(--sheet); border-color: var(--text); }
.btn.primary:hover { opacity: 0.88; }

/* ---------- dialog, toast ---------- */
.dialog { width: min(520px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 14px; background: var(--sheet); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / 0.3); }
.dialog h2 { margin: 0 0 10px; font-size: 18px; }
.dialog p { color: var(--muted); }
.dialog a { color: var(--text); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; padding: 9px 14px; border-radius: 8px; background: var(--text); color: var(--sheet); font-size: 13px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity 0.16s ease, transform 0.16s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- phone and tablet ---------- */
@media (max-width: 860px) {
  :root { --pad: 16px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 280px; background: var(--ground); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform 0.2s ease; }
  .side.open { transform: none; }
  .top, .sheet { grid-column: 1; }
  .top { padding-left: 8px; }
  .sheet { margin-left: var(--inset); }
  .menu-btn { display: inline-grid; width: 44px; height: 44px; }
  #theme-btn { width: 44px; height: 44px; }
  .kbd { display: none; }
  .range input { width: 90px; }
  .grid { grid-template-columns: 1fr; }
  .tools { position: static; }
  .nav-item { height: 44px; }
  .side-link { min-height: 44px; }
  .seg button { height: 40px; min-width: 44px; }
  .toggle { width: 44px; height: 44px; }
  .sample { height: 44px; }
  .icon-btn.small { width: 40px; height: 40px; }
  .fav { width: 44px; height: 44px; }
  .tabs button { height: 44px; }
  .btn { height: 44px; }
  .specimen { font-size: 44px; }
  .axis { grid-template-columns: 92px 1fr 44px; }
  .style-row span { width: 96px; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) { .side { transition: none; } }
.axes .btn { justify-self: start; }
