/* ─── Variables & Reset ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Dark (default) ── values from desktop Theme.cs */
:root,
[data-theme="dark"] {
  --bg-base:     #15171c;
  --bg-surface:  #1d2027;
  --bg-elevated: #22252d;
  --bg-card:     #292c36;
  --border:              rgba(255,255,255,0.07);
  --border-focus:        rgba(78,225,194,0.45);
  --text-primary:  #ebedf2;
  --text-secondary:#a0a3af;
  --text-muted:    #4a5060;
  --accent:        #4ee1c2;
  --accent-glow:   rgba(78,225,194,0.25);
  --accent-active: #7eeedd;
  --accent2:       #ff6b4a;
  --pad-empty:          #1d2027;
  --pad-empty-border:   rgba(255,255,255,0.06);
  --pad-assigned:       #1a2e2a;
  --pad-assigned-border:rgba(78,225,194,0.3);
  --pad-playing:        rgba(78,225,194,0.2);
  --pad-playing-border: #4ee1c2;
  --danger:  #ff5c5c;
  --success: #5cd98c;
  --warn:    #ffb347;
  --crown:   #ffc107;
}

[data-theme="light"] {
  --bg-base:     #f0f1f5;
  --bg-surface:  #ffffff;
  --bg-elevated: #e6e8ee;
  --bg-card:     #dde0ea;
  --border:              rgba(0,0,0,0.10);
  --border-focus:        rgba(0,150,120,0.5);
  --text-primary:  #14161e;
  --text-secondary:#646978;
  --text-muted:    #9ca3b0;
  --accent:        #009678;
  --accent-glow:   rgba(0,150,120,0.2);
  --accent-active: #007a62;
  --accent2:       #e05a32;
  --pad-empty:          #dde0ea;
  --pad-empty-border:   rgba(0,0,0,0.08);
  --pad-assigned:       #c0e8e0;
  --pad-assigned-border:rgba(0,150,120,0.4);
  --pad-playing:        rgba(0,150,120,0.15);
  --pad-playing-border: #009678;
  --danger:  #e03030;
  --success: #1a9950;
  --warn:    #d4820a;
  --crown:   #c8900a;
}

[data-theme="midnight"] {
  --bg-base:     #080a10;
  --bg-surface:  #0e111a;
  --bg-elevated: #141824;
  --bg-card:     #1a1f30;
  --border:              rgba(255,255,255,0.06);
  --border-focus:        rgba(80,200,240,0.4);
  --text-primary:  #d8daf0;
  --text-secondary:#7880a8;
  --text-muted:    #3a4060;
  --accent:        #50c8f0;
  --accent-glow:   rgba(80,200,240,0.2);
  --accent-active: #80daf7;
  --accent2:       #ff6b4a;
  --pad-empty:          #0e111a;
  --pad-empty-border:   rgba(255,255,255,0.05);
  --pad-assigned:       #0f2030;
  --pad-assigned-border:rgba(80,200,240,0.3);
  --pad-playing:        rgba(80,200,240,0.15);
  --pad-playing-border: #50c8f0;
  --danger:  #ff5c5c;
  --success: #5cd98c;
  --warn:    #ffb347;
  --crown:   #ffc107;
}

[data-theme="neon"] {
  --bg-base:     #0a0c14;
  --bg-surface:  #0f121e;
  --bg-elevated: #141626;
  --bg-card:     #1a1c30;
  --border:              rgba(200,50,255,0.12);
  --border-focus:        rgba(200,50,255,0.5);
  --text-primary:  #e8d0ff;
  --text-secondary:#9060c0;
  --text-muted:    #402860;
  --accent:        #c832ff;
  --accent-glow:   rgba(200,50,255,0.25);
  --accent-active: #e060ff;
  --accent2:       #ffe020;
  --pad-empty:          #0f121e;
  --pad-empty-border:   rgba(200,50,255,0.08);
  --pad-assigned:       #200a30;
  --pad-assigned-border:rgba(200,50,255,0.35);
  --pad-playing:        rgba(200,50,255,0.2);
  --pad-playing-border: #c832ff;
  --danger:  #ff4466;
  --success: #44ff88;
  --warn:    #ffdd22;
  --crown:   #ffe020;
}

/* ── Common ── */
--radius-sm: 6px;
--radius-md: 10px;
--radius-lg: 16px;
--shadow-sm: 0 1px 4px rgba(0,0,0,0.4);
--shadow-md: 0 4px 16px rgba(0,0,0,0.5);
--shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
--font-ui:   'Inter', system-ui, sans-serif;
--font-mono: 'JetBrains Mono', monospace;

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  transition: background .3s, color .3s;
}

/* ─── SVG Icons ──────────────────────────────────────────────────── */
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ─── Guard Screen ───────────────────────────────────────────────── */
#guard-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base); z-index: 9999; padding: 24px;
}
.guard-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 48px;
  max-width: 520px; width: 100%; text-align: center;
  box-shadow: var(--shadow-lg);
}
.guard-icon-wrap { margin-bottom: 20px; }
.guard-icon-wrap svg { width: 56px; height: 56px; color: var(--accent); }
.guard-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.guard-desc  { color: var(--text-secondary); font-size: 14px; line-height: 1.7; margin-bottom: 24px; }
.guard-steps { background: var(--bg-elevated); border-radius: var(--radius-md); padding: 16px 20px; margin-bottom: 24px; text-align: left; }
.guard-steps li { list-style: none; padding: 6px 0; color: var(--text-secondary); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.guard-steps .step-num { background: var(--accent); color: var(--bg-base); font-size: 11px; font-weight: 700; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.guard-url-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 16px; font-family: var(--font-mono); font-size: 13px; color: var(--accent-active); display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; cursor: pointer; transition: border-color .2s; }
.guard-url-box:hover { border-color: var(--accent); }
.btn-copy { background: none; border: none; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; transition: color .2s; }
.btn-copy:hover { color: var(--accent); }
.guard-blocked .guard-icon-wrap svg { color: var(--text-muted); }

/* ─── App Layout ─────────────────────────────────────────────────── */
#app { display: none; flex-direction: column; height: 100vh; overflow: hidden; }
#app.visible { display: flex; }

/* ── Header ── */
#header {
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  padding: 0 14px; height: 48px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.header-logo { font-weight: 700; font-size: 14px; letter-spacing: .06em; white-space: nowrap; }
.header-logo span { color: var(--accent); }
.header-logo small { font-size: 10px; opacity: .4; font-weight: 400; }
.header-divider { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
.header-stat { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.header-stat strong { color: var(--text-primary); }
.header-spacer { flex: 1; }

.header-btn {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  font-size: 11px; font-family: var(--font-ui);
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
  transition: all .15s;
}
.header-btn:hover { background: var(--bg-card); color: var(--text-primary); border-color: rgba(255,255,255,0.12); }
.header-btn svg { width: 13px; height: 13px; }

.header-select {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-ui); font-size: 11px; padding: 4px 6px;
  cursor: pointer; outline: none; max-width: 120px;
}

.plan-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 9px;
  border: 1px solid;
}
.plan-badge.free     { color: var(--text-muted);  border-color: var(--text-muted); }
.plan-badge.pro      { color: var(--crown);        border-color: var(--crown); }
.plan-badge.beta     { color: var(--accent);       border-color: var(--accent); }
.plan-badge.creator  { color: #c4b5fd;             border-color: #8b5cf6; }
.plan-badge.business { color: #67e8f9;             border-color: #22d3ee; }

/* Master volume */
.master-vol { display: flex; align-items: center; gap: 6px; }
.master-vol svg { width: 13px; height: 13px; color: var(--text-secondary); }
.master-vol input[type=range] {
  -webkit-appearance: none; width: 72px; height: 3px;
  background: var(--bg-card); border-radius: 2px; outline: none; cursor: pointer;
}
.master-vol input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 5px var(--accent-glow);
}
.master-vol-label { font-size: 11px; color: var(--text-secondary); min-width: 30px; font-family: var(--font-mono); }

/* ── Main / Keyboard ── */
#main {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 12px;
}
#keyboard-wrapper { position: relative; }
#keyboard-scaler { transform-origin: top left; transition: transform .15s; }
#keyboard        { position: relative; }

/* Pads */
.key-pad {
  position: absolute;
  background: var(--pad-empty); border: 1px solid var(--pad-empty-border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; user-select: none;
  transition: background .1s, border-color .1s, box-shadow .1s, transform .06s;
}
.key-pad:hover { background: var(--bg-card); border-color: rgba(255,255,255,0.13); }
.key-pad:active { transform: scale(0.92); }
.key-pad.assigned { background: var(--pad-assigned); border-color: var(--pad-assigned-border); }
.key-pad.playing  {
  background: var(--pad-playing); border-color: var(--pad-playing-border);
  box-shadow: 0 0 10px var(--accent-glow), inset 0 0 8px rgba(78,225,194,0.08);
}
.key-pad.drag-over {
  border-color: var(--accent);
  background: rgba(78,225,194,0.08);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.pad-label { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--text-muted); pointer-events: none; line-height: 1; }
.key-pad.assigned .pad-label { color: var(--text-secondary); }
.key-pad.playing   .pad-label { color: var(--accent-active); }
.pad-name  { font-size: 9px; color: var(--text-muted); text-align: center; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; margin-top: 2px; }
.key-pad.assigned .pad-name { color: var(--accent-active); }
.pad-color-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); opacity: 0; transition: opacity .2s; }
.key-pad.assigned .pad-color-bar { opacity: 1; }

@keyframes ripple-out {
  0%   { box-shadow: 0 0 0 0 rgba(78,225,194,0.6); }
  100% { box-shadow: 0 0 0 12px rgba(78,225,194,0); }
}
.key-pad.triggered { animation: ripple-out .3s ease-out forwards; }

/* ── Debug Bar ── */
#debug-bar {
  flex-shrink: 0; background: var(--bg-surface); border-top: 1px solid var(--border);
  height: 28px; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
}
#debug-bar .dbg-key  { color: var(--accent-active); }
#debug-bar .dbg-file { color: var(--text-secondary); }
#debug-bar .dbg-mode { margin-left: auto; font-size: 10px; }

/* ── Pad Panel ── */
#pad-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 272px;
  background: var(--bg-surface); border-left: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 14px;
  transform: translateX(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 100; overflow-y: auto;
}
#pad-panel.open { transform: translateX(0); }
.panel-title    { font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.panel-close    { background: none; border: none; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; padding: 2px; transition: color .2s; }
.panel-close:hover { color: var(--danger); }
.panel-close svg { width: 16px; height: 16px; }
.panel-section  { display: flex; flex-direction: column; gap: 6px; }
.panel-label    { font-size: 11px; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; }
.panel-label.locked { color: var(--text-muted); }
.panel-locked-hint  { font-size: 10px; color: var(--warn); background: rgba(255,179,71,0.1); border: 1px solid rgba(255,179,71,0.2); border-radius: var(--radius-sm); padding: 4px 8px; display: flex; align-items: center; gap: 5px; }
.panel-locked-hint svg { width: 11px; height: 11px; flex-shrink: 0; }
.panel-row   { display: flex; align-items: center; gap: 8px; }
.panel-input {
  flex: 1; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-ui); font-size: 13px; padding: 6px 10px; outline: none;
  transition: border-color .2s;
}
.panel-input:focus { border-color: var(--border-focus); }
.panel-input:disabled { opacity: 0.4; cursor: not-allowed; }
.panel-range { flex: 1; -webkit-appearance: none; height: 3px; background: var(--bg-card); border-radius: 2px; outline: none; cursor: pointer; }
.panel-range::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); }
.panel-range:disabled { opacity: 0.4; cursor: not-allowed; }
.panel-range-val { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); min-width: 32px; text-align: right; }
.panel-btn { width: 100%; padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-primary); font-family: var(--font-ui); font-size: 13px; cursor: pointer; transition: all .15s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.panel-btn:hover { background: var(--bg-card); }
.panel-btn svg { width: 14px; height: 14px; }
.panel-btn.danger { color: var(--danger); border-color: rgba(255,92,92,0.25); }
.panel-btn.danger:hover { background: rgba(255,92,92,0.08); }
.color-swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 4px; border: 2px solid transparent; cursor: pointer; transition: transform .15s, border-color .15s; }
.swatch:hover  { transform: scale(1.15); }
.swatch.active { border-color: #fff; }

/* ── Context Menu ── */
#context-menu {
  position: fixed; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 6px; z-index: 200;
  box-shadow: var(--shadow-lg); min-width: 176px; display: none;
}
#context-menu.visible { display: block; }
.ctx-item { padding: 7px 11px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; transition: background .12s, color .12s; }
.ctx-item:hover { background: var(--bg-card); color: var(--text-primary); }
.ctx-item.danger:hover { background: rgba(255,92,92,0.1); color: var(--danger); }
.ctx-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── URL Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 300; display: none; }
.modal-backdrop.visible { display: flex; }
.modal { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; width: 440px; max-width: 95vw; box-shadow: var(--shadow-lg); }
.modal-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.modal-title svg { width: 16px; height: 16px; color: var(--accent); }
.modal-input { width: 100%; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-ui); font-size: 13px; padding: 8px 12px; outline: none; transition: border-color .2s; margin-bottom: 14px; }
.modal-input:focus { border-color: var(--border-focus); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-primary { background: var(--accent); border: none; border-radius: var(--radius-sm); color: var(--bg-base); font-family: var(--font-ui); font-size: 13px; font-weight: 700; padding: 7px 18px; cursor: pointer; transition: opacity .2s, box-shadow .2s; }
.btn-primary:hover { opacity: .88; box-shadow: 0 0 12px var(--accent-glow); }
.btn-ghost  { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); font-family: var(--font-ui); font-size: 13px; padding: 7px 14px; cursor: pointer; transition: all .15s; }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 36px; right: 16px; display: flex; flex-direction: column-reverse; gap: 6px; z-index: 500; pointer-events: none; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 14px; font-size: 12px; color: var(--text-primary); box-shadow: var(--shadow-md); animation: toast-in .2s ease-out; max-width: 280px; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
