/* =========================================================================
 * app.css — Doka Photo Report Builder
 *
 * The Engineer's Notebook design system (../engineers-notebook-style/
 * DESIGN-SYSTEM.md). The :root block is shared byte-for-byte with the other
 * apps in the family — never retune it here. App-local tokens and components
 * start at "the light table" and are marked as such.
 *
 * One thing to know before editing: the page preview (.sheet and its children)
 * is positioned entirely from JavaScript, in points × a scale factor, by
 * render.js. Do not add padding, margins or font sizes to .pv-* rules — they
 * would silently pull the preview out of agreement with the PDF.
 * ========================================================================= */

/* Self-hosted, because this app is behind a sign-in gate: loading from Google
 * would hand a third party every visitor's IP and Referer before they
 * authenticate. These are the same subset files pdf.js embeds (see
 * tools/build-fonts.sh); -Medium and -SemiBold are chrome-only. */
@font-face { font-family: "Fraunces"; src: url("../fonts/Fraunces-SemiBold.ttf") format("truetype"); font-weight: 640; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("../fonts/DMSans-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("../fonts/DMSans-Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("../fonts/DMSans-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("../fonts/DMSans-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --paper: #F6F2E9;
  --card: #FFFDF7;
  --ink: #2B2A26;
  --ink-soft: #6B675C;
  --line: #DDD5C4;
  --line-soft: #EAE3D4;
  --rust: #B3502D;
  --rust-deep: #8F3E21;
  --amber: #E0A41B;
  --teal: #1F6F9C;
  --green: #4A7A43;
  --purple: #6E4FA3;
  --warn-bg: #F6E3DC;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --nav-h: 58px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 42, 38, .10), 0 4px 14px rgba(43, 42, 38, .06);
}

* { box-sizing: border-box; }

/* Load-bearing. View switching uses the hidden attribute; an author
 * display:flex on a hidden pane paints an empty overlay over the whole app. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--teal); }

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 640; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

.mono, code, pre, .kv dt, .kv dd { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.num { font-variant-numeric: tabular-nums; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The signature small-caps label. */
.label, .ctl-label, .isec-head {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft);
}
.hint { font-size: 12.5px; color: var(--ink-soft); margin: 8px 0 0; }
.hint-warn { color: var(--rust-deep); }

/* ------------------------------------------------------------ buttons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:disabled:hover { border-color: var(--line); }

.btn-primary { background: var(--rust); border-color: var(--rust-deep); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled), .btn-primary:active { background: var(--rust-deep); }
.btn-ghost { border-color: transparent; color: var(--ink-soft); background: none; }
.btn-ghost:hover { color: var(--ink); background: var(--paper); border-color: var(--line); }
.btn-ghost.danger { color: var(--rust-deep); border-color: var(--rust); background: none; }
.btn-ghost.danger:hover { background: var(--warn-bg); border-color: var(--rust-deep); }
.btn-tiny { font-size: 12px; padding: 3px 8px; }

/* ------------------------------------------------------------- inputs ---- */

.text-input, input[type=text], input[type=date], select, textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 13px;
  padding: 6px 9px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--ink);
}
input[type=text], input[type=date], select { height: 36px; }
input.mono, .text-input.mono { font-family: var(--font-mono); }
textarea { resize: vertical; min-height: 56px; line-height: 1.5; }
.text-input:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal);
}

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ctl { display: flex; flex-direction: column; gap: 3px; flex: 1 1 150px; min-width: 0; }
.ctl-actions { display: flex; gap: 7px; }
.ctl-actions.wrap { flex-wrap: wrap; }
.ctl-out { font-size: 13px; height: 36px; display: flex; align-items: center; color: var(--ink-soft); }
.controls.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 12px; align-items: end;
}
.controls.form-grid .ctl { flex: none; }
.controls.form-grid .ctl-wide { grid-column: 1 / -1; }

.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--rust); margin: 0; }

/* ------------------------------------------------------------- chips ----- */

.pill {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--teal); color: var(--teal);
  border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.segmented button { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.segmented button.active { background: var(--ink); color: var(--paper); }

.env-chip {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .06em;
  padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  cursor: pointer; flex-shrink: 0;
}
.env-chip:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ------------------------------------------------- empty / loading ------- */

.empty-state { text-align: center; padding: 56px 28px; color: var(--ink-soft); }
.empty-mark { font-size: 34px; color: var(--line); margin-bottom: 10px; line-height: 1; }
.empty-state h2 { color: var(--ink); font-size: 21px; margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: 13.5px; max-width: 44ch; margin-inline: auto; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--rust);
  animation: spin .8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.view { min-height: 100%; }
.view-center { display: flex; justify-content: center; padding: 32px 20px; }
.fatal-card {
  max-width: 760px; margin: auto;
  background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--rust-deep); border-radius: var(--radius);
  padding: 24px 28px; box-shadow: var(--shadow);
}
.fatal-title { font-family: var(--font-display); font-size: 24px; margin: 0 0 10px; color: var(--rust-deep); }
.raw {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.45; margin: 0;
  background: #FBF7EE; border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
details.raw-wrap { margin-top: 10px; }
details.raw-wrap > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft); padding: 4px 0; }

/* ------------------------------------------------------------ topbar ----- */

.topbar {
  display: flex; align-items: center; gap: 20px;
  height: var(--nav-h); padding: 0 18px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; flex-direction: column; line-height: 1.15; flex-shrink: 0; }
.topbar-name { font-family: var(--font-mono); font-size: 14px; font-weight: 600; margin: 0; }
.topbar-sub { font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--rust); }
.topbar-nav { display: flex; gap: 2px; margin-left: auto; }
.topbar-right { margin-left: 10px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tabnav-btn {
  font-size: 13px; font-weight: 500; padding: 7px 13px;
  border: 1px solid transparent; border-radius: 7px; color: var(--ink-soft);
}
.tabnav-btn:hover { color: var(--ink); background: var(--paper); }
.tabnav-btn.is-active { color: var(--rust-deep); background: var(--paper); border-color: var(--line); font-weight: 700; }

/* =========================================================================
 * App-local components below this line.
 * ========================================================================= */

/* ------------------------------------------------------- the sign-in gate -
 * Clerk renders its own component inside .gate-mount; everything around it is
 * ours. Nothing here styles Clerk's internals. */

.gate-card {
  margin: auto; width: 100%; max-width: 440px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 26px 22px; box-shadow: var(--shadow);
}
.gate-brand { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.gate-name { font-family: var(--font-mono); font-size: 17px; font-weight: 600; margin: 0; }
.gate-brand .topbar-sub { text-align: center; }
.gate-lede { margin: 0; font-size: 13.5px; color: var(--ink-soft); text-align: center; max-width: 40ch; }
.gate-boot { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); padding: 14px 0; }
.gate-mount { width: 100%; display: flex; justify-content: center; }
#gateNote { text-align: center; max-width: 40ch; }

.user-slot { display: flex; align-items: center; }

/* ---------------------------------------------------------- the shell ---- */

.app { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }

.workspace {
  min-height: 0; display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
  gap: 14px; padding: 14px;
}
/* Grid and flex children default to min-content, which is wider than a phone
 * once a form grid is inside them. Both axes have to be told to shrink. */
.workspace > * { min-width: 0; }

.panel {
  min-height: 0; min-width: 0; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.panel-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px; }

/* Each inspector section is a <details>, so it collapses with no JS. */
.isec { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--line); }
.isec:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.isec-head {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  color: var(--rust); border-bottom: 1px solid var(--line);
  padding-bottom: 5px; margin-bottom: 10px; font-family: var(--font-body);
  list-style: none; user-select: none;
}
.isec-head::-webkit-details-marker { display: none; }
/* A typographic caret, not an icon font or an emoji. */
.isec-head::before {
  content: "\25B8"; font-size: 11px; line-height: 1;
  transition: transform .15s ease;
}
.isec[open] > .isec-head::before { transform: rotate(90deg); }
.isec-head:hover { color: var(--rust-deep); }
.isec:not([open]) > .isec-head { margin-bottom: 0; border-bottom-color: var(--line-soft); }
.ctl-actions.gap-above { margin-top: 7px; }

.canvas { background: var(--paper); }
.canvas-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line);
}
.canvas-stat { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.canvas-stat .mono { font-size: 12px; }
.canvas-tools { display: flex; align-items: center; gap: 8px; }

.busy {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; font-size: 12.5px; color: var(--ink-soft);
  background: var(--card); border-bottom: 1px solid var(--line-soft);
}
.busy .spinner { width: 15px; height: 15px; }

/* ------------------------------------------------------ the light table -- */

/* Outside .panel-scroll, so tiles pass behind nothing and it can never cover
 * the first row. */
.lt-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; flex: 0 0 auto;
  padding: 8px 18px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.lt-bar-left, .lt-bar-right { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.lt-count { font-size: 12px; color: var(--ink-soft); }

.lt-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px; align-content: start; min-height: 120px;
}
/* The empty state is a child of the grid, so it has to be told to span it. */
.lt-grid > .empty-state { grid-column: 1 / -1; }

.tile {
  margin: 0; position: relative;
  display: flex; flex-direction: column; gap: 5px;
  cursor: grab;
  border-radius: 8px;
  transition: opacity .15s, filter .15s;
}
.tile:active { cursor: grabbing; }
.tile-frame {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  background: #E8E4D8; border: 1px solid var(--line); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.tile-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-broken { font-size: 22px; color: var(--amber); }

.tile-idx {
  position: absolute; left: 5px; bottom: 5px;
  min-width: 20px; padding: 1px 5px; border-radius: 4px;
  background: rgba(43, 42, 38, .78); color: var(--paper);
  font-size: 10.5px; font-weight: 600; text-align: center;
}
.tile-inc { position: absolute; top: 5px; left: 5px; display: flex; }
.tile-edit {
  position: absolute; right: 5px; bottom: 5px;
  width: 22px; height: 22px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(43, 42, 38, .78); color: var(--paper);
  font-size: 12px; line-height: 1;
}
.tile-edit:hover { background: var(--rust); }
.tile-check { width: 17px; height: 17px; margin: 0; accent-color: var(--rust); cursor: pointer; }
.tile-flags { position: absolute; top: 5px; right: 5px; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.tile-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 4px; background: var(--ink-soft); color: #FFFDF7;
}
.tile-badge.out { background: var(--ink); }
.tile-badge.note { background: var(--teal); }
.tile-badge.bad { background: var(--amber); color: var(--ink); }

.tile-name {
  font-size: 10.5px; color: var(--ink-soft); line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tile.is-sel .tile-frame { border-color: var(--rust); box-shadow: 0 0 0 2px var(--rust); }
.tile.is-sel .tile-name { color: var(--rust-deep); font-weight: 600; }
.tile.is-out .tile-frame img { filter: grayscale(1); opacity: .45; }
.tile.is-bad .tile-frame { border-color: var(--amber); }
.tile.is-dragging { opacity: .4; }

/* The insertion marker while dragging: a rust rule on the edge the tile lands. */
.tile.drop-before::before, .tile.drop-after::after {
  content: ""; position: absolute; top: 0; bottom: 18px; width: 3px;
  background: var(--rust); border-radius: 2px;
}
.tile.drop-before::before { left: -8px; }
.tile.drop-after::after { right: -8px; }

/* ------------------------------------------------------ page preview ----- */

.pages-scroll { background: #E8E4D8; }
/* `safe center` matters here: a sheet wider than the pane (tabloid, or 100%
 * zoom in a narrow window) would otherwise centre-overflow and put its left
 * edge out of reach of the scrollbar. The plain value stays first as the
 * fallback for browsers without safe alignment. */
.pages {
  display: flex; flex-direction: column; gap: 18px;
  align-items: center;
  align-items: safe center;
  padding: 4px;
}

.sheet {
  position: relative; flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(43, 42, 38, .18);
  overflow: hidden;
}

/* Every .pv-* box is positioned in points × scale by render.js. Adding any
 * padding, margin or font-size here would break agreement with the PDF. */
/* render.js sets the family, weight and style per op, from the same face table
 * pdf.js embeds. line-height:1 is what baselineFraction() assumes. */
.pv-text { position: absolute; line-height: 1; white-space: pre; margin: 0; }
.pv-img { position: absolute; overflow: hidden; }
.pv-img img { position: absolute; display: block; }
.pv-img.is-clickable { cursor: zoom-in; }
.pv-img.is-clickable:hover { outline: 2px solid var(--rust); outline-offset: 1px; }
.pv-line { position: absolute; }
.pv-rect { position: absolute; }

/* ------------------------------------------------------ drop veil -------- */

.dropveil {
  position: fixed; inset: 0; z-index: 2050;
  display: flex; align-items: center; justify-content: center;
  background: rgba(43, 42, 38, .42);
}
.dropveil-card {
  background: var(--paper); border: 2px dashed var(--rust); border-radius: 14px;
  padding: 34px 44px; text-align: center; color: var(--ink);
  font-size: 15px; font-weight: 600;
}
.dropveil-mark { font-size: 34px; color: var(--rust); line-height: 1; margin-bottom: 8px; }
.dropveil-card p { margin: 0; }

/* ------------------------------------------------ overlays & toast ------
 * z-index ladder — keep every overlay inside it:
 *   light-table sticky bar        5
 *   drop veil                  2050
 *   modal                      2100
 *   toast                      2200
 */

.overlay { position: fixed; inset: 0; z-index: 2100; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(43, 42, 38, .42); }
.modal-panel {
  position: absolute; left: 14px; right: 14px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 12px;
  max-width: 560px; margin: 0 auto; max-height: 84dvh; overflow-y: auto;
  background: var(--paper); border-radius: 14px; padding: 20px 18px;
  box-shadow: 0 12px 40px rgba(43, 42, 38, .3);
}
.modal-title {
  font-family: var(--font-display); font-size: 19px; margin: 0;
  overflow-wrap: anywhere;                 /* modal titles are often file names */
}
/* .ctl is flex: 1 1 150px for toolbar rows. Inside a column-flex modal that
 * becomes a 150px height basis that then grows, which opened a dead band
 * between the slider and everything under it. */
.modal-panel .ctl { flex: none; }
.modal-body { margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; font-size: 12.5px; }
.kv dt { color: var(--ink-soft); font-size: 11px; white-space: nowrap; }
.kv dd { margin: 0; word-break: break-word; }

.edit-body { display: flex; flex-direction: column; gap: 9px; }
.edit-frame {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: #E8E4D8; border: 1px solid var(--line); border-radius: 8px;
  height: 190px; overflow: hidden;
}
.edit-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.edit-rotate { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  background: rgba(43, 42, 38, .78); color: var(--paper);
  font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: var(--rust); }
.edit-body .kv { max-height: 150px; overflow-y: auto; }
.kv dd.is-null { color: var(--ink-soft); font-style: italic; }

.pdf-dialog { display: flex; flex-direction: column; gap: 9px; }
.detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.detail-stop { font-size: 12.5px; font-weight: 600; color: var(--rust-deep); }
.detail-slider { width: 100%; accent-color: var(--rust); margin: 4px 0 0; display: block; }
/* The estimate belongs to the slider, so it sits tight under it. */
.detail-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-soft); margin-bottom: 2px; }
.pdf-dialog .ctl { gap: 0; }
.detail-size {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  font-size: 12.5px; min-height: 40px;
}
.size-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--green); }
.dot-warn { background: var(--amber); }
.dot-over { background: var(--rust); }
.size-val { font-weight: 600; font-size: 13px; }
.size-note { color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(8px);
  bottom: 54px; z-index: 2200; max-width: min(560px, calc(100vw - 28px));
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius); padding: 11px 14px; font-size: 13.5px;
  box-shadow: 0 6px 22px rgba(43, 42, 38, .32);
  opacity: 0; transition: opacity .22s, transform .22s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-msg { min-width: 0; }
.toast-action {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--amber); flex-shrink: 0;
}
.toast-action:hover { text-decoration: underline; }

/* --------------------------------------------------------- credit tag ---- */

.appfoot {
  display: flex; align-items: center; justify-content: center; gap: 0;
  flex-wrap: wrap;
  padding: 0 14px 10px;
}
.credit {
  font-family: var(--font-body); font-size: 11.5px; font-weight: 600;
  color: var(--ink-soft); opacity: .6; text-decoration: none;
}
.credit:hover, .credit:active { opacity: .85; }
.credit-sep { margin: 0 8px; color: var(--line); user-select: none; font-size: 11.5px; }

/* -------------------------------------------------------- a11y & motion -- */

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible, .tabnav-btn:focus-visible { outline-offset: 1px; }
.tile:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; border-top-color: var(--line); }
}

/* ------------------------------------------------------------ widths ----- */

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .inspector { max-height: 44dvh; }
}

@media (max-width: 640px) {
  /* The topbar carries four things; on a phone it becomes two rows rather than
     forcing the whole page into a horizontal scroll. */
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 8px 10px; }
  .topbar-nav { gap: 0; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .topbar-right .btn { flex: 1; }
  .env-chip { max-width: 45%; overflow: hidden; text-overflow: ellipsis; }

  .workspace { padding: 10px; gap: 10px; }
  .panel-scroll { padding: 12px; }
  .lt-bar { padding: 8px 12px; }
  .lt-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
  /* minmax(0, 1fr), not 1fr: a bare 1fr keeps each column at min-content. */
  .controls.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn { min-height: 40px; padding: 9px 14px; }
  .btn-tiny { min-height: 32px; padding: 4px 9px; }
  /* The credit stays visible on a phone — it wraps to two lines rather than
     disappearing. No rule anywhere hides the footer at any width. */
  .appfoot { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
