:root {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #ececef;
  --field: #f5f5f7;
  --ink: #111114;
  --muted: #5f6068;
  --faint: #6f7079;
  --line: #e2e2e7;
  --line-strong: #cfd0d8;
  --accent: #1e3a8a;
  --accent-ink: #f7f8ff;
  --accent-soft: #e7eaf6;
  --grid: #d9dae1;
  --canvas-bg: #e9e9ee;
  --canvas-dot: #d2d3db;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --danger-ink: #7a1a13;
  --code-bg: #fafafc;
  --shadow: 0 16px 38px rgba(16, 18, 28, 0.08);
  --shadow-card: 0 8px 22px rgba(16, 18, 28, 0.05);
  --board-shadow: 0 24px 60px rgba(16, 18, 28, 0.16);
  --r-ctl: 10px;
  --r-card: 16px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e;
    --surface: #141417;
    --surface-2: #1e1e23;
    --field: #1a1a1f;
    --ink: #f1f1f4;
    --muted: #a2a3ad;
    --faint: #8b8c96;
    --line: #292a30;
    --line-strong: #3d3e47;
    --accent: #8fa8ff;
    --accent-ink: #0b0e1a;
    --accent-soft: #1c2440;
    --grid: #23232a;
    --canvas-bg: #0a0a0c;
    --canvas-dot: #24242c;
    --danger: #ff7b72;
    --danger-soft: #2a1512;
    --danger-ink: #ffb4ae;
    --code-bg: #17171b;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
    --shadow-card: 0 10px 26px rgba(0, 0, 0, 0.35);
    --board-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.only-mobile { display: none !important; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.library {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.library-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 54px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.brand svg { flex: none; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: -6px;
  border: 0;
  border-radius: var(--r-ctl);
  background: transparent;
  color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.close-drawer { margin-left: auto; margin-right: -6px; color: var(--muted); }

/* ---------- search / filters ---------- */
.search {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  margin: 12px 12px 9px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--field);
  color: var(--muted);
  transition: border-color 0.12s ease;
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: 0.5; }
.search kbd {
  flex: none;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--faint);
  font: 10px/1.4 var(--mono);
  text-align: center;
}

.filters {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 12px 10px;
}
.filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.filter span { font: 10px var(--mono); opacity: 0.7; }
.filter:hover { background: var(--surface-2); }
.filter.is-active { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.filter.is-active span { opacity: 0.75; }

/* ---------- file list ---------- */
.library-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 14px;
  color: var(--faint);
  font: 9.5px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.section-count {
  margin-left: auto;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0;
}
.designs-head {
  height: auto;
  min-height: 34px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.list { padding: 2px 8px 6px; }
.design-list { padding: 0 8px 14px; }
.design-list .list-empty { padding: 16px 14px; }
.group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 8px 6px;
  color: var(--faint);
  font: 9.5px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.group::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.group-count { order: 2; letter-spacing: 0; }

.item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 18px 7px 8px;
  border: 0;
  border-radius: var(--r-ctl);
  background: transparent;
  text-align: left;
  transition: background 0.12s ease;
}
.item:hover { background: var(--surface-2); }
.item.is-active { background: var(--accent-soft); }
.item.is-active::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
}
.item-row { position: relative; }
.item-row .item { padding-right: 52px; }
.item-row .item.is-active::after { right: 44px; }
.item-delete {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  opacity: 0.55;
  transform: translateY(-50%);
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.item-row:hover .item-delete,
.item-row:focus-within .item-delete,
.item-delete:hover,
.item-delete:focus-visible {
  opacity: 1;
}
.item-delete:hover {
  color: var(--danger);
  background: var(--surface);
}
.item-delete:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.item-delete:disabled {
  opacity: 0.35;
  cursor: default;
}
.thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 32px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--faint);
  transition: border-color 0.12s ease;
}
.item.is-active .thumb { border-color: var(--accent); }
.thumb svg { width: 100%; height: 100%; }
.item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.item-meta {
  overflow: hidden;
  color: var(--muted);
  font: 10px var(--mono);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.list-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}
.list-empty svg { color: var(--faint); }
.list-empty p { margin: 0; font-size: 12.5px; line-height: 1.5; }
.list-empty strong { color: var(--ink); font-weight: 600; }
.list-empty .hint { font-size: 11px; color: var(--faint); }

.library-foot {
  flex: 0 0 auto;
  display: grid;
  gap: 6px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.watch {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10.5px;
}
.watch .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.foot-note {
  color: var(--faint);
  font: 9.5px var(--mono);
  letter-spacing: 0.02em;
}

/* ---------- workspace ---------- */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumb-label { color: var(--muted); font-size: 12px; }
.crumbs > svg { flex: none; color: var(--faint); }
.crumb-file {
  overflow: hidden;
  max-width: 46vw;
  color: var(--ink);
  font: 12.5px var(--mono);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.type-chip {
  flex: none;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 9px var(--mono);
  letter-spacing: 0.08em;
}
.conn {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: var(--muted);
  font: 9.5px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.conn .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.conn.online .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.conn.offline .dot {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--muted);
}
.conn.online { color: var(--muted); }

/* ---------- empty state ---------- */
.empty {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 24px;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.empty-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: center;
}
.empty-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty-card h1 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.empty-card p {
  margin: 0 auto;
  max-width: 34ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.empty-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font: 9.5px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.empty-foot .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- viewer chrome ---------- */
.viewer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.seg {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface);
}
.seg-btn {
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}
.seg-btn:hover { background: var(--surface-2); color: var(--ink); }
.seg-btn.is-active { background: var(--ink); color: var(--surface); }
.seg-btn.is-active:hover { background: var(--ink); color: var(--surface); }
.seg-icons .seg-btn { display: grid; place-items: center; width: 34px; padding: 0; }
.tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.small { height: 28px; padding: 0 9px; font-size: 11.5px; }
.btn.is-copied { border-color: var(--accent); color: var(--accent); }

/* ---------- stage ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 18px 18px;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.stage-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 26px;
  padding: 0 2px 6px;
  color: var(--faint);
  font: 9.5px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.stage-meta { display: flex; align-items: center; gap: 9px; min-width: 0; }
.edited {
  overflow: hidden;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.edited.is-flash { color: var(--accent); }
.sep { opacity: 0.45; }
.dims { color: var(--muted); white-space: nowrap; }
.stage-body { flex: 1; min-height: 0; display: flex; }
.frame-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; }

.frame {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1120px;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: width 0.18s ease;
}
.frame-wrap.is-mobile .frame { width: min(390px, 100%); }
.frame-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 12px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font: 9.5px var(--mono);
}
.sandbox { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sandbox svg { color: var(--accent); }
.sandbox code {
  padding: 1px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--ink);
  font: 9px var(--mono);
}
.frame-note {
  margin-left: auto;
  color: var(--faint);
  white-space: nowrap;
}
.frame-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}
.frame-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

/* ---------- code ---------- */
.code-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.code-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.code-name {
  overflow: hidden;
  color: var(--muted);
  font: 10.5px var(--mono);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.code-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  overflow: auto;
  background: var(--code-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.code-lines {
  position: sticky;
  left: 0;
  z-index: 1;
  flex: none;
  margin: 0;
  padding: 16px 10px 26px 14px;
  border-right: 1px solid var(--line);
  background: var(--code-bg);
  color: var(--faint);
  font: 10.5px/20px var(--mono);
  text-align: right;
  white-space: pre;
  user-select: none;
}
.code {
  flex: 1 0 auto;
  margin: 0;
  padding: 16px 22px 26px 16px;
  color: var(--ink);
  font: 12px/20px var(--mono);
  white-space: pre;
  tab-size: 2;
}

/* ---------- design canvas ---------- */
.design-view {
  flex: 1;
  min-height: 0;
  display: flex;
}
.design-canvas {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
  background-color: var(--canvas-bg);
  background-image: radial-gradient(circle, var(--canvas-dot) 1px, transparent 1px);
  background-size: 22px 22px;
}
.design-canvas.is-panning { cursor: grabbing; }
.design-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.board-layer { position: absolute; top: 0; left: 0; }

.board {
  position: absolute;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong), var(--board-shadow);
  contain: layout style;
  transition: opacity 0.16s ease, outline-color 0.16s ease;
}
.board.is-placeholder {
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.board.is-placeholder::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  opacity: 0.45;
}
.board iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  pointer-events: none;
}
.board.is-focused {
  z-index: 2;
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.design-canvas.is-focus .board:not(.is-focused) { opacity: 0.35; }
.design-canvas.is-interacting .gesture-layer { pointer-events: none; }
.design-canvas.is-interacting .board.is-focused iframe { pointer-events: auto; }

.board-labels {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}
.board-label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 260px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(16, 18, 28, 0.12);
  font: 11px/1.25 var(--sans);
  white-space: nowrap;
  will-change: transform;
}
.board-name { overflow: hidden; text-overflow: ellipsis; }
.board-size { color: var(--muted); font: 9.5px var(--mono); }
.board-label.is-focused { border-color: var(--accent); }
.design-canvas.is-focus .board-label:not(.is-focused) { opacity: 0.35; }

.gesture-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: none;
  cursor: grab;
}
.design-canvas.is-panning .gesture-layer { cursor: grabbing; }

.canvas-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.canvas-btn,
.zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
}
.canvas-btn:hover,
.zoom-btn:hover { background: var(--surface-2); }
.zoom-controls {
  display: flex;
  align-items: center;
  padding: 0 3px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.zoom-btn { width: 30px; padding: 0; font-size: 16px; font-weight: 500; }
.zoom-value {
  min-width: 44px;
  color: var(--muted);
  font: 10px var(--mono);
  text-align: center;
}

.focus-bar {
  position: absolute;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.focus-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
}
.focus-btn:hover { background: var(--surface-2); }
.focus-btn:disabled { opacity: 0.35; cursor: default; }
.focus-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 110px;
  max-width: 38vw;
  padding: 0 10px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.focus-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.focus-size {
  color: var(--muted);
  font: 9px var(--mono);
  white-space: nowrap;
}
.focus-interact .toggle-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}
.focus-interact[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.focus-interact[aria-pressed="true"] .toggle-dot { background: var(--accent); }

.design-error {
  position: absolute;
  top: 58px;
  left: 50%;
  z-index: 35;
  max-width: min(560px, calc(100% - 24px));
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger-ink);
  box-shadow: var(--shadow-card);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  transform: translateX(-50%);
}

/* ---------- scrim / motion ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(6, 7, 12, 0.55);
}
@media (min-width: 821px) {
  .scrim { display: none !important; }
}
.is-spinning svg { animation: spin 0.5s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
@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;
  }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: inline-flex !important; }
  .library {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(86vw, 320px);
    padding-top: env(safe-area-inset-top);
    border-right: 0;
    box-shadow: var(--shadow);
    transform: translateX(-102%);
    transition: transform 0.19s cubic-bezier(0.23, 1, 0.32, 1);
  }
  body.drawer-open .library { transform: translateX(0); }
  .crumb-label, .crumbs > svg { display: none; }
  body:not(.has-file) .crumb-label { display: inline; }
  .crumb-file { max-width: 58vw; }
  .stage {
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    background-size: 16px 16px;
  }
  .stage-top { height: 22px; padding-bottom: 4px; }
  .stage-hint { display: none; }
  .frame { border-radius: 14px; }
  .frame-bar { height: 30px; }
  .frame-note { display: none; }
  .code-panel { border-radius: 14px; }
  .toolbar { padding: 0 10px; }
  .topbar { padding: env(safe-area-inset-top) 10px 0; }
  .search { height: 40px; }
  .search input { font-size: 16px; }
  .canvas-controls { top: 8px; right: 8px; }
  .canvas-btn, .zoom-btn { height: 34px; }
  .focus-bar { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .focus-btn { height: 36px; padding: 0 9px; }
  .focus-meta { min-width: 92px; padding: 0 8px; }
  .design-error { top: 52px; }
  .board-label { max-width: 180px; }
  .design-canvas { background-size: 18px 18px; }
  .empty {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    background-size: 16px 16px;
  }
  .empty-card { padding: 22px; }
  .empty-card h1 { font-size: 18px; }
  .empty-card p { font-size: 12.5px; }
}
@media (max-width: 560px) {
  .toolbar .btn span { display: none; }
  .toolbar .btn { width: 32px; padding: 0; }
  .seg-btn { padding: 6px 10px; font-size: 11.5px; }
  .type-chip { display: none; }
  .code-lines { font-size: 9.5px; }
  .code { font-size: 11.5px; }
  .canvas-btn { padding: 0 8px; }
  .zoom-value { min-width: 38px; }
}
