
  :root{
    --bg:#0c0e12; --panel:#15181f; --panel-2:#1b1f28; --line:#262b36;
    --text:#f2f4f8; --muted:#9aa3b2; --faint:#6b7280;
    --accent:#ffb020; --accent-ink:#1a1200;
    --danger:#ff4d4d; --ok:#2fd67c;
    --radius:14px;
    --deck-gap:10px;
  }
  @media (prefers-color-scheme: light){
    :root{ --bg:#eceef2; --panel:#ffffff; --panel-2:#f4f5f8; --line:#d9dde6; --text:#14171d; --muted:#5b6472; --faint:#8a93a3; }
  }
  *{ box-sizing:border-box; }
  html,body{ min-height:100%; }
  body{ margin:0; background:var(--bg); color:var(--text); font-family:"Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-tap-highlight-color:transparent; }
  button, select, input{ font:inherit; color:inherit; }
  button{ cursor:pointer; }
  button, [role="button"], select, input:not([type="checkbox"],[type="radio"]){ min-height:2.25rem; }

  .app{ display:flex; flex-direction:column; min-height:100dvh; }

  /* ---------- Toolbar ---------- */
  .toolbar{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; padding:10px 12px; background:var(--panel); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:30; }
  .brand{ display:flex; align-items:center; gap:9px; margin-right:4px; }
  .brand b{ font-size:16px; letter-spacing:.2px; }
  .brand small{ display:block; color:var(--muted); font-size:11px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; }
  .tgroup{ display:flex; align-items:center; gap:6px; background:var(--panel-2); border:1px solid var(--line); border-radius:10px; padding:4px; }
  .tgroup .lbl{ font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); padding:0 4px 0 6px; }
  .tbtn{ border:1px solid transparent; background:transparent; border-radius:8px; padding:6px 11px; font-size:13px; font-weight:600; color:var(--muted); min-height:2.25rem; }
  .tbtn:hover{ color:var(--text); }
  .tbtn.on{ background:var(--accent); color:var(--accent-ink); }
  .tbtn.danger.on{ background:var(--danger); color:#fff; }
  .tbtn.solid{ background:var(--panel-2); border-color:var(--line); color:var(--text); }
  .tbtn.stop{ background:#2a1215; border:1px solid #57222a; color:#ff8585; }
  @media (prefers-color-scheme: light){ .tbtn.stop{ background:#fdecec; border-color:#f3c2c2; color:#b32626; } }
  .spacer{ flex:1; }
  input[type="range"]{ accent-color:var(--accent); width:110px; min-height:2.25rem; }
  .volval{ font-size:12px; color:var(--muted); min-width:34px; text-align:right; font-variant-numeric:tabular-nums; }
  .fsbtn{ background:var(--accent); color:var(--accent-ink); border:none; border-radius:10px; font-weight:800; padding:8px 16px; font-size:14px; }
  .fsbtn:hover{ filter:brightness(1.07); }

  /* ---------- Deck tools: save / share / export ---------- */
  .deckbar{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; padding:8px 12px; background:var(--panel); border-bottom:1px solid var(--line); }
  .deckbar .dbtn{ border:1px solid var(--line); background:var(--panel-2); color:var(--text); border-radius:9px; padding:7px 13px; font-size:13px; font-weight:700; min-height:2.4rem; }
  .deckbar .dbtn:hover{ border-color:var(--accent); }
  .deckbar .dbtn.share{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
  .deckbar .dbtn.armed{ background:var(--danger); border-color:var(--danger); color:#fff; }
  .savestate{ margin-left:auto; font-size:12.5px; color:var(--muted); display:flex; align-items:center; gap:7px; flex-wrap:wrap; }
  .savestate .dotok{ width:8px; height:8px; border-radius:50%; background:var(--ok); flex:none; }
  .srctag{ background:var(--panel-2); border:1px solid var(--accent); color:var(--accent); border-radius:999px; padding:2px 9px; font-size:11.5px; font-weight:700; }

  /* ---------- Pages bar ---------- */
  .pagesbar{ display:flex; gap:8px; align-items:center; padding:10px 12px 2px; flex-wrap:wrap; }
  .page-tab{ display:flex; align-items:center; gap:7px; border:1px solid var(--line); background:var(--panel); color:var(--muted); border-radius:999px; padding:7px 14px; font-weight:700; font-size:13px; min-height:2.5rem; }
  .page-tab .dot{ width:9px; height:9px; border-radius:50%; }
  .page-tab.on{ color:var(--text); border-color:var(--accent); box-shadow:0 0 0 1px var(--accent) inset; }
  .page-tab.add{ border-style:dashed; }
  .page-tab.del{ color:#ff8585; border-color:#57222a; background:#2a1215; }
  @media (prefers-color-scheme: light){ .page-tab.del{ background:#fdecec; border-color:#f3c2c2; color:#b32626; } }
  .page-tab.del.armed{ background:var(--danger); border-color:var(--danger); color:#fff; max-width:100%; white-space:normal; text-align:left; line-height:1.35; }
  .page-tab.del:disabled{ opacity:.45; cursor:not-allowed; }
  .hint{ margin-left:auto; font-size:12px; color:var(--faint); }
  kbd{ background:var(--panel-2); border:1px solid var(--line); border-bottom-width:2px; border-radius:5px; padding:1px 5px; font-size:11px; font-family:inherit; font-weight:700; }

  /* ---------- Layout ---------- */
  .layout{ flex:1; display:grid; grid-template-columns:300px 1fr; gap:12px; padding:12px; align-items:start; }
  @media (max-width:860px){ .layout{ grid-template-columns:1fr; } }

  /* Library */
  .library{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:12px; position:sticky; top:118px; max-height:calc(100dvh - 140px); display:flex; flex-direction:column; }
  @media (max-width:860px){ .library{ position:static; max-height:none; order:2; } }
  .library h2{ margin:0 0 4px; font-size:15px; }
  .library p{ margin:0 0 10px; font-size:12px; color:var(--muted); line-height:1.45; }
  .search{ width:100%; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:8px 11px; font-size:14px; margin-bottom:10px; }
  .search:focus{ outline:2px solid var(--accent); outline-offset:-1px; }
  .chips{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:10px; }
  .chip{ border:1px solid var(--line); background:var(--panel-2); color:var(--muted); border-radius:999px; padding:5px 11px; font-size:12px; font-weight:700; min-height:2rem; }
  .chip.on{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
  .liblist{ overflow-y:auto; display:flex; flex-direction:column; gap:6px; padding-right:2px; }
  .libitem{ display:flex; align-items:center; gap:10px; text-align:left; background:var(--panel-2); border:1px solid var(--line); border-radius:10px; padding:8px 10px; min-height:3rem; }
  .libitem:hover{ border-color:var(--accent); }
  .libitem .ic{ width:34px; height:34px; flex:none; border-radius:9px; display:grid; place-items:center; font-size:18px; color:#fff; text-shadow:0 1px 2px rgba(0,0,0,.35); }
  .libitem .nm{ font-size:13px; font-weight:700; line-height:1.25; }
  .libitem .ct{ font-size:11px; color:var(--muted); }
  .libitem .mp3badge{ display:inline-block; background:var(--accent); color:var(--accent-ink); border-radius:4px; padding:0 5px; font-size:10px; font-weight:800; vertical-align:1px; }
  .libitem .drag{ margin-left:auto; color:var(--faint); font-size:15px; flex:none; }
  .libempty{ font-size:13px; color:var(--muted); padding:14px 4px; text-align:center; }
  .sitecontrols{ display:flex; gap:6px; margin-bottom:8px; }
  .sitecontrols select{ flex:1; min-width:0; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:8px 6px; font-size:12.5px; font-weight:700; min-height:2.5rem; }
  .sitemeta{ font-size:12px; color:var(--muted); line-height:1.5; margin-bottom:8px; }
  .sitemeta b{ color:var(--text); }
  .siteprogress{ height:8px; background:var(--panel-2); border:1px solid var(--line); border-radius:5px; overflow:hidden; margin:6px 0; }
  .siteprogress > i{ display:block; height:100%; background:var(--accent); width:0%; transition:width .3s ease; }
  .siterow{ cursor:pointer; }
  .libitem .pvbtn{ flex:none; width:34px; height:34px; border-radius:9px; border:1px solid var(--line); background:var(--panel); color:var(--accent); font-size:14px; display:grid; place-items:center; padding:0; min-height:2rem; }
  .libitem .pvbtn:hover{ border-color:var(--accent); }
  .libitem .meta{ min-width:0; flex:1; }
  .libitem .meta .nm{ display:block; overflow-wrap:break-word; }
  .catchip{ display:inline-block; background:var(--panel); border:1px solid var(--line); border-radius:999px; padding:0 7px; font-size:10.5px; font-weight:700; }
  .playsbadge{ color:var(--accent); font-weight:800; }
  .varbadge{ display:inline-block; background:#2e86de; color:#fff; border-radius:4px; padding:0 5px; font-size:10px; font-weight:800; }
  .sitemore{ width:100%; margin-top:8px; border:1px solid var(--line); background:var(--panel-2); color:var(--text); border-radius:9px; padding:9px; font-weight:800; font-size:13px; min-height:2.6rem; }
  .sitemore:hover{ border-color:var(--accent); }
  .siterefresh{ border:1px solid var(--line); background:var(--panel-2); color:var(--text); border-radius:7px; padding:3px 10px; font-size:12px; font-weight:700; min-height:2rem; }
  .siteerror{ border:1px solid #57222a; background:#2a1215; color:#ffb3b3; border-radius:10px; padding:10px; font-size:12.5px; line-height:1.5; margin-bottom:8px; }
  @media (prefers-color-scheme: light){ .siteerror{ background:#fdecec; border-color:#f3c2c2; color:#8c1d1d; } }

  /* Deck */
  .deckwrap{ background:var(--panel); border:1px solid var(--line); border-radius:18px; padding:16px; }
  .deckhead{ display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
  .deckhead h1{ margin:0; font-size:19px; }
  .deckhead span{ font-size:12px; color:var(--muted); }
  .deck{ display:grid; gap:var(--deck-gap); }
  .cell{ position:relative; border:1px solid rgba(255,255,255,.22); border-radius:16px; aspect-ratio:1.18; width:100%; min-width:0; min-height:76px; padding:12px 9px 10px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; text-align:center; color:#fff; overflow:hidden; transition:transform .08s ease, box-shadow .15s ease, filter .15s ease; box-shadow:inset 0 1px 0 rgba(255,255,255,.38), inset 0 -4px 0 rgba(0,0,0,.20), 0 5px 12px rgba(0,0,0,.30); }
  .cell:hover{ transform:translateY(-2px); filter:brightness(1.08); }
  @media (max-width:560px){
    .deckwrap{ padding:10px; }
    .deck{ gap:6px; }
    .cell{ min-height:62px; padding:8px 4px 7px; border-radius:12px; }
    .cell .nm{ font-size:11px; }
    .cell .nm.long{ font-size:10px; }
    .cell .nm.xlong{ font-size:9px; }
    .cell .hk{ top:4px; right:4px; padding:0 4px; font-size:9.5px; }
    .cell .loopbadge{ top:4px; left:4px; padding:0 4px; font-size:8.5px; }
  }
  .cell:active{ transform:scale(.96); filter:brightness(.97); }
  .cell .nm{ font-size:clamp(12px, 1.6vw, 15px); font-weight:700; letter-spacing:.01em; line-height:1.22; text-shadow:0 1px 3px rgba(0,0,0,.5); pointer-events:none; max-width:100%; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; overflow-wrap:break-word; }
  .cell .nm.long{ font-size:clamp(10.5px, 1.35vw, 12.5px); }
  .cell .nm.xlong{ font-size:clamp(9.5px, 1.15vw, 11px); }
  .cell .badgerow{ display:flex; gap:4px; flex-wrap:wrap; justify-content:center; pointer-events:none; }
  .cell.isloop{ outline:2px dotted rgba(255,255,255,.55); outline-offset:-6px; }
  .cell .hk{ position:absolute; top:6px; right:6px; background:rgba(0,0,0,.45); border-radius:5px; padding:1px 6px; font-size:10.5px; font-weight:800; letter-spacing:.03em; }
  .cell .loopbadge{ position:absolute; top:6px; left:6px; background:rgba(0,0,0,.45); border-radius:5px; padding:1px 6px; font-size:9.5px; font-weight:800; letter-spacing:.08em; }
  .cell.empty{ background:var(--panel-2); color:var(--faint); box-shadow:inset 0 1px 0 rgba(255,255,255,.05); border:2px dashed var(--line); }
  .cell.empty:hover{ transform:none; filter:none; }
  .cell.empty .plus{ font-size:22px; font-weight:300; opacity:.55; line-height:1; }
  .cell.empty .nm{ color:var(--faint); font-weight:600; text-shadow:none; font-size:10.5px; letter-spacing:.05em; }
  .cell.playing{ box-shadow:0 0 0 3px var(--keyc, #fff), 0 0 24px var(--keyc, rgba(255,255,255,.5)), inset 0 1px 0 rgba(255,255,255,.4); animation:keypulse 1s ease-in-out infinite; }
  @keyframes keypulse{ 50%{ box-shadow:0 0 0 3px var(--keyc, #fff), 0 0 7px var(--keyc, rgba(255,255,255,.35)), inset 0 1px 0 rgba(255,255,255,.4); } }
  .cell .eq{ display:none; position:absolute; bottom:9px; left:50%; transform:translateX(-50%); gap:2.5px; align-items:flex-end; height:12px; pointer-events:none; }
  .cell.playing .eq{ display:flex; }
  .cell .eq i{ width:3.5px; height:40%; background:rgba(255,255,255,.92); border-radius:2px; animation:eqb .7s ease-in-out infinite; }
  .cell .eq i:nth-child(2){ animation-delay:.18s; }
  .cell .eq i:nth-child(3){ animation-delay:.36s; }
  .cell .eq i:nth-child(4){ animation-delay:.1s; }
  @keyframes eqb{ 0%,100%{ height:30%; } 50%{ height:100%; } }
  body.deckonly .cell{ border-radius:18px; }
  body.deckonly .cell .nm{ font-size:clamp(14px, 2vw, 20px); }
  body.deckonly .cell .nm.long{ font-size:clamp(12px, 1.7vw, 16px); }
  body.deckonly .cell .nm.xlong{ font-size:clamp(11px, 1.4vw, 13.5px); }
  .cell.playing::after{ content:""; position:absolute; inset:0 10px auto; height:4px; border-radius:2px; background:rgba(255,255,255,.9); transform-origin:left; animation:prog var(--dur,1s) linear forwards; }
  @keyframes prog{ from{ transform:scaleX(0);} to{ transform:scaleX(1);} }
  .cell.dragover{ box-shadow:0 0 0 3px var(--accent); }
  .cell .editbadge{ display:none; position:absolute; bottom:6px; right:6px; background:rgba(0,0,0,.55); border-radius:5px; padding:1px 6px; font-size:10px; font-weight:700; }
  body.editing .cell .editbadge{ display:block; }

  /* Status bar */
  .statusbar{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; padding:10px 12px; background:var(--panel); border-top:1px solid var(--line); font-size:13px; color:var(--muted); position:sticky; bottom:0; z-index:20; }
  .statusbar .live{ display:flex; align-items:center; gap:7px; font-weight:700; color:var(--text); }
  .pulse{ width:9px; height:9px; border-radius:50%; background:var(--faint); }
  .pulse.on{ background:var(--ok); animation:pl 0.9s ease-in-out infinite; }
  @keyframes pl{ 50%{ opacity:.35; } }
  .statusbar .right{ margin-left:auto; display:flex; gap:6px; flex-wrap:wrap; }
  @media (max-width:560px){
    /* Thanh trạng thái không sticky ở điện thoại để không che hàng nút cuối của deck */
    .statusbar{ position:static; }
    .statusbar .right{ margin-left:0; }
  }
  .tag{ background:var(--panel-2); border:1px solid var(--line); border-radius:999px; padding:3px 10px; font-size:12px; font-weight:600; }

  /* Sheets (editor + share/import) */
  .scrim{ position:fixed; inset:0; background:rgba(0,0,0,.55); display:none; z-index:50; }
  .scrim.open{ display:block; }
  .sheet{ position:fixed; left:50%; bottom:0; transform:translate(-50%,105%); width:min(480px, 100%); background:var(--panel); border:1px solid var(--line); border-bottom:none; border-radius:18px 18px 0 0; padding:18px; z-index:60; transition:transform .22s ease; max-height:88dvh; overflow-y:auto; }
  .sheet.open{ transform:translate(-50%,0); }
  @media (min-width:700px){ .sheet{ bottom:auto; top:50%; transform:translate(-50%,-46%) scale(.97); opacity:0; pointer-events:none; border-radius:18px; border-bottom:1px solid var(--line); } .sheet.open{ transform:translate(-50%,-50%) scale(1); opacity:1; pointer-events:auto; } }
  .sheet h3{ margin:0 0 2px; font-size:17px; }
  .sheet .sub{ font-size:12px; color:var(--muted); margin-bottom:14px; line-height:1.5; }
  .field{ margin-bottom:14px; }
  .field label{ display:block; font-size:12px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; color:var(--muted); margin-bottom:6px; }
  .field input[type="text"]{ width:100%; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:9px 11px; font-size:15px; }
  .field textarea{ width:100%; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:9px 11px; font-size:12.5px; line-height:1.5; min-height:130px; resize:vertical; word-break:break-all; color:var(--text); font-family:ui-monospace, Consolas, monospace; }
  .swatches{ display:flex; gap:8px; flex-wrap:wrap; }
  .sw{ width:40px; height:40px; border-radius:10px; border:2px solid transparent; padding:0; }
  .sw.on{ border-color:#fff; box-shadow:0 0 0 2px var(--accent); }
  .emojis{ display:flex; gap:6px; flex-wrap:wrap; }
  .em{ width:42px; height:42px; border-radius:10px; border:1px solid var(--line); background:var(--panel-2); font-size:19px; padding:0; }
  .em.on{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
  .hkrow{ display:flex; gap:8px; align-items:center; }
  .hkcap{ flex:1; background:var(--panel-2); border:1px dashed var(--line); border-radius:9px; padding:9px 11px; font-weight:800; text-align:center; font-size:14px; min-height:2.75rem; }
  .hkcap.listening{ border-color:var(--accent); color:var(--accent); }
  .sheet .row{ display:flex; gap:8px; flex-wrap:wrap; }
  .btn{ border:1px solid var(--line); background:var(--panel-2); border-radius:10px; padding:9px 14px; font-weight:700; font-size:14px; min-height:2.75rem; }
  .btn.primary{ background:var(--accent); color:var(--accent-ink); border-color:var(--accent); flex:1; }
  .btn.danger{ color:#ff8585; border-color:#57222a; background:#2a1215; }
  @media (prefers-color-scheme: light){ .btn.danger{ background:#fdecec; border-color:#f3c2c2; color:#b32626; } }
  .checkline{ display:flex; align-items:center; gap:9px; font-size:14px; font-weight:600; padding:6px 0; cursor:pointer; min-height:2.5rem; }
  .checkline input{ width:20px; height:20px; accent-color:var(--accent); }

  .libitem .cbadge{ display:inline-block; border-radius:4px; padding:0 5px; font-size:10px; font-weight:800; vertical-align:1px; background:#2e86de; color:#fff; }

  /* Per-button controls in editor */
  .field input[type="number"]{ width:100%; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:9px 11px; font-size:15px; }
  .field .rangerow{ display:flex; align-items:center; gap:10px; }
  .field .rangerow input[type="range"]{ flex:1; width:auto; }
  .field .rval{ font-size:13px; font-weight:800; min-width:52px; text-align:right; font-variant-numeric:tabular-nums; }
  .trimrow{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; }
  .trimrow .sublbl{ font-size:11px; color:var(--muted); font-weight:600; margin-bottom:4px; display:block; text-transform:none; letter-spacing:0; }
  .cell .ctrlbadge{ position:absolute; bottom:6px; left:6px; background:rgba(0,0,0,.5); border-radius:5px; padding:1px 6px; font-size:9.5px; font-weight:700; pointer-events:none; }
  .cell .typebadge{ display:inline-block; background:rgba(0,0,0,.62); color:#fff; border:1px solid rgba(255,255,255,.35); border-radius:999px; padding:1px 7px; font-size:9.5px; font-weight:800; letter-spacing:.04em; pointer-events:none; line-height:1.5; }
  .cell .ladflash{ position:absolute; top:6px; left:50%; transform:translateX(-50%); background:#ffb020; color:#1a1200; border-radius:999px; padding:2px 9px; font-size:12px; font-weight:900; pointer-events:none; opacity:0; z-index:3; box-shadow:0 2px 8px rgba(0,0,0,.35); }
  .cell .ladflash.show{ animation:ladpop .95s ease-out; }
  @keyframes ladpop{ 0%{ opacity:0; transform:translateX(-50%) translateY(5px) scale(.75); } 14%{ opacity:1; transform:translateX(-50%) translateY(0) scale(1.12); } 30%{ transform:translateX(-50%) scale(1); } 72%{ opacity:1; } 100%{ opacity:0; transform:translateX(-50%) translateY(-3px); } }
  @media (prefers-reduced-motion: reduce){ .cell .ladflash.show{ animation-duration:.01s; } }
  .automenu{ display:none; gap:8px; align-items:center; flex-wrap:wrap; padding:8px 12px 2px; }
  .automenu.open{ display:flex; }
  .automenu .amlabel{ font-size:12.5px; font-weight:800; color:var(--muted); }
  body.deckonly .automenu{ display:none !important; }
  .typesel{ display:grid; grid-template-columns:repeat(auto-fit,minmax(96px,1fr)); gap:6px; }
  .typesel button{ border:1px solid var(--line); background:var(--panel-2); border-radius:9px; padding:8px 4px; font-size:12.5px; font-weight:800; min-height:2.6rem; }
  .typesel button.on{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
  @media (max-width:560px){ .typesel{ grid-template-columns:repeat(2,1fr); } }
  .steprow,.randrow{ display:flex; align-items:center; gap:8px; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:7px 9px; margin-bottom:6px; font-size:13px; }
  .steprow .sname,.randrow .sname{ flex:1; font-weight:700; min-width:0; overflow-wrap:break-word; }
  .steprow .mini,.randrow .mini{ flex:none; width:32px; height:32px; border-radius:8px; border:1px solid var(--line); background:var(--panel); font-weight:800; padding:0; min-height:2rem; }
  .randrow input{ width:20px; height:20px; accent-color:var(--accent); flex:none; }
  .pickrow{ display:flex; gap:8px; }
  .pickrow select{ flex:1; min-width:0; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:8px 10px; font-size:14px; min-height:2.6rem; }
  .field select{ width:100%; background:var(--panel-2); border:1px solid var(--line); border-radius:9px; padding:9px 11px; font-size:15px; min-height:2.6rem; }
  .scrollpick{ max-height:220px; overflow-y:auto; padding-right:2px; }
  .typenote{ font-size:12px; color:var(--muted); line-height:1.5; margin:0 0 10px; }
  body.editing .cell .ctrlbadge{ bottom:auto; top:26px; }

  /* ---------- View tabs + Sequencer ---------- */
  .viewtabs{ display:flex; gap:8px; align-items:center; padding:8px 12px 0; flex-wrap:wrap; }
  .vtab{ border:1px solid var(--line); background:var(--panel); color:var(--muted); border-radius:999px; padding:8px 18px; font-weight:800; font-size:14px; min-height:2.6rem; }
  .vtab.on{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
  .seqwrap{ margin:12px; background:var(--panel); border:1px solid var(--line); border-radius:18px; padding:16px; }
  .seqhead{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:12px; }
  .seqhead h2{ margin:0; font-size:19px; }
  .seqhead p{ margin:0; font-size:12.5px; color:var(--muted); line-height:1.5; flex-basis:100%; }
  .seqtransport{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; background:var(--panel-2); border:1px solid var(--line); border-radius:12px; padding:10px; margin-bottom:12px; }
  .seqbtn{ border:1px solid var(--line); background:var(--panel); color:var(--text); border-radius:9px; padding:8px 14px; font-weight:800; font-size:13.5px; min-height:2.6rem; }
  .seqbtn.play{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); min-width:118px; }
  .seqbtn.stopb{ background:#2a1215; border-color:#57222a; color:#ff8585; }
  @media (prefers-color-scheme: light){ .seqbtn.stopb{ background:#fdecec; border-color:#f3c2c2; color:#b32626; } }
  .seqbpm{ display:flex; align-items:center; gap:8px; margin-left:4px; }
  .seqbpm label{ font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
  .seqbpm input[type="range"]{ width:150px; }
  .seqbpm .bpmval{ font-weight:800; font-variant-numeric:tabular-nums; min-width:86px; }
  .seqstatus{ margin-left:auto; font-size:13px; font-weight:700; color:var(--muted); }
  .seqstatus.on{ color:var(--ok); }
  .seqscroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; border:1px solid var(--line); border-radius:12px; background:var(--panel-2); }
  .seqgrid{ min-width:820px; padding:10px; display:flex; flex-direction:column; gap:8px; }
  .seqrow{ display:grid; grid-template-columns:210px repeat(16, minmax(34px, 1fr)); gap:5px; align-items:center; }
  .seqrowhead{ position:sticky; left:0; z-index:2; background:var(--panel-2); display:flex; gap:6px; align-items:center; padding-right:8px; }
  .seqrowhead .dotc{ width:12px; height:12px; border-radius:50%; flex:none; }
  .seqrowhead select{ flex:1; min-width:0; background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:7px 6px; font-size:12.5px; font-weight:700; min-height:2.4rem; }
  .seqmute{ flex:none; width:36px; height:36px; border-radius:8px; border:1px solid var(--line); background:var(--panel); padding:0; font-size:15px; }
  .seqmute.muted{ background:var(--danger); border-color:var(--danger); color:#fff; }
  .stepcell{ height:42px; border-radius:8px; border:1px solid var(--line); background:var(--panel); padding:0; min-height:2.6rem; position:relative; }
  .stepcell.beatstart{ border-left:3px solid var(--muted); }
  .stepcell.on{ background:var(--rowc, var(--accent)); border-color:var(--rowc, var(--accent)); box-shadow:inset 0 -3px 0 rgba(0,0,0,.25); }
  .stepcell.playcol{ outline:3px solid #fff; outline-offset:-1px; }
  .stepcell.on.playcol{ filter:brightness(1.25); }
  .seqstepshead{ display:grid; grid-template-columns:210px repeat(16, minmax(34px, 1fr)); gap:5px; align-items:center; }
  .seqstepshead .sh{ text-align:center; font-size:11px; font-weight:800; color:var(--faint); }
  .seqstepshead .sh.beat{ color:var(--text); }
  body.deckonly .viewtabs, body.deckonly .seqwrap{ display:none !important; }

  /* Deck-only (fullscreen) mode */
  body.deckonly .toolbar, body.deckonly .deckbar, body.deckonly .pagesbar, body.deckonly .library, body.deckonly .statusbar .right, body.deckonly .deckhead span{ display:none; }
  body.deckonly .layout{ grid-template-columns:1fr; padding:10px; }
  body.deckonly .deckwrap{ border:none; background:transparent; padding:6px; }
  body.deckonly{ background:#000; }
  body.deckonly .deckwrap{ background:#000; }
  .exitfs{ display:none; position:fixed; top:10px; right:10px; z-index:80; background:rgba(20,22,28,.85); color:#fff; border:1px solid #3a4152; border-radius:999px; padding:8px 15px; font-weight:700; font-size:13px; backdrop-filter:blur(4px); }
  body.deckonly .exitfs{ display:block; }
  .toast{ position:fixed; left:50%; bottom:76px; transform:translateX(-50%) translateY(20px); background:#1d212b; color:#fff; border:1px solid #343b4a; padding:10px 16px; border-radius:10px; font-size:13.5px; font-weight:600; opacity:0; pointer-events:none; transition:.2s; z-index:90; max-width:92vw; text-align:center; }
  .toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
  /* ---------- Tabs scroll + Piano / Hands-free / Timer / Ambient ---------- */
  .viewtabs{ flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-bottom:4px; }
  .viewtabs .vtab{ flex:none; }
  .viewtabs .hint{ flex:none; }
  body.deckonly .seqwrap, body.deckonly #extrasPanel, body.deckonly #pianoPanel, body.deckonly #ambientPanel{ display:none !important; }
  .extrasgrid{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
  @media (max-width:860px){ .extrasgrid{ grid-template-columns:1fr; } }
  .xbox{ border:1px solid var(--line); border-radius:12px; padding:12px; background:var(--panel-2); }
  .xbox h3{ margin:0 0 6px; font-size:15px; }
  .xbox p{ margin:0 0 10px; font-size:12.5px; color:var(--muted); line-height:1.5; }
  .xrow{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:10px; }
  .xrow select, .xrow input[type="text"], .xrow input[type="number"]{ flex:1; min-width:130px; background:var(--panel); border:1px solid var(--line); border-radius:9px; padding:8px 10px; font-size:14px; min-height:2.6rem; }
  .xbtn{ border:1px solid var(--line); background:var(--panel); color:var(--text); border-radius:9px; padding:8px 14px; font-weight:800; font-size:13.5px; min-height:2.6rem; }
  .xbtn.on{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
  .xbtn.stopb{ background:#2a1215; border-color:#57222a; color:#ff8585; }
  @media (prefers-color-scheme: light){ .xbtn.stopb{ background:#fdecec; border-color:#f3c2c2; color:#b32626; } }
  .xstatus{ font-size:13px; font-weight:700; color:var(--muted); }
  .xstatus.on{ color:var(--ok); }
  .levelbar{ height:14px; background:var(--panel); border:1px solid var(--line); border-radius:7px; overflow:hidden; margin:6px 0 10px; position:relative; }
  .levelbar > i{ display:block; height:100%; width:0%; background:var(--ok); transition:width .05s linear; }
  .levelbar > b{ position:absolute; top:0; bottom:0; width:2px; background:var(--danger); }
  .sensrow{ display:flex; align-items:center; gap:10px; margin-bottom:8px; }
  .sensrow label{ font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
  .sensrow input[type="range"]{ flex:1; width:auto; }
  .presetbtn{ border:1px dashed var(--line); background:transparent; color:var(--muted); border-radius:999px; padding:5px 12px; font-size:12.5px; font-weight:700; min-height:2.2rem; }
  .presetbtn:hover{ color:var(--text); border-color:var(--accent); }
  .timerrow{ display:flex; align-items:center; gap:8px; background:var(--panel); border:1px solid var(--line); border-radius:9px; padding:7px 10px; margin-bottom:6px; font-size:13.5px; }
  .timerrow .tname{ flex:1; font-weight:700; min-width:0; overflow-wrap:break-word; }
  .timerrow .tremain{ font-weight:800; font-variant-numeric:tabular-nums; color:var(--accent); }
  .timerrow .mini{ flex:none; width:32px; height:32px; border-radius:8px; border:1px solid var(--line); background:var(--panel-2); font-weight:800; padding:0; min-height:2rem; }
  /* Piano */
  .piano{ position:relative; height:210px; background:#101216; border:1px solid var(--line); border-radius:12px; padding:10px; overflow:hidden; }
  .pwhites{ display:flex; height:100%; gap:2px; }
  .pkey-w{ flex:1; min-width:0; background:linear-gradient(#ffffff,#dfe3ea); color:#22242a; border:1px solid #9aa0ad; border-radius:0 0 8px 8px; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; gap:2px; padding:0 1px 8px; font-weight:800; cursor:pointer; }
  .pkey-w .kn{ font-size:12px; }
  .pkey-w .kk, .pkey-b .kk{ font-size:10px; font-weight:700; opacity:.65; text-transform:uppercase; }
  .pkey-b{ position:absolute; top:10px; height:56%; background:linear-gradient(#2b2e35,#0c0d10); color:#fff; border:1px solid #000; border-radius:0 0 6px 6px; z-index:2; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; gap:2px; padding:0 1px 6px; font-weight:800; cursor:pointer; }
  .pkey-b .kn{ font-size:10.5px; }
  .pkey-w.hit, .pkey-b.hit{ background:var(--accent); color:var(--accent-ink); }
  /* Ambient */
  .ambrow{ display:flex; gap:10px; align-items:center; background:var(--panel-2); border:1px solid var(--line); border-radius:12px; padding:10px 12px; margin-bottom:8px; flex-wrap:wrap; }
  .ambrow .aic{ font-size:22px; }
  .ambrow .anm{ font-weight:800; min-width:110px; }
  .ambrow input[type="range"]{ flex:1; min-width:110px; width:auto; }
  .ambrow .aval{ font-size:12.5px; color:var(--muted); min-width:38px; text-align:right; font-variant-numeric:tabular-nums; }
  .fxbadge{ display:inline-block; background:#111827; color:#fff; border:1px solid rgba(255,255,255,.4); border-radius:999px; padding:1px 7px; font-size:9.5px; font-weight:800; letter-spacing:.03em; pointer-events:none; line-height:1.5; }
  .cell.gpflash{ box-shadow:0 0 0 4px #fff, 0 0 26px rgba(255,255,255,.7) !important; transform:scale(.95); }
  .gprow{ display:flex; align-items:center; gap:8px; background:var(--panel); border:1px solid var(--line); border-radius:9px; padding:6px 9px; margin-bottom:6px; font-size:13px; }
  .gprow .gdot{ width:12px; height:12px; border-radius:50%; background:var(--faint); flex:none; }
  .gprow .gdot.on{ background:var(--ok); box-shadow:0 0 8px var(--ok); }
  .gprow .gname{ font-weight:800; min-width:86px; }
  .gprow select{ flex:1; min-width:0; background:var(--panel-2); border:1px solid var(--line); border-radius:8px; padding:7px 8px; min-height:2.4rem; }
  .ambrow .adel{ flex:none; width:34px; height:34px; border-radius:9px; border:1px solid var(--line); background:var(--panel); color:#ff8585; font-weight:800; display:grid; place-items:center; padding:0; min-height:2rem; }
  .ambrow .adel:hover{ border-color:var(--danger); }
  .ambrow.missing{ opacity:.72; }
  .ambrow .anote{ flex-basis:100%; font-size:12px; color:#ff8585; line-height:1.45; }
  .xbtn:disabled{ opacity:.5; cursor:not-allowed; }
  #ambLoopPicker{ border:1px solid var(--line); border-radius:12px; padding:10px; background:var(--panel); margin-bottom:10px; }
  #ambLoopPicker .liblist{ max-height:320px; }
  @media (prefers-reduced-motion: reduce){ *{ animation:none !important; transition:none !important; } }

  /* ================= ĐỢT TỐI ƯU DESKTOP + MOBILE ================= */
  html{ -webkit-tap-highlight-color:transparent; }
  html, body{ overflow-x:clip; }
  /* CSS containment: giảm chi phí repaint cho ô deck + hàng thư viện */
  .cell{ contain:layout paint; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; touch-action:manipulation; }
  .libitem{ contain:layout paint; }
  /* Tap target ≥44px cho mọi control tương tác */
  button, [role="button"], select, input:not([type="checkbox"],[type="radio"]){ min-height:2.75rem; }
  .tbtn, .chip, .page-tab, .dbtn, .vtab, .seqbtn, .xbtn, .presetbtn, .siterefresh, .sitemore{ min-height:2.75rem; }
  .libitem{ min-height:3rem; }
  .libitem .pvbtn{ width:44px; height:44px; min-height:44px; }
  .libitem .delx{ width:40px; height:44px; }
  .seqmute{ width:44px; height:44px; }
  .stepcell{ height:44px; min-height:44px; }
  .steprow .mini, .randrow .mini, .timerrow .mini{ width:40px; height:44px; min-height:44px; }
  .ambrow .adel{ width:44px; height:44px; min-height:44px; }
  .gprow select{ min-height:2.75rem; }
  .sw{ width:44px; height:44px; } .em{ width:44px; height:44px; }
  .checkline{ min-height:2.75rem; }

  /* Bố cục: <1200px một cột (deck trước, rail dưới); ≥1200px deck trái + rail phải sticky cuộn độc lập */
  .layout{ grid-template-columns:minmax(0,1fr); }
  .layout > *, .rail > *{ min-width:0; }
  .rail{ display:flex; flex-direction:column; gap:12px; min-width:0; }
  .rail .library{ position:static; max-height:none; flex:none; order:0; }
  .rail .seqwrap{ margin:0; }
  .rail .extrasgrid{ grid-template-columns:1fr; }
  @media (min-width:1200px){
    .layout{ grid-template-columns:minmax(0,1fr) 400px; align-items:start; }
    /* Trừ thêm ~66px cho thanh trạng thái sticky ở đáy viewport: mép dưới của
       rail phải nằm TRÊN thanh trạng thái, nếu không hàng thư viện cuối rail
       (vd nút Preview) bị thanh trạng thái phủ lên và không bấm được. */
    .rail{ position:sticky; top:70px; max-height:calc(100dvh - 148px); overflow-y:auto; overscroll-behavior:contain; padding-right:2px; scrollbar-width:thin; }
  }

  /* Editor: 700–768px giữ bottom sheet (ghi đè rule modal giữa màn hình ở ≥700px) */
  @media (min-width:700px) and (max-width:768px){
    .sheet{ bottom:0; top:auto; transform:translate(-50%,105%); opacity:1; pointer-events:auto; border-radius:18px 18px 0 0; border-bottom:none; }
    .sheet.open{ transform:translate(-50%,0); opacity:1; pointer-events:auto; }
  }

  /* Thanh điều khiển dính cho mobile (ẩn mặc định + ẩn trong Deck Mode) */
  .mobilebar{ display:none; }
  body.deckonly .mobilebar{ display:none !important; }
  body.deckonly .app{ padding-bottom:0; }

  /* Deck Mode toàn màn hình: khớp dvh + safe-area cả dọc lẫn ngang, chặn pull-to-refresh */
  body.deckonly{ overscroll-behavior:none; }
  html:has(body.deckonly){ overscroll-behavior:none; }
  body.deckonly .deckhead{ display:none; }
  body.deckonly .layout{ padding:calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); }
  body.deckonly .deck{ height:calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); grid-auto-rows:minmax(0,1fr); }
  body.deckonly .cell{ aspect-ratio:auto; height:100%; min-height:0; }

  /* Kéo-thả cảm ứng (Pointer Events): ghost + khoá cuộn trang khi đang kéo */
  .td-ghost{ position:fixed; z-index:200; pointer-events:none; background:var(--accent); color:var(--accent-ink); font-weight:800; font-size:13px; padding:10px 14px; border-radius:10px; box-shadow:0 10px 24px rgba(0,0,0,.45); transform:translate(-50%,-140%); max-width:70vw; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  body.td-dragging{ overflow:hidden; touch-action:none; }
  .td-src{ opacity:.45; touch-action:none; }

  @media (max-width:768px){
    /* Chữ trong input/select ≥16px để iOS không tự zoom khi focus */
    input, select, textarea{ font-size:16px !important; }
    .sheet{ width:100%; max-width:100%; max-height:85dvh; padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
    /* Hàng tab page cuộn ngang */
    .pagesbar{ flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-bottom:6px; scrollbar-width:none; }
    .pagesbar::-webkit-scrollbar{ display:none; }
    .pagesbar > *{ flex:none; }
    .pagesbar .hint{ display:none; }
    .viewtabs .hint{ display:none; }
    /* Giảm chi phí chuyển động trên màn hình nhỏ: bỏ pulse/EQ động, giữ chỉ báo tĩnh */
    .cell.playing{ animation:none; box-shadow:0 0 0 3px var(--keyc, #fff), inset 0 1px 0 rgba(255,255,255,.4); }
    .cell .eq i{ animation:none; height:70%; }
    .cell, .libitem, .tbtn, .vtab, .page-tab, .chip{ transition-duration:.08s; }
    .app{ padding-bottom:calc(72px + env(safe-area-inset-bottom)); }
    .statusbar{ position:static; }
    .mobilebar{ display:flex; gap:8px; align-items:center; position:fixed; left:0; right:0; bottom:0; z-index:45; background:var(--panel); border-top:1px solid var(--line); padding:8px 10px calc(8px + env(safe-area-inset-bottom)); }
    .mobilebar .mb-stop{ background:#2a1215; border:1px solid #57222a; color:#ff8585; border-radius:10px; font-weight:800; padding:8px 12px; min-height:44px; white-space:nowrap; }
    @media (prefers-color-scheme: light){ .mobilebar .mb-stop{ background:#fdecec; border-color:#f3c2c2; color:#b32626; } }
    .mobilebar input[type="range"]{ flex:1; min-width:0; width:auto; }
    .mobilebar .mb-volval{ font-size:12px; color:var(--muted); min-width:34px; text-align:right; font-variant-numeric:tabular-nums; }
    .mobilebar .mb-fs{ background:var(--accent); color:var(--accent-ink); border:none; border-radius:10px; font-weight:800; padding:8px 12px; min-height:44px; white-space:nowrap; }
    /* Accordion cho các panel ở tab Deck: thu gọn mặc định, bấm tiêu đề để mở */
    #extrasPanel .xbox > *:not(h3){ display:none; }
    #extrasPanel .xbox.open > *:not(h3){ display:block; }
    #extrasPanel .xbox.open > .xrow, #extrasPanel .xbox.open > .sensrow{ display:flex; }
    #extrasPanel .xbox h3{ cursor:pointer; position:relative; padding-right:30px; min-height:44px; display:flex; align-items:center; margin-bottom:0; }
    #extrasPanel .xbox.open h3{ margin-bottom:6px; }
    #extrasPanel .xbox h3::after{ content:"▸"; position:absolute; right:8px; font-size:19px; color:var(--muted); }
    #extrasPanel .xbox.open h3::after{ content:"▾"; }
    /* Sequencer: cột chọn track hẹp hơn trên mobile để dành chỗ cho step */
    .seqgrid{ min-width:760px; }
  }
  @media (max-width:560px){
    .toolbar{ padding:8px; gap:6px; }
    .brand small{ display:none; }
    .fsbtn{ padding:8px 12px; font-size:13px; }
    .deckbar{ padding:8px; }
  }
  @media (max-width:768px){
    /* FIX 1 — Chrome mobile KHÔNG còn là hàng cuộn ngang ẩn: toolbar gói thành
       các hàng compact, điều khiển chính (Play / Volume / Stop All / Edit /
       Fullscreen) luôn thấy trọn trong bề ngang ban đầu; mục phụ (Grid,
       Share / Export / Import / Reset) nằm trong menu "⋯ More". */
    .toolbar{ flex-wrap:wrap; overflow:visible; gap:6px; }
    .toolbar .spacer{ display:none; }
    .brand{ order:1; flex:1 1 auto; min-width:0; }
    .brand small{ display:none; }
    .fsbtn{ order:2; flex:none; }
    .playgroup{ order:3; flex:none; }
    #editToggle{ order:4; flex:none; margin-left:auto; }
    .volgroup{ order:5; flex:1 1 170px; min-width:0; }
    .volgroup input[type="range"]{ flex:1; min-width:52px; width:auto; }
    #stopAll{ order:6; flex:none; }
    .gridgroup{ order:7; flex:1 1 100%; }
    .toolbar .tbtn{ font-size:12px; padding:6px 8px; }
    body:not(.moreopen) .gridgroup{ display:none; }
    .deckbar{ flex-wrap:wrap; overflow:visible; }
    .deckbar > *{ flex:none; }
    .deckbar #btnMore{ display:inline-block; }
    body:not(.moreopen) .deckbar .dbtn:not(#btnMore){ display:none; }
    .deckbar .savestate{ margin-left:auto; }
    /* Gợi ý cuộn ngang cho 2 thanh được phép cuộn: mép phải mờ dần */
    .viewtabs, .pagesbar{ -webkit-mask-image:linear-gradient(90deg, #000 93%, transparent 100%); mask-image:linear-gradient(90deg, #000 93%, transparent 100%); }
  }
  #btnMore{ display:none; }

  /* ================= DECK MODE QUICK ACTIONS (HUD / STRIP / NOW / RECENT / QS) ================= */
  .dmhud, .dmbottom{ display:none; }
  body.deckonly .app{ height:100dvh; min-height:0; overflow:hidden; }
  body.deckonly .dmhud{ display:flex; align-items:center; gap:10px; padding:calc(6px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 6px calc(10px + env(safe-area-inset-left)); background:#000; flex:none; max-width:100%; }
  body.deckonly .layout{ flex:1 1 auto; min-height:0; display:flex; flex-direction:column; }
  body.deckonly .rail{ display:none; }
  body.deckonly .deckwrap{ flex:1 1 auto; min-height:0; display:flex; flex-direction:column; }
  body.deckonly .deck{ flex:1 1 auto; height:auto; min-height:0; }
  body.deckonly .statusbar{ display:none; }
  body.deckonly .dmbottom{ display:flex; flex-direction:column; flex:none; background:#000; max-width:100%; }
  body.deckonly .exitfs{ top:calc(64px + env(safe-area-inset-top)); }
  .dmnavbtn{ flex:none; width:52px; height:48px; border-radius:12px; border:1px solid #3a4152; background:#171a21; color:#fff; font-size:19px; font-weight:800; }
  .dmnavbtn:disabled{ opacity:.35; }
  .dmpageinfo{ flex:1 1 auto; min-width:0; text-align:center; }
  .dmpagename{ font-size:16px; font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .dmdots{ display:flex; gap:6px; justify-content:center; margin-top:4px; overflow:hidden; }
  .dmdot{ width:9px; height:9px; border-radius:50%; background:#3a4152; flex:none; }
  .dmdot.on{ background:var(--accent); }
  .dmclockbox{ flex:none; text-align:right; font-variant-numeric:tabular-nums; }
  .dmclockbox #dmClock{ font-size:17px; font-weight:800; }
  .dmclockbox .dmsep{ color:var(--faint); margin:0 5px; }
  .dmclockbox #dmSession{ font-size:13px; color:var(--muted); font-weight:700; }
  .deck.pageanim{ animation:dmpagein .18s ease; }
  @keyframes dmpagein{ from{ opacity:.2; transform:translateX(var(--dm-slide, 18px)); } }
  /* Recent strip */
  .dmrecent{ border-top:1px solid #262b36; padding:4px 10px 2px; }
  .dmrecenthead{ display:flex; align-items:center; gap:8px; min-height:30px; cursor:pointer; }
  .dmrecenthead .dmrtitle{ font-size:12px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
  .dmrecenthead .dmrchev{ color:var(--muted); font-size:13px; }
  .dmrecent.collapsed .dmrchev{ transform:rotate(-90deg); display:inline-block; }
  .dmclear{ margin-left:auto; background:none; border:none; color:var(--muted); font-size:12px; font-weight:700; text-decoration:underline; min-height:30px; padding:0 6px; }
  .dmchips{ display:flex; gap:7px; overflow-x:auto; -webkit-overflow-scrolling:touch; padding:2px 0 7px; scrollbar-width:none; max-width:100%; }
  .dmchips::-webkit-scrollbar{ display:none; }
  .dmrecent.collapsed .dmchips{ display:none; }
  .dmchip{ flex:none; max-width:46vw; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border:1px solid #3a4152; background:#171a21; color:#fff; border-radius:999px; padding:8px 13px; font-size:13px; font-weight:700; min-height:40px; }
  .dmchip:disabled{ opacity:.42; }
  .dmchips .dmrempty{ font-size:12.5px; color:var(--faint); padding:6px 2px; }
  /* Now Playing banner */
  .dmnow{ display:none; align-items:center; gap:10px; margin:6px 10px 0; background:#171a21; border:1px solid var(--accent); border-radius:12px; padding:9px 12px; }
  .dmnow.show{ display:flex; }
  .dmnowdot{ width:10px; height:10px; border-radius:50%; background:var(--ok); flex:none; animation:pl .9s ease-in-out infinite; }
  .dmnowname{ flex:1 1 auto; min-width:0; font-size:16px; font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .dmnowtime{ flex:none; font-size:13px; color:var(--muted); font-weight:700; font-variant-numeric:tabular-nums; }
  .dmnowstop{ flex:none; background:#2a1215; border:1px solid #57222a; color:#ff8585; border-radius:9px; font-weight:800; padding:8px 13px; min-height:44px; }
  /* Performance strip */
  .dmstrip{ display:flex; align-items:center; gap:8px; padding:8px 10px calc(8px + env(safe-area-inset-bottom)); border-top:1px solid #262b36; }
  .dmpanic{ flex:none; background:var(--danger); color:#fff; border:none; border-radius:12px; font-weight:900; font-size:15px; padding:12px 16px; min-height:52px; letter-spacing:.02em; }
  .dmpanic:active{ transform:scale(.97); }
  .dmvol{ flex:1 1 auto; min-width:0; display:flex; align-items:center; gap:7px; }
  .dmvol span{ font-size:11px; font-weight:800; letter-spacing:.05em; text-transform:uppercase; color:var(--muted); flex:none; }
  .dmvol input[type="range"]{ flex:1 1 auto; min-width:0; width:auto; }
  .dmvol #dmVolVal{ min-width:36px; text-align:right; font-variant-numeric:tabular-nums; }
  .dmbtn{ flex:none; border:1px solid #3a4152; background:#171a21; color:#fff; border-radius:11px; font-weight:800; font-size:13.5px; padding:10px 13px; min-height:52px; }
  @media (max-width:560px){
    .dmpanic{ font-size:13px; padding:11px 11px; }
    .dmbtn{ padding:9px 9px; font-size:12.5px; }
    .dmvol span.lbl{ display:none; }
  }
  /* Lock mode: hide Exit + secondary strip controls; PANIC, grid, page nav, lock stay */
  body.dm-locked .exitfs{ display:none !important; }
  body.dm-locked .dm-hide-lock{ display:none !important; }
  /* Quick Search overlay */
  .qsoverlay{ position:fixed; inset:0; z-index:130; background:rgba(4,5,8,.98); display:none; flex-direction:column; padding:calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
  .qsoverlay.open{ display:flex; }
  .qsbar{ display:flex; gap:8px; align-items:center; flex:none; }
  .qsbar input{ flex:1 1 auto; min-width:0; font-size:18px; background:#171a21; color:#fff; border:1px solid #3a4152; border-radius:12px; padding:13px 14px; min-height:54px; }
  .qsbar input:focus{ outline:2px solid var(--accent); outline-offset:-1px; }
  .qsclose{ flex:none; background:#171a21; color:#fff; border:1px solid #3a4152; border-radius:12px; font-weight:800; padding:12px 14px; min-height:54px; }
  .qsmeta{ flex:none; font-size:13px; color:var(--muted); line-height:1.5; padding:10px 2px 6px; }
  .qslist{ flex:1 1 auto; min-height:0; overflow-y:auto; display:flex; flex-direction:column; gap:7px; }
  .qsrow{ display:flex; align-items:center; gap:10px; text-align:left; background:#171a21; border:1px solid #262b36; border-radius:12px; padding:12px; color:#fff; min-height:56px; width:100%; }
  .qsrow:hover{ border-color:var(--accent); }
  .qsrow .qsnm{ flex:1 1 auto; min-width:0; font-weight:800; font-size:15px; overflow-wrap:break-word; }
  .qsrow .qsplay{ flex:none; color:var(--accent); font-weight:900; font-size:13px; }
  .qsempty{ font-size:14px; color:var(--muted); text-align:center; padding:22px 8px; line-height:1.6; }

  /* ================= ĐỢT VÁ LỖI XÁC NHẬN (FIX 2 + FIX 6) ================= */
  /* FIX 2 — Badge phím tắt / LOOP không đè chữ: chừa khoảng trên cho badge khi
     ô có badge, badge nhỏ lại; nhãn TUYỆT ĐỐI không vỡ giữa từ (overflow-wrap:
     normal) — chữ tự thu nhỏ theo độ dài; chỉ từ đơn dài >12 ký tự (không thể
     vừa một dòng ở bất kỳ cỡ nào) mới được bẻ bất đắc dĩ qua class .anyw. */
  .cell .nm{ word-break:normal; overflow-wrap:normal; }
  .cell .nm.anyw{ overflow-wrap:anywhere; }
  .cell.hashk, .cell.hasloop{ padding-top:26px; }
  .cell .hk{ max-width:calc(100% - 12px); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  @media (max-width:560px){
    .cell.hashk, .cell.hasloop{ padding-top:19px; }
    .cell .hk{ font-size:9px; padding:0 3px; }
    .cell .loopbadge{ font-size:8px; padding:0 3px; }
    /* Ô hẹp 5 cột: thu chữ thêm để nhãn dài nằm trọn 2–3 dòng nguyên từ trong ô */
    .cell .nm{ font-size:10.5px; line-height:1.18; }
    .cell .nm.long{ font-size:9.5px; }
    .cell .nm.xlong{ font-size:8.5px; }
  }
  /* Thanh điều khiển dính ở đáy (mobilebar) không được che mất control khi
     trình duyệt cuộn control đó vào tầm nhìn */
  @media (max-width:768px){
    button, input, select, textarea, [tabindex]{ scroll-margin-bottom:calc(92px + env(safe-area-inset-bottom)); }
    /* Mobilebar chỉ trượt vào SAU khi người dùng cuộn xuống (>120px): ở đầu
       trang nó nằm hẳn ngoài khung hình nên không phủ lên bất kỳ control nào
       ở cuối màn hình đầu (vd ô tìm kiếm thư viện). */
    .mobilebar{ transform:translateY(calc(100% + 6px)); transition:transform .25s ease; }
    .mobilebar.mb-on{ transform:none; }
  }
  /* FIX 6 (desktop) — Thanh trạng thái sticky ở đáy không được che control:
     đợt vá trước chỉ chừa khoảng chống che cho mobile ≤768px (nơi statusbar
     đã chuyển static), còn desktop statusbar vẫn sticky bottom:0 nên control
     nào cuộn tới vệt đáy viewport (vd nút Preview của hàng thư viện) bị nó
     phủ lên, không bấm được. Bổ sung khoảng chừa tương đương cho desktop:
     scroll-margin cho mọi control + scroll-padding cho trang và cho các
     vùng cuộn độc lập (rail ≥1200px, danh sách thư viện / Quick Search). */
  @media (min-width:769px){
    html{ scroll-padding-bottom:96px; }
    button, input, select, textarea, [tabindex]{ scroll-margin-bottom:96px; }
    .rail{ scroll-padding-bottom:96px; }
    .liblist, .qslist{ scroll-padding-bottom:24px; }
  }
  /* FIX 6 — Sheet / Quick Search đã đóng: ngoài tầm tab + cây accessibility */
  .sheet{ visibility:hidden; transition:transform .22s ease, visibility 0s linear .22s; }
  .sheet.open{ visibility:visible; transition:transform .22s ease, visibility 0s; }
  .qsoverlay{ visibility:hidden; }
  .qsoverlay.open{ visibility:visible; }
  /* FIX 6 — span.tag ở status bar không bao giờ che input của các thanh đáy */
  .statusbar .tag{ pointer-events:none; }
  .mobilebar{ z-index:60; }
  .mobilebar input[type="range"], .dmvol input[type="range"]{ position:relative; z-index:2; }
  /* Random editor: chip sound đã chọn */
  .randchip{ display:inline-flex; align-items:center; gap:6px; background:var(--panel); border:1px solid var(--accent); border-radius:999px; padding:3px 6px 3px 11px; font-size:12.5px; font-weight:700; margin:0 6px 6px 0; max-width:100%; }
  .randchip button{ flex:none; width:26px; height:26px; min-height:26px; border-radius:50%; border:1px solid var(--line); background:var(--panel-2); color:#ff8585; font-weight:800; padding:0; display:grid; place-items:center; }

  /* ================= PiP MODE (Document Picture-in-Picture + fallback panel) ================= */
  .fsbtn.on{ box-shadow:0 0 0 2px var(--bg), 0 0 0 4px var(--accent-ink); }
  .piproot{ display:none; flex-direction:column; background:var(--bg); color:var(--text); min-height:0; container-type:inline-size; container-name:pipdeck; }
  .piproot.open{ display:flex; }
  /* Inside the real PiP window: fill the whole floating window */
  .piproot.inwin{ height:100dvh; width:100%; }
  /* Fallback: floating panel inside the page — drag the bottom-right corner to resize it */
  .piproot.float{ position:fixed; right:12px; bottom:calc(84px + env(safe-area-inset-bottom)); z-index:120; width:min(430px, calc(100vw - 24px)); height:min(580px, 74dvh); min-width:260px; min-height:320px; max-width:calc(100vw - 16px); max-height:94dvh; resize:both; background:var(--panel); border:1px solid var(--line); border-radius:16px; box-shadow:0 18px 48px rgba(0,0,0,.5); overflow:hidden; }
  .piproot.float::after{ content:""; position:absolute; right:3px; bottom:3px; width:15px; height:15px; pointer-events:none; background:linear-gradient(135deg, transparent 50%, var(--faint) 50%, var(--faint) 58%, transparent 58%, transparent 68%, var(--faint) 68%, var(--faint) 76%, transparent 76%); opacity:.8; }
  @media (max-width:560px){ .piproot.float{ right:8px; width:calc(100vw - 16px); } }
  .piphead{ display:flex; align-items:center; gap:8px; padding:7px 10px; background:var(--panel); border-bottom:1px solid var(--line); flex:none; }
  .piproot.inwin .piphead{ background:var(--panel-2); }
  .piphead .piptitle{ font-weight:800; font-size:13.5px; flex:1 1 auto; min-width:0; display:flex; align-items:center; gap:6px; }
  .piphead .piptitletxt{ min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .piproot.float .piphead{ cursor:grab; touch-action:none; }
  .piproot.float .piphead:active{ cursor:grabbing; }
  .pipclose{ flex:none; width:34px; height:34px; min-height:34px; border-radius:9px; border:1px solid var(--line); background:var(--panel-2); color:var(--text); font-weight:800; display:grid; place-items:center; padding:0; }
  .pipclose:hover{ border-color:var(--danger); color:#ff8585; }
  .pipnav{ display:flex; align-items:center; gap:10px; padding:8px 10px 4px; flex:none; }
  .pipnav .dmnavbtn{ width:46px; height:44px; min-height:44px; }
  .pipdeck{ flex:1 1 auto; min-height:0; display:grid; gap:8px; padding:6px 10px 10px; grid-auto-rows:minmax(0,1fr); }
  .pipdeck .cell{ aspect-ratio:auto; height:100%; min-height:0; }
  .piproot .dmnow{ margin:0 10px 8px; flex:none; }
  .piproot{ position:relative; }
  .piproot .dmstrip{ flex:none; flex-wrap:wrap; border-top:1px solid var(--line); padding:8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .piproot .dmpanic{ min-height:48px; padding:10px 13px; }
  .piproot .dmbtn{ min-height:48px; }
  .piproot .dmbtn:disabled{ opacity:.45; cursor:not-allowed; }
  .piproot .dmbtn.on{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
  /* PiP Recent row: collapsed by default, costs no space until toggled */
  .piproot .piprecent{ flex:none; border-top:1px solid var(--line); padding:2px 10px 0; }
  .piproot .piprecent .dmchips{ padding-bottom:5px; }
  /* PiP Quick Search: overlay covering the PiP root itself (never the main page) */
  .pipqs{ position:absolute; inset:0; z-index:6; background:var(--bg); display:none; flex-direction:column; padding:10px; }
  .pipqs.open{ display:flex; }
  body.deckonly .piproot.float{ display:none !important; }
  /* ---- Responsive PiP: keys + controls adapt to the PiP window's own width.
     Container queries on .piproot (container-type: inline-size) so the SAME
     rules drive the real Document PiP window (resized by dragging its edges)
     and the in-page fallback panel (resized by its corner). The chosen deck
     layout (3×2 / 5×3 / 8×4) never changes — only size and density do — and
     the grid is minmax(0,1fr) with min-height:0 rows, so no horizontal
     scrollbar and no overlap appears at any window size. ---- */
  @container pipdeck (max-width:400px){
    .piphead{ padding:5px 8px; }
    .piphead .piptitle{ font-size:12.5px; }
    .pipclose{ width:32px; height:32px; min-height:32px; }
    .pipnav{ gap:6px; padding:6px 6px 2px; }
    .pipnav .dmnavbtn{ width:40px; height:40px; min-height:40px; font-size:16px; }
    .pipnav .dmpagename{ font-size:14px; }
    .pipnav .dmdot{ width:7px; height:7px; }
    .pipdeck{ gap:5px; padding:4px 6px 6px; }
    .pipdeck .cell{ padding:6px 3px 5px; border-radius:10px; }
    .pipdeck .cell .nm{ font-size:10.5px; line-height:1.18; }
    .pipdeck .cell .nm.long{ font-size:9.5px; }
    .pipdeck .cell .nm.xlong{ font-size:8.5px; }
    .pipdeck .cell.hashk, .pipdeck .cell.hasloop{ padding-top:19px; }
    .piproot .dmnow{ margin:0 6px 6px; padding:7px 9px; gap:7px; }
    .piproot .dmnowname{ font-size:13.5px; }
    .piproot .dmnowtime{ display:none; }
    .piproot .dmnowstop{ padding:6px 9px; min-height:40px; }
    .piproot .dmstrip{ gap:5px; padding:6px 8px calc(6px + env(safe-area-inset-bottom)); }
    .piproot .dmpanic{ min-height:44px; padding:8px 9px; font-size:12.5px; }
    .piproot .dmbtn{ min-height:44px; padding:8px; font-size:12px; }
    .piproot .dmvol{ gap:5px; }
    .piproot .dmvol .lbl{ display:none; }
    .piproot .dmvol input[type="range"]{ min-width:38px; }
    .piproot .piprecent{ padding:2px 6px 0; }
    .piproot .dmchip{ min-height:36px; padding:6px 10px; font-size:12px; max-width:62vw; }
    .pipqs{ padding:7px; }
    .pipqs .qsbar input{ font-size:15px; padding:10px 11px; min-height:46px; }
    .pipqs .qsclose{ padding:9px 10px; min-height:46px; }
    .pipqs .qsmeta{ padding:7px 2px 4px; font-size:12px; }
    .pipqs .qsrow{ padding:9px; min-height:48px; gap:7px; }
    .pipqs .qsrow .qsnm{ font-size:13.5px; }
  }
  @container pipdeck (max-width:300px){
    .pipdeck{ gap:4px; padding:3px 5px 5px; }
    .pipdeck .cell{ padding:5px 2px 4px; border-radius:9px; }
    .pipdeck .cell .nm{ font-size:9.5px; }
    .pipdeck .cell .nm.long{ font-size:8.5px; }
    .pipdeck .cell .nm.xlong{ font-size:8px; }
    .piproot .dmpanic{ font-size:11.5px; padding:8px 7px; }
    .piproot .dmbtn{ font-size:11px; padding:7px 6px; }
    .piproot .dmvol #pipVolVal{ display:none; }
    .pipnav .dmdots{ display:none; }
    .pipqs .qsrow .catchip, .pipqs .qsrow .playsbadge{ display:none; }
    .pipqs .qsclose{ font-size:12px; padding:8px; }
  }
  @container pipdeck (min-width:580px){
    .pipnav{ padding:10px 14px 4px; }
    .pipdeck{ gap:11px; padding:8px 14px 14px; }
    .pipdeck .cell{ border-radius:18px; }
    .pipdeck .cell .nm{ font-size:15px; }
    .pipdeck .cell .nm.long{ font-size:13px; }
    .pipdeck .cell .nm.xlong{ font-size:11.5px; }
    .piproot .dmnow{ margin:0 14px 10px; }
    .piproot .dmstrip{ gap:10px; padding:10px 14px calc(10px + env(safe-area-inset-bottom)); }
  }
  @container pipdeck (min-width:840px){
    /* Very wide: cap the grid so keys stop growing and stay centered */
    .pipdeck{ width:min(100%, 880px); margin-inline:auto; }
    .pipnav{ width:min(100%, 880px); margin-inline:auto; }
    .piproot .dmnow{ width:min(calc(100% - 28px), 852px); margin-inline:auto; }
    .piproot .dmstrip{ justify-content:center; }
    .piproot .dmvol{ max-width:440px; }
    .pipdeck .cell .nm{ font-size:16px; }
    .pipdeck .cell .nm.long{ font-size:14px; }
    .pipdeck .cell .nm.xlong{ font-size:12.5px; }
  }
  /* Short PiP windows (viewport height of the PiP window itself): compact
     chrome so the key grid keeps the room. Grid rows already flex via
     minmax(0,1fr), so keys shrink instead of overlapping. */
  @media (max-height:430px){
    .piproot.inwin .piphead{ padding-top:4px; padding-bottom:4px; }
    .piproot.inwin .pipnav{ padding-top:4px; padding-bottom:0; }
    .piproot.inwin .pipnav .dmnavbtn{ width:42px; height:38px; min-height:38px; }
    .piproot.inwin .pipnav .dmdots{ display:none; }
    .piproot.inwin .dmstrip{ padding-top:5px; padding-bottom:calc(5px + env(safe-area-inset-bottom)); }
    .piproot.inwin .dmpanic{ min-height:42px; padding:8px 11px; }
    .piproot.inwin .dmbtn{ min-height:42px; }
  }

/* v0.2.0 UX: brand-safe workspace, fast searchable Key Assignment */
.sbpsp-workspace{display:flex;align-items:center;gap:7px;flex-wrap:wrap;padding:9px 12px;background:var(--panel);border-bottom:1px solid var(--line)}
.sbpsp-workspace .sbpsp-work-label{font-weight:900;font-size:13px;white-space:nowrap;color:var(--text)}
.sbpsp-workspace select,.sbpsp-workspace button{background:var(--panel-2);border:1px solid var(--line);color:var(--text);border-radius:9px;padding:7px 10px;min-height:42px;font-weight:750;font-size:12.5px}
.sbpsp-workspace select{width:min(245px,100%);flex:0 1 245px}
.sbpsp-workspace button:hover{border-color:var(--accent)}
.sbpsp-workspace button:disabled{opacity:.4;cursor:not-allowed}
.sbpsp-work-spacer{flex:1}
.sbpsp-qa-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.72);z-index:107}
.sbpsp-qa{position:fixed;inset:5vh auto auto 50%;transform:translateX(-50%);height:min(90dvh,770px);width:min(760px,calc(100vw - 24px));display:flex;flex-direction:column;z-index:108;border-radius:18px;background:var(--panel);color:var(--text);border:1px solid var(--line);box-shadow:0 24px 90px #000b;overflow:hidden}
.sbpsp-qa[hidden],.sbpsp-qa-backdrop[hidden]{display:none!important}
.sbpsp-qa-head{display:flex;justify-content:space-between;gap:14px;padding:18px 19px 12px;border-bottom:1px solid var(--line)}
.sbpsp-qa-head h2{margin:4px 0 2px;font-size:20px}.sbpsp-qa-head p{margin:0;color:var(--muted);font-size:12px}.sbpsp-qa-kicker{font-size:10px;font-weight:900;letter-spacing:.14em;color:var(--accent)}
.sbpsp-qa-head button{border:1px solid var(--line);background:var(--panel-2);border-radius:9px;min-width:42px;min-height:42px}
.sbpsp-qa-filters{display:grid;grid-template-columns:minmax(0,1fr) 155px 125px;gap:8px;padding:13px 18px}
.sbpsp-qa-filters input,.sbpsp-qa-filters select{border:1px solid var(--line);background:var(--panel-2);border-radius:9px;padding:10px;color:var(--text);min-height:44px;width:100%;min-width:0;font-size:14px}
.sbpsp-qa-search-wrap{position:relative;min-width:0}.sbpsp-qa-search-wrap span{position:absolute;left:11px;top:7px;font-size:23px;color:var(--muted)}.sbpsp-qa-search-wrap input{padding-left:36px}
.sbpsp-qa-info{padding:0 18px 8px;font-size:12px;color:var(--muted)}
.sbpsp-qa-results{padding:0 18px 12px;overflow:auto;flex:1;display:flex;flex-direction:column;gap:7px}
.sbpsp-qa-row{display:grid;grid-template-columns:42px minmax(0,1fr) 48px 86px;align-items:center;gap:9px;border:1px solid var(--line);border-radius:12px;padding:9px;background:var(--panel-2);min-width:0}
.sbpsp-qa-swatch{width:38px;height:38px;border-radius:10px;display:grid;place-items:center;font-size:19px;color:white}
.sbpsp-qa-title{font-size:13px;font-weight:800;overflow-wrap:anywhere;line-height:1.25}
.sbpsp-qa-sub{font-size:11px;color:var(--muted);margin-top:4px}
.sbpsp-qa-row button{border:1px solid var(--line);min-height:40px;border-radius:8px;background:var(--panel);font-weight:800;font-size:13px}
.sbpsp-qa-row .sbpsp-qa-add{background:var(--accent);border-color:var(--accent);color:var(--accent-ink);font-weight:900}
.sbpsp-qa-row button:hover{filter:brightness(1.10)}
.sbpsp-qa-foot{padding:10px 18px;border-top:1px solid var(--line);display:flex;align-items:center;gap:10px;justify-content:space-between;flex-wrap:wrap;font-size:12px;color:var(--muted)}
.sbpsp-qa-foot button{border:1px solid var(--accent);background:transparent;color:var(--accent);padding:8px 12px;border-radius:8px;font-weight:800}
body.sbpsp-qa-open{overflow:hidden}
body.sbpsp-qa-open .app{pointer-events:none}
body.sbpsp-qa-open .sbpsp-qa,body.sbpsp-qa-open .sbpsp-qa-backdrop{pointer-events:auto}
.cell.empty .nm{font-size:11px}.cell.empty .plus{font-size:26px;color:var(--accent)}
@media(max-width:768px){.sbpsp-workspace{padding:8px;gap:6px}.sbpsp-workspace .sbpsp-work-label{flex:1 1 100%}.sbpsp-workspace select{flex:1 1 100%;width:100%}.sbpsp-work-spacer{display:none}.sbpsp-qa{inset:auto 0 0;width:100%;max-width:100%;height:min(88dvh,850px);transform:none;border-radius:17px 17px 0 0}.sbpsp-qa-filters{grid-template-columns:minmax(0,1fr) 1fr;padding:10px;gap:6px}.sbpsp-qa-search-wrap{grid-column:1/-1}.sbpsp-qa-results{padding:0 10px 10px}.sbpsp-qa-row{grid-template-columns:36px minmax(0,1fr) 42px 70px;gap:5px;padding:7px}.sbpsp-qa-swatch{width:34px;height:34px}.sbpsp-qa-head{padding:12px}.sbpsp-qa-row .sbpsp-qa-add{font-size:12px}.sbpsp-qa-foot{padding:9px 11px}}

/* Theme compatibility: desktop + embedded tool default to SoundButtonsPro dark neon.
   Only the Original Light preference opts into the light palette. */
:root{--bg:#080a19;--panel:#11162b;--panel-2:#171b33;--line:#303754;--text:#f5f6ff;--muted:#abb7d4;--faint:#8b9ab5;--accent:#9561ff;--accent-ink:#fff;--danger:#ff5575;--ok:#34dba3}
:root.sbpsp-original-light{--bg:#f5f7ff;--panel:#fff;--panel-2:#ecf0fa;--line:#d5dced;--text:#18223a;--muted:#5a647a;--faint:#808aa3;--accent:#6e42d9;--accent-ink:#fff;--danger:#c63453;--ok:#087f91}
.sbpsp-workspace .sbpsp-profile-actions{display:flex;gap:7px;align-items:center;flex-wrap:wrap;flex:1 1 auto}
.sbpsp-workspace #sbpspManage{display:none}
.sbpsp-workspace .sbpsp-work-spacer{flex:1 1 auto}
@media(max-width:768px){
 .sbpsp-workspace{gap:7px;flex-wrap:wrap}
 .sbpsp-workspace .sbpsp-work-label{flex:0 0 auto;font-size:12px}
 .sbpsp-workspace select{flex:1 1 100px;min-width:100px;max-width:none;width:auto}
 .sbpsp-workspace #sbpspManage{display:block;flex:0 0 auto;min-height:38px}
 .sbpsp-workspace .sbpsp-profile-actions{display:none;flex:1 1 100%;padding-top:4px}
 .sbpsp-workspace .sbpsp-profile-actions.sbpsp-show-tools{display:flex}
 .toolbar .pipbtn{display:none}
}
@media(max-width:375px){.sbpsp-workspace .sbpsp-work-label{flex:1 1 100%}.sbpsp-workspace select{flex:1 1 auto}}
