 :root {
      color-scheme: dark;
      --bg: #0b0e15;
      --surface: rgba(23, 29, 42, 0.92);
      --surface-2: rgba(30, 38, 55, 0.92);
      --line: rgba(255, 255, 255, 0.09);
      --text: #f6f8fc;
      --muted: #9da8ba;
      --accent: #6ee7ff;
      --danger: #ff546d;
      --success: #42e6a4;
      --warning: #ffc95f;
      --radius: 24px;
      --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
    }

    * {
      box-sizing: border-box;
    }

    [hidden] {
      display: none !important;
    }

    html {
      min-width: 320px;
      background: var(--bg);
    }

    body {
      min-height: 100vh;
      margin: 0;
      color: var(--text);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background:
        radial-gradient(circle at 12% -10%, rgba(89, 219, 255, 0.15), transparent 32%),
        radial-gradient(circle at 94% 8%, rgba(255, 80, 136, 0.13), transparent 28%),
        linear-gradient(160deg, #090c12 0%, #111726 52%, #090c12 100%);
    }

    button,
    input,
    select {
      font: inherit;
    }

    button {
      color: inherit;
    }

    .app-shell {
      width: min(1380px, calc(100% - 18px));
      margin: 0 auto;
      padding: 8px 0 18px;
    }

    .topbar {
      position: sticky;
      top: 8px;
      z-index: 20;
      display: grid;
      grid-template-columns: minmax(220px, .95fr) minmax(320px, 1.15fr) auto;
      gap: 7px;
      align-items: center;
      padding: 9px 10px;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: rgba(14, 18, 27, 0.84);
      box-shadow: var(--shadow);
      backdrop-filter: blur(22px);
    }

    .brand {
      min-width: 0;
    }

    .brand-kicker {
      display: block;
      margin-bottom: 2px;
      color: var(--accent);
      font-size: 0.66rem;
      font-weight: 800;
      letter-spacing: 0.15em;
      text-transform: uppercase;
    }

    .brand h1 {
      overflow: hidden;
      margin: 0;
      font-size: clamp(1.03rem, 1.45vw, 1.42rem);
      line-height: 1.15;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .master-controls {
      display: grid;
      grid-template-columns: minmax(168px, 1fr) minmax(148px, .84fr);
      gap: 7px;
      min-width: 0;
    }

    .control-box {
      min-width: 0;
      padding: 6px 9px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.035);
    }

    .control-row {
      display: flex;
      gap: 10px;
      align-items: center;
      justify-content: space-between;
    }

    .control-label {
      color: var(--muted);
      font-size: 0.73rem;
      font-weight: 700;
    }

    .volume-value {
      color: var(--text);
      font-variant-numeric: tabular-nums;
      font-size: 0.69rem;
      font-weight: 800;
    }

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

    .now-playing {
      overflow: hidden;
      margin-top: 3px;
      color: var(--text);
      font-size: 0.8rem;
      font-weight: 750;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .toolbar-actions {
      display: flex;
      gap: 7px;
      align-items: center;
      justify-content: flex-end;
      flex-wrap: wrap;
    }

    .action-btn {
      min-height: 36px;
      padding: 0 12px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.055);
      box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
      font-size: 0.75rem;
      font-weight: 800;
      cursor: pointer;
      transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
    }

    .action-btn:hover {
      transform: translateY(-2px);
      border-color: rgba(255, 255, 255, 0.2);
      background: rgba(255, 255, 255, 0.095);
    }

    .action-btn:active {
      transform: translateY(0);
    }

    .action-btn.stop {
      border-color: rgba(255, 84, 109, 0.32);
      background: linear-gradient(180deg, rgba(255, 84, 109, 0.24), rgba(255, 84, 109, 0.1));
      color: #ffdce2;
    }

    .action-btn.stop:hover {
      border-color: rgba(255, 84, 109, 0.65);
      background: linear-gradient(180deg, rgba(255, 84, 109, 0.36), rgba(255, 84, 109, 0.14));
    }

    .secondary-bar {
      display: grid;
      grid-template-columns: minmax(220px, 1fr) auto;
      gap: 7px;
      margin: 10px 0;
      align-items: center;
    }

    .search-wrap {
      position: relative;
    }

    .search-wrap::before {
      position: absolute;
      top: 50%;
      left: 15px;
      content: "⌕";
      color: var(--muted);
      font-size: 1.35rem;
      transform: translateY(-54%);
      pointer-events: none;
    }

    .search-input {
      width: 100%;
      min-height: 42px;
      padding: 0 14px 0 39px;
      border: 1px solid var(--line);
      border-radius: 15px;
      outline: none;
      background: rgba(255, 255, 255, 0.05);
      color: var(--text);
      box-shadow: 0 14px 28px rgba(0, 0, 0, 0.12);
      transition: border-color 150ms ease, box-shadow 150ms ease;
    }

    .search-input:focus {
      border-color: rgba(110, 231, 255, 0.55);
      box-shadow: 0 0 0 4px rgba(110, 231, 255, 0.08);
    }

    .mode-toggle {
      display: flex;
      gap: 10px;
      align-items: center;
      min-height: 42px;
      padding: 0 12px;
      border: 1px solid var(--line);
      border-radius: 15px;
      background: rgba(255, 255, 255, 0.04);
      color: var(--muted);
      font-size: 0.84rem;
      font-weight: 750;
      cursor: pointer;
      user-select: none;
    }

    .mode-toggle input {
      width: 16px;
      height: 16px;
      accent-color: var(--accent);
    }

    .zones {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      align-items: start;
    }

    .zone {
      overflow: hidden;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: linear-gradient(180deg, rgba(31, 39, 57, 0.9), rgba(18, 23, 34, 0.92));
      box-shadow: var(--shadow);
    }

    .zone-header {
      display: flex;
      gap: 10px;
      align-items: center;
      justify-content: space-between;
      padding: 11px 13px;
      border-bottom: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.024);
    }

    .zone-title-wrap {
      min-width: 0;
    }

    .zone-title {
      margin: 0;
      font-size: 0.92rem;
      line-height: 1.2;
    }

    .zone-description {
      margin: 3px 0 0;
      color: var(--muted);
      font-size: 0.7rem;
    }

    .zone-count {
      flex: 0 0 auto;
      padding: 4px 8px;
      border: 1px solid var(--line);
      border-radius: 999px;
      color: var(--muted);
      background: rgba(255, 255, 255, 0.04);
      font-size: 0.76rem;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
    }

    .sound-grid {
      display: grid;
      align-items: stretch;
      grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
      gap: 7px;
      padding: 9px;
    }

    .sound-card {
      --button-hue: 350;
      position: relative;
      display: flex;
      min-width: 0;
      min-height: 112px;
      padding: 7px 4px 6px;
      border: 1px solid rgba(255, 255, 255, 0.07);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.025);
      transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
    }

    .sound-card:hover {
      transform: translateY(-2px);
      border-color: hsla(var(--button-hue), 85%, 67%, 0.35);
      background: hsla(var(--button-hue), 70%, 55%, 0.055);
    }

    .sound-card.is-playing {
      border-color: hsla(var(--button-hue), 90%, 70%, 0.62);
      background: hsla(var(--button-hue), 80%, 55%, 0.105);
      box-shadow: inset 0 0 0 1px hsla(var(--button-hue), 90%, 72%, 0.12), 0 7px 18px hsla(var(--button-hue), 90%, 45%, 0.11);
    }

    .sound-card.is-hidden {
      display: none;
    }

    .sound-button {
      display: flex;
      gap: 0;
      flex: 1;
      min-width: 0;
      padding: 0;
      border: 0;
      outline: none;
      background: transparent;
      cursor: pointer;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
    }

    .sound-button:focus-visible .button-disc {
      box-shadow:
        0 0 0 3px rgba(110, 231, 255, 0.30),
        0 6px 0 hsl(var(--button-hue) 60% 29%),
        0 9px 14px rgba(0, 0, 0, 0.32),
        inset 0 5px 9px rgba(255, 255, 255, 0.24),
        inset 0 -7px 10px rgba(0, 0, 0, 0.26);
    }

    .button-disc {
      position: relative;
      width: clamp(52px, 4.4vw, 62px);
      height: clamp(52px, 4.4vw, 62px);
      margin: 1px auto 8px;
      border: 4px solid hsl(var(--button-hue) 62% 37%);
      border-radius: 50%;
      background:
        radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.6) 0 8%, transparent 10%),
        radial-gradient(circle at 50% 36%, hsl(var(--button-hue) 98% 64%) 0 24%, hsl(var(--button-hue) 88% 51%) 52%, hsl(var(--button-hue) 76% 38%) 100%);
      box-shadow:
        0 6px 0 hsl(var(--button-hue) 60% 29%),
        0 9px 14px rgba(0, 0, 0, 0.32),
        inset 0 5px 9px rgba(255, 255, 255, 0.24),
        inset 0 -7px 10px rgba(0, 0, 0, 0.26);
      transition: transform 90ms ease, box-shadow 90ms ease, filter 130ms ease;
    }

    .button-disc::before {
      position: absolute;
      inset: 7px 9px auto;
      height: 13px;
      border-radius: 50%;
      content: "";
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0));
      filter: blur(0.2px);
    }

    .button-disc::after {
      position: absolute;
      right: 7px;
      bottom: 5px;
      width: 11px;
      height: 7px;
      border-radius: 50%;
      content: "";
      background: rgba(0, 0, 0, 0.18);
      filter: blur(2px);
      transform: rotate(-23deg);
    }

    .sound-button:hover .button-disc {
      filter: saturate(1.08) brightness(1.06);
      transform: translateY(-1px);
    }

    .sound-button:active .button-disc,
    .sound-card.is-playing .button-disc {
      transform: translateY(5px) scale(0.98);
      box-shadow:
        0 2px 0 hsl(var(--button-hue) 60% 27%),
        0 5px 9px rgba(0, 0, 0, 0.30),
        inset 0 5px 9px rgba(255, 255, 255, 0.2),
        inset 0 -6px 9px rgba(0, 0, 0, 0.27);
    }

    .sound-name {
      display: -webkit-box;
      overflow: hidden;
      min-height: 2.2em;
      color: var(--text);
      font-size: clamp(0.64rem, 0.9vw, 0.73rem);
      font-weight: 800;
      line-height: 1.22;
      text-align: center;
      text-overflow: ellipsis;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }

    .sound-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 3px;
      align-items: center;
      justify-content: center;
      margin-top: 4px;
      color: var(--muted);
      font-size: 0.57rem;
      font-weight: 750;
    }

    .key-badge,
    .url-badge {
      display: inline-flex;
      min-height: 17px;
      padding: 1px 5px;
      border: 1px solid var(--line);
      border-radius: 999px;
      align-items: center;
      justify-content: center;
      background: rgba(255, 255, 255, 0.04);
      white-space: nowrap;
    }

    .url-badge.is-ready {
      color: var(--success);
      border-color: rgba(66, 230, 164, 0.24);
      background: rgba(66, 230, 164, 0.07);
    }

    .url-badge.is-empty {
      color: var(--warning);
      border-color: rgba(255, 201, 95, 0.24);
      background: rgba(255, 201, 95, 0.07);
    }

    .empty-search {
      display: none;
      padding: 40px 20px 46px;
      color: var(--muted);
      text-align: center;
    }

    .empty-search.is-visible {
      display: block;
    }

    .footer-note {
      display: flex;
      gap: 10px;
      align-items: center;
      justify-content: center;
      margin-top: 18px;
      color: var(--muted);
      font-size: 0.76rem;
      text-align: center;
    }

    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--success);
      box-shadow: 0 0 16px rgba(66, 230, 164, 0.72);
    }

    .toast-stack {
      position: fixed;
      right: 20px;
      bottom: 20px;
      z-index: 50;
      display: grid;
      width: min(390px, calc(100vw - 40px));
      gap: 10px;
      pointer-events: none;
    }

    .toast {
      padding: 11px 13px;
      border: 1px solid var(--line);
      border-radius: 15px;
      background: rgba(18, 23, 34, 0.96);
      box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
      color: var(--text);
      font-size: 0.82rem;
      font-weight: 700;
      animation: toast-in 180ms ease both;
      backdrop-filter: blur(16px);
    }

    .toast.warning {
      border-color: rgba(255, 201, 95, 0.36);
    }

    .toast.error {
      border-color: rgba(255, 84, 109, 0.42);
    }

    @keyframes toast-in {
      from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    @media (max-width: 1180px) {
      .topbar {
        grid-template-columns: 1fr auto;
      }

      .master-controls {
        grid-column: 1 / -1;
        grid-row: 2;
      }

      .sound-grid {
        grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
      }
    }

    @media (max-width: 820px) {
      .app-shell {
        width: min(100% - 12px, 800px);
        padding-top: 6px;
      }

      .topbar {
        top: 4px;
        grid-template-columns: 1fr;
        gap: 7px;
      }

      .toolbar-actions {
        justify-content: stretch;
      }

      .toolbar-actions .action-btn {
        flex: 1;
      }

      .master-controls {
        grid-column: auto;
        grid-row: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .secondary-bar {
        grid-template-columns: minmax(0, 1fr) auto;
      }

      .zones {
        grid-template-columns: 1fr;
      }

      .sound-grid {
        grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
      }
    }

    @media (max-width: 580px) {
      .brand-kicker {
        letter-spacing: .10em;
      }

      .master-controls,
      .secondary-bar {
        grid-template-columns: 1fr;
      }

      .sound-grid {
        grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
        gap: 6px;
        padding: 7px;
      }

      .sound-card {
        min-height: 104px;
        padding: 7px 4px 6px;
      }

      .button-disc {
        width: clamp(48px, 17vw, 58px);
        height: clamp(48px, 17vw, 58px);
      }

      .zone-header {
        padding: 10px 11px;
      }

      .footer-note {
        padding: 0 8px;
      }
    }

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


    .mode-badge {
      display: inline-flex;
      min-height: 34px;
      padding: 0 12px;
      border: 1px solid var(--line);
      border-radius: 999px;
      align-items: center;
      gap: 7px;
      background: rgba(255, 255, 255, 0.045);
      color: var(--muted);
      font-size: 0.75rem;
      font-weight: 850;
      white-space: nowrap;
    }

    .mode-badge::before {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      content: "";
      background: var(--success);
      box-shadow: 0 0 14px rgba(66, 230, 164, 0.62);
    }

    .mode-badge.admin {
      color: #ffe1a6;
      border-color: rgba(255, 201, 95, 0.34);
      background: rgba(255, 201, 95, 0.08);
    }

    .mode-badge.admin::before {
      background: var(--warning);
      box-shadow: 0 0 14px rgba(255, 201, 95, 0.62);
    }

    .action-btn.add {
      border-color: rgba(66, 230, 164, 0.28);
      background: linear-gradient(180deg, rgba(66, 230, 164, 0.18), rgba(66, 230, 164, 0.07));
      color: #d8fff0;
    }

    .source-note {
      display: block;
      margin-top: 4px;
      color: var(--muted);
      font-size: 0.7rem;
      line-height: 1.35;
    }

    .sound-card.is-custom .sound-name {
      padding-inline: 8px;
    }

    .sound-card.is-empty-source {
      border-style: dashed;
      background: rgba(255, 255, 255, 0.018);
    }

    .sound-card.is-empty-source .button-disc {
      filter: saturate(.55) brightness(.78);
      opacity: .76;
    }

    .sound-delete {
      position: absolute;
      top: 6px;
      right: 6px;
      z-index: 3;
      display: grid;
      width: 24px;
      height: 24px;
      padding: 0;
      border: 1px solid rgba(255, 84, 109, 0.28);
      border-radius: 9px;
      place-items: center;
      background: rgba(255, 84, 109, 0.12);
      color: #ffdce2;
      cursor: pointer;
      opacity: 0.72;
      transition: opacity 140ms ease, transform 140ms ease, background 140ms ease;
    }

    .sound-delete:hover {
      opacity: 1;
      transform: scale(1.05);
      background: rgba(255, 84, 109, 0.22);
    }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      z-index: 100;
      display: none;
      padding: 12px;
      place-items: center;
      background: rgba(3, 6, 12, 0.74);
      backdrop-filter: blur(14px);
    }

    .modal-backdrop.is-open {
      display: grid;
    }

    .sound-modal {
      width: min(660px, 100%);
      max-height: min(760px, calc(100vh - 28px));
      overflow: auto;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 20px;
      background: linear-gradient(180deg, rgba(28, 35, 50, 0.99), rgba(13, 17, 26, 0.99));
      box-shadow: 0 35px 100px rgba(0, 0, 0, 0.58);
    }

    .modal-header {
      display: flex;
      gap: 10px;
      align-items: flex-start;
      justify-content: space-between;
      padding: 15px 17px 12px;
      border-bottom: 1px solid var(--line);
    }

    .modal-header h2 {
      margin: 0;
      font-size: 1.08rem;
    }

    .modal-header p {
      margin: 5px 0 0;
      color: var(--muted);
      font-size: 0.75rem;
      line-height: 1.45;
    }

    .modal-close {
      width: 32px;
      height: 32px;
      border: 1px solid var(--line);
      border-radius: 11px;
      background: rgba(255,255,255,.05);
      color: var(--text);
      cursor: pointer;
    }

    .sound-form {
      display: grid;
      gap: 12px;
      padding: 15px 17px 17px;
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }

    .field {
      display: grid;
      gap: 7px;
      min-width: 0;
    }

    .field.full {
      grid-column: 1 / -1;
    }

    .field label,
    .field-label {
      color: var(--muted);
      font-size: 0.76rem;
      font-weight: 800;
    }

    .text-input,
    .select-input,
    .file-input {
      width: 100%;
      min-height: 40px;
      padding: 0 11px;
      border: 1px solid var(--line);
      border-radius: 12px;
      outline: none;
      background: rgba(255, 255, 255, 0.05);
      color: var(--text);
    }

    .file-input {
      padding: 7px 9px;
    }

    .text-input:focus,
    .select-input:focus,
    .file-input:focus {
      border-color: rgba(110, 231, 255, 0.52);
      box-shadow: 0 0 0 3px rgba(110, 231, 255, 0.08);
    }

    .select-input {
      color-scheme: dark;
      background-color: #202736;
      color: var(--text);
    }

    .select-input option {
      background: #171e2b;
      color: #f6f8fc;
    }

    .select-input option:checked {
      background: #28425a;
      color: #ffffff;
    }

    .field[hidden],
    .mode-badge[hidden] {
      display: none !important;
    }

    .source-switch {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 7px;
      padding: 5px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.035);
    }

    .source-switch label {
      display: flex;
      min-height: 34px;
      padding: 0 10px;
      border-radius: 10px;
      align-items: center;
      justify-content: center;
      gap: 7px;
      color: var(--muted);
      font-size: 0.75rem;
      font-weight: 800;
      cursor: pointer;
    }

    .source-switch label:has(input:checked) {
      background: rgba(110, 231, 255, 0.11);
      color: var(--text);
    }

    .source-switch input {
      accent-color: var(--accent);
    }

    .form-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
      padding-top: 4px;
    }

    .form-actions .action-btn {
      min-width: 112px;
    }

    .admin-warning {
      display: none;
      padding: 11px 13px;
      border: 1px solid rgba(255, 201, 95, 0.28);
      border-radius: 13px;
      background: rgba(255, 201, 95, 0.07);
      color: #ffe9bd;
      font-size: 0.76rem;
      line-height: 1.45;
    }

    .admin-warning.is-visible {
      display: block;
    }

    @media (max-width: 700px) {
      .form-grid {
        grid-template-columns: 1fr;
      }

      .field.full {
        grid-column: auto;
      }

      .form-actions {
        flex-direction: column-reverse;
      }

      .form-actions .action-btn {
        width: 100%;
      }
    

  /* ===== Layout gọn kiểu soundboard, giữ nguyên theme gốc ===== */
    .app-shell {
      width: min(1680px, calc(100% - 32px));
      margin: 0 auto;
      padding: 22px 0 36px;
    }

    .topbar {
      position: sticky;
      top: 2px;
      z-index: 20;
      display: grid;
      box-sizing: border-box;
      gap: 2px;
      align-items: center;
      padding: 4px 8px;
      border: 1px solid var(--line);
      border-radius: 22px;
      background: rgba(14, 18, 27, 0.84);
      box-shadow: var(--shadow);
      backdrop-filter: blur(22px);
    }

    .brand {
      min-width: 0;
    }

    .brand-kicker {
      display: block;
      margin-bottom: 3px;
      color: var(--accent);
      font-size: 0.75rem;
      font-weight: 800;
      letter-spacing: 0.15em;
      text-transform: uppercase;
    }

    .brand h1 {
      overflow: hidden;
      margin: 0;
      font-size: clamp(0.8rem, 1.2vw, 1.42rem);
      line-height: 1.15;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

  .playing-summary {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2px 6px;
    border-left: 1px solid var(--line);
  }

  .playing-summary .control-label {
    font-size: .54rem;
  }

  .playing-summary .now-playing {
    margin-top: 0;
    font-size: .64rem;
  }

  .toolbar-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .toolbar-actions .action-btn,
  .icon-action-btn,
  .overlap-compact {
    min-height: 27px;
  }

  .toolbar-actions .action-btn {
    padding: 0 7px;
    border-radius: 8px;
    font-size: .61rem;
    white-space: nowrap;
  }

  .mode-badge {
    min-height: 25px;
    padding: 0 6px;
    font-size: .58rem;
  }

  .mode-badge::before {
    width: 5px;
    height: 5px;
  }

  .overlap-compact {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,.04);
    color: var(--muted);
    font-size: .59rem;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
  }

  .overlap-compact input {
    width: 11px;
    height: 11px;
    margin: 0;
    accent-color: var(--accent);
  }

  .icon-action-btn {
    display: grid;
    width: 28px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    place-items: center;
    background: rgba(255,255,255,.05);
    color: var(--accent);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
  }

  .icon-action-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(110,231,255,.42);
    background: rgba(110,231,255,.09);
  }

  /* Slot giữ vị trí trên header; chỉ chính control bên trong nổi lên khi scroll */
  .quick-control-slot {
    min-width: 0;
    height: 30px;
  }

  .sticky-audio-controls {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 5px;
    align-items: center;
    width: 100%;
    height: 30px;
    padding: 3px 4px 3px 7px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(255,255,255,.035);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
    backdrop-filter: blur(18px);
  }

  .sticky-audio-controls.is-stuck {
    position: fixed;
    top: 5px;
    right: 7px;
    z-index: 50;
    width: min(310px, calc(100vw - 14px));
    height: 32px;
    padding: 4px 5px 4px 8px;
    background: rgba(14,18,27,.91);
    box-shadow: 0 10px 28px rgba(0,0,0,.30);
  }

  .sticky-volume {
    display: grid;
    grid-template-columns: auto minmax(72px,1fr) auto;
    gap: 5px;
    align-items: center;
    min-width: 0;
  }

  .sticky-volume .control-label,
  .sticky-volume .volume-value {
    font-size: .57rem;
    white-space: nowrap;
  }

  .sticky-volume input[type="range"] {
    width: 100%;
    min-width: 72px;
    margin: 0;
  }

  .compact-stop {
    min-height: 24px;
    padding: 0 7px;
    border-radius: 7px;
    font-size: .58rem;
    white-space: nowrap;
  }

  .sticky-control-sentinel {
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
  }

  /* Hiển thị ô tìm kiếm và chế độ phát vốn có trong HTML */
  .secondary-bar {
    display: grid;
  }

  /* Soundboard: header nhỏ, card thấp, mật độ nút cao */
  .zones {
    gap: 7px;
    margin-top: 6px;
  }

  .zone {
    border-radius: 13px;
    background: linear-gradient(180deg, rgba(31,39,57,.92), rgba(18,23,34,.94));
    box-shadow: 0 14px 36px rgba(0,0,0,.25);
  }

  .zone-header {
    gap: 7px;
    padding: 6px 8px;
    background: rgba(255,255,255,.022);
  }

  .zone-title {
    font-size: .79rem;
    line-height: 1.12;
  }

  .zone-description {
    margin-top: 1px;
    font-size: .56rem;
    line-height: 1.2;
  }

  .zone-count {
    padding: 2px 6px;
    border-radius: 999px;
    font-size: .56rem;
  }

  .sound-grid {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 5px;
    padding: 6px;
    align-items: stretch;
  }

  .sound-card {
    min-height: 43px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
  }

  .sound-card:hover,
  .sound-card.is-playing {
    transform: none;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .sound-button {
    position: relative;
    justify-content: center;
    min-height: 43px;
    padding: 5px 6px 4px;
    border: 1px solid rgba(255,255,255,.095);
    border-radius: 8px;
    background:
      linear-gradient(180deg,
        hsla(var(--button-hue), 68%, 58%, .105),
        hsla(var(--button-hue), 58%, 42%, .04)),
      rgba(255,255,255,.022);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.05),
      0 4px 10px rgba(0,0,0,.13);
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
  }

  .sound-button:hover {
    transform: translateY(-1px);
    border-color: hsla(var(--button-hue), 88%, 68%, .43);
    background:
      linear-gradient(180deg,
        hsla(var(--button-hue), 74%, 58%, .17),
        hsla(var(--button-hue), 60%, 42%, .065)),
      rgba(255,255,255,.03);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.065),
      0 6px 13px hsla(var(--button-hue), 75%, 38%, .10);
  }

  .sound-button:active,
  .sound-card.is-playing .sound-button {
    transform: translateY(1px);
    border-color: hsla(var(--button-hue), 92%, 72%, .62);
    background:
      linear-gradient(180deg,
        hsla(var(--button-hue), 78%, 56%, .22),
        hsla(var(--button-hue), 62%, 40%, .095)),
      rgba(255,255,255,.035);
    box-shadow:
      inset 0 1px 3px rgba(0,0,0,.18),
      0 3px 9px hsla(var(--button-hue), 80%, 38%, .09);
  }

  .button-disc {
    display: none !important;
  }

  .sound-name {
    min-height: auto;
    font-size: clamp(.54rem, .64vw, .61rem);
    font-weight: 600;
    line-height: 1.16;
    letter-spacing: 0;
    color: var(--text);
    -webkit-line-clamp: 2;
  }

  .sound-meta {
    margin-top: 2px;
    gap: 3px;
    min-height: 12px;
    font-size: .49rem;
  }

  .key-badge,
  .url-badge {
    min-height: 13px;
    padding: 0 4px;
    font-size: .48rem;
  }

  /* Trạng thái "sẵn sàng" không cần chiếm chỗ trên soundboard chính */
  .url-badge {
    display: none;
  }

  .sound-card.is-empty-source {
    border: 0;
    background: transparent;
  }

  .sound-card.is-empty-source .sound-button {
    border-style: dashed;
    opacity: .78;
  }

  .sound-card.is-custom .sound-name {
    padding-inline: 0;
  }

  .sound-delete {
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 5px;
    font-size: 9px;
  }

  .footer-note {
    margin-top: 7px;
    font-size: .62rem;
  }

  @media (max-width: 980px) {
    .topbar {
      grid-template-columns: minmax(0, 1fr) auto;
    }

    .overlap-compact span {
      display: none;
    }

    .overlap-compact {
      width: 27px;
      padding: 0;
      justify-content: center;
    }
  }

  @media (max-width: 760px) {
    .topbar {
      grid-template-columns: minmax(0, 1fr) auto;
    }

    .playing-summary {
      display: none;
    }

    .zones {
      grid-template-columns: repeat(2, minmax(0,1fr));
    }

    .sound-grid {
      grid-template-columns: repeat(auto-fit, minmax(84px,1fr));
    }
  }

  @media (max-width: 620px) {
    .topbar {
      grid-template-columns: minmax(0, 1fr);
      gap: 5px;
      padding: 5px 6px;
    }

    .quick-control-slot {
      grid-column: 1 / -1;
      height: 29px;
    }

    .zones {
      grid-template-columns: 1fr;
      margin-top: 5px;
    }

    .sound-grid {
      grid-template-columns: repeat(4, minmax(0,1fr));
      gap: 4px;
      padding: 5px;
    }

    .sound-button {
      min-height: 40px;
      padding: 4px 4px 3px;
    }

    .sound-name {
      font-size: .52rem;
      font-weight: 600;
    }

    .sound-meta {
      margin-top: 1px;
    }

    .zone-header {
      padding: 5px 7px;
    }
  }

  @media (max-width: 420px) {
    .brand-kicker {
      display: none;
    }

    .toolbar-actions .action-btn {
      padding-inline: 6px;
    }

    .sound-grid {
      grid-template-columns: repeat(3, minmax(0,1fr));
    }

    .sticky-audio-controls.is-stuck {
      left: 5px;
      right: 5px;
      width: auto;
    }
  }

  /* Popup tìm kiếm nhỏ, chỉ nổi trên nền mờ */
  .search-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: min(12vh, 92px) 14px 14px;
    background: rgba(3,6,12,.30);
    backdrop-filter: blur(5px);
  }

  .search-backdrop.is-open {
    display: flex;
  }

  .search-popover {
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    gap: 8px;
    align-items: center;
    width: min(440px, 100%);
    padding: 7px 8px 7px 11px;
    border: 1px solid rgba(110,231,255,.30);
    border-radius: 13px;
    background: rgba(18,23,34,.96);
    box-shadow: 0 18px 52px rgba(0,0,0,.42), 0 0 0 1px rgba(255,255,255,.025) inset;
  }

  .search-popover-icon {
    color: var(--accent);
    font-size: 1.17rem;
    line-height: 1;
  }

  .search-popover-input {
    width: 100%;
    min-height: 32px;
    padding: 0 2px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: .82rem;
  }

  .search-popover-input::placeholder {
    color: var(--muted);
  }

  .search-close-btn {
    display: grid;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    place-items: center;
    background: rgba(255,255,255,.045);
    color: var(--muted);
    cursor: pointer;
  }

  .search-close-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,.085);
  }

  body.search-open {
    overflow: hidden;
  }

  /* Modal thêm audio vẫn giữ dark theme, chỉ nén kích thước */
  .sound-modal {
    width: min(620px, 100%);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(28,35,50,.99), rgba(13,17,26,.99));
  }

  .modal-header {
    padding: 12px 14px 10px;
  }

  .sound-form {
    padding: 12px 14px 14px;
    gap: 10px;
  }

  .form-grid {
    gap: 9px;
  }

  .text-input,
  .select-input,
  .file-input {
    min-height: 38px;
    border-radius: 10px;
  }

  .source-switch {
    border-radius: 10px;
  }

  .source-switch label {
    min-height: 31px;
    border-radius: 8px;
  }

  body {
      min-height: 100vh;
      margin: 0;
      color: var(--text);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background:
        radial-gradient(circle at 12% -10%, rgba(89, 219, 255, 0.15), transparent 32%),
        radial-gradient(circle at 94% 8%, rgba(255, 80, 136, 0.13), transparent 28%),
        linear-gradient(160deg, #090c12 0%, #111726 52%, #090c12 100%);
    }

    button,
    input {
      font: inherit;
    }

    button {
      color: inherit;
    }

    .app-shell {
      width: min(1680px, calc(100% - 32px));
      margin: 0 auto;
      padding: 22px 0 36px;
    }

    .topbar {
      position: sticky;
      top: 2px;
      z-index: 20;
      display: grid;
      box-sizing: border-box;
      gap: 2px;
      align-items: center;
      padding: 4px 8px;
      border: 1px solid var(--line);
      border-radius: 22px;
      background: rgba(14, 18, 27, 0.84);
      box-shadow: var(--shadow);
      backdrop-filter: blur(22px);
    }

    .brand {
      min-width: 0;
    }

    .brand-kicker {
      display: block;
      margin-bottom: 3px;
      color: var(--accent);
      font-size: 0.75rem;
      font-weight: 800;
      letter-spacing: 0.15em;
      text-transform: uppercase;
    }

    .brand h1 {
      overflow: hidden;
      margin: 0;
      font-size: clamp(0.8rem, 1.2vw, 1.42rem);
      line-height: 1.15;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .master-controls {
      display: grid;
      gap: 14px;
      min-width: 0;
    }

    .control-box {
      min-width: 0;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.035);
    }

    .control-row {
      display: flex;
      gap: 10px;
      align-items: center;
      justify-content: space-between;
    }

    .control-label {
      display: flex !important;
      position: static;
      color: var(--muted);
      font-size: 0.8rem;
      font-weight: 700;
    }

    .volume-value {
      position: static;
      color: var(--text);
      font-variant-numeric: tabular-nums;
      font-size: 0.82rem;
      font-weight: 800;
    }

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

    .now-playing {
      overflow: hidden;
      margin-top: 5px;
      color: var(--text);
      font-size: 0.9rem;
      font-weight: 750;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .toolbar-actions {
      display: flex;
      gap: 10px;
      align-items: center;
      justify-content: flex-end;
    }

    .action-btn {
      min-height: 46px;
      padding: 0 16px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: rgba(255, 255, 255, 0.055);
      box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
      font-size: 0.88rem;
      font-weight: 800;
      cursor: pointer;
      transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
    }

    .action-btn:hover {
      transform: translateY(-2px);
      border-color: rgba(255, 255, 255, 0.2);
      background: rgba(255, 255, 255, 0.095);
    }

    .action-btn:active {
      transform: translateY(0);
    }

    .action-btn.stop {
      border-color: rgba(255, 84, 109, 0.32);
      background: linear-gradient(180deg, rgba(255, 84, 109, 0.24), rgba(255, 84, 109, 0.1));
      color: #ffdce2;
    }

    .action-btn.stop:hover {
      border-color: rgba(255, 84, 109, 0.65);
      background: linear-gradient(180deg, rgba(255, 84, 109, 0.36), rgba(255, 84, 109, 0.14));
    }

    .secondary-bar {
      display: grid;
      gap: 14px;
      margin: 18px 0;
      align-items: center;
    }

    .search-wrap {
      position: relative;
    }

    .search-wrap::before {
      position: absolute;
      top: 50%;
      left: 15px;
      content: "⌕";
      color: var(--muted);
      font-size: 1.35rem;
      transform: translateY(-54%);
      pointer-events: none;
    }

    .search-input {
      width: 100%;
      min-height: 48px;
      padding: 0 16px 0 43px;
      border: 1px solid var(--line);
      border-radius: 15px;
      outline: none;
      background: rgba(255, 255, 255, 0.05);
      color: var(--text);
      box-shadow: 0 14px 28px rgba(0, 0, 0, 0.12);
      transition: border-color 150ms ease, box-shadow 150ms ease;
    }

    .search-input:focus {
      border-color: rgba(110, 231, 255, 0.55);
      box-shadow: 0 0 0 4px rgba(110, 231, 255, 0.08);
    }

    .mode-toggle {
      display: flex;
      gap: 10px;
      align-items: center;
      min-height: 48px;
      padding: 0 15px;
      border: 1px solid var(--line);
      border-radius: 15px;
      background: rgba(255, 255, 255, 0.04);
      color: var(--muted);
      font-size: 0.84rem;
      font-weight: 750;
      cursor: pointer;
      user-select: none;
    }

    .mode-toggle input {
      width: 18px;
      height: 18px;
      accent-color: var(--accent);
    }

    .zones {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 18px;
      align-items: start;
    }

    .zone {
      overflow: hidden;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: linear-gradient(180deg, rgba(31, 39, 57, 0.9), rgba(18, 23, 34, 0.92));
      box-shadow: var(--shadow);
    }

    .zone-header {
      display: flex;
      gap: 14px;
      align-items: center;
      justify-content: space-between;
      padding: 20px 22px;
      border-bottom: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.024);
    }

    .zone-title-wrap {
      min-width: 0;
    }

    .zone-title {
      margin: 0;
      font-size: 1.06rem;
      line-height: 1.2;
    }

    .zone-description {
      margin: 5px 0 0;
      color: var(--muted);
      font-size: 0.78rem;
    }

    .zone-count {
      flex: 0 0 auto;
      padding: 6px 10px;
      border: 1px solid var(--line);
      border-radius: 999px;
      color: var(--muted);
      background: rgba(255, 255, 255, 0.04);
      font-size: 0.76rem;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
    }

    .sound-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 14px;
      padding: 18px;
    }

    .sound-card {
      --button-hue: 350;
      position: relative;
      display: flex;
      min-width: 0;
      min-height: 176px;
      padding: 15px 10px 13px;
      border: 1px solid rgba(255, 255, 255, 0.07);
      border-radius: 19px;
      background: rgba(255, 255, 255, 0.025);
      transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
    }

    .sound-card:hover {
      transform: translateY(-3px);
      border-color: hsla(var(--button-hue), 85%, 67%, 0.35);
      background: hsla(var(--button-hue), 70%, 55%, 0.055);
    }

    .sound-card.is-playing {
      border-color: hsla(var(--button-hue), 90%, 70%, 0.62);
      background: hsla(var(--button-hue), 80%, 55%, 0.105);
      box-shadow: inset 0 0 0 1px hsla(var(--button-hue), 90%, 72%, 0.12), 0 13px 34px hsla(var(--button-hue), 90%, 45%, 0.13);
    }

    .sound-card.is-hidden {
      display: none;
    }
