/*
 * Scrapbook Print Sheets
 * Plain CSS, no build step, no remote resources.
 */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f5f5f7;
  --desk: #e4e4e8;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --track: #e6e6ea;
  --text: #1d1d1f;
  --text-2: #5c5c63;
  --line: rgba(0, 0, 0, 0.12);
  --line-strong: rgba(0, 0, 0, 0.2);
  --hover: rgba(0, 0, 0, 0.05);
  --active: rgba(0, 0, 0, 0.1);

  --accent: #0066cc;          /* text, rings, borders */
  --accent-fill: #0066cc;     /* filled controls with white text */
  --accent-fill-hover: #0058b0;
  --accent-tint: rgba(0, 102, 204, 0.1);
  --on-accent: #ffffff;
  --warn: #9a5b00;
  --danger: #c9342b;
  --orange: #ff9f0a;
  --green: #30b96b;

  --paper: #ffffff;
  --paper-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.1), 0 18px 40px rgba(0, 0, 0, 0.14);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.1), 0 12px 32px rgba(0, 0, 0, 0.18);
  --shadow-raised: 0 1px 2px rgba(0, 0, 0, 0.14);

  --toast-bg: #1d1d1f;
  --toast-text: #ffffff;
  --toast-accent: #7cbcff;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;

  --r-s: 6px;
  --r-m: 8px;
  --r-l: 12px;

  --control-h: 36px;
  --fast: 120ms;
  --med: 220ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --spring: cubic-bezier(0.2, 1.35, 0.4, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --desk: #101012;
    --surface: #1e1e21;
    --surface-2: #29292d;
    --track: #121214;
    --text: #f5f5f7;
    --text-2: #a4a4ac;
    --line: rgba(255, 255, 255, 0.13);
    --line-strong: rgba(255, 255, 255, 0.24);
    --hover: rgba(255, 255, 255, 0.07);
    --active: rgba(255, 255, 255, 0.13);

    --accent: #58a6ff;
    --accent-fill: #1f6fd6;
    --accent-fill-hover: #2a7be3;
    --accent-tint: rgba(88, 166, 255, 0.16);
    --warn: #ffb340;
    --danger: #ff6961;

    --paper-shadow: 0 1px 1px rgba(0, 0, 0, 0.5), 0 6px 14px rgba(0, 0, 0, 0.45), 0 22px 48px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.4), 0 14px 36px rgba(0, 0, 0, 0.55);
    --shadow-raised: 0 1px 2px rgba(0, 0, 0, 0.5);

    --toast-bg: #3a3a3f;
  }
}

@media (pointer: coarse) {
  :root { --control-h: 44px; }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  font: 14px/1.4 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; }

h2, p, dl, dd { margin: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Page layout ---------- */

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 0;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--desk);
}

.sheet-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.sheet-caption {
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  padding: 0 var(--s4);
}

.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s2) var(--s4) var(--s3);
}

.sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s1);
}

.panel {
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 0 var(--s4) var(--s4);
}

.tray {
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-width: 0;
}

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

.toolbar-group { display: flex; align-items: center; gap: var(--s1); }
.toolbar-spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: var(--s2); margin-right: var(--s2); min-width: 0; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-name { font-weight: 600; white-space: nowrap; }
.bm-paper { fill: #ffffff; stroke: rgba(0, 0, 0, 0.35); stroke-width: 1; }
.bm-a { fill: var(--accent-fill); }
.bm-b { fill: var(--orange); }
.bm-c { fill: var(--green); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--active); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn:disabled:hover { background: var(--surface); }

.btn.primary {
  background: var(--accent-fill);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-fill-hover); }
.btn.primary:active { filter: brightness(0.92); }
.btn.primary:disabled:hover { background: var(--accent-fill); }

.btn.quiet {
  border-color: transparent;
  background: transparent;
}
.btn.quiet:hover { background: var(--hover); }
.btn.quiet:active { background: var(--active); }
.btn.quiet:disabled:hover { background: transparent; }

.btn.icon-only {
  width: var(--control-h);
  padding: 0;
}

/* ---------- Export menu ---------- */

.export-wrap { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 800;
  min-width: 180px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-pop);
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover { background: var(--hover); }
.menu-item:active { background: var(--active); }

/* ---------- Segmented control ---------- */

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 2px;
  background: var(--track);
  border-radius: var(--r-m);
}

.segmented button {
  min-height: calc(var(--control-h) - 4px);
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-raised);
}

@media (prefers-color-scheme: dark) {
  .segmented button[aria-pressed="true"] { background: #3a3a40; }
}

/* ---------- Side panel ---------- */

.panel-section {
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.panel-section h2,
.shortcuts summary {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  font-size: 13px;
}
.field-label output {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  min-height: 24px;
  accent-color: var(--accent-fill);
  cursor: pointer;
}

.hint { font-size: 12px; color: var(--text-2); }

.button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s2);
}
.button-row .btn { padding: 0 var(--s2); min-width: 0; }
.button-row .btn-label { overflow: hidden; text-overflow: ellipsis; }

#slot-controls,
#photo-controls { display: flex; flex-direction: column; gap: var(--s3); }
#slot-controls + #photo-controls {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.slot-cut { font-weight: 600; font-variant-numeric: tabular-nums; }

.photo-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quality { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.quality.warn { color: var(--warn); font-weight: 600; }

.shortcuts { display: block; }
.shortcuts summary { cursor: pointer; padding: 2px 0; border-radius: var(--r-s); }
.shortcuts dl { margin-top: var(--s3); display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.shortcuts dl > div { display: flex; gap: var(--s2); }
.shortcuts dt { flex: none; width: 92px; font-weight: 600; }
.shortcuts dd { color: var(--text-2); }

.privacy {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: var(--s4);
  font-size: 12px;
  color: var(--text-2);
}
.privacy .icon { width: 14px; height: 14px; }

/* ---------- Layout picker ---------- */

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s2);
}

.layout-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--s2) var(--s2) 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.layout-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }

.layout-icon {
  display: block;
  width: 100%;
  height: 56px;
  max-height: 56px;
  margin-bottom: var(--s1);
  overflow: visible;
}
.li-paper {
  fill: #ffffff;
  stroke: rgba(0, 0, 0, 0.3);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.li-slot { fill: #a6a6ae; }

.layout-name { font-size: 13px; font-weight: 600; }
.layout-size {
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.layout-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: 0 0 0 1px var(--accent);
}
.layout-btn[aria-pressed="true"] .li-slot { fill: var(--accent-fill); }

/* ---------- Sheet and slots ---------- */

.sheet {
  position: relative;
  flex: none;
  background: var(--paper);
  box-shadow: var(--paper-shadow);
  user-select: none;
  -webkit-user-select: none;
}

.slot {
  position: absolute;
  overflow: hidden;
  cursor: grab;
  outline: none;
  background: #e9e9ec;
}
.slot:active { cursor: grabbing; }

.slot > img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  max-height: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

/* Rings are drawn on an overlay so the slot never changes size. */
.slot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: box-shadow var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.slot.selected { touch-action: none; }
.slot.selected::after {
  box-shadow: inset 0 0 0 2px #0a84ff, inset 0 0 0 3px rgba(255, 255, 255, 0.85);
}
.slot:focus-visible::after {
  box-shadow: inset 0 0 0 3px #0a84ff, inset 0 0 0 5px rgba(255, 255, 255, 0.9);
}
.slot.drop-target::after {
  background: rgba(10, 132, 255, 0.28);
  box-shadow: inset 0 0 0 4px #0a84ff;
}

/* Empty slots sit on white paper in both themes, so these greys are fixed. */
.slot.empty {
  cursor: pointer;
  background: #f1f1f4;
  container-type: size;
}
.slot.empty:hover { background: #eaeaee; }

.slot-empty {
  position: absolute;
  inset: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1.5px dashed #b2b2ba;
  border-radius: 4px;
  color: #6a6a72;
  pointer-events: none;
}
.slot-empty-label { font-size: 11px; line-height: 1.2; text-align: center; }

@container (max-width: 84px) { .slot-empty-label { display: none; } }
@container (max-height: 62px) { .slot-empty-label { display: none; } }

.slot-badge {
  display: none;
  position: absolute;
  left: 4px;
  bottom: 4px;
  z-index: 3;
  align-items: center;
  gap: 3px;
  max-width: calc(100% - 8px);
  padding: 2px 6px 2px 4px;
  border-radius: 999px;
  background: #ffc53d;
  color: #3a2a00;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}
.slot.lowres .slot-badge { display: inline-flex; }
.slot-badge .icon { width: 12px; height: 12px; stroke-width: 2; }

.slot-handle {
  position: absolute;
  left: 4px;
  top: 4px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  cursor: grab;
  touch-action: none;
  opacity: 0;
  transition: opacity var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.slot-handle .icon { width: 16px; height: 16px; }
.slot-handle:hover { background: rgba(0, 0, 0, 0.75); }
.slot:hover .slot-handle,
.slot.selected .slot-handle,
.slot:focus-visible .slot-handle { opacity: 1; }

@media (hover: none) {
  .slot.selected .slot-handle { opacity: 1; }
}

/* Cut lines: the white gap between two neighbours, draggable to resize them.
   They sit on white paper in both themes, so the blue is fixed. */
.divider {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  outline: none;
  touch-action: none;
}
.divider-h { cursor: col-resize; }
.divider-v { cursor: row-resize; }
.divider-grip {
  border-radius: 999px;
  background: #0a84ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease);
}
.divider-h .divider-grip { width: 3px; height: calc(100% - 6px); }
.divider-v .divider-grip { height: 3px; width: calc(100% - 6px); }
.divider:hover .divider-grip,
.divider.active .divider-grip,
.divider:focus-visible .divider-grip { opacity: 1; }
.divider-h:focus-visible .divider-grip { width: 5px; }
.divider-v:focus-visible .divider-grip { height: 5px; }

/* Cut size on every slot while a cut line is moving. */
.slot-size {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  translate: -50% -50%;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
}
.sheet.resizing .slot-size { display: block; }
.sheet.resizing .slot-handle,
.sheet.resizing .slot-empty { visibility: hidden; }

body.resizing-h, body.resizing-h * { cursor: col-resize !important; user-select: none; -webkit-user-select: none; }
body.resizing-v, body.resizing-v * { cursor: row-resize !important; user-select: none; -webkit-user-select: none; }

@keyframes settle {
  from { opacity: 0; scale: 1.07; }
  to { opacity: 1; scale: 1; }
}
img.settle { animation: settle 480ms var(--spring) both; }

/* ---------- Sheet tabs ---------- */

.sheet-tab {
  min-width: 32px;
  min-height: 32px;
  padding: 0 var(--s2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease);
}
.sheet-tab:hover { background: var(--surface-2); }
.sheet-tab[aria-current="true"] {
  background: var(--accent-fill);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
}

@media (pointer: coarse) {
  .sheet-tab { min-width: 44px; min-height: 44px; }
}

/* ---------- Photo tray ---------- */

.tray-header {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s1) var(--s2) 0 var(--s4);
}

.tray-title { font-size: 13px; font-weight: 600; white-space: nowrap; }
.tray-count { color: var(--text-2); font-weight: 400; font-variant-numeric: tabular-nums; }

.tray-status {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tray-list {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 96px;
  padding: 10px var(--s4) 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.tray-empty {
  flex: 1;
  align-self: center;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

.thumb {
  position: relative;
  flex: none;
  width: 72px;
  height: 72px;
}

.thumb-main {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  overflow: hidden;
  background: var(--surface-2);
  cursor: grab;
  touch-action: pan-x;
}
.thumb-main img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease);
}
.thumb.used .thumb-main img { opacity: 0.72; }

.thumb-check {
  display: none;
  position: absolute;
  right: 4px;
  bottom: 4px;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-fill);
  color: #ffffff;
  box-shadow: 0 0 0 1.5px var(--surface);
  pointer-events: none;
}
.thumb.used .thumb-check { display: grid; }
.thumb-check .icon { width: 12px; height: 12px; stroke-width: 2.5; }

.thumb-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(30, 30, 32, 0.82);
  color: #ffffff;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.thumb-remove .icon { width: 12px; height: 12px; stroke-width: 2.5; }
.thumb-remove:hover { background: var(--danger); }
.thumb:hover .thumb-remove,
.thumb:focus-within .thumb-remove { opacity: 1; }

@media (hover: none) {
  .thumb-remove { opacity: 1; }
}

@media (prefers-color-scheme: dark) {
  .thumb-remove { background: rgba(90, 90, 96, 0.95); }
}

/* ---------- Dragging ---------- */

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: var(--r-m);
  overflow: hidden;
  pointer-events: none;
  z-index: 1000;
  rotate: -4deg;
  background: var(--surface-2);
  box-shadow: 0 0 0 2px #ffffff, 0 10px 28px rgba(0, 0, 0, 0.4);
}
.drag-ghost img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.dragging,
body.dragging * {
  cursor: grabbing !important;
  user-select: none;
  -webkit-user-select: none;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  display: grid;
  place-items: center;
  opacity: 0;
  background: var(--accent-tint);
  box-shadow: inset 0 0 0 9999px rgba(127, 127, 127, 0.12);
  transition: opacity var(--med) var(--ease);
}
.drop-overlay::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 3px dashed var(--accent);
  border-radius: var(--r-l);
}
.drop-overlay.show { opacity: 1; }

.drop-overlay-card {
  position: relative;
  padding: var(--s3) var(--s5);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 16px;
  font-weight: 600;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 140px;
  z-index: 950;
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: min(92vw, 560px);
  padding: 6px 6px 6px var(--s4);
  border-radius: 22px;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  translate: -50% 12px;
  transition: opacity var(--med) var(--ease), translate var(--med) var(--ease);
}
.toast.show {
  opacity: 1;
  pointer-events: auto;
  translate: -50% 0;
}
.toast.error { box-shadow: inset 4px 0 0 #ff6961, var(--shadow-pop); }

.toast-msg { padding: 4px 0; font-size: 13px; line-height: 1.35; }

.toast-action,
.toast-close {
  flex: none;
  min-height: 32px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
}
.toast-action {
  padding: 0 var(--s3);
  color: var(--toast-accent);
  font-weight: 600;
  white-space: nowrap;
}
.toast-close {
  display: grid;
  place-items: center;
  width: 32px;
  padding: 0;
  color: rgba(255, 255, 255, 0.8);
}
.toast-close .icon { width: 14px; height: 14px; }
.toast-action:hover,
.toast-close:hover { background: rgba(255, 255, 255, 0.14); }
.toast-action:focus-visible,
.toast-close:focus-visible { outline-color: var(--toast-accent); }

@media (pointer: coarse) {
  .toast-action, .toast-close { min-height: 44px; }
  .toast-close { width: 44px; }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 820px) {
  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .workspace { display: contents; }

  .toolbar { order: 0; position: sticky; top: 0; }
  .stage { order: 1; }
  .tray { order: 2; }
  .panel {
    order: 3;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .sheet-wrap {
    flex: none;
    height: clamp(240px, 58vh, 560px);
    padding: 12px;
  }

  .toast { bottom: 20px; }
}

@media (max-width: 560px) {
  .brand-name { display: none; }
  .toolbar { gap: var(--s2); padding: var(--s2) var(--s3); }
}

@media (max-width: 400px) {
  #btn-add .btn-label { display: none; }
  #btn-add { width: var(--control-h); padding: 0; }
}

/* ---------- Reduced motion ---------- */

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