/* CAFE CORNER: warm paper, deep teal, sage, brass and terracotta, like a menu on a cafe table. */
:root {
  --teal: #25565a; --teal-deep: #1c4548; --teal-ink: #143336;
  --cream: #f4ead5; --paper: #fbf5e7; --card: #fffaf0;
  --sage: #86a38f; --sage-soft: #dde5d8; --sage-deep: #47685a;
  --brass: #b9944a; --brass-light: #e6cd93; --brass-deep: #775a1f;
  --terracotta: #c0704f; --terracotta-deep: #98492b;
  --ink: #2b2622; --muted: #685d51;
  --line: #2b26221f; --line-strong: #2b262238;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Apple SD Gothic Neo", "Noto Serif KR", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
  font-family: var(--sans);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--cream); color: var(--ink); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; transition: background .16s, color .16s, border-color .16s, box-shadow .16s; }
button:disabled { cursor: wait; opacity: .5; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
:lang(ko) h1, :lang(ko) h2, :lang(ko) h3, :lang(ko) p { word-break: keep-all; }
ul { list-style: none; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 2px; }

.icon-sheet { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.solid { fill: currentColor; stroke: none; }
kbd { font: 600 10px/1 var(--mono); opacity: .62; border: 1px solid currentColor; border-radius: 3px; padding: 2px 3px; }

/* Header: a shop front with its awning */
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 9px 24px; background: var(--teal); color: var(--cream); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: 2.4px; line-height: 1.15; white-space: nowrap; }
.brand-text small { margin-top: 2px; font-size: 12px; color: #d5e0d6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.language-switch { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #b9cbc1; white-space: nowrap; }
.language-switch button { border: 0; background: none; padding: 8px 2px; color: #b9cbc1; font-weight: 600; }
.language-switch button[aria-pressed=true] { color: var(--cream); box-shadow: inset 0 -2px 0 var(--brass-light); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; font-size: 13px; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.button-accent { background: var(--brass-light); color: var(--ink); }
.button-accent:hover { background: #f0dcab; }
.button-ghost { border-color: #f4ead55c; color: var(--cream); }
.button-ghost:hover { background: #f4ead51f; }
.button-muted { background: var(--card); border-color: var(--line-strong); color: var(--ink); }
.button-muted:hover { background: var(--sage-soft); }
.awning {
  position: relative; z-index: 2; height: 18px; margin-bottom: -8px;
  background: repeating-linear-gradient(90deg, var(--sage) 0 26px, #fffaf0 26px 52px);
  -webkit-mask: linear-gradient(#000 0 5px, #0000 5px), radial-gradient(13px at 13px 5px, #000 96%, #0000) 0 0 / 26px 100%;
  mask: linear-gradient(#000 0 5px, #0000 5px), radial-gradient(13px at 13px 5px, #000 96%, #0000) 0 0 / 26px 100%;
  filter: drop-shadow(0 1px 1px #2b262240);
}

main { max-width: 1800px; margin: 0 auto; padding: 0 24px; }

/* Intro: tall frames only; embeds go straight to the demo */
.intro { display: flex; justify-content: space-between; align-items: center; gap: 32px; padding: 26px 0 20px; }
.eyebrow { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 650; letter-spacing: 1.2px; color: var(--muted); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--terracotta); flex: none; }
.intro h1 { margin: 8px 0 6px; font-family: var(--serif); font-size: clamp(27px, 3.1vw, 42px); font-weight: 700; line-height: 1.14; letter-spacing: -.4px; color: var(--teal); }
.intro-copy { max-width: 720px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.intro-stats { display: flex; gap: 10px; flex: none; }
.intro-stats li { display: flex; flex-direction: column; justify-content: center; width: 124px; min-height: 84px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--paper); }
.intro-stats strong { font-family: var(--serif); font-size: 28px; line-height: 1.05; color: var(--teal); font-variant-numeric: lining-nums; }
.intro-stats span { margin-top: 3px; font-size: 12px; line-height: 1.3; color: var(--muted); }

/* Tabs */
.view-bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; border-bottom: 1px solid var(--line-strong); margin-bottom: 12px; }
.tabs { display: flex; gap: 22px; }
.tab { display: flex; align-items: center; gap: 7px; margin-bottom: -1px; padding: 12px 1px 10px; border: 0; border-bottom: 2.5px solid transparent; background: none; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected=true] { color: var(--teal); border-bottom-color: var(--terracotta); }
.preview-note { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-headline { display: none; flex: 1; min-width: 0; font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--teal); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-message { position: fixed; top: 74px; left: 50%; z-index: 10; transform: translateX(-50%); width: max-content; max-width: min(520px, calc(100vw - 24px)); padding: 10px 14px; border-radius: 9px; background: var(--ink); color: var(--cream); box-shadow: 0 6px 18px #2b262240; font-size: 13px; line-height: 1.5; }

/* Viewports */
.viewport { position: relative; overflow: hidden; height: 360px; background: var(--cream); color: var(--ink); isolation: isolate; }
.viewport canvas { position: absolute; inset: 0; z-index: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.viewport.is-night { background: #10282a; }
#recipes-view .viewport:not(.is-night) { background: #c8d4bf; }
.viewport-label { position: absolute; top: 12px; left: 12px; z-index: 2; pointer-events: none; }
.viewport-pill { display: inline-block; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fffaf0d9; font-size: 10px; font-weight: 650; letter-spacing: .8px; color: var(--ink); }
.viewport.is-night .viewport-pill { background: #143336cc; border-color: #f4ead53d; color: var(--cream); }
.viewport-asset { position: absolute; top: 12px; right: 12px; z-index: 2; max-width: 56%; padding: 5px 8px; border-radius: 6px; background: #fffaf0d9; font: 500 11px/1.3 var(--mono); color: var(--muted); pointer-events: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewport.is-night .viewport-asset { background: #143336cc; color: #cbdad3; }
.canvas-hint { position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 1; text-align: center; font-size: 11px; line-height: 1.5; color: #5f564b; pointer-events: none; }
.viewport.is-night .canvas-hint { color: #b9cdc8; }
.loading-overlay { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 30px; background: #f4ead5f2; text-align: center; font-size: 13px; line-height: 1.6; }
.is-night .loading-overlay { background: #10282af2; color: var(--cream); }
.spinner { width: 28px; height: 28px; border: 2.5px solid #2b262226; border-top-color: var(--terracotta); border-radius: 50%; animation: spin 1s linear infinite; }
.loading-overlay progress { width: min(230px, 80%); height: 4px; accent-color: var(--terracotta); }
@keyframes spin { to { transform: rotate(360deg); } }

.tool-button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.tool-button:hover { background: var(--sage-soft); color: var(--ink); }
.tool-button[aria-pressed=true] { background: #25565a1a; border-color: #25565a40; color: var(--teal); }
.viewer-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); }
.segment { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 0; border-radius: 7px; background: none; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.segment:hover { background: var(--sage-soft); color: var(--ink); }
.segment[aria-pressed=true] { background: var(--teal); color: var(--cream); }

/* Catalog */
.catalog-layout { display: flex; flex-direction: column; gap: 14px; }
.sidebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.section-label { display: none; font-size: 11px; font-weight: 650; letter-spacing: 1px; color: var(--muted); }
.search-wrap { display: flex; align-items: center; gap: 6px; flex: 1 1 170px; min-width: 0; padding-left: 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--card); color: var(--muted); }
input[type=search] { width: 100%; min-width: 0; padding: 10px 8px 10px 0; border: 0; background: transparent; color: var(--ink); font-size: 14px; outline-offset: -3px; }
input::placeholder { color: #7d7264; }
.filter-chip { padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--card); font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.filter-chip[aria-pressed=true] { background: var(--sage-soft); border-color: var(--sage-deep); color: var(--sage-deep); }
.desktop-label, .category-list, .sidebar-note { display: none; }
.category-select { flex: 1 1 140px; min-width: 0; padding: 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--card); color: var(--ink); font-size: 13px; }
.mobile-filter-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.library-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.library-heading h2 { font-family: var(--serif); font-size: 16px; font-weight: 700; color: var(--teal); }
.library-heading > span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.asset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: max-content; gap: 8px; max-height: 330px; overflow: auto; padding: 3px; margin: -3px; scrollbar-width: thin; scrollbar-color: #b8a98f transparent; }
.asset-card { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; text-align: left; }
.asset-card:hover { border-color: var(--sage-deep); }
.asset-card[aria-pressed=true] { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.asset-image { position: relative; aspect-ratio: 1; flex: none; width: 100%; background: #f8efde; overflow: hidden; }
.asset-sprite { display: block; width: 100%; height: 100%; background-repeat: no-repeat; filter: url(#warm-balance); mix-blend-mode: multiply; }
.free-badge { position: absolute; top: 6px; left: 6px; padding: 3px 5px; border-radius: 4px; background: var(--teal); color: var(--cream); font-size: 9px; font-weight: 700; letter-spacing: .5px; }
.selected-mark { position: absolute; right: 6px; bottom: 6px; display: none; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--teal); color: var(--cream); font-size: 11px; }
.asset-card[aria-pressed=true] .selected-mark { display: grid; }
.asset-card-copy { padding: 7px 8px 8px; }
.asset-name { display: block; font-size: 12px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.asset-meta { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.catalog-paging { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.empty-state { padding: 34px 15px; text-align: center; font-size: 13px; color: var(--muted); }
.empty-state h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 17px; color: var(--teal); }
.empty-state p { margin-bottom: 16px; line-height: 1.6; }
.inspector { order: -1; display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); overflow: hidden; scroll-margin-top: 8px; }
.model-info { padding: 12px 14px 14px; }
.model-info .eyebrow { font-size: 11px; letter-spacing: .4px; }
.model-info h2 { margin: 3px 0 2px; font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1.2; color: var(--teal); }
.model-description { font-size: 13px; line-height: 1.5; color: var(--muted); }
.model-stats { display: flex; gap: 22px; margin-top: 8px; }
.model-stats dt { font-size: 10px; letter-spacing: .5px; color: var(--muted); }
.model-stats dd { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.model-stats dd small { margin-left: 3px; font-size: 11px; font-weight: 500; color: var(--muted); }
.text-link { margin-top: 8px; padding: 0; border: 0; background: none; color: var(--terracotta-deep); font-size: 13px; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.text-link:hover { color: var(--teal); }

/* Recipes and Upgrades */
.lab { display: flex; flex-direction: column; gap: 10px; }
.lab-list { min-width: 0; }
.lab-list-head { display: none; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.lab-list-head h2 { font-family: var(--serif); font-size: 17px; font-weight: 700; color: var(--teal); }
.lab-list-head span { font-size: 12px; color: var(--muted); }
.lab-items { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: -2px; scrollbar-width: none; }
.lab-items::-webkit-scrollbar { display: none; }
.lab-item { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; padding: 5px 4px 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); text-align: center; }
.lab-item:hover { border-color: var(--sage-deep); }
.lab-item[aria-pressed=true] { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); background: #eef2e6; }
.lab-thumb { display: block; width: 44px; height: 44px; flex: none; border-radius: 7px; background: #f8efde; overflow: hidden; }
.lab-item[aria-pressed=true] .lab-thumb { background: #eef2e6; }
.lab-item-copy { display: flex; flex-direction: column; min-width: 0; }
.lab-item-copy strong { font-size: 11px; font-weight: 650; line-height: 1.2; }
.lab-item-copy small, .lab-item-value { display: none; }
.lab-main { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.lab-viewport { height: min(50vh, 430px); height: min(50svh, 430px); min-height: 260px; }
.lab-dock { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.dock-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.dock-title { flex: 1 1 240px; min-width: 0; }
.dock-title h2 { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.15; color: var(--teal); }
.dock-facts { display: flex; flex-wrap: wrap; gap: 1px 12px; margin-top: 2px; }
.dock-facts div { display: flex; gap: 4px; font-size: 12px; line-height: 1.4; white-space: nowrap; }
.dock-facts dt { color: var(--muted); }
.dock-facts dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.dock-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.transport { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); }
.transport { align-items: center; }
.transport-button { display: grid; place-items: center; width: 34px; height: 32px; border: 0; border-radius: 7px; background: none; color: var(--ink); }
.transport-button:hover { background: var(--sage-soft); }
.transport-play { background: var(--terracotta-deep); color: #fff7e8; }
.transport-play:hover { background: var(--terracotta); }
.transport-count { min-width: 92px; padding: 0 8px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dock-tools { display: flex; gap: 2px; }
.dock-tools .tool-button { padding: 8px; }
.step-bar { display: flex; flex: 1 1 320px; gap: 4px; min-width: 0; }
.step-chip { position: relative; flex: 1 1 0; display: flex; align-items: center; gap: 6px; min-width: 0; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); overflow: hidden; font-size: 13px; font-weight: 650; text-align: left; white-space: nowrap; }
.step-chip:hover { border-color: var(--teal); }
.step-fill { position: absolute; inset: 0; background: #b9cdb7; transform: scaleX(0); transform-origin: left; pointer-events: none; }
.step-chip > span, .step-chip > small { position: relative; }
.step-index { display: grid; place-items: center; width: 18px; height: 18px; flex: none; border-radius: 50%; background: var(--ink); color: var(--cream); font-size: 11px; font-weight: 700; }
.step-name { overflow: hidden; text-overflow: ellipsis; }
.step-note { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.step-tris { font-size: 11px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step-chip[aria-pressed=true] { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.step-chip[aria-pressed=true] .step-index { background: var(--teal); }
.dock-clock { min-width: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dock-clock:empty { display: none; }

/* Upgrade rungs wear the colours of the ladder */
#upgrades-view .step-chip:nth-child(1) .step-fill { background: #e9c8b4; }
#upgrades-view .step-chip:nth-child(2) .step-fill { background: #c5d3bd; }
#upgrades-view .step-chip:nth-child(3) .step-fill { background: var(--brass-light); }

.stage-labels { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.stage-label { position: absolute; top: 0; left: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; width: 0; padding-top: 6px; will-change: transform; }
.stage-label b { padding: 3px 9px; border-radius: 999px; background: #fffaf0e6; box-shadow: 0 1px 3px #2b262233; font-size: 12px; font-weight: 650; white-space: nowrap; }
.stage-label small { padding: 1px 6px; border-radius: 6px; background: #fffaf0b3; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stage-label.is-active b { background: var(--teal); color: var(--cream); }
.viewport.is-night .stage-label b { background: #143336e6; color: var(--cream); }
.viewport.is-night .stage-label small { background: #1433368c; color: #cbdad3; }
.viewport.is-night .stage-label.is-active b { background: var(--brass-light); color: var(--ink); }
.stage-size { position: absolute; top: 0; left: 0; margin: -9px 0 0 10px; padding: 2px 6px; border-radius: 5px; background: var(--terracotta-deep); color: #fff7e8; font: 600 11px/1.4 var(--mono); white-space: nowrap; will-change: transform; }
.stage-size.is-upright { margin: -24px 0 0; }

/* Shop */
.scene-panel { display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.scene-viewport { height: min(52vh, 470px); height: min(52svh, 470px); min-height: 280px; }
.scene-bottom { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.scene-copy { min-width: 0; }
.scene-copy h2 { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.2; color: var(--teal); }
.scene-copy p { margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.scene-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.scene-controls .viewer-toolbar { padding: 0; border: 0; }
.scene-controls .button kbd { display: none; }
.tier-switch #room-small_1[aria-pressed=true] { background: var(--terracotta-deep); }
.tier-switch #room-small_2[aria-pressed=true] { background: var(--sage-deep); }
.tier-switch #room-small_3[aria-pressed=true] { background: var(--brass-light); color: var(--ink); }
.room-busy { position: absolute; top: 0; left: 0; right: 0; z-index: 2; height: 3px; background: linear-gradient(90deg, transparent, var(--terracotta), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: busy 1s linear infinite; }
@keyframes busy { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.walk-crosshair { position: absolute; top: 50%; left: 50%; z-index: 1; transform: translate(-50%, -50%); color: var(--cream); text-shadow: 0 0 3px var(--ink); font-size: 22px; pointer-events: none; }

.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; padding: 12px 0 16px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.footer-divider { margin: 0 6px; opacity: .5; }
.skip-link { position: fixed; top: -80px; left: 12px; z-index: 20; padding: 10px 12px; border-radius: 6px; background: var(--brass-light); color: var(--ink); }
.skip-link:focus { top: 12px; }

/* Below the desktop layout the headline only opens the catalog; the other tabs lead with their stage. */
@media (max-width: 920px) {
  body:not([data-view=catalog]) .intro { display: none; }
}
@media (max-width: 1000px) {
  .preview-note { display: none; }
}
@media (max-width: 1150px) {
  .tool-button kbd { display: none; }
}

/* Phones */
@media (max-width: 560px) {
  .site-header { padding: 8px 12px; gap: 8px; }
  .brand { gap: 8px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-text strong { font-size: 14px; letter-spacing: 1.1px; }
  .brand-text small, #sampler-link, .site-header .button .icon { display: none; }
  .header-actions { gap: 8px; }
  .button { padding: 8px 10px; font-size: 12px; }
  .language-switch { gap: 4px; }
  main { padding: 0 12px; }
  .intro { padding: 16px 0 8px; }
  .intro h1 { font-size: 24px; }
  .intro-copy { font-size: 13px; }
  .intro-stats, .preview-note { display: none; }
  .tabs { gap: 0; justify-content: space-between; width: 100%; }
  .tab { padding-left: 6px; padding-right: 6px; font-size: 13px; gap: 5px; }
  .tab .icon { display: none; }
  kbd { display: none; }
  .segment { padding: 7px 9px; }
  .dock-controls, .transport, .scene-controls > .segmented { width: 100%; }
  .transport-button { flex: 1; width: auto; }
  .transport-count { flex: none; }
  .dock-controls .segmented { flex: 1; }
  .dock-controls .segment, .scene-controls .segment { flex: 1; justify-content: center; }
  .canvas-hint { display: none; }
  .viewport-asset { top: 40px; left: 12px; right: auto; max-width: calc(100% - 24px); padding: 3px 6px; font-size: 10px; }
  .step-tris { display: none; }
  .step-chip { flex-basis: auto; padding: 8px 6px; font-size: 12px; }
  .tool-button { gap: 4px; padding: 7px 4px; font-size: 11px; }
  .inspector .viewer-toolbar { justify-content: space-between; flex-wrap: nowrap; }
  #upgrades-view .step-chip { flex-wrap: wrap; gap: 0 5px; }
  #upgrades-view .step-note { flex-basis: 100%; margin: 1px 0 0 23px; font-size: 12px; }
  .dock-clock { width: 100%; }
  .site-footer { font-size: 11px; }
}

/* The narrowest phones drop the mark; the name, the language and the store link stay. */
@media (max-width: 360px) {
  .brand-mark { display: none; }
}

/* Tablets: room for the collections and a wider grid */
@media (min-width: 561px) and (max-width: 920px) {
  .asset-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .intro-stats li { width: 104px; }
  .lab-viewport { height: min(58vh, 520px); height: min(58svh, 520px); }
  .scene-viewport { height: min(58vh, 540px); height: min(58svh, 540px); }
}

/* Desktop: an app that fills the window; lists scroll inside their panels, the page never does. */
@media (min-width: 921px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; min-height: 560px; }
  main { display: flex; flex-direction: column; flex: 1; width: 100%; min-height: 0; }
  .view { flex: 1; min-height: 0; }
  .catalog-layout { display: grid; grid-template-columns: 186px minmax(250px, .82fr) minmax(380px, 1.3fr); gap: 18px; }
  .sidebar { display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; min-height: 0; overflow: auto; scrollbar-width: thin; }
  .section-label { display: block; margin-bottom: 6px; }
  .search-wrap { flex: none; margin-bottom: 8px; }
  .filter-chip { align-self: flex-start; margin-bottom: 12px; }
  .desktop-label { display: block; }
  .category-list { display: grid; gap: 1px; }
  .category-select, .mobile-filter-label { display: none; }
  .category-button { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 7px; background: none; text-align: left; font-size: 13px; color: var(--muted); }
  .category-button:hover { background: var(--sage-soft); color: var(--ink); }
  .category-button[aria-pressed=true] { background: var(--teal); color: var(--cream); }
  .category-button span:last-child { font-size: 11px; opacity: .75; font-variant-numeric: tabular-nums; }
  .sidebar-note { display: block; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
  .sidebar-note strong { display: block; font-family: var(--serif); font-size: 14px; color: var(--teal); }
  .sidebar-note p { margin: 4px 0 8px; font-size: 12px; line-height: 1.5; color: var(--muted); }
  .format-tag { display: inline-block; padding: 3px 6px; border: 1px solid var(--line-strong); border-radius: 4px; font-size: 11px; color: var(--muted); }
  .library { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
  .asset-grid { flex: 1; min-height: 0; max-height: none; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); align-content: start; }
  .inspector { order: 0; min-height: 0; min-width: 0; }
  .inspector .viewport { flex: 1; height: auto; min-height: 200px; }
  .lab { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 14px; }
  .lab-list { display: flex; flex-direction: column; min-height: 0; }
  .lab-list-head { display: flex; }
  .lab-items { flex: 1; flex-direction: column; gap: 2px; overflow-x: hidden; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
  .lab-item { flex-direction: row; gap: 8px; width: 100%; padding: 2px 8px 2px 3px; text-align: left; flex: none; }
  .lab-thumb { width: 34px; height: 34px; }
  .lab-item-copy { flex: 1; }
  .lab-item-copy strong { font-size: 13px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lab-item-copy small { display: block; font-size: 11px; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lab-item-value { display: block; flex: none; font-size: 12px; font-weight: 650; color: var(--brass-deep); font-variant-numeric: tabular-nums; }
  .lab-main { min-height: 0; }
  .lab-viewport { flex: 1; height: auto; min-height: 220px; }
  .scene-viewport { flex: 1; height: auto; min-height: 220px; }
  .scene-bottom { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
  .scene-copy { flex: 1 1 280px; }
}

/* Short frames (itch.io embeds at 1280 x 720): skip the intro and footer so every view fits. */
@media (min-width: 921px) and (max-height: 820px) {
  .intro, .site-footer, .sidebar-note, .lab-list-head { display: none; }
  .bar-headline { display: block; }
  main { padding-bottom: 12px; }
  .view-bar { margin-top: 2px; margin-bottom: 8px; }
  .tab { padding-top: 9px; padding-bottom: 8px; }
  .canvas-hint { display: none; }
  .viewer-toolbar { padding: 4px 6px; }
  .model-info { padding: 8px 12px 10px; }
  .model-stats { margin-top: 5px; }
  .catalog-paging { margin-top: 4px; min-height: 30px; }
  .lab-dock { gap: 6px; padding: 8px 10px; }
  .scene-bottom { padding: 8px 12px; }
  .scene-copy p { display: none; }
  .scene-copy h2 { font-size: 17px; }
}

@media (min-width: 1500px) {
  .catalog-layout { grid-template-columns: 200px minmax(430px, 1fr) minmax(480px, 1.15fr); }
  .lab { grid-template-columns: 300px minmax(0, 1fr); }
}

/* Narrow desktops keep the tabs and the headline; the counts return with more room. */
@media (min-width: 921px) and (max-width: 1240px) and (max-height: 820px) {
  .preview-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; scroll-behavior: auto !important; }
}
