/* ==========================================================================
   有聲有戲 POCKET SHOW V2.0 — Physical Tactile Soundboard Console Stylesheet
   Deep Obsidian & Illuminated Purple Hardware Design Language
   ========================================================================== */

:root {
  --bg-desk: #050408;
  --bg-chassis: #0B0911;
  --bg-deck: #13101D;
  --bg-well: #09070F;
  --bg-pad-top: #1E192E;
  --bg-pad-bottom: #141021;
  --bg-pad-active-top: #2B1F47;
  --bg-pad-active-bottom: #1A1230;

  --border-chassis: rgba(155, 92, 255, 0.16);
  --border-bevel-hi: rgba(255, 255, 255, 0.085);
  --border-bevel-lo: rgba(0, 0, 0, 0.65);

  --purple-500: #8B5CF6;
  --purple-400: #A855F7;
  --purple-300: #C084FC;
  --purple-glow: rgba(168, 85, 247, 0.48);

  --danger: #F43F5E;
  --danger-glow: rgba(244, 63, 94, 0.45);
  --success: #10B981;

  --text-primary: #F5F3FF;
  --text-secondary: #B8AED2;
  --text-muted: #7F749B;

  --font-sans: "SF Pro Display", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-chassis: 22px;
  --radius-pad: 16px;
  --radius-key: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-desk);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  justify-content: center;
  background:
    radial-gradient(ellipse 85% 40% at 50% 0%, rgba(124, 58, 237, 0.18), transparent 68%),
    linear-gradient(180deg, #07050C 0%, #050408 100%);
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Console Hardware Shell ---- */
.console-chassis {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(10px + var(--safe-top)) 12px calc(18px + var(--safe-bottom));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0%, rgba(255, 255, 255, 0) 14%),
    var(--bg-chassis);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 540px) {
  body {
    padding: 20px 16px;
    align-items: flex-start;
  }
  .console-chassis {
    min-height: auto;
    border-radius: var(--radius-chassis);
    border: 1px solid var(--border-chassis);
    box-shadow:
      0 28px 70px rgba(0, 0, 0, 0.78),
      0 0 0 1px rgba(255, 255, 255, 0.04) inset,
      0 1px 0 rgba(255, 255, 255, 0.09) inset;
    padding: 18px 18px 22px;
  }
}

/* ---- SVG Icon Defaults ---- */
.icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.icon-xs {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.icon-inline {
  width: 13px;
  height: 13px;
  display: inline-block;
  vertical-align: -2px;
  margin-left: 2px;
}

.icon-pad {
  width: 30px;
  height: 30px;
}

/* ---- Top Hardware Header ---- */
.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-plate {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(160deg, #1E1831, #100D1A);
  border: 1px solid rgba(168, 85, 247, 0.35);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  gap: 4px;
  place-content: center;
  flex-shrink: 0;
}

.brand-dot {
  border-radius: 2.5px;
  background: #2C2442;
}

.brand-dot.is-lit {
  background: var(--purple-400);
  box-shadow: 0 0 8px var(--purple-glow);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--text-primary);
}

.brand-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--purple-300);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.status-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3F3658;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.status-led.is-live {
  background: var(--purple-300);
  box-shadow: 0 0 8px var(--purple-400);
}

.status-led.is-loop {
  background: #22D3EE;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.8);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hw-chip-btn,
.hw-icon-btn {
  height: 38px;
  min-width: 38px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, #1E192E 0%, #141020 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}

.hw-icon-btn {
  padding: 0;
  width: 38px;
  font-size: 1.35rem;
  line-height: 1;
}

.hw-chip-btn:active,
.hw-icon-btn:active {
  transform: translateY(1px) scale(0.97);
}

/* ---- Master Control Deck ---- */
.master-deck {
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, #161224 0%, #100D1A 100%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 6px 18px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.volume-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mute-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #211B33 0%, #151123 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple-300);
  cursor: pointer;
  flex-shrink: 0;
}

.mute-btn.is-muted {
  color: var(--text-muted);
  border-color: rgba(244, 63, 94, 0.35);
}

.fader-group {
  flex: 1;
  min-width: 0;
}

.fader-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.mono-readout {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--purple-300);
}

.fader-track-wrap {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
}

.fader-track-bg {
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-well);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  pointer-events: none;
}

.fader-track-fill {
  height: 100%;
  width: 85%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6D28D9 0%, #A855F7 65%, #D8B4FE 100%);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.65);
}

.fader-input {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 28px;
}

.fader-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(180deg, #F5F3FF 0%, #C4B5FD 100%);
  border: 1.5px solid #4C1D95;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.65), 0 0 10px rgba(168, 85, 247, 0.5);
}

.fader-input::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(180deg, #F5F3FF 0%, #C4B5FD 100%);
  border: 1.5px solid #4C1D95;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.65), 0 0 10px rgba(168, 85, 247, 0.5);
}

/* Transport Keys (LOOP + STOP ALL) */
.transport-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
}

.hw-key-btn {
  height: 46px;
  border-radius: var(--radius-key);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, #221C36 0%, #161226 100%);
  box-shadow:
    0 4px 0 #08060D,
    0 6px 12px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.15s, background 0.15s;
}

.hw-key-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #08060D,
    0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.hw-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3B3255;
  transition: all 0.15s;
}

.hw-key-loop.is-active {
  border-color: rgba(192, 132, 252, 0.72);
  background: linear-gradient(180deg, #4C1D95 0%, #2E1065 100%);
  box-shadow:
    0 2px 0 #140829,
    0 0 18px rgba(168, 85, 247, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transform: translateY(1px);
}

.hw-key-loop.is-active .hw-led {
  background: #E9D5FF;
  box-shadow: 0 0 10px #C084FC;
}

.hw-key-stop {
  border-color: rgba(244, 63, 94, 0.28);
  color: #FDA4AF;
}

.hw-key-stop.is-armed {
  background: linear-gradient(180deg, #9F1239 0%, #6D0D29 100%);
  border-color: rgba(251, 113, 133, 0.8);
  color: #FFFFFF;
  box-shadow:
    0 4px 0 #3B0615,
    0 0 20px var(--danger-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

/* ---- Filter Tabs & Mode Bar ---- */
.mode-bar {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
}

.tab-group {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg-well);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-width: 0;
}

.tab-btn {
  height: 34px;
  padding: 0 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn.is-active {
  background: #271F3F;
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.mode-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.mode-btn {
  height: 36px;
  padding: 0 9px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: #1A1529;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.14s;
}

.mode-btn .icon {
  width: 16px;
  height: 16px;
}

.mode-btn.is-active {
  border-color: var(--purple-400);
  background: rgba(139, 92, 246, 0.24);
  color: var(--text-primary);
}

.mode-btn-primary {
  background: linear-gradient(180deg, #8B5CF6 0%, #6D28D9 100%);
  border-color: rgba(216, 180, 254, 0.45);
  color: #FFFFFF;
  box-shadow: 0 3px 12px rgba(124, 58, 237, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.mode-btn-primary:active {
  transform: translateY(1px);
}

.reorder-banner {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(168, 85, 247, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  color: #E9D5FF;
}

.text-link-btn {
  background: transparent;
  border: 1px solid rgba(216, 180, 254, 0.4);
  border-radius: 7px;
  padding: 4px 9px;
  color: #F5F3FF;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.storage-warning-banner {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.5);
  font-size: 0.8rem;
  line-height: 1.45;
  color: #FDE68A;
}

.backup-bar {
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 11px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.backup-hint {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backup-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ---- 3-Column Tactile Pad Bank ---- */
.pad-bank-wrap {
  margin-top: 10px;
  padding: 9px;
  border-radius: 18px;
  background: var(--bg-well);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.8);
  flex: 1;
}

.pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.pad-cell {
  position: relative;
  border-radius: var(--radius-pad);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.pad-cell.is-drag-origin {
  opacity: 0.28;
}

.pad-cell.is-drop-target {
  outline: 2px dashed var(--purple-300);
  outline-offset: 2px;
  transform: scale(0.96);
}

/* Individual Physical Sampler Pad */
.sound-pad {
  --pad-accent: #9B5CFF;
  --pad-glow: rgba(155, 92, 255, 0.52);
  --play-progress: 0;

  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.08;
  min-height: 112px;
  border-radius: var(--radius-pad);
  padding: 7px 6px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--bg-pad-top) 0%, var(--bg-pad-bottom) 100%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 5px 0 #07050B,
    0 8px 14px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.45);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition:
    transform 0.08s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.12s ease,
    border-color 0.14s ease,
    background 0.14s ease;
}

.pad-grid.is-reordering .sound-pad {
  touch-action: none;
  cursor: grab;
  aspect-ratio: auto;
  min-height: 132px;
  padding-bottom: 10px;
  border-style: dashed;
  border-color: rgba(192, 132, 252, 0.45);
}

.pad-grid.is-reordering .icon-pad {
  width: 24px;
  height: 24px;
}

.pad-grid.is-reordering .pad-label {
  font-size: 0.82rem;
  -webkit-line-clamp: 1;
}

.sound-pad:focus-visible {
  outline: 2px solid var(--purple-300);
  outline-offset: 2px;
}

/* Active Depressed + Luminous Glow State */
.sound-pad.is-pressed,
.sound-pad.is-playing {
  transform: translateY(3.5px) scale(0.972);
  background: linear-gradient(180deg, var(--bg-pad-active-top) 0%, var(--bg-pad-active-bottom) 100%);
  border-color: var(--pad-accent);
  box-shadow:
    0 1.5px 0 #06040A,
    0 0 22px var(--pad-glow),
    inset 0 2px 10px rgba(0, 0, 0, 0.48),
    inset 0 0 18px color-mix(in srgb, var(--pad-accent) 26%, transparent);
}

/* Illuminated Progress Sweep Layer */
.pad-sweep {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--pad-accent) 24%, transparent) 0%,
    color-mix(in srgb, var(--pad-accent) 10%, transparent) 100%
  );
  transform-origin: left center;
  transform: scaleX(var(--play-progress));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s linear;
}

.sound-pad.is-playing .pad-sweep {
  opacity: 1;
}

.pad-top-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.pad-top-left {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pad-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pad-accent) 42%, #1D182C);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6);
  transition: all 0.12s;
}

.sound-pad.is-playing .pad-led {
  background: #FFFFFF;
  box-shadow: 0 0 8px #FFFFFF, 0 0 14px var(--pad-accent);
}

.pad-index {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

.pad-corner-btn {
  width: 28px;
  height: 28px;
  margin: -4px -3px 0 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.14s, background 0.14s;
}

.pad-edit-btn {
  margin: -4px 0 0 -2px;
  color: var(--purple-300);
}

.pad-fav-btn.is-fav {
  color: #FBBF24;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.45));
}

.pad-grip {
  color: var(--purple-300);
  display: inline-flex;
  align-items: center;
}

.pad-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  padding: 2px 2px 2px;
}

.pad-icon {
  color: var(--pad-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, filter 0.12s, color 0.12s;
}

.sound-pad.is-playing .pad-icon {
  color: #FFFFFF;
  filter: drop-shadow(0 0 10px var(--pad-accent));
  transform: scale(1.06);
}

.pad-label {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.18;
  text-align: center;
  color: var(--text-primary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* Reorder quick arrow buttons */
.pad-reorder-controls {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}

.pad-move-btn {
  flex: 1;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(192, 132, 252, 0.35);
  background: rgba(15, 11, 26, 0.9);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pad-move-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

/* Bottom Illuminated Progress Bar */
.pad-progress-track {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 5px;
  height: 3.5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  z-index: 2;
}

.pad-progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pad-accent), #FFFFFF);
  box-shadow: 0 0 8px var(--pad-accent);
  transform-origin: left center;
  transform: scaleX(var(--play-progress));
}

/* Drag Ghost */
.drag-ghost {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  transform: scale(1.06);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.72), 0 0 22px var(--purple-glow);
  opacity: 0.94;
}

/* Empty State */
.empty-state {
  padding: 46px 18px;
  text-align: center;
}

.empty-title {
  margin: 0 0 8px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ---- PWA Install Banner ---- */
.install-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 13px;
  background: linear-gradient(90deg, rgba(109, 40, 217, 0.25), rgba(30, 24, 49, 0.9));
  border: 1px solid rgba(168, 85, 247, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.install-text {
  font-size: 0.82rem;
  line-height: 1.35;
  color: #EDE9FE;
}

.install-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.install-primary-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: none;
  background: var(--purple-500);
  color: #FFFFFF;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.install-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
}

/* ---- Modals & Bottom Sheets ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4, 3, 8, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px;
}

.modal-backdrop[hidden] {
  display: none;
}

@media (min-width: 540px) {
  .modal-backdrop {
    align-items: center;
  }
}

.sr-file-input {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.modal-sheet {
  width: 100%;
  max-width: 492px;
  max-height: calc(90dvh - var(--safe-top));
  border-radius: 20px;
  background: #120F1C;
  border: 1px solid rgba(168, 85, 247, 0.28);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 16px 36px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  background: #120F1C;
  padding: 12px 16px calc(14px + var(--safe-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  gap: 10px;
}

/* ---- Custom Sound Studio ---- */
.studio-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.studio-section-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--purple-300);
}

.capture-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.studio-action-btn {
  height: 48px;
  min-width: 0;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #211B35 0%, #151125 100%);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.14s;
}

.studio-action-btn .icon {
  width: 17px;
  height: 17px;
}

.studio-browse-all-btn {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(192, 132, 252, 0.38);
  background: rgba(139, 92, 246, 0.09);
  color: #E9D5FF;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}

.studio-browse-all-btn:active {
  background: rgba(139, 92, 246, 0.2);
}

.studio-rec-btn.is-recording {
  background: linear-gradient(180deg, #BE123C 0%, #881337 100%);
  border-color: #FDA4AF;
  box-shadow: 0 0 18px var(--danger-glow);
  animation: recPulse 1.1s infinite ease-in-out;
}

@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(244, 63, 94, 0.45); }
  50% { box-shadow: 0 0 26px rgba(244, 63, 94, 0.85); }
}

.rec-timer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  color: #FDA4AF;
}

.decoding-status {
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-well);
  color: var(--purple-300);
  font-size: 0.88rem;
}

/* Interactive Waveform Canvas & Trim Handles */
.waveform-shell {
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-well);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.waveform-container {
  position: relative;
  width: 100%;
  height: 98px;
  border-radius: 10px;
  background: #07050C;
  overflow: visible;
  touch-action: none;
}

#waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 10px;
}

.trim-handle {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 44px;
  margin-left: -22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  touch-action: none;
  z-index: 4;
}

.trim-knob {
  width: 14px;
  height: 46px;
  border-radius: 7px;
  background: linear-gradient(180deg, #E9D5FF 0%, #A855F7 100%);
  border: 2px solid #2E1065;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7), 0 0 10px rgba(168, 85, 247, 0.65);
  transition: transform 0.1s;
}

.trim-handle.is-dragging .trim-knob {
  transform: scale(1.16);
  background: #FFFFFF;
}

.trim-readouts {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.trim-readouts em {
  font-style: normal;
  margin-right: 4px;
}

.trim-tip {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.studio-section.is-live-recording .trim-readouts,
.studio-section.is-live-recording .trim-tip,
.studio-section.is-live-recording .studio-preview-btn {
  display: none;
}

.studio-preview-btn {
  height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(168, 85, 247, 0.45);
  background: rgba(139, 92, 246, 0.18);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}

.studio-preview-btn.is-playing {
  background: var(--purple-500);
  color: #FFFFFF;
}

/* Form Inputs & Pickers */
.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.studio-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--bg-well);
  color: var(--text-primary);
  font-size: 0.96rem;
  font-weight: 600;
}

.studio-input:focus {
  outline: none;
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.22);
}

.picker-color-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.picker-color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  background: var(--swatch);
  cursor: pointer;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.35);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.picker-color-btn.is-selected {
  border-color: #FFFFFF;
  transform: scale(1.12);
  box-shadow: 0 0 14px var(--swatch);
}

.picker-icon-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
  padding-bottom: 14px;
}

@media (max-width: 380px) {
  .picker-icon-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.picker-icon-btn {
  height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--bg-well);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.picker-icon-btn.is-selected {
  border-color: var(--purple-400);
  background: rgba(139, 92, 246, 0.25);
  color: #FFFFFF;
}

.btn-primary,
.btn-danger {
  flex: 1;
  height: 48px;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, #9333EA 0%, #6D28D9 100%);
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-danger {
  flex: 0 0 auto;
  padding: 0 16px;
  background: rgba(244, 63, 94, 0.16);
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #FDA4AF;
}

/* ---- Licenses & Privacy Modal ---- */
.info-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px 16px 0;
  gap: 8px;
}

.info-tab-btn {
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--bg-well);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.info-tab-btn.is-active {
  border-color: var(--purple-400);
  background: rgba(139, 92, 246, 0.22);
  color: #FFFFFF;
}

.info-intro {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.license-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.license-card {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-well);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.license-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.license-sound-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.license-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #6EE7B7;
  text-decoration: none;
  white-space: nowrap;
}

.license-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.license-meta a {
  color: var(--purple-300);
  text-decoration: underline;
  word-break: break-word;
}

.privacy-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.privacy-block {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-well);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.privacy-block h3 {
  margin: 0 0 6px;
  font-size: 0.94rem;
  color: var(--purple-300);
}

.privacy-block p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translate(-50%, 16px);
  z-index: 400;
  max-width: calc(100vw - 28px);
  padding: 11px 16px;
  border-radius: 12px;
  background: #211B36;
  border: 1px solid rgba(192, 132, 252, 0.45);
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast--error {
  border-color: rgba(244, 63, 94, 0.65);
  background: #35111E;
}

.toast--success {
  border-color: rgba(16, 185, 129, 0.65);
  background: #0F2922;
}

.toast--warning {
  border-color: rgba(245, 158, 11, 0.75);
  background: #33230A;
  color: #FEF3C7;
}

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