/* MotionStudio web — the chrome around the preview.
   Desktop: menu bar · [tool strip | hint bar / preview / transport | inspector] · timeline (full width) · status bar.
   Phone (≤780px): preview first, transport, bottom tool bar; Timeline, Panels and Inspect open as bottom sheets.
   Nothing floats over the preview (iPadOS consistency): tools are docked left (or in the bottom bar), panels
   docked right/bottom (or sheets). StratusUI (dist/stratus-ui.css) supplies the sui-* controls; its --sui-*
   tokens are mapped here to a light theme with a dark variant. */

:root {
  --accent: #2f6bff;
  --bg: #f6f6f8;
  --panel: #ffffff;
  --card: #f3f3f6;
  --line: rgba(20, 20, 40, 0.09);
  --line-strong: rgba(20, 20, 40, 0.16);
  --fg: #1c1c22;
  --fg-2: #55566a;
  --fg-3: #8a8b9c;
  --hover: rgba(20, 20, 40, 0.055);
  --active: rgba(47, 107, 255, 0.12);
  --pasteboard: #e4e4e9;
  --track: #f0f0f3;
  --track-alt: #f6f6f8;
  --playhead: #e5484d;
  --key: #f2b134;
  --ok: #2e9d4f; --warn: #d98a00; --bad: #d83a3a;
  /* Layer bar colours by type (the native timeline's label colours) */
  --c-solid: #ef8f99; --c-shape: #7fb2f0; --c-text: #f3a0a8; --c-image: #a8d8a0; --c-video: #a6dba0; --c-precomp: #f4c08e;
  --c-adjustment: #c3b2ef; --c-null: #d9d4c4; --c-audio: #8fd3d0; --c-camera: #b9bfcc; --c-light: #f1dc86;

  --sui-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --sui-surface: var(--panel);
  --sui-surface-2: #ffffff;
  --sui-border: var(--line-strong);
  --sui-fg: var(--fg);
  --sui-text: var(--fg-2);
  --sui-text-dim: var(--fg-3);
  --sui-text-faint: #b9bac6;
  --sui-accent: var(--accent);
  --sui-accent-2: var(--accent);
  --sui-accent-contrast: #ffffff;
  --sui-accent-soft: rgba(47, 107, 255, 0.22);
  --sui-radius: 12px;
  --sui-radius-sm: 7px;
  --sui-shadow: 0 12px 36px rgba(20, 20, 40, 0.16), 0 2px 6px rgba(20, 20, 40, 0.08);

  --menubar-h: 42px;
  --hint-h: 34px;
  --transport-h: 44px;
  --status-h: 28px;
  --inspector-w: 308px;
  --strip-w: 48px;
  --timeline-h: 280px;
  --rows-w: 260px;
  --row-h: 28px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #5b8cff;
    --bg: #1c1c21; --panel: #24242a; --card: #2c2c33;
    --line: rgba(255, 255, 255, 0.07); --line-strong: rgba(255, 255, 255, 0.14);
    --fg: #ececf1; --fg-2: #b1b2c0; --fg-3: #80818f;
    --hover: rgba(255, 255, 255, 0.07); --active: rgba(91, 140, 255, 0.22);
    --pasteboard: #141418; --track: #26262c; --track-alt: #222227;
    --sui-surface-2: #34343c; --sui-text-faint: #5c5d6a;
    --sui-accent-soft: rgba(91, 140, 255, 0.3);
    --sui-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #5b8cff;
  --bg: #1c1c21; --panel: #24242a; --card: #2c2c33;
  --line: rgba(255, 255, 255, 0.07); --line-strong: rgba(255, 255, 255, 0.14);
  --fg: #ececf1; --fg-2: #b1b2c0; --fg-3: #80818f;
  --hover: rgba(255, 255, 255, 0.07); --active: rgba(91, 140, 255, 0.22);
  --pasteboard: #141418; --track: #26262c; --track-alt: #222227;
  --sui-surface-2: #34343c; --sui-text-faint: #5c5d6a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 13px/1.35 var(--sui-font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { overflow: hidden; }
button { font: inherit; color: inherit; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 21px; height: 21px; }

/* ── Grid ── */
.app {
  position: fixed; inset: 0; display: grid;
  grid-template-columns: var(--strip-w) minmax(0, 1fr) var(--inspector-w);
  grid-template-rows: var(--menubar-h) minmax(0, 1fr) var(--timeline-h) var(--status-h);
  grid-template-areas: "menubar menubar menubar" "strip stage inspector" "timeline timeline timeline" "status status status";
}
.menubar { grid-area: menubar; }
.toolstrip { grid-area: strip; }
.stage { grid-area: stage; }
.inspector { grid-area: inspector; }
.timeline { grid-area: timeline; }
.statusbar { grid-area: status; }
.bottombar { display: none; }

/* ── Menu bar ── */
.menubar { display: flex; align-items: center; gap: 6px; padding: 0 10px 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -0.01em; margin-right: 6px; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7v10l8-5z' fill='white'/%3E%3C/svg%3E") center/18px no-repeat; flex: none; }
.brand-mark.big { width: 44px; height: 44px; border-radius: 12px; background-size: 34px; }
.menus { display: flex; gap: 1px; }
.menu-btn { border: 0; background: none; padding: 5px 9px; border-radius: 6px; color: var(--fg); cursor: default; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--hover); }
.doc-title { flex: 1; display: flex; justify-content: center; align-items: center; gap: 6px; min-width: 0; }
.title-input { border: 1px solid transparent; background: none; color: var(--fg); font: 600 13px var(--sui-font); text-align: center; padding: 4px 8px; border-radius: 6px; width: min(320px, 100%); }
.title-input:hover { border-color: var(--line); }
.title-input:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); opacity: 0; flex: none; }
.dirty-dot.on { opacity: 1; }
.bar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn { padding: 6px !important; min-width: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn.sm { padding: 4px !important; }
.icon-btn[aria-pressed="true"] { background: var(--active); color: var(--accent); }
.icon-btn:disabled { opacity: 0.35; }
.btn-sm { padding: 5px 12px !important; font-size: 12.5px !important; }

.menu-pop { position: fixed; z-index: 60; min-width: 220px; max-height: 70vh; overflow: auto; padding: 5px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--sui-shadow); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 6px 10px; border-radius: 6px; text-align: left; color: var(--fg); }
.menu-item:hover:not(:disabled), .menu-item.focus { background: var(--accent); color: #fff; }
.menu-item:disabled { color: var(--fg-3); }
.menu-item .kbd { margin-left: auto; color: var(--fg-3); font-size: 11.5px; }
.menu-item:hover .kbd { color: rgba(255, 255, 255, 0.8); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 6px; }
.menu-head { padding: 6px 10px 3px; font-size: 11px; font-weight: 600; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Tool strip ── */
.toolstrip { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.tool { width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--fg-2); display: flex; align-items: center; justify-content: center; position: relative; }
.tool:hover { background: var(--hover); color: var(--fg); }
.tool[aria-pressed="true"] { background: var(--active); color: var(--accent); }
.tool-sep { width: 26px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }

/* ── Stage ── */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--pasteboard); }
.hintbar { height: var(--hint-h); display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); color: var(--fg-2); white-space: nowrap; overflow: hidden; }
.hintbar b { color: var(--fg); font-weight: 600; }
.hint-spacer { flex: 1; }
.sui-input.mini { padding: 3px 24px 3px 8px; font-size: 12px; height: 26px; width: auto; }
.viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; overscroll-behavior: none; }
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
.drop-hint { position: absolute; inset: 14px; border: 2px dashed var(--accent); border-radius: 14px; display: none; align-items: center; justify-content: center; color: var(--accent); background: rgba(47, 107, 255, 0.06); font-weight: 600; text-align: center; padding: 20px; pointer-events: none; }
.viewport.dragging .drop-hint { display: flex; }
.transport { height: var(--transport-h); display: flex; align-items: center; gap: 4px; padding: 0 10px; background: var(--panel); border-top: 1px solid var(--line); }
.tp-btn { width: 32px; height: 32px; border: 0; background: none; border-radius: 8px; color: var(--fg-2); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tp-btn:hover { background: var(--hover); color: var(--fg); }
.tp-btn.play { color: var(--fg); }
.tp-btn[aria-pressed="true"] { color: var(--accent); }
.tp-btn[aria-pressed="false"] { color: var(--fg-3); }
.scrub { flex: 1; min-width: 60px; margin: 0 8px; }
.timecode { font: 500 12.5px ui-monospace, 'SF Mono', Menlo, monospace; font-variant-numeric: tabular-nums; color: var(--fg); min-width: 66px; text-align: right; }
.frame-field { width: 58px !important; padding: 3px 6px !important; height: 26px; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px !important; }

/* ── Inspector ── */
.inspector { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
.panel-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
.panel-tab { border: 0; background: none; border-radius: 8px; padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--fg-2); font-size: 10.5px; min-width: 0; }
.panel-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-tab:hover { background: var(--hover); color: var(--fg); }
.panel-tab[aria-selected="true"] { background: var(--active); color: var(--accent); }
.panel-tab .badge-dot { position: absolute; }
.panel-body { flex: 1; overflow-y: auto; padding: 10px 12px 18px; scrollbar-width: thin; }
.panel-title { display: flex; align-items: center; gap: 6px; margin: 2px 2px 10px; }
.panel-title h2 { margin: 0; font-size: 14px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--card); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.card-head { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px 2px; }
.card-head .grow { flex: 1; }
.card-head button { text-transform: none; letter-spacing: 0; }
.row { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.row + .row { margin-top: 4px; }
.row > label, .row > .lbl { flex: 0 0 86px; color: var(--fg-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .lbl.scrubbable { cursor: ew-resize; }
.row .sui-input { min-width: 0; flex: 1; padding: 4px 7px; height: 28px; font-size: 12.5px; }
.row .sui-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.row select.sui-input { padding-right: 22px; }
.row .vals { display: flex; gap: 4px; flex: 1; min-width: 0; }
.row .vals .sui-input { flex: 1; width: 0; }
.prop-row { display: grid; grid-template-columns: 20px 20px minmax(0, 1fr) minmax(0, 1.25fr); align-items: center; gap: 2px 4px; min-height: 30px; }
.prop-row + .prop-row { margin-top: 3px; }
.prop-row .lbl { color: var(--fg); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: ew-resize; user-select: none; }
.prop-row .lbl.expr { color: var(--accent); }
.prop-row .vals { display: flex; gap: 4px; min-width: 0; }
.prop-row .vals .sui-input { flex: 1; width: 0; min-width: 0; padding: 4px 6px; height: 27px; font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.mini-btn { width: 20px; height: 20px; border: 0; background: none; padding: 0; color: var(--fg-3); display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; }
.mini-btn:hover { color: var(--fg); background: var(--hover); }
.mini-btn.on { color: var(--accent); }
.mini-btn .ic { width: 15px; height: 15px; }
.key-btn.on { color: var(--key); }
.color-well { width: 44px; height: 26px; padding: 0; border: 1px solid var(--line-strong); border-radius: 7px; background: none; flex: none; cursor: pointer; }
.color-well::-webkit-color-swatch-wrapper { padding: 2px; }
.color-well::-webkit-color-swatch { border: 0; border-radius: 5px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 7px; padding: 2px; gap: 2px; flex: 1; }
.seg button { flex: 1; border: 0; background: none; border-radius: 5px; padding: 3px 6px; font-size: 12px; color: var(--fg-2); }
.seg button[aria-pressed="true"] { background: var(--active); color: var(--accent); font-weight: 600; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-row .sui-btn { flex: 1; }
.muted { color: var(--fg-3); font-size: 12px; }
.empty { text-align: center; color: var(--fg-3); padding: 26px 10px; font-size: 12.5px; }
.empty .ic { width: 28px; height: 28px; display: block; margin: 0 auto 8px; opacity: 0.6; }
.fx-card .card-head { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--fg); }
.textarea { width: 100%; min-height: 64px; resize: vertical; font: 12.5px/1.4 var(--sui-font); }
.code { font: 12px/1.45 ui-monospace, 'SF Mono', Menlo, monospace !important; }
.list { display: flex; flex-direction: column; gap: 2px; }
.list-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; min-height: 32px; }
.list-item:hover { background: var(--hover); }
.list-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--fg-3); font-size: 11.5px; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.12s; }
.warn-list { margin: 6px 0 0; padding-left: 16px; color: var(--fg-2); font-size: 12px; max-height: 180px; overflow: auto; }
.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 30px; }
.switch-row + .switch-row { margin-top: 2px; }

/* ── Timeline ── */
.timeline { position: relative; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); min-height: 0; }
.tl-resize { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; z-index: 5; }
.tl-head { display: flex; height: 30px; border-bottom: 1px solid var(--line); flex: none; }
.tl-head-left { width: var(--rows-w); flex: none; display: flex; align-items: center; gap: 2px; padding: 0 6px 0 12px; border-right: 1px solid var(--line); }
.tl-title { font-size: 12px; color: var(--fg-2); font-weight: 600; margin-right: 4px; }
.tl-spacer { flex: 1; }
.tl-ruler { flex: 1; position: relative; min-width: 0; cursor: col-resize; }
.tl-ruler canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tl-body { flex: 1; display: flex; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative; scrollbar-width: thin; }
.tl-rows { width: var(--rows-w); flex: none; border-right: 1px solid var(--line); background: var(--panel); position: sticky; left: 0; z-index: 2; align-self: flex-start; min-height: 100%; }
.tl-tracks { flex: 1; position: relative; min-width: 0; overflow: hidden; align-self: stretch; }
.tl-track-inner { position: relative; }
.tl-row { height: var(--row-h); display: flex; align-items: center; gap: 4px; padding: 0 6px 0 4px; border-bottom: 1px solid var(--line); cursor: default; user-select: none; }
.tl-row:hover { background: var(--hover); }
.tl-row.sel { background: var(--active); }
.tl-row.prop { padding-left: 34px; color: var(--fg-2); font-size: 12px; }
.tl-row .twisty { width: 18px; height: 18px; border: 0; background: none; padding: 0; color: var(--fg-3); display: inline-flex; align-items: center; justify-content: center; transition: transform 0.12s; flex: none; }
.tl-row .twisty.open { transform: rotate(90deg); }
.tl-row .vis { width: 22px; height: 22px; border: 0; background: none; padding: 0; color: var(--fg-2); display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 5px; }
.tl-row .vis.off { color: var(--fg-3); opacity: 0.5; }
.tl-row .type { color: var(--fg-3); display: inline-flex; flex: none; }
.tl-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row .name input { width: 100%; font: inherit; border: 1px solid var(--accent); border-radius: 4px; padding: 1px 4px; background: var(--panel); color: var(--fg); }
.tl-row .tags { display: flex; gap: 2px; color: var(--fg-3); }
.tl-row .tags .ic { width: 13px; height: 13px; }
.tl-row .pkey { margin-left: auto; }
.tl-track { height: var(--row-h); position: relative; border-bottom: 1px solid var(--line); }
.tl-track:nth-child(odd) { background: var(--track-alt); }
.tl-track.sel { background: var(--active); }
.tl-bar { position: absolute; top: 4px; bottom: 4px; border-radius: 5px; background: var(--c, #9ab); opacity: 0.88; cursor: grab; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.tl-bar.off { opacity: 0.35; }
.tl-track.sel .tl-bar { opacity: 1; box-shadow: inset 0 0 0 2px var(--accent); }
.tl-bar .trim { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.tl-bar .trim.l { left: 0; border-radius: 5px 0 0 5px; }
.tl-bar .trim.r { right: 0; border-radius: 0 5px 5px 0; }
.tl-bar .trim:hover { background: rgba(0, 0, 0, 0.16); }
.tl-bar .bar-label { position: absolute; left: 9px; right: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; color: rgba(0, 0, 0, 0.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.kf { position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; transform: rotate(45deg); background: var(--panel); border: 1.5px solid var(--fg-2); border-radius: 1.5px; cursor: ew-resize; z-index: 1; }
.kf.hold { border-radius: 0; background: var(--fg-2); }
.kf.bezier { border-radius: 50%; transform: none; }
.kf.sel { background: var(--key); border-color: #a76c00; }
.tl-track .kf.summary { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-width: 1px; background: #fff; border-color: rgba(0, 0, 0, 0.45); pointer-events: none; }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--playhead); pointer-events: none; z-index: 3; }
.tl-graph { flex: 1; position: relative; min-height: 0; border-top: 1px solid var(--line); }
.tl-graph canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.graph-legend { position: absolute; left: 10px; top: 6px; font-size: 11.5px; color: var(--fg-2); pointer-events: none; }
.timeline.graph .tl-body { display: none; }

/* ── Status bar ── */
.statusbar { display: flex; align-items: center; gap: 0; padding: 0 8px; background: var(--panel); border-top: 1px solid var(--line); font-size: 11.5px; color: var(--fg-2); white-space: nowrap; overflow: hidden; }
.status-item { padding: 0 9px; border-right: 1px solid var(--line); line-height: 16px; font-variant-numeric: tabular-nums; }
.status-item:last-child { border-right: 0; }
.status-item.link { border: 0; border-right: 1px solid var(--line); background: none; cursor: pointer; color: var(--fg-2); font-size: 11.5px; }
.status-item.warn { color: var(--warn); }
.status-spacer { flex: 1; }

/* ── Toasts, boot ── */
.toast-host { position: fixed; left: 50%; bottom: calc(var(--status-h) + 16px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 80; pointer-events: none; }
.toast { background: var(--fg); color: var(--panel); padding: 8px 14px; border-radius: 9px; font-size: 12.5px; box-shadow: var(--sui-shadow); max-width: min(520px, 90vw); pointer-events: none; }
.toast.bad { background: var(--bad); color: #fff; }
.boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 90; transition: opacity 0.25s; }
.boot-card { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--fg-2); }
.boot-bar { width: 220px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 10%; background: var(--accent); transition: width 0.2s; }
.app:not(.loading) .boot { opacity: 0; pointer-events: none; }

/* ── Sheets (phone) ── */
.sheet-back { position: fixed; inset: 0; background: rgba(10, 10, 20, 0.32); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 78vh; background: var(--panel); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18); z-index: 41; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 7px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; padding: 4px 10px 8px 16px; flex: none; }
.sheet-head b { flex: 1; font-size: 15px; }
.sheet-body { overflow-y: auto; flex: 1; min-height: 0; padding: 0 12px 14px; }
.sheet-body .panel-grid { border: 0; padding: 0 0 8px; }
.sheet-body .timeline { position: static; border: 0; height: 52vh; display: flex; }
.sheet-body .tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 2px 8px; }
.tool-grid .tool { width: auto; height: 64px; flex-direction: column; gap: 4px; font-size: 11.5px; background: var(--card); }

/* ── Tablet ── */
@media (max-width: 1100px) {
  :root { --inspector-w: 280px; --rows-w: 220px; }
  .brand-name { display: none; }
}

/* ── Phone ── */
@media (max-width: 780px) {
  :root { --menubar-h: 46px; --rows-w: 150px; --row-h: 34px; }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--menubar-h) minmax(0, 1fr) auto calc(56px + env(safe-area-inset-bottom));
    grid-template-areas: "menubar" "stage" "status" "bottombar";
  }
  .toolstrip, .inspector, .timeline, .menus { display: none; }
  .sheet-body .inspector, .sheet-body .timeline { display: flex; border: 0; }
  .sheet-body .inspector { background: none; }
  .sheet-body .panel-body { overflow: visible; padding: 0; }
  .menubar { padding: 0 6px 0 10px; padding-top: env(safe-area-inset-top); height: auto; }
  .brand-name { display: none; }
  .doc-title { justify-content: flex-start; }
  .title-input { text-align: left; font-size: 15px; }
  .bar-actions #btnExport { padding: 5px 10px !important; }
  .hintbar { display: none; }
  .transport { height: 50px; gap: 2px; padding: 0 6px; }
  #tpStart, #tpEnd, #tpLoop, .frame-field { display: none; }
  .statusbar { font-size: 11px; }
  #stSel, #stEngine, #stIssues { display: none; }
  .bottombar { grid-area: bottombar; display: flex; justify-content: space-around; align-items: stretch; background: var(--panel); border-top: 1px solid var(--line); padding: 2px 2px env(safe-area-inset-bottom); }
  .bb-btn { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; color: var(--fg-2); border-radius: 8px; padding: 4px 0; min-width: 0; }
  .bb-btn .ic { width: 22px; height: 22px; }
  .bb-btn[aria-pressed="true"] { color: var(--accent); }
  .sui-input, select, input, textarea { font-size: 16px !important; }
  .prop-row .vals .sui-input, .row .sui-input { height: 34px; }
  .menu-pop { left: 8px !important; right: 8px; bottom: calc(64px + env(safe-area-inset-bottom)); top: auto !important; max-height: 60vh; }
}

/* Anything hidden stays hidden, whatever its display rule. */
[hidden] { display: none !important; }
.transport .scrub { height: 4px; background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--line-strong) var(--pct, 0%)); }
.transport .scrub::-webkit-slider-thumb { width: 14px; height: 14px; }
.sui-switch:not(.is-on) { background: var(--line-strong); box-shadow: none; }
.sui-switch .sui-switch-thumb { background: #fff; }
@media (max-width: 1240px) { .hintbar #hintText { display: none; } }
.hintbar { min-width: 0; overflow: hidden; }
.graph-legend { left: calc(var(--rows-w) + 10px); right: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body .panel-title h2 { display: none; }
