:root {
  --bg: #0d0b0a; --bg2: #14110f; --panel: #181412; --line: #2a231d; --line2: #3a3028;
  --text: #f4eee7; --muted: #a39789; --dim: #6f645a;
  --accent: #d9893a; --accent-2: #f0a85a; --sel: #ffd93d; --pick: #ffd93d; --pick-ink: #1a0f05;
  --pick-text: var(--pick);
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --thumb: 20px;
  --track: #2e2620; --thumb-sh: rgba(0,0,0,.55); --sh: #000; --chk1: #15110f; --chk2: #1a1613;
  --img1: #222; --img2: #111; --img3: #0b0908; --veil: rgba(5,4,3,.68); --tab1: #2a2119; --tab2: #211a14;
  --tile-top: #1b1714; --tile-sh: none; --panel-sh: none; --backdrop: rgba(5,4,3,.72);
  --ok: #5fe08a; --warn: #ff8a3d; --info: #9ef0ff; --danger: #ff8a80; --on-solid: #0d0b0a; --accent-ink: #f0a85a;
  --on-c: #111; --on-mix: 26%; --glow: 13%; --glow2: 8%; --tint: 11%;
  color-scheme: dark;
}
/* light theme: warm paper surfaces, soft layered shadows, deeper accent + family shades (set in JS) */
:root[data-theme="light"] {
  --bg: #f3eee7; --bg2: #faf7f2; --panel: #fffdf9; --line: #e8dfd3; --line2: #d9cdbe;
  --text: #1f1813; --muted: #6b5e52; --dim: #9a8c7e;
  --accent: #c8741f; --accent-2: #b0631a; --accent-ink: #a65a12;
  --track: #e6ddd1; --thumb-sh: rgba(70,45,20,.28); --sh: rgba(70,45,20,.22); --chk1: #efe8de; --chk2: #f6f1ea;
  --img1: #fff; --img2: #f3ece2; --img3: #e3d8ca; --veil: rgba(250,247,242,.74); --tab1: #fffdf9; --tab2: #fbf7f1;
  --tile-top: #fffefb; --tile-sh: 0 1px 2px rgba(70,45,20,.05);
  --panel-sh: 0 1px 2px rgba(70,45,20,.05), 0 10px 30px -18px rgba(70,45,20,.22);
  --backdrop: rgba(60,45,30,.35);
  --ok: #16884a; --warn: #c2540f; --info: #0b7a93; --danger: #c2372c; --on-solid: #fff;
  --on-c: #fff; --on-mix: 13%; --glow: 9%; --glow2: 7%; --tint: 9%;
  color-scheme: light;
}
@media (pointer: coarse) { :root { --thumb: 28px; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans);
  background-image: radial-gradient(900px 420px at 18% -120px, color-mix(in srgb, var(--sel) var(--glow), transparent), transparent 70%),
                    radial-gradient(900px 400px at 100% 0, color-mix(in srgb, var(--accent) var(--glow2), transparent), transparent 70%);
  background-repeat: no-repeat; min-height: 100vh;
}
em { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.k { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }

/* app shell */
.app { max-width: 1480px; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 18px; padding: 14px 20px 10px; }
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.brand-mark { width: 30px; height: 21px; border: 2.5px solid var(--accent); border-radius: 3px; position: relative; flex: none; }
.brand-mark::after { content: ''; position: absolute; inset: 3px 8px; background: var(--accent); border-radius: 1px; }
h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
h2 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
h2 em { font-weight: 400; }

.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line2); background: var(--bg2); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13px; white-space: nowrap; min-height: 38px; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--accent); }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: 12.5px; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1a0f05; font-weight: 700; }
.btn.accent:hover { background: var(--accent-2); }
.pill { background: var(--accent); color: #1a0f05; border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; justify-content: center; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line2); background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-height: 32px; }
.chip:hover { color: var(--text); border-color: var(--dim); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.sm { padding: 3px 9px; min-height: 28px; font-size: 11.5px; }

/* layout */
.layout { display: grid; gap: 14px; grid-template-columns: 440px minmax(0, 1fr); padding: 0 20px 16px; align-items: start; }
.col-left { display: grid; gap: 14px; align-content: start; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; box-shadow: var(--panel-sh); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.hint { margin: 0; color: var(--dim); font-size: 12px; text-align: right; }

/* readout */
.ro-head { margin: 0 0 1px; line-height: 1.25; }
.readout { container-type: inline-size; padding: 9px 18px 9px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--sel) 14%, var(--panel)), var(--panel) 60%); border-color: color-mix(in srgb, var(--sel) 35%, var(--line)); transition: border-color .3s; }
.readout-dims { --fs: min(74px, 15.5cqi); font-weight: 800; font-size: var(--fs); letter-spacing: -.045em; line-height: .98; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout-dims .x { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--sel); margin: 0 .1em; font-size: .62em; transition: color .3s; }
.readout-dims .unit { font-size: .24em; color: var(--muted); font-weight: 600; letter-spacing: 0; margin-left: .3em; }
.readout-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.readout-meta b { color: var(--text); font-weight: 700; }
.ro-label { color: var(--sel); font-weight: 800; font-size: 16px; transition: color .3s; }
.ro-name { font-family: var(--serif); font-style: italic; color: var(--text); font-size: 15px; }
.ro-print { display: block; flex-basis: 100%; font-size: 12px; color: var(--dim); }
.ro-print .dot { display: none; }
.dot { color: var(--dim); }
.swatch { --c: var(--sel); display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 12px var(--c); flex: none; }
.ro-note { margin-top: 4px; min-height: 1.35em; font-size: 12px; color: var(--muted); }
.ro-note b { color: var(--text); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; font-weight: 600; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--track); border: 1px solid var(--line2); position: relative; transition: background .2s; flex: none; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + .track { background: var(--pick); border-color: var(--pick); }
.switch input:checked + .track .knob { transform: translateX(16px); background: #1a0f05; }
.switch input:focus-visible + .track { outline: 2px solid var(--pick); outline-offset: 2px; }

/* compact linked sliders */
.field { display: grid; grid-template-columns: 64px minmax(0, 1fr) 96px; align-items: center; gap: 12px; padding: 3px 0; }
.field label { font-weight: 700; font-size: 13px; white-space: nowrap; }
.field label small { color: var(--dim); font-weight: 600; font-size: 11px; margin-left: 2px; }
.num { width: 100%; text-align: right; background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 5px 9px; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; min-height: 34px; transition: border-color .15s; }
.num:focus { border-color: var(--pick); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--pick) 30%, transparent); }
.range { --p: 50%; -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 0; touch-action: pan-y; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--pick) 70%, #000) 0, var(--pick) var(--p), var(--track) var(--p)); }
.range::-moz-range-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, var(--pick) var(--p), var(--track) var(--p)); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: calc((6px - var(--thumb)) / 2); border-radius: 50%; background: #fff6ec; border: 3px solid var(--pick); box-shadow: 0 2px 8px var(--thumb-sh), 0 0 0 4px rgba(217,137,58,.0); transition: box-shadow .15s, transform .15s; }
.range::-moz-range-thumb { width: var(--thumb); height: var(--thumb); border-radius: 50%; background: #fff6ec; border: 3px solid var(--pick); }
.range:hover::-webkit-slider-thumb, .range:focus-visible::-webkit-slider-thumb { box-shadow: 0 2px 8px var(--thumb-sh), 0 0 0 6px rgba(217,137,58,.22); }
.range:active::-webkit-slider-thumb { transform: scale(1.1); }
.range:focus-visible { outline: none; }

.opts { display: grid; grid-template-columns: 1fr 1fr 1.9fr; gap: 10px; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line); }
.mini { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
.mini input { background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 5px 8px; font-weight: 700; color: var(--text); font-size: 13.5px; min-height: 34px; width: 100%; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-left: 1px solid var(--line2); background: var(--bg); padding: 0; font-weight: 700; font-size: 12.5px; color: var(--muted); min-height: 34px; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--pick); color: var(--pick-ink); }
.presets { display: grid; grid-template-columns: auto repeat(7, minmax(0, 1fr)); align-items: center; gap: 5px; margin-top: 10px; }
.presets .chip { padding-left: 0; padding-right: 0; font-variant-numeric: tabular-nums; }
.presets .k { margin-right: 3px; }

/* convert */
select { width: 100%; background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 5px 8px; font-weight: 600; font-size: 13px; min-height: 34px; }
.convert-body { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; }
.crop-stage { display: grid; place-items: center; height: 120px; background: repeating-conic-gradient(var(--chk1) 0 25%, var(--chk2) 0 50%) 0 0/12px 12px; border-radius: 12px; border: 1px solid var(--line); }
.crop-src { position: relative; display: grid; place-items: center; border-radius: 3px; overflow: hidden; transition: width .25s, height .25s;
  background: radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--c) 55%, var(--img1)) 0%, color-mix(in srgb, var(--c) 30%, var(--img2)) 60%, var(--img3) 100%); }
.crop-keep { position: relative; border: 2px solid var(--c); box-shadow: 0 0 0 999px var(--veil); transition: width .25s, height .25s; }
.crop-keep::after { content: attr(data-label); position: absolute; left: 4px; top: 2px; font-weight: 800; font-size: 11px; color: #fff; text-shadow: 0 1px 4px #000; }
.crop-result .big { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.crop-result .big small { font-size: 12px; color: var(--muted); }
.keep-bar { height: 5px; border-radius: 999px; background: var(--track); overflow: hidden; margin: 6px 0 7px; }
.keep-bar span { display: block; height: 100%; border-radius: 999px; transition: width .25s; }
.crop-result p { margin: 0; color: var(--muted); font-size: 12.5px; }
.crop-result p b { color: var(--text); }

/* tabbed tools panel */
.tabs-panel { display: flex; flex-direction: column; padding-top: 10px; }
.tabbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.tabbar button { border: 0; background: transparent; border-radius: 9px; padding: 6px 8px; font-weight: 700; font-size: 13px; color: var(--muted); min-height: 32px; transition: background .15s, color .15s; }
.tabbar button em { color: inherit; font-size: 14px; }
.tabbar button:hover { color: var(--text); }
.tabbar button.on { background: linear-gradient(180deg, var(--tab1), var(--tab2)); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2), 0 2px 8px -2px var(--sh); }
.tabbar button.on em { color: var(--pick-text); }
.pane { display: grid; gap: 9px; align-content: start; }
.pane[hidden] { display: none; }
.pane-row { display: flex; align-items: center; gap: 10px; }
.pane-row .k { flex: none; }
.pane-row select { flex: 1; min-width: 0; }
.print-pick select { flex: 1 1 0; }

.ppi-table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.ppi-table th, .ppi-table td { padding: 3px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ppi-table tr:last-child th, .ppi-table tr:last-child td { border-bottom: 0; }
.ppi-table th { text-align: left; font-weight: 600; color: var(--muted); }
.ppi-table th b { color: var(--q); font-size: 13.5px; margin-right: 4px; }
.ppi-table th span { font-size: 11px; }
.qdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--q); box-shadow: 0 0 8px var(--q); margin-right: 7px; vertical-align: 1px; }
.ppi-table td { text-align: right; color: var(--muted); padding-left: 8px; }
.ppi-table td b { color: var(--text); font-weight: 700; }
.sizes-k { margin-top: 2px; }
.muted-n { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--dim); }
.sizes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.size:nth-child(n+9) b { letter-spacing: .02em; }
.size { display: grid; justify-items: center; gap: 0; padding: 4px 2px 3px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--q) 45%, transparent);
  background: color-mix(in srgb, var(--q) var(--tint), var(--bg)); cursor: default; }
.size b { font-size: 12px; font-weight: 800; letter-spacing: -.01em; }
.size span { font-size: 9.5px; font-weight: 800; color: var(--q); letter-spacing: .02em; }
.size.no { border-style: dashed; border-color: var(--line2); background: transparent; }
.size.no b { color: var(--dim); }

.use-card { --c: var(--accent); border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); border-radius: 14px; padding: 10px 12px; display: grid; gap: 7px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--c) 9%, var(--bg2)), var(--bg2) 70%); }
.use-top { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.use-vig { display: grid; place-items: center; width: 44px; height: 44px; }
.use-main .big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.use-main .big small { font-size: 12px; color: var(--muted); }
.use-meta { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.badge { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); }
.badge.official { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.badge.recommended { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.badge.math { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.use-verdict { margin: 0; display: grid; grid-template-columns: 18px 1fr; gap: 7px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.use-verdict i { font-style: normal; font-weight: 900; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: var(--on-solid); margin-top: 1px; }
.use-verdict.ok i { background: var(--ok); }
.use-verdict.short i { background: var(--warn); }
.use-verdict b { color: var(--text); }
.use-src { margin: 0; font-size: 11px; color: var(--dim); line-height: 1.3; }

/* ratio picker tiles */
.results { display: flex; flex-direction: column; min-height: 0; }
.tiles { list-style: none; margin: 0; padding: 2px; display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); grid-auto-rows: minmax(96px, 1fr); gap: 8px; }
.tile {
  position: relative; display: grid; grid-template-columns: calc(var(--vs, 46px) + 4px) minmax(0, 1fr) auto; grid-template-rows: auto auto; align-content: center; grid-template-areas: "vig main star" "dims dims keep";
  align-items: center; column-gap: 10px; row-gap: 6px; padding: 9px 8px 9px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--tile-top), var(--bg2)); box-shadow: var(--tile-sh); transition: background .15s, border-color .15s, transform .12s, box-shadow .2s;
}
.tile::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.tile:hover { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); }
.tile.on { background: linear-gradient(160deg, color-mix(in srgb, var(--c) var(--on-mix), var(--bg2)), var(--bg2) 85%); border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset, 0 10px 30px -14px var(--c); }
.tile.near { border-style: dashed; border-color: var(--c); }
.near-tag { position: absolute; top: -7px; right: 36px; background: var(--c); color: var(--on-c); font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; border-radius: 999px; padding: 1px 7px; }
.tile-vig { grid-area: vig; display: grid; place-items: center; width: var(--vs, 46px); height: var(--vs, 46px); transition: width .2s, height .2s; }
.vig {
  display: block; border-radius: 3px; flex: none; width: calc(var(--vs, 46px) * var(--rw, 1)); height: calc(var(--vs, 46px) * var(--rh, 1));
  background: radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--c) 82%, #fff) 0%, var(--c) 42%, color-mix(in srgb, var(--c) 40%, #000) 100%);
  box-shadow: 0 4px 14px -5px color-mix(in srgb, var(--c) 75%, transparent), inset 0 0 0 1px rgba(255,255,255,.18);
}
.tile-main { grid-area: main; display: grid; min-width: 0; }
.tile-ratio { font-size: 19px; font-weight: 800; color: var(--c); line-height: 1.1; letter-spacing: -.02em; }
.tile-name { font-family: var(--serif); font-style: italic; font-size: 12.5px; line-height: 1.18; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-cat { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); font-weight: 700; margin-top: 1px; }
.tile-dims { grid-area: dims; display: flex; align-items: baseline; gap: 8px; min-width: 0; font-variant-numeric: tabular-nums; }
.tile-dims b { font-size: 14px; white-space: nowrap; }
.tile-dims span { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-dims i { color: var(--accent); font-style: normal; }
.tile-keep { grid-area: keep; justify-self: end; display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; grid-column: 2 / 4; }
.tile-keep .kb { width: 34px; height: 4px; border-radius: 9px; background: var(--track); overflow: hidden; }
.tile-keep .kb span { display: block; height: 100%; background: var(--c); }
.tile-dims { grid-column: 1 / 3; }
.star { align-self: start; width: 30px; height: 30px; border: 0; background: transparent; font-size: 17px; color: var(--dim); border-radius: 50%; display: grid; place-items: center; padding: 0; }
.star:hover { color: var(--accent); background: rgba(217,137,58,.12); }
.star.on { color: var(--accent); }
.tiles .empty, .mgr-list .empty { color: var(--muted); padding: 20px; list-style: none; grid-column: 1 / -1; }

/* manager dialog */
.manager { width: min(600px, calc(100vw - 24px)); max-height: min(90vh, 900px); padding: 0; border: 1px solid var(--line2); border-radius: 20px; background: var(--panel); color: var(--text); overflow: hidden; }
.manager[open] { display: flex; flex-direction: column; }
.manager::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.mgr-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 4px; margin: 0; }
.mgr-head h2 { font-size: 18px; }
.icon-btn { border: 1px solid var(--line2); background: var(--bg2); border-radius: 9px; min-width: 36px; min-height: 36px; padding: 0 10px; font-size: 12.5px; font-weight: 600; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.del, .del-btn { color: var(--danger); }
.mgr-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 18px 8px; flex-wrap: wrap; }
.mgr-list { list-style: none; margin: 0; padding: 0 10px; overflow-y: auto; flex: 1 1 auto; min-height: 120px; }
.mgr-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 32px auto auto; align-items: center; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.mgr-row .row-vig { display: grid; place-items: center; width: 38px; height: 32px; }
.mgr-row .row-main { display: grid; min-width: 0; }
.mgr-row .row-main b { color: var(--c); }
.row-name { font-family: var(--serif); font-style: italic; font-size: 13px; }
.row-cat { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 700; }
.mgr-row .star { grid-area: auto; position: static; width: 32px; height: 32px; align-self: center; }
.mgr-row.is-hidden { opacity: .45; }
.mgr-row.is-hidden .eye { opacity: 1; border-color: var(--accent); color: var(--accent); }
.add-form { border-top: 1px solid var(--line); padding: 12px 18px 12px; background: var(--bg2); }
.add-form h3 { margin: 0 0 8px; font-size: 13.5px; }
.add-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.add-grid label { display: grid; gap: 4px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.add-grid .wide { grid-column: 1 / -1; }
.add-grid input:not([type=color]) { background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 6px 9px; min-height: 36px; width: 100%; color: var(--text); }
.add-grid input[type=color] { width: 100%; height: 36px; border: 1px solid var(--line2); border-radius: 9px; background: var(--bg); padding: 3px; }
.form-err { color: var(--danger); font-size: 12.5px; min-height: 1.2em; margin: 6px 0; }
.mgr-foot { margin: 0; padding: 8px 18px 12px; color: var(--dim); font-size: 11px; background: var(--bg2); }

/* desktop: everything on one screen, the tile grid fills (and if needed scrolls) the right column */
@media (min-width: 1100px) and (min-height: 680px) {
  html, body { height: 100%; overflow: hidden; }
  .app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .layout { height: 100%; min-height: 0; align-items: stretch; }
  .col-left { overflow-y: auto; scrollbar-width: thin; grid-template-rows: auto auto minmax(0, 1fr); align-content: stretch; gap: 12px; }
  .results { height: 100%; }
  .tiles { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; align-content: stretch; }
}
@media (min-width: 1100px) and (max-height: 820px) {
  .readout-dims { --fs: min(64px, 14cqi); }
  .tiles { grid-auto-rows: minmax(84px, 1fr); grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .tile { row-gap: 3px; padding-top: 6px; padding-bottom: 6px; }
  .tile-cat { display: none; }
}

@media (min-width: 1100px) and (min-height: 860px) {
  .field { padding: 4px 0; }
  .crop-stage { height: 150px; }
  .convert-body { grid-template-columns: 170px minmax(0, 1fr); }
  .readout { padding: 18px 20px 14px; }
}
/* tablet */
@media (max-width: 1099px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col-left { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
  .readout { grid-column: 1 / -1; }
  .tiles { grid-auto-rows: auto; }
}

/* phone */
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 12px 14px 6px; }
  .brand { flex: 1; min-width: 0; }
  h1 { font-size: 20px; }
  .tag { font-size: 11.5px; }
  #openManager .lbl { display: none; }
  #openManager { padding: 8px 11px; }
  .chips { order: 3; flex-basis: 100%; justify-content: flex-start; margin: 0 -14px; padding: 0 14px; }
  .layout { padding: 0 10px 20px; gap: 10px; }
  .col-left { display: contents; }
  .readout { order: 1; } .controls { order: 2; } .results { order: 3; } .convert { order: 4; }
  .panel { padding: 12px 13px; border-radius: 16px; }
  .readout { position: sticky; top: 0; z-index: 5; padding: 10px 14px 8px; border-radius: 0 0 16px 16px; margin: 0 -10px; border-top: 0;
    background: linear-gradient(160deg, color-mix(in srgb, var(--sel) 16%, var(--panel)), var(--panel) 65%); box-shadow: 0 10px 24px -12px var(--sh); }
  .readout-dims { --fs: min(60px, 15cqi); }
  .readout-meta { font-size: 12px; gap: 2px 7px; }
  .ro-print { display: none; }
  .ro-note { font-size: 11.5px; }
  .field { grid-template-columns: minmax(0, 1fr) 108px; grid-template-areas: "lab num" "rng rng"; gap: 2px 10px; padding: 4px 0 2px; }
  .field label { grid-area: lab; }
  .field .num { grid-area: num; min-height: 38px; font-size: 16px; }
  .field .range { grid-area: rng; height: 36px; }
  .opts { grid-template-columns: 1fr 1fr; }
  .opts .mult { grid-column: 1 / -1; }
  .seg button, .mini input { min-height: 40px; font-size: 15px; }
  .chip.sm { min-height: 34px; padding: 4px 11px; }
  .panel-head { flex-wrap: wrap; }
  .results .panel-head { display: grid; gap: 2px; }
  .hint { text-align: left; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .tile { grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: 7px; padding: 8px 6px 8px 9px; }
  .tiles { --vs: 38px; }
  .tile-ratio { font-size: 17px; }
  .tile-name { font-size: 11.5px; }
  .tile-dims { grid-column: 1 / -1; }
  .tile-dims b { font-size: 13px; }
  .tile { grid-template-areas: "vig main star" "dims dims dims" "keep keep keep"; }
  .tile-keep { grid-column: 1 / -1; justify-self: stretch; }
  .tile-keep .kb { flex: 1; }
  .star { width: 28px; height: 28px; }
  .sizes { grid-template-columns: repeat(4, 1fr); }
  .tabbar button { min-height: 40px; font-size: 14px; }
  .use-main .big { font-size: 19px; }
  .convert-body { grid-template-columns: 116px minmax(0, 1fr); gap: 10px; }
  .crop-stage { height: 100px; }
  .crop-result .big { font-size: 20px; }
  .add-grid { grid-template-columns: 1fr 1fr; }
  .mgr-row { grid-template-columns: 32px minmax(0, 1fr) 32px auto; }
  .mgr-row .del { grid-column: 2 / -1; justify-self: end; }
}

/* ---------- round 3: theme toggle, typed ratio, family chips, scalable tiles, custom ---------- */
.theme-btn { box-sizing: border-box; position: relative; flex: none; width: 40px; height: 38px; border-radius: 999px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text); display: grid; place-items: center; padding: 0; transition: border-color .15s, background .15s; }
.theme-btn:hover { border-color: var(--accent); }
.theme-btn svg { width: 18px; height: 18px; position: absolute; inset: 0; margin: auto; display: block; transition: opacity .2s; }  /* sun & moon stacked in one fixed box, cross-fade only */
.theme-btn .sun { color: #f0a85a; }
:root[data-theme="light"] .theme-btn .sun, :root:not([data-theme="light"]) .theme-btn .moon { opacity: 0; }
:root[data-theme="light"] .theme-btn .moon { color: #5b4bc4; }

.ratio-in { position: relative; display: flex; align-items: center; gap: 7px; min-width: 0; }
.ratio-in .swatch { width: 10px; height: 10px; }
#ratioInput { width: 92px; background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 4px 9px; min-height: 32px; font-weight: 800; font-size: 15px; letter-spacing: -.01em; color: var(--sel); font-variant-numeric: tabular-nums; transition: border-color .15s, width .2s; }
#ratioInput:focus { outline: none; border-color: var(--pick); color: var(--text); width: 108px; }
#ratioInput.bad { border-color: var(--danger); }
.ri-save { border: 1px solid color-mix(in srgb, var(--sel) 55%, var(--line2)); background: color-mix(in srgb, var(--sel) 14%, var(--bg2)); color: var(--text); border-radius: 999px; padding: 3px 10px; min-height: 30px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ri-save:hover { border-color: var(--sel); }
.ri-msg { position: absolute; left: 0; top: calc(100% + 3px); font-size: 11px; color: var(--muted); white-space: nowrap; pointer-events: none; z-index: 3; background: var(--panel); padding: 0 4px 0 0; }
.ri-msg:empty { display: none; }

.chip.fam .fdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fc); margin-right: 6px; vertical-align: 0; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fc) 22%, transparent); }
.chip.fam.on { background: color-mix(in srgb, var(--fc) 18%, var(--bg2)); border-color: var(--fc); color: var(--text); }
.chip-sep { flex: none; width: 1px; align-self: stretch; margin: 5px 2px; background: var(--line2); }
.niche-chip:disabled { opacity: .45; cursor: default; }
.niche-k { color: var(--c, var(--accent)); letter-spacing: .06em; }
.hint .niche-k { color: var(--accent-ink); font-weight: 700; }
.hint b { color: var(--text); }

.tile-acts { grid-area: star; align-self: start; display: flex; gap: 0; margin: -2px -2px 0 0; }
.tile .edit { width: 30px; height: 30px; border: 0; background: transparent; color: var(--dim); border-radius: 50%; display: grid; place-items: center; padding: 0; }
.tile .edit svg { width: 15px; height: 15px; }
.tile .edit:hover { color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.tile-cat .niche-k { color: var(--c); }
.add-tile { padding: 0; display: block; border-style: dashed; border-color: color-mix(in srgb, var(--c) 45%, var(--line2)); background: color-mix(in srgb, var(--c) 5%, transparent); box-shadow: none; }
.add-tile::before { display: none; }
.add-tile:hover { background: color-mix(in srgb, var(--c) 10%, transparent); }
.add-btn { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; height: 100%; min-height: 80px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px; border-radius: 14px; color: var(--text); }
.add-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.add-plus { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 400; color: var(--c); border: 1.5px dashed var(--c); flex: none; }
.add-btn b { display: block; font-size: 15px; color: var(--c); }
.add-btn small { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--serif); font-style: italic; }

/* bigger type when the grid has room (category filters) */
.tiles.roomy .tile { padding: 12px 12px 12px 14px; column-gap: 14px; row-gap: 8px; }
.tiles.roomy .tile-ratio { font-size: 24px; }
.tiles.roomy .tile-name { font-size: 14px; }
.tiles.roomy .tile-cat { display: block; font-size: 9.5px; margin-top: 3px; }
.tiles.roomy .tile-dims b { font-size: 15.5px; }
.tiles.huge .tile-ratio { font-size: 30px; }
.tiles.huge .tile-name { font-size: 15.5px; -webkit-line-clamp: 3; }
.tiles.huge .tile-dims b { font-size: 17px; }
.tiles.huge .tile-keep .kb { width: 56px; }
.tiles.roomy .add-plus { width: 48px; height: 48px; font-size: 26px; }
.tiles.dense .tile { row-gap: 3px; padding-top: 6px; padding-bottom: 6px; }

/* custom ratio dialog */
.custom-dlg { width: min(520px, calc(100vw - 24px)); --c: var(--accent); }
.cd-form { display: flex; flex-direction: column; margin: 0; }
.cd-body { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 10px 18px 4px; align-items: start; }
.cd-preview { display: grid; justify-items: center; gap: 6px; padding: 12px 8px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line)); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 14%, var(--bg2)), var(--bg2) 80%); text-align: center; }
.cd-vig { display: grid; place-items: center; width: 70px; height: 70px; }
.cd-preview b { font-size: 22px; font-weight: 800; color: var(--c); letter-spacing: -.02em; }
.cd-preview span:last-child { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cd-preview .dup { color: var(--accent-ink); font-style: italic; font-family: var(--serif); }
.cd-fields { display: grid; gap: 10px; }
.cd-ratio { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 6px; }
.cd-colon { font-family: var(--serif); font-style: italic; font-size: 26px; color: var(--c); padding-bottom: 3px; }
.cd-fields label { display: grid; gap: 4px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.cd-fields input { background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 6px 10px; min-height: 40px; width: 100%; color: var(--text); font-weight: 700; font-size: 16px; }
.cd-fields .cd-name input { font-weight: 500; font-size: 14px; }
.cd-fields input:focus { outline: none; border-color: var(--c); }
.cd-fields .form-err { margin: 0; }
.cd-foot { display: flex; align-items: center; gap: 12px; padding: 10px 18px 16px; }
.cd-note { flex: 1; font-size: 11.5px; color: var(--dim); }
.cd-note .amber { color: var(--c); }
.del-btn:hover { border-color: var(--danger); }
.custom-dlg .btn.accent { background: var(--c); border-color: var(--c); }

/* light-theme refinements */
:root[data-theme="light"] .vig { box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--c) 80%, transparent), inset 0 0 0 1px rgba(255,255,255,.35); }
:root[data-theme="light"] .swatch { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 20%, transparent); }
:root[data-theme="light"] .tile:hover { box-shadow: 0 6px 18px -12px rgba(70,45,20,.4); }
:root[data-theme="light"] .tile.on { box-shadow: 0 0 0 1px var(--c) inset, 0 12px 26px -16px var(--c); }
:root[data-theme="light"] .chip.on:not(.fam) { background: var(--text); color: var(--panel); }
:root[data-theme="light"] .readout { background: linear-gradient(160deg, color-mix(in srgb, var(--sel) 10%, var(--panel)), var(--panel) 60%); }
:root[data-theme="light"] .qdot { box-shadow: none; }
:root[data-theme="light"] .range::-webkit-slider-thumb { background: #fff; }
:root[data-theme="light"] .crop-keep::after { color: var(--text); text-shadow: 0 1px 3px #fff; }
:root[data-theme="light"] .manager { box-shadow: 0 30px 80px -30px rgba(70,45,20,.45); }

@media (max-width: 640px) {
  .ratio-in .k { display: none; }
  #ratioInput { width: 84px; }
  .theme-btn { width: 38px; height: 38px; }
  .add-btn { min-height: 64px; justify-content: flex-start; }
  .tiles .add-tile { grid-column: 1 / -1; }
  .cd-body { grid-template-columns: 1fr; }
  .cd-preview { grid-template-columns: auto 1fr; justify-items: start; text-align: left; }
  .cd-preview .cd-vig { grid-row: span 2; }
  .cd-note { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.brand h1 .tld { color: var(--accent); font-style: normal; }

.credit { text-align: center; font-size: 11.5px; color: var(--dim); padding: 6px 0 10px; letter-spacing: .02em; }
.credit a { color: var(--accent); text-decoration: none; }
.credit a:hover { text-decoration: underline; text-underline-offset: 3px; }

.credit .sep { margin: 0 8px; opacity: .5; }

.credit .emoji { font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif; font-style: normal; }

/* Hide native number spinners (Safari/WebKit draws them always, Chrome on hover) — they crowd the right-aligned values; arrow keys still step. */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- round 3: no layout jumping ----------
   Everything whose text changes on selection gets a fixed box, so selecting a tile only repaints. */
.readout-dims { height: calc(var(--fs) * .98); line-height: calc(var(--fs) * .98); }   /* fitReadout shrinks font-size inline; the box stays put */
.ro-line { display: flex; align-items: center; gap: 4px 8px; flex: 1 1 100%; min-width: 0; white-space: nowrap; }   /* one line, always */
.ro-line > * { flex: none; }
.ro-line .ro-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ro-print { white-space: nowrap; height: 1.3em; }
.ro-note { height: 1.35em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.results h2 em { white-space: nowrap; }
#swapLabel { display: inline-block; min-width: 4.9em; text-align: left; }
.tile-keep .kp { display: inline-block; width: 4ch; text-align: right; }   /* "100%" vs "7%" no longer slides the bar */
.tile-keep.off { visibility: hidden; }
.tile-dims b { flex: none; }
.tile-dims > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* click-to-edit readout numbers: same font, same box — only an underline appears */
.ro-num { outline: none; border-radius: 4px; cursor: text; text-decoration: underline dotted transparent; text-decoration-thickness: 2px; text-underline-offset: .12em; transition: text-decoration-color .15s, background .15s; caret-color: var(--accent); }
.readout-dims .ro-num { text-decoration-thickness: max(2px, .035em); }
.ro-num:hover { text-decoration-color: color-mix(in srgb, var(--text) 45%, transparent); }
.ro-num:focus { text-decoration: underline solid var(--accent); text-decoration-thickness: max(2px, .04em); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ro-num:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }
.ro-num.ro-ro { cursor: default; }
.ro-num.ro-ro:hover { text-decoration-color: transparent; }

/* W / H / MP padlocks */
.field { grid-template-columns: 64px minmax(0, 1fr) 88px 30px; gap: 10px; }
.lock { box-sizing: border-box; flex: none; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border-radius: 8px; border: 1px solid var(--line2); background: transparent; color: var(--dim); cursor: pointer; transition: color .15s, background .15s, border-color .15s; }
.lock svg { display: block; width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* closed/open shackles are stacked in the same 16×16 box and cross-fade — nothing moves or resizes */
.lock .shackle { transition: opacity .15s; }
.lock[aria-pressed="false"] .sh-closed, .lock[aria-pressed="true"] .sh-open { opacity: 0; }
.lock:hover { color: var(--text); border-color: var(--dim); }
.lock[aria-pressed="true"] { background: var(--pick); border-color: var(--pick); color: var(--pick-ink); }
.lock:focus-visible { outline: 2px solid var(--pick); outline-offset: 2px; }
.field.is-locked .num { border-color: var(--pick); }
.field.is-locked label { color: var(--pick-text); }
.field.derived .num, .field.derived .range { opacity: .45; cursor: not-allowed; }
.field.derived label::after { content: " auto"; font-size: 10px; font-weight: 600; color: var(--dim); }
.range:disabled { cursor: not-allowed; }

/* Quick MP: 8 buttons (8 … 100 MP) in one fixed row under a small label, so nothing reflows */
.presets { grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: auto 28px; row-gap: 4px; gap: 4px; }
.presets .k { grid-column: 1 / -1; margin: 0; line-height: 1.2; }
.presets .chip.sm { min-height: 0; height: 28px; padding-top: 0; padding-bottom: 0; }

/* Print: every size it can hit, scrolling inside the panel */
.tabs-panel { min-height: 0; }
#pane-print { min-height: 0; grid-template-rows: auto auto auto minmax(0, 1fr); }
.sizes-legend { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 10.5px; color: var(--dim); }
.sizes-legend .lg::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 0; background: var(--qc); }
.lg.q-good { --qc: #7fc97a; } .lg.q-ok { --qc: #d8c25a; } .lg.q-fair { --qc: #e08a3c; } .lg.q-no { --qc: var(--line2); }
.lg-x::before { content: "= "; font-weight: 800; color: var(--muted); }
.lg-c::before { content: ""; }
.lg-s::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-right: 4px; vertical-align: 1px; }
.sizes { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); overflow-y: auto; scrollbar-width: thin; min-height: 0; align-content: start; padding-right: 2px; }
.size { position: relative; padding: 3px 2px 3px; line-height: 1.15; }
.size b { font-size: 12px; letter-spacing: -.01em !important; }
.size .pp { font-size: 10px; font-weight: 800; color: var(--q); }
.size .pp small { font-size: 8px; font-weight: 700; margin-left: 1px; opacity: .8; }
.size .fx { font-size: 9px; font-weight: 700; color: var(--muted); }
.size.site::after { content: ""; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.size.q-fair { border-style: dashed; }
.size.q-no { border-style: dashed; border-color: var(--line2); background: transparent; }
.size.q-no b, .size.q-no .pp { color: var(--dim); }

@media (max-width: 640px) {
  .field { grid-template-columns: minmax(0, 1fr) 108px 38px; grid-template-areas: "lab num lock" "rng rng rng"; }
  .field .lock { grid-area: lock; width: 38px; height: 38px; }
  .presets { grid-template-rows: auto 34px; }
  .presets .chip.sm { height: 34px; }
  .sizes { grid-template-columns: repeat(4, 1fr); max-height: 260px; }
}

/* tile footer: dims (+ "fit"/"max" flag) and the % bar share one flex row — the flag truncates, never overlaps the bar */
.tile { grid-template-areas: "vig main star" "foot foot foot"; }
.tile-foot { grid-area: foot; grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.tile-foot .tile-dims { grid-area: auto; grid-column: auto; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.tile-foot .tile-keep { grid-area: auto; grid-column: auto; flex: none; justify-self: auto; margin-left: auto; }
/* previews: true aspect ratio inside a fixed square box, whatever the box size (contain, never stretched) */
.tile-vig { flex: none; min-width: 0; overflow: visible; }
.vig { aspect-ratio: var(--rw) / var(--rh); width: auto; height: auto; max-width: none; max-height: none; }
.vig { width: calc(var(--vs, 46px) * var(--rw, 1)); height: auto; }
.tile-ratio { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  .tile { grid-template-areas: "vig main star" "foot foot foot"; }
  .tile-foot { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .tile-foot .tile-keep { margin-left: 0; justify-self: stretch; }
}
/* narrow tiles (e.g. 1280×800, 6 columns): shrink the dims and bar instead of clipping or overlapping */
.tile-foot { container-type: inline-size; }
@container (max-width: 176px) { .tile-foot .tile-dims b { font-size: 12.5px; letter-spacing: -.01em; } .tile-foot .tile-keep .kb { width: 18px; } .tile-foot .tile-keep { gap: 4px; } }
.tiles .tile-foot.tight .tile-keep .kb { display: none; }
.tiles .tile-foot.tighter .tile-dims b { font-size: 11px; letter-spacing: -.02em; }
.tiles .tile-foot.tighter { gap: 4px; }
@container (max-width: 140px) { .tile-foot .tile-keep .kb { width: 14px; } .tile-foot .tile-dims b { font-size: 12px; } .tile-foot .tile-keep { gap: 3px; } }
@container (max-width: 118px) { .tile-foot .tile-keep .kb { display: none; } }
.chip .cnt { font-size: 10px; font-weight: 800; opacity: .75; margin-left: 2px; font-variant-numeric: tabular-nums; }
.custom-slot { display: contents; }
.custom-slot.empty { display: flex; flex: none; gap: 6px; visibility: hidden; }
@media (max-width: 640px) { .custom-slot.empty { display: none; } }

/* ---------- round 3: desktop tiles — star floats in the corner, names get the whole text column ---------- */
.tiles.fstar .tile { grid-template-columns: calc(var(--vs, 46px) + 4px) minmax(0, 1fr); grid-template-areas: "vig main" "foot foot"; }
.tiles.fstar .star { position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; font-size: 15px; z-index: 1; }
.tiles.fstar .tile-ratio { padding-right: 22px; }
.tiles.fstar .tile-name { -webkit-line-clamp: 3; }
.tiles.compact .tile { grid-template-columns: calc(var(--vs) + 2px) minmax(0, 1fr); column-gap: 8px; row-gap: 4px; padding: 6px 8px 6px 10px; }
.tiles.compact .star { top: 3px; right: 3px; width: 24px; height: 24px; font-size: 14px; }
.tiles.compact .tile-ratio { padding-right: 20px; font-size: 17px; }
.tiles.compact .tile-name { font-size: 11.5px; line-height: 1.15; }
.tiles.compact .tile-cat { display: none; }
/* footer credit: bogucki.photo, echoing the ratio.photo wordmark (whole link stays the accent colour) */
.credit a.site { font-weight: 700; letter-spacing: 0; }
.credit a.site .tld { font-weight: 500; opacity: .8; }
@media (max-width: 640px) {
  .results .panel-head { grid-template-columns: minmax(0, 1fr); }
  .results h2 em { white-space: normal; }
}

/* round 4: control highlights follow the picked ratio's colour (--pick, set from the selected tile's colour in the
   current theme); brand accents (logo .photo, footer, Custom tile/chip, stars) stay orange (--accent).
   Registered as <color> so every use — including slider gradients — cross-fades instead of snapping. */
@property --pick { syntax: '<color>'; inherits: true; initial-value: #ffd93d; }
@property --pick-ink { syntax: '<color>'; inherits: true; initial-value: #1a0f05; }
:root { transition: --pick .3s ease, --pick-ink .3s ease; }
:root[data-theme="light"] { --pick-text: color-mix(in srgb, var(--pick) 62%, var(--text)); }
:root .presets .chip.sm.on:not(.fam) { background: var(--pick); border-color: var(--pick); color: var(--pick-ink); }
.seg button, .lock, .presets .chip, .num, .switch .track { transition: background-color .3s, border-color .3s, color .3s, box-shadow .15s; }
.presets .chip:focus-visible, .seg button:focus-visible { outline-color: var(--pick); }
