/*
 * Atlas Studio for Frasch Construction — the app's stylesheet.
 *
 * Mobile first (390 px), then desktop from 900 px. The site's own tokens (site/src/styles/tokens.css),
 * system-ui text (no web fonts), every tap target at least 46 px tall (L7), no horizontal overflow.
 * Inline styles are permitted by the CSP; inline scripts are not, and none exist.
 */
:root {
  --black: #0d0d0c;
  --black-raised: #161513;
  --black-2: #1e1c19;
  --black-3: #262320;
  --ivory: #f7ecd9;
  --ivory-soft: #d9cfbd;
  --muted: #a79f90;
  --gold-hi: #f8d39c;
  --gold: #ca9c68;
  --gold-deep: #9f7548;
  --hairline: #3a3428;
  --hairline-gold: rgba(202, 156, 104, 0.38);
  --moss: #8fa07e;
  --rust: #c9705a;
  --amber: #d9a441;
  --focus: var(--gold-hi);
  --radius: 2px;
  --tap: 46px;
  --gutter: 16px;
  --tabbar: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; background: var(--black); color: var(--ivory); }
body {
  font: 16px/1.5 var(--font);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-wrap: anywhere;
}
body.is-locked { overflow: hidden; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-hi); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--black); padding: 10px 14px; z-index: 100; }
.skip:focus { left: 8px; }

/* ------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 8px var(--gutter);
  background: rgba(13, 13, 12, 0.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; flex-direction: column; gap: 0; min-width: 0; line-height: 1.2; }
.brand-mark { font-weight: 600; font-size: 15px; letter-spacing: 0.02em; color: var(--ivory); white-space: nowrap; }
.brand-sub { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); white-space: nowrap; }
.who { font-size: 12px; line-height: 1.3; color: var(--muted); text-align: right; min-width: 0; }
.who b { display: block; color: var(--ivory-soft); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

/* ------------------------------------------------------------- tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--black-raised); border-top: 1px solid var(--hairline);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tap); padding: 4px 2px; border: 0; border-top: 2px solid transparent;
  background: transparent; color: var(--muted);
  font-size: 11px; line-height: 1.1; font-weight: 500; text-align: center; letter-spacing: 0.01em;
}
.tab svg { width: 18px; height: 18px; flex: none; }
.tab[aria-current="page"] { color: var(--gold-hi); border-top-color: var(--gold); }
.tab .badge { position: absolute; }
.tab { position: relative; }
.badge {
  display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  font-size: 11px; line-height: 18px; font-weight: 600; text-align: center;
  background: var(--gold); color: var(--black);
}
.tab .badge { top: 4px; right: calc(50% - 22px); }

/* ------------------------------------------------------------- layout */
.main { padding: 0 var(--gutter) 24px; max-width: 100%; }
.panel { padding-top: 12px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 8px 0 12px; }
.panel-head h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 500; letter-spacing: 0.005em; }
.panel-head .measured { font-size: 12px; color: var(--muted); }
.lede { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 12px; }
.card {
  background: var(--black-raised); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 14px;
}
.card h2, .card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 13px; }
.small:not(.btn) { font-size: 13px; color: var(--muted); } /* .btn.small is the button size modifier, not muted text */
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.gold { color: var(--gold-hi); }
.hairline { border-top: 1px solid var(--hairline); margin: 12px 0; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; font-size: 14px; }
.stamp { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 16px;
  border: 1px solid var(--hairline); border-radius: var(--radius);
  background: var(--black-2); color: var(--ivory); font-weight: 500; font-size: 15px; line-height: 1.2;
  text-decoration: none; white-space: normal; text-align: center;
}
.btn:hover { border-color: var(--hairline-gold); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--black); font-weight: 600; }
.btn.primary:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn.danger { border-color: rgba(201, 112, 90, 0.6); color: #f0b7a8; }
.btn.ghost { background: transparent; }
.btn.small { font-size: 14px; padding: 8px 12px; }
.btn.block { width: 100%; }
.btn.is-on { background: var(--black-3); border-color: var(--gold); color: var(--gold-hi); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: var(--tap); padding: 8px 14px; border-radius: 23px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ivory-soft); font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--black-3); border-color: var(--gold); color: var(--gold-hi); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  background: var(--black); border: 1px solid var(--hairline); border-radius: var(--radius); color: var(--ivory);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 160px; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.check { display: flex; align-items: flex-start; gap: 12px; min-height: var(--tap); padding: 8px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; accent-color: var(--gold); }
.check span { font-size: 15px; line-height: 1.4; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 8px 14px; border: 1px solid var(--hairline); border-radius: var(--radius); cursor: pointer; }
.radio-row label:has(input:checked) { border-color: var(--gold); color: var(--gold-hi); background: var(--black-3); }
.radio-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--gold); }
.counter { font-size: 12px; color: var(--muted); text-align: right; }
.counter.bad { color: var(--rust); }
.counter.ok { color: var(--moss); }

/* ------------------------------------------------------------- notices */
.notice { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--hairline); background: var(--black-raised); font-size: 14px; }
.notice.bad { border-color: rgba(201, 112, 90, 0.7); background: rgba(201, 112, 90, 0.1); color: #f3c4b8; }
.notice.warn { border-color: rgba(217, 164, 65, 0.6); background: rgba(217, 164, 65, 0.08); color: #f1d9a8; }
.notice.ok { border-color: rgba(143, 160, 126, 0.6); background: rgba(143, 160, 126, 0.1); color: #cfd9c3; }
.notice pre { margin: 6px 0 0; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em; line-height: 1.5;
  background: var(--black-3); color: var(--ivory-soft); border: 1px solid var(--hairline);
}
.pill.ok { color: #cfe0bd; border-color: rgba(143, 160, 126, 0.7); }
.pill.bad { color: #f3c4b8; border-color: rgba(201, 112, 90, 0.7); }
.pill.warn { color: #f1d9a8; border-color: rgba(217, 164, 65, 0.7); }
.pill.gold { color: var(--gold-hi); border-color: var(--gold); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.busy .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pill.busy .dot { animation: none; } }

.toasts { position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 14px; background: var(--black-3); border: 1px solid var(--hairline-gold); border-radius: var(--radius); color: var(--ivory); font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.toast.bad { border-color: var(--rust); }
.toast.ok { border-color: var(--moss); }

/* ------------------------------------------------------------- sheets */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); }
.sheet {
  position: fixed; inset: 0; z-index: 51; display: flex; flex-direction: column;
  background: var(--black); color: var(--ivory);
  overflow: hidden;
}
.sheet-head {
  display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px var(--gutter) 6px 6px;
  border-bottom: 1px solid var(--hairline); background: var(--black-raised); flex: none;
}
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; line-height: 1.2; min-width: 0; }
.sheet-body { flex: 1; overflow: auto; padding: 14px var(--gutter) 24px; -webkit-overflow-scrolling: touch; }
.sheet-body.flush { padding: 0; display: flex; flex-direction: column; }
.sheet-foot { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--hairline); background: var(--black-raised); }
.sheet-foot .btn { flex: 1 1 140px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); min-width: var(--tap); padding: 8px 12px; border: 0; background: transparent; color: var(--gold-hi); font-weight: 500; }
.back svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------- photos */
.photo-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.panel.is-drop .grid, .panel.is-drop .empty { outline: 2px dashed var(--gold); outline-offset: 6px; }
.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
.photo {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  background: var(--black-raised); border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden;
  padding: 0 0 6px;
}
.photo.is-selected { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.photo .thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; background: var(--black-2);
  border: 0; padding: 0; cursor: pointer;
}
.photo .thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo .thumb .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.photo .thumb .progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.12); z-index: 3; }
.photo .again { margin: 2px 8px 4px; }
.photo .thumb .progress > i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 200ms linear; }
.photo .sel {
  position: absolute; top: 0; left: 0; z-index: 2; width: var(--tap); height: var(--tap);
  border: 0; background: transparent; padding: 0; display: flex; align-items: flex-start; justify-content: flex-start;
}
.photo .sel i { display: block; width: 24px; height: 24px; margin: 6px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); background: rgba(0, 0, 0, 0.35); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.photo.is-selected .sel i { background: var(--gold); border-color: var(--gold-hi); }
.photo.is-selected .sel i::after { content: ""; display: block; width: 7px; height: 12px; margin: 2px 0 0 7px; border: solid var(--black); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.photo .mark {
  position: absolute; top: 6px; right: 6px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  display: none; align-items: center; justify-content: center; font-size: 16px; line-height: 1;
  background: rgba(13, 13, 12, 0.8); color: var(--gold-hi); border: 1px solid var(--gold);
}
.photo[data-onsite="live"] .mark, .photo[data-onsite="staged"] .mark { display: flex; }
.photo[data-onsite="staged"] .mark { color: var(--ivory-soft); border-style: dashed; }
.photo .status {
  position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 2; text-align: left;
  font-size: 11px; line-height: 1.3; font-weight: 600; padding: 3px 7px; border-radius: 10px;
  background: rgba(13, 13, 12, 0.82); color: var(--ivory-soft); border: 1px solid var(--hairline);
  max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.photo[data-status="ready"] .status { display: none; }
.photo[data-status="error"] .status { color: #f3c4b8; border-color: var(--rust); }
.photo[data-status="error"] .thumb { opacity: 0.55; }
.photo .note { padding: 0 8px; font-size: 12px; line-height: 1.3; color: var(--muted); }
.photo[data-status="error"] .note { color: #f3c4b8; }
.photo[data-status="uploading"] .status, .photo[data-status="processing"] .status, .photo[data-status="converting"] .status, .photo[data-status="hashing"] .status { color: var(--gold-hi); border-color: var(--hairline-gold); }
.photo .name { padding: 0 8px; font-size: 12px; color: var(--ivory-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo .again { margin: 0 8px; }
.selbar {
  position: sticky; top: 56px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 10px; margin: 0 0 10px; background: var(--black-3); border: 1px solid var(--gold); border-radius: var(--radius);
}
.selbar b { flex: 1 1 100%; font-size: 14px; }

/* lightbox */
.lightbox-img { width: 100%; max-height: 52vh; object-fit: contain; background: var(--black-2); border: 1px solid var(--hairline); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.actions { display: grid; gap: 8px; }

/* ------------------------------------------------------------- pages */
.pages { display: grid; gap: 12px; }
.pages-side { display: grid; gap: 12px; }
.preview-view { display: none; }
.preview-view.is-open { display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 45; background: var(--black); }
.preview-toolbar {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 6px var(--gutter) 6px 6px; border-bottom: 1px solid var(--hairline); background: var(--black-raised); min-height: 56px;
}
.preview-toolbar .route { flex: 1 1 120px; font-size: 13px; color: var(--muted); font-family: var(--mono); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-frame { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }
.preview-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.route-list { display: grid; gap: 8px; }

/* editor */
.editor-where { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.editor-now { margin: 0; padding: 10px 12px; border-left: 3px solid var(--hairline-gold); background: var(--black-raised); color: var(--ivory-soft); font-size: 15px; white-space: pre-wrap; }
.hits { display: grid; gap: 8px; }
.hit { text-align: left; display: grid; gap: 4px; padding: 10px 12px; }
.hit .where { font-family: var(--mono); font-size: 12px; color: var(--gold-hi); }
.hit .val { color: var(--ivory-soft); font-size: 14px; }
.draftbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border: 1px dashed var(--hairline-gold); border-radius: var(--radius); font-size: 14px; }
.draftbar span { flex: 1 1 100%; }

/* ------------------------------------------------------------- lists */
.list { display: grid; gap: 10px; }
.item { display: grid; gap: 6px; padding: 12px 14px; background: var(--black-raised); border: 1px solid var(--hairline); border-radius: var(--radius); }
.item.stale { border-style: dashed; opacity: .85; }
.measured-note { margin: -4px 0 6px; font-size: 12px; color: var(--muted); }
.item .title { font-weight: 600; }
.item .why { color: var(--ivory-soft); font-size: 14px; }
.item details { font-size: 13px; }
.item summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; color: var(--gold-hi); list-style: none; }
.item summary::-webkit-details-marker { display: none; }
.item summary::before { content: "▸"; margin-right: 8px; transition: transform 150ms; }
.item details[open] summary::before { transform: rotate(90deg); }
.item ul { margin: 4px 0 0; padding-left: 18px; color: var(--ivory-soft); }
.item li { margin: 2px 0; font-family: var(--mono); font-size: 12px; }
.item .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.item .foot > span.small { flex: 1 1 200px; }
.item .foot > .btn { flex: none; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12px; }
.steps { margin: 6px 0 0; padding-left: 18px; font-size: 12px; font-family: var(--mono); color: var(--ivory-soft); }

/* ------------------------------------------------------------- drafts */
.draft-grid { display: grid; gap: 14px; }
.draft-side { display: grid; gap: 12px; }
.pack { max-height: 40vh; overflow: auto; border: 1px solid var(--hairline); border-radius: var(--radius); padding: 8px 12px; background: var(--black-raised); }
.pack li { font-size: 13px; margin: 6px 0; color: var(--ivory-soft); }
.pack li .src { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.flag { border-left: 3px solid var(--rust); padding: 8px 12px; background: rgba(201, 112, 90, 0.08); font-size: 14px; }
.flag q { display: block; color: var(--ivory); font-style: italic; }
.flag .claim { color: #f3c4b8; font-size: 13px; margin-top: 4px; }
.section-edit { padding: 12px; border: 1px solid var(--hairline); border-radius: var(--radius); display: grid; gap: 8px; background: var(--black-raised); }
.section-edit .row { justify-content: space-between; }

/* ------------------------------------------------------------- prompts */
.law { margin: 0; padding: 12px; background: var(--black-raised); border: 1px solid var(--hairline-gold); border-radius: var(--radius); white-space: pre-wrap; font-family: var(--mono); font-size: 12px; color: var(--ivory-soft); max-height: 40vh; overflow: auto; }
.law-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gold-hi); }
.history li { font-size: 13px; margin: 6px 0; }
.history .sha { font-family: var(--mono); color: var(--gold-hi); }
.history .at { color: var(--muted); }

/* ------------------------------------------------------------- status */
.health { display: grid; gap: 12px; }
.health .card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------------- gate screens */
.gate { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 24px var(--gutter); }
.gate .card { max-width: 420px; }
.gate p { color: var(--ivory-soft); }

/* ------------------------------------------------------------- desktop */
@media (min-width: 900px) {
  :root { --tabbar: 0px; }
  body { padding-bottom: 0; padding-left: 232px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .brand { flex-direction: row; align-items: baseline; gap: 12px; }
  .brand-mark { font-size: 17px; }
  .who { font-size: 13px; }
  .who b { display: inline; max-width: none; }
  .who b::after { content: " · "; color: var(--muted); font-weight: 400; }
  .tabs {
    top: 57px; bottom: 0; left: 0; right: auto; width: 232px; height: auto;
    display: flex; flex-direction: column; gap: 2px; padding: 12px 10px;
    border-top: 0; border-right: 1px solid var(--hairline);
  }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 10px 14px; border-top: 0; border-left: 2px solid transparent; font-size: 15px; text-align: left; border-radius: var(--radius); }
  .tab[aria-current="page"] { border-left-color: var(--gold); background: var(--black-2); }
  .tab .badge { position: static; margin-left: auto; }
  .main { padding: 0 24px 40px; max-width: 1400px; }
  .panel-head h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .toasts { left: auto; right: 24px; bottom: 24px; width: 380px; }
  .selbar { top: 57px; }

  .sheet { inset: auto; top: 50%; left: calc(50% + 116px); transform: translate(-50%, -50%); width: min(680px, calc(100vw - 280px)); max-height: min(88vh, 900px); border: 1px solid var(--hairline-gold); border-radius: 4px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7); }
  .sheet.wide { width: min(1120px, calc(100vw - 280px)); }
  .sheet-head .back .lbl { display: none; }

  .pages { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
  .preview-view { display: flex; flex-direction: column; position: sticky; top: 72px; height: calc(100vh - 96px); border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
  .preview-view.is-open { position: sticky; inset: auto; z-index: auto; }
  .preview-toolbar .back { display: none; }
  .pages-side .open-preview, .pages-side .open-preview + .hairline, .pages-side .hairline:has(+ .open-preview) { display: none; }

  .draft-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .pack { max-height: 50vh; }
  .health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
