:root { --bg:#f4f1ea; --panel:#ffffff; --ink:#23303b; --muted:#6b7884; --accent:#1f9e8f; --accent2:#f2a541; --line:#e2ddd2; --danger:#d95c4a; }
* { box-sizing: border-box; }
[hidden] { display:none !important; }
html, body { margin:0; height:100%; overscroll-behavior:none; -webkit-tap-highlight-color: transparent; font-family: "Nunito", "Segoe UI", system-ui, sans-serif; color:var(--ink); background:var(--bg); }
body { display:grid; grid-template-rows: auto 1fr auto; height:100vh; height:100dvh; overflow:hidden; }
button, .btn, select, label, input { touch-action: manipulation; }
button, .btn, select, input[type=number] { font:inherit; font-size:13px; border:1px solid var(--line); background:#fff; color:var(--ink); border-radius:8px; padding:6px 10px; cursor:pointer; }
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity:.45; cursor:default; }
button.primary { background:var(--accent); color:#fff; border-color:var(--accent); font-weight:700; }
button.primary:hover { filter:brightness(1.08); }
button.danger { color: var(--danger); }
button.ghost, .btn.ghost { background:transparent; }
button.wide { width:100%; margin-top:8px; padding:10px; }
button.next { margin-top:16px; background:#23303b; color:#fff; border-color:#23303b; }
button.active-tool { background:var(--accent2); color:#fff; border-color:var(--accent2); }

.topbar { display:flex; align-items:center; gap:16px; padding:8px 16px; background:#23303b; color:#fff; }
.brand { font-size:18px; white-space:nowrap; } .brand b { color: var(--accent2); }
.steps { display:flex; gap:4px; flex:1; justify-content:center; }
.steps button { background:transparent; color:#cfd8df; border:none; border-radius:20px; padding:7px 14px; }
.steps button i { font-style:normal; display:inline-grid; place-items:center; width:20px; height:20px; border-radius:50%; background:#3a4955; margin-right:6px; font-size:12px; }
.steps button.active { background:#fff; color:#23303b; font-weight:700; }
.steps button.active i { background: var(--accent); color:#fff; }
.steps button.done i { background: var(--accent2); color:#fff; }
.top-actions { display:flex; gap:6px; } .top-actions .ghost { color:#fff; border-color:#4a5966; }

.layout { display:grid; grid-template-columns: 1fr 340px; min-height:0; }
.stage-wrap { position:relative; min-height:0; overflow:hidden;
  background-color:#e9e5dc; background-image: linear-gradient(45deg,#e1dcd1 25%,transparent 25%), linear-gradient(-45deg,#e1dcd1 25%,transparent 25%), linear-gradient(45deg,transparent 75%,#e1dcd1 75%), linear-gradient(-45deg,transparent 75%,#e1dcd1 75%);
  background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
#stage { position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; -webkit-user-select:none; user-select:none; }
.stage-hint { position:absolute; top:12px; left:50%; transform:translateX(-50%); background:rgba(35,48,59,.88); color:#fff; padding:8px 14px; border-radius:20px; font-size:14px; pointer-events:none; max-width:80%; text-align:center; }
.stage-hint:empty { display:none; }
.zoom-ctrls { position:absolute; right:12px; bottom:12px; display:flex; gap:4px; }
.zoom-ctrls button { width:36px; padding:6px 0; } .zoom-ctrls button:last-child { width:auto; padding:6px 10px; }
.view-help { position:absolute; left:12px; bottom:12px; font-size:11px; color:var(--muted); }
.drop-overlay { position:absolute; inset:0; display:none; place-items:center; background:rgba(31,158,143,.25); border:4px dashed var(--accent); font-size:28px; font-weight:800; color:#16584f; }
.drop-overlay.show { display:grid; }

.panel { background:var(--panel); border-left:1px solid var(--line); overflow-y:auto; padding:14px 16px 24px; }
.panel h2 { margin:2px 0 8px; font-size:19px; }
.panel h3 { margin:16px 0 6px; font-size:14px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); }
.sub { margin:0 0 10px; font-size:13px; color:#43515d; line-height:1.4; }
.tiny { font-size:12px; color:var(--muted); line-height:1.4; }
.info { margin-top:10px; font-size:13px; color:#43515d; background:#f6f4ef; border-radius:8px; padding:8px 10px; }
.dropcard { display:flex; flex-direction:column; align-items:center; gap:4px; text-align:center; border:2px dashed #c9c2b3; border-radius:12px; padding:22px 12px; cursor:pointer; background:#faf8f4; font-size:14px; }
.dropcard.small { padding:12px; }
.dropcard:hover, .dropcard.hover { border-color:var(--accent); background:#eef8f6; }
.dropcard .big { font-size:34px; } .dropcard small { color:var(--muted); font-size:12px; }
.row { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0; }
.field { display:flex; align-items:center; gap:8px; margin:7px 0; font-size:13px; flex-wrap:wrap; }
.field > span { width:88px; color:#43515d; }
.field input[type=range] { flex:1; min-width:90px; accent-color: var(--accent); }
.field output { width:42px; text-align:right; font-size:12px; color:var(--muted); }
.field.colors label { display:flex; align-items:center; gap:4px; }
.field input[type=color] { width:34px; height:26px; border:1px solid var(--line); border-radius:6px; padding:0; background:none; }
.field input[type=number] { width:70px; }
.check { display:flex; align-items:center; gap:6px; font-size:13px; margin:6px 0; cursor:pointer; }
.check.small { font-size:12px; margin:0; }
.sep { height:1px; background:var(--line); margin:12px 0; }
.dummy-wrap { background:#f6f4ef; border-radius:12px; padding:4px; }
#dummy { width:100%; height:300px; display:block; }
.prompt { margin:10px 0 4px; padding:10px 12px; background:#fff6e6; border:1px solid #f4d9a8; border-radius:10px; font-size:14px; line-height:1.35; }
.prompt b.num { display:inline-grid; place-items:center; width:24px; height:24px; border-radius:50%; background:var(--accent2); color:#fff; margin-right:4px; }
.progress { height:6px; background:#eee8dc; border-radius:4px; overflow:hidden; margin:8px 0; }
.progress div { height:100%; width:0; background:var(--accent); transition:width .2s; }
.viseme-btns { display:flex; flex-wrap:wrap; gap:4px; margin:6px 0 10px; }
.viseme-btns button { padding:4px 8px; font-size:12px; font-weight:700; }
.viseme-btns button.on { color:#fff; }
.stats { display:flex; flex-wrap:wrap; gap:4px; font-size:11px; }
.stats span { padding:2px 6px; border-radius:6px; color:#23303b; }
details.custom { margin-top:10px; font-size:13px; } details.custom summary { cursor:pointer; color:#43515d; }
.custom-row { display:flex; align-items:center; gap:6px; margin:4px 0; font-size:12px; }
.custom-row b { width:56px; }

.timeline-wrap { background:#fff; border-top:1px solid var(--line); padding:6px 10px 8px; }
.transport { display:flex; align-items:center; gap:10px; margin-bottom:4px; }
.transport .time { font-variant-numeric: tabular-nums; font-size:13px; width:140px; }
.now-vis { font-size:12px; font-weight:800; padding:2px 8px; border-radius:6px; min-width:60px; text-align:center; }
.tl-scroll { overflow-x:auto; overflow-y:hidden; border-radius:8px; -webkit-overflow-scrolling:touch; }
#timeline { width:100%; height:128px; display:block; border-radius:8px; background:#fbfaf7; cursor:pointer; touch-action:pan-x; }
.sheet-toggle { display:none; }
.mob-only { display:none; }
@media (max-width: 767px) { .mob-only { display:inline; } }
.dummy-inset { position:absolute; left:8px; top:8px; background:rgba(246,244,239,.94); border:1px solid var(--line); border-radius:12px; padding:4px; box-shadow:0 2px 8px rgba(0,0,0,.12); z-index:3; }
.dummy-inset #dummy { width:96px; height:166px; }
.inset-toggle { display:block; width:100%; min-height:36px; font-size:12px; padding:4px 8px; }
.dummy-inset.collapsed #dummyInsetBody { display:none; }
.toast { position:fixed; left:50%; bottom:170px; transform:translateX(-50%); background:#23303b; color:#fff; padding:8px 16px; border-radius:20px; font-size:14px; opacity:0; transition:opacity .25s; pointer-events:none; z-index:10; }
.toast.show { opacity:.95; }

/* ================= Mobile / narrow screens (< 768px) ================= */
@media (max-width: 767px) {
  body { display:flex; flex-direction:column; }
  .layout { display:contents; }
  .topbar { order:0; gap:6px; padding:6px 8px; padding-top:max(6px, env(safe-area-inset-top)); }
  .brand { font-size:0; } .brand .logo { font-size:22px; }
  .steps { justify-content:flex-start; overflow-x:auto; scrollbar-width:none; gap:2px; }
  .steps::-webkit-scrollbar { display:none; }
  .steps button { min-height:44px; min-width:44px; padding:6px 8px; flex:0 0 auto; }
  .steps button i { margin-right:0; width:24px; height:24px; font-size:13px; }
  .steps button .lbl { display:none; }
  .steps button.active .lbl { display:inline; margin-left:6px; font-size:13px; }
  .top-actions .lbl { display:none; }
  .top-actions button, .top-actions .btn { min-width:44px; min-height:44px; padding:6px; font-size:18px; display:inline-grid; place-items:center; }
  .stage-wrap { order:1; flex:0 0 auto; height:46vh; height:46dvh; }
  body.sheet-big .stage-wrap { height:28vh; height:28dvh; }
  .view-help { display:none; }
  .stage-hint { font-size:13px; top:8px; max-width:calc(100% - 130px); left:auto; right:8px; transform:none; padding:6px 10px; }
  .zoom-ctrls button { min-width:44px; min-height:44px; }
  .timeline-wrap { order:2; padding:4px 6px; }
  body.step-1 .timeline-wrap, body.step-2 .timeline-wrap, body.step-3 .timeline-wrap { display:none; }
  .transport { gap:6px; flex-wrap:wrap; }
  .transport button { min-width:44px; min-height:44px; font-size:16px; }
  .transport .time { width:auto; font-size:12px; }
  .panel { order:3; flex:1 1 auto; min-height:0; border-left:none; border-top:1px solid var(--line); padding:4px 12px calc(16px + env(safe-area-inset-bottom)); border-radius:14px 14px 0 0; box-shadow:0 -4px 14px rgba(0,0,0,.08); }
  .sheet-toggle { display:block; width:100%; height:28px; min-height:28px; border:none; background:transparent; padding:0; margin-bottom:2px; }
  .sheet-toggle span { display:block; width:44px; height:5px; border-radius:3px; background:#c9c2b3; margin:0 auto; }
  .panel h2 { font-size:17px; }
  .panel button, .panel .btn, .panel select { min-height:44px; font-size:14px; }
  .panel input[type=number] { min-height:44px; font-size:16px; }
  .panel button.wide { padding:12px; }
  .field input[type=range] { height:44px; }
  .field input[type=color] { width:44px; height:44px; }
  .check { min-height:44px; font-size:14px; }
  .check input { width:22px; height:22px; }
  .check.small { min-height:44px; font-size:13px; }
  .dropcard { padding:16px 10px; }
  #dummyHome { display:none; }
  .viseme-btns button { min-width:48px; }
  .custom-row input[type=file] { max-width:60%; }
  .toast { bottom:calc(16px + env(safe-area-inset-bottom)); max-width:90%; text-align:center; }
  .desk-only { display:none; }
}
