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

:root {
  --bg:       #09090d;
  --bg1:      #0f0f14;
  --bg2:      #15151c;
  --bg3:      #1c1c25;
  --bg4:      #24242f;
  --line:     rgba(255,255,255,0.055);
  --line2:    rgba(255,255,255,0.09);
  --line3:    rgba(255,255,255,0.14);
  --t1:       #f0f0f8;
  --t2:       rgba(240,240,248,0.52);
  --t3:       rgba(240,240,248,0.26);
  --a:        #e05590;
  --a2:       #c44778;
  --a-glow:   rgba(224,85,144,0.26);
  --blue:     #5ba3e0;
  --purple:   #9b72e0;
  --green:    #56dba0;
  --amber:    #e0a855;
  --r:        8px;
  --r-sm:     5px;
  --r-md:     10px;
  --r-lg:     14px;
  --ff:       'Inter', system-ui, -apple-system, sans-serif;
  --mono:     'JetBrains Mono', 'Fira Mono', monospace;
  --ease:     cubic-bezier(0.32, 0, 0.18, 1);
  --eout:     cubic-bezier(0, 0, 0.18, 1);
  --tf:       140ms;
  --tm:       230ms;
  --ts:       370ms;
}

html, body { height: 100%; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--t1);
  overflow: hidden;
  height: 100dvh;
}

/* ── Page ─────────────────────────────────────────────────────────────────── */
.page {
  height: 100dvh;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}

/* ── Ambient blur ─────────────────────────────────────────────────────────── */
.ambient {
  position: fixed; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
  filter: blur(90px) brightness(0.07) saturate(3);
  transform: scale(1.18);
  transition: background-image var(--ts) var(--ease);
  pointer-events: none;
}

/* ── Screen transitions ───────────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0;
  transform: translateY(10px) scale(0.996);
  pointer-events: none;
  transition: opacity var(--tm) var(--eout), transform var(--tm) var(--eout);
  z-index: 1;
  will-change: opacity, transform;
}
.screen.visible {
  opacity: 1; transform: none;
  pointer-events: all;
  transition-duration: var(--ts);
}
.screen.out {
  opacity: 0; transform: translateY(-7px) scale(1.003);
  transition-duration: var(--tf);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px; height: 46px;
  background: rgba(9,9,13,0.82);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.header-logo { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.logo-icon {
  width: 20px; height: 20px; border-radius: 5px;
  object-fit: cover;
  filter: drop-shadow(0 2px 6px var(--a-glow));
}
.logo-text { font-size: 14px; font-weight: 650; color: var(--t1); letter-spacing: -0.02em; }
.logo-text b { color: var(--a); font-weight: 700; }

.header-track {
  flex: 1; display: flex; align-items: center; gap: 7px; min-width: 0;
  opacity: 0; transform: translateX(-4px);
  transition: opacity var(--ts) var(--eout), transform var(--ts) var(--eout);
}
.header-track.show { opacity: 1; transform: none; }
.ht-title { font-size: 12.5px; font-weight: 600; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ht-sep   { color: var(--t3); flex-shrink: 0; font-size: 11px; }
.ht-artist { font-size: 12px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.badge-ffmpeg {
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--line2);
  color: var(--t3); text-transform: lowercase;
  transition: all var(--tm) var(--ease);
}
.badge-ffmpeg.ok  { color: var(--green);  border-color: rgba(86,219,160,0.28); background: rgba(86,219,160,0.07); }
.badge-ffmpeg.err { color: #ff7070; border-color: rgba(255,112,112,0.28); }

/* ── Import screen ────────────────────────────────────────────────────────── */
.screen-import { align-items: center; justify-content: center; padding: 32px 20px; }

.import-wrap {
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 24px;
  animation: fadeUp var(--ts) var(--eout) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.import-brand { text-align: center; }
.brand-icon {
  width: 52px; height: 52px; border-radius: 13px; object-fit: cover;
  margin-bottom: 16px;
  box-shadow: 0 0 0 1px var(--line2), 0 8px 24px var(--a-glow);
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}
.brand-title {
  font-size: 24px; font-weight: 700; letter-spacing: -0.04em;
  color: var(--t1); margin-bottom: 7px;
}
.brand-sub { font-size: 13px; color: var(--t2); line-height: 1.55; }

.import-card {
  background: var(--bg1); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: 0 24px 48px rgba(0,0,0,0.55), inset 0 1px 0 var(--line2);
}

/* Tabs */
.tab-bar { display: flex; border-bottom: 1px solid var(--line); background: var(--bg); }
.tab {
  flex: 1; padding: 11px 16px;
  background: none; border: none;
  font-family: var(--ff); font-size: 12.5px; font-weight: 500;
  color: var(--t3); cursor: pointer; position: relative;
  transition: color var(--tf) var(--ease);
}
.tab::after {
  content: ''; position: absolute;
  bottom: -1px; left: 50%; right: 50%; height: 2px;
  background: var(--a); border-radius: 1px 1px 0 0;
  transition: left var(--tm) var(--ease), right var(--tm) var(--ease);
}
.tab.active { color: var(--t1); }
.tab.active::after { left: 14px; right: 14px; }
.tab:hover:not(.active) { color: var(--t2); }

.tab-pane { display: none; padding: 18px 18px 20px; }
.tab-pane.active { display: block; }

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--line3); border-radius: var(--r-md);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: border-color var(--tf) var(--ease), background var(--tf) var(--ease);
}
.dropzone:hover, .dropzone.over {
  border-color: var(--a); background: rgba(224,85,144,0.04);
}
.dz-svg {
  width: 40px; height: 40px; color: var(--t3);
  margin: 0 auto 11px; display: block;
  transition: color var(--tf) var(--ease);
}
.dropzone:hover .dz-svg, .dropzone.over .dz-svg { color: var(--a); }
.dz-main { font-size: 13.5px; font-weight: 500; color: var(--t1); margin-bottom: 3px; }
.dz-hint { font-size: 12px; color: var(--t3); }

/* Field */
.field-group { margin-bottom: 12px; }
.field-label {
  display: block; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--t3); margin-bottom: 6px;
}
.field-input {
  width: 100%; padding: 9px 12px;
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--r-sm); color: var(--t1);
  font-family: var(--ff); font-size: 13px; outline: none;
  transition: border-color var(--tf) var(--ease), box-shadow var(--tf) var(--ease);
}
.field-input:focus { border-color: var(--a); box-shadow: 0 0 0 3px var(--a-glow); }
.field-input::placeholder { color: var(--t3); }

/* Primary button */
.btn-primary {
  width: 100%; padding: 10px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--a); border: none; border-radius: var(--r-sm);
  color: #fff; font-family: var(--ff); font-size: 13.5px; font-weight: 600;
  cursor: pointer; letter-spacing: -0.01em;
  transition: background var(--tf) var(--ease), transform var(--tf) var(--ease), box-shadow var(--tf) var(--ease);
}
.btn-primary svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary:hover { background: var(--a2); transform: translateY(-1px); box-shadow: 0 6px 18px var(--a-glow); }
.btn-primary:active { transform: none; box-shadow: none; }

/* Load bar */
.load-bar { padding: 14px 18px; border-top: 1px solid var(--line); background: var(--bg); }
.lb-text { font-size: 11.5px; color: var(--t2); margin-bottom: 7px; }
.lb-track { height: 2px; background: var(--bg3); border-radius: 1px; overflow: hidden; }
.lb-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--a), var(--purple)); border-radius: 1px;
  transition: width 0.3s var(--ease);
  animation: shimmer 1.6s ease infinite;
}
@keyframes shimmer { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }

/* ── Player screen ────────────────────────────────────────────────────────── */
.screen-player { overflow: hidden; }

/* Topbar */
.topbar {
  flex-shrink: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px;
  background: var(--bg1); border-bottom: 1px solid var(--line);
  position: relative;
}
.topbar-btn {
  width: 30px; height: 30px; flex-shrink: 0;
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--r-sm); color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--tf) var(--ease);
}
.topbar-btn svg { width: 15px; height: 15px; }
.topbar-btn:hover { color: var(--t1); border-color: var(--a); background: rgba(224,85,144,0.08); }

.topbar-info { flex: 1; min-width: 0; overflow: hidden; }
.ti-title {
  display: block; font-size: 13px; font-weight: 600; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--t1); line-height: 1.3;
}
.ti-sub {
  display: block; font-size: 10.5px; color: var(--t3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4;
}

/* Difficulty bar — dedicated row above the viewport */
.diff-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.diff-bar-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--t3); flex-shrink: 0;
}
.diff-select {
  flex: 1; max-width: 500px;
  padding: 6px 10px;
  background: var(--bg2); border: 1px solid var(--line3);
  border-radius: var(--r-sm); color: var(--t1);
  font-family: var(--ff); font-size: 13px; font-weight: 500;
  cursor: pointer; outline: none;
  -webkit-appearance: auto; appearance: auto;
  transition: border-color var(--tf) var(--ease);
}
.diff-select:focus { border-color: var(--a); }
.diff-select option, .diff-select optgroup { background: #1a1a24; color: #f0f0f8; }

.topbar-chips { display: flex; gap: 3px; flex-wrap: wrap; margin-left: auto; }
.chip {
  padding: 2px 6px; border-radius: 3px; font-size: 9.5px; font-weight: 650;
  background: var(--bg3); border: 1px solid var(--line); color: var(--t3);
}
.chip.cs { color: var(--blue);   border-color: rgba(91,163,224,0.2); background: rgba(91,163,224,0.06); }
.chip.ar { color: var(--green);  border-color: rgba(86,219,160,0.2); background: rgba(86,219,160,0.06); }
.chip.od { color: var(--a);      border-color: rgba(224,85,144,0.2); background: rgba(224,85,144,0.06); }
.chip.hp { color: var(--purple); border-color: rgba(155,114,224,0.2); background: rgba(155,114,224,0.06); }

/* Player body */
.player-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }

/* Viewport */
.viewport { position: relative; flex: 1; background: #000; overflow: hidden; min-width: 0; }
.vp-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vp-dim { position: absolute; inset: 0; background: rgba(0,0,0,0.3); pointer-events: none; }

/* Side panel */
.side {
  width: 208px; flex-shrink: 0;
  background: var(--bg1); border-left: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.side-block { padding: 12px; border-bottom: 1px solid var(--line); }
.side-block:last-child { border-bottom: none; }
.side-label {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--t3); margin-bottom: 9px;
}

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.sg-cell {
  background: var(--bg2); border-radius: var(--r-sm);
  padding: 6px 8px; border: 1px solid var(--line);
}
.sg-k {
  display: block; font-size: 8.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--t3); margin-bottom: 2px;
}
.sg-v { font-size: 11px; font-weight: 500; color: var(--t1); }
.mono { font-family: var(--mono); }
.dim  { color: var(--t2); }

/* Controls */
.ctrl-row { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.ctrl-row:last-child { margin-bottom: 0; }
.ctrl-row-2 { display: flex; gap: 5px; margin-bottom: 7px; }
.ctrl-row.half { flex: 1; margin-bottom: 0; }
.cr-label { font-size: 10.5px; color: var(--t2); flex-shrink: 0; width: 63px; }

/* Toggle */
.sw { position: relative; width: 30px; height: 17px; flex-shrink: 0; cursor: pointer; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw-track {
  position: absolute; inset: 0; border-radius: 9px;
  background: var(--bg4); border: 1px solid var(--line2);
  transition: background var(--tf) var(--ease), border-color var(--tf) var(--ease);
}
.sw-track::after {
  content: ''; position: absolute;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--t3); top: 2px; left: 2px;
  transition: transform var(--tf) var(--ease), background var(--tf) var(--ease);
}
.sw input:checked + .sw-track { background: var(--a); border-color: var(--a); }
.sw input:checked + .sw-track::after { transform: translateX(13px); background: #fff; }

/* Range */
.sl {
  flex: 1; -webkit-appearance: none; height: 2px; border-radius: 1px;
  background: var(--bg4); outline: none; cursor: pointer;
}
.sl::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; border-radius: 50%;
  background: var(--a); cursor: pointer;
  transition: transform var(--tf) var(--ease), box-shadow var(--tf) var(--ease);
}
.sl::-webkit-slider-thumb:hover { transform: scale(1.3); box-shadow: 0 0 0 3px var(--a-glow); }
.sl-val { font-size: 10px; color: var(--t3); width: 28px; text-align: right; flex-shrink: 0; }

/* Select / number */
.sel {
  flex: 1; padding: 4px 6px;
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--r-sm); color: var(--t1);
  font-family: var(--ff); font-size: 11px; cursor: pointer; outline: none;
  transition: border-color var(--tf) var(--ease);
}
.sel:focus { border-color: var(--a); }
.num-in {
  flex: 1; padding: 4px 6px;
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--r-sm); color: var(--t1);
  font-family: var(--mono); font-size: 10.5px; outline: none; min-width: 0;
  transition: border-color var(--tf) var(--ease), box-shadow var(--tf) var(--ease);
}
.num-in:focus { border-color: var(--a); box-shadow: 0 0 0 2px var(--a-glow); }

/* Export button */
.btn-export {
  width: 100%; padding: 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--r-sm); color: var(--t2);
  font-family: var(--ff); font-size: 12.5px; font-weight: 500;
  cursor: pointer; margin-top: 2px;
  transition: all var(--tf) var(--ease);
}
.btn-export svg { width: 13px; height: 13px; flex-shrink: 0; }
.btn-export:hover {
  background: var(--a); border-color: var(--a); color: #fff;
  transform: translateY(-1px); box-shadow: 0 4px 14px var(--a-glow);
}
.btn-export:active { transform: none; }
.btn-export:disabled { opacity: 0.38; cursor: not-allowed; transform: none; box-shadow: none; }

.exp-progress { margin-top: 9px; }
.ep-label { font-size: 10.5px; color: var(--t2); margin-bottom: 5px; display: block; }
.ep-track { height: 2px; background: var(--bg4); border-radius: 1px; overflow: hidden; }
.ep-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--a), var(--purple)); border-radius: 1px;
  transition: width 0.25s var(--ease);
}

/* ── Timeline ─────────────────────────────────────────────────────────────── */
.timeline {
  flex-shrink: 0; position: relative; height: 36px;
  background: var(--bg); border-top: 1px solid var(--line);
}
.tl-wave { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.25; }
.tl-interact { position: absolute; inset: 0; cursor: pointer; }
.tl-progress {
  height: 100%;
  background: linear-gradient(90deg, rgba(224,85,144,0.13), rgba(155,114,224,0.08));
  pointer-events: none; transition: width 55ms linear;
}
.tl-marks { position: absolute; inset: 0; pointer-events: none; }
.tl-mark { position: absolute; top: 0; bottom: 0; width: 1px; transform: translateX(-50%); opacity: 0.3; }
.tl-mark.circle  { background: var(--a); }
.tl-mark.slider  { background: var(--blue); }
.tl-mark.spinner { background: var(--purple); }
.tl-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 9px; height: 9px; border-radius: 50%; background: var(--a);
  box-shadow: 0 0 0 2px rgba(224,85,144,0.3), 0 0 10px var(--a-glow);
  pointer-events: none; transition: left 55ms linear;
}

/* ── Transport ────────────────────────────────────────────────────────────── */
.transport {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; gap: 12px;
  background: var(--bg1); border-top: 1px solid var(--line);
}
.tr-left, .tr-right { display: flex; align-items: center; gap: 5px; }
.tr-btn {
  width: 32px; height: 32px;
  background: transparent; border: 1px solid var(--line2);
  border-radius: var(--r-sm); color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: color var(--tf) var(--ease), background var(--tf) var(--ease), border-color var(--tf) var(--ease);
}
.tr-btn svg { width: 14px; height: 14px; }
.tr-btn:hover { color: var(--t1); background: var(--bg3); border-color: var(--line3); }
.tr-btn.tr-sm { width: 26px; height: 26px; }
.tr-btn.tr-sm svg { width: 12px; height: 12px; }

.tr-play {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--a); border-color: transparent; color: #fff;
  box-shadow: 0 2px 10px var(--a-glow);
  transition: background var(--tf) var(--ease), transform var(--tf) var(--ease), box-shadow var(--tf) var(--ease);
}
.tr-play:hover {
  background: var(--a2); border-color: transparent; color: #fff;
  transform: scale(1.07); box-shadow: 0 4px 18px rgba(224,85,144,0.42);
}
.tr-play svg { width: 15px; height: 15px; }
.icon-play, .icon-pause { display: block; }
.icon-play.hidden, .icon-pause.hidden { display: none; }

.tr-time { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 500; }
.tr-sep { color: var(--t3); font-size: 11px; }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed; bottom: 18px; right: 18px; z-index: 999;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast {
  padding: 10px 14px;
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--r-md); font-size: 12.5px; font-weight: 500; color: var(--t1);
  pointer-events: auto; max-width: 300px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: tIn var(--tm) var(--eout) both;
}
@keyframes tIn {
  from { opacity: 0; transform: translateX(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.toast.out { animation: tOut var(--tf) var(--ease) forwards; }
@keyframes tOut { to { opacity: 0; transform: translateX(8px) scale(0.96); } }
.toast.success { border-color: rgba(86,219,160,0.28); color: var(--green); }
.toast.error   { border-color: rgba(255,112,112,0.28); color: #ff8080; }
.toast.warn    { border-color: rgba(224,168,85,0.28);  color: var(--amber); }

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

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .side { width: 100%; max-height: 240px; border-left: none; border-top: 1px solid var(--line); }
  .player-body { flex-direction: column; }
  .topbar-chips { display: none; }
  .brand-title { font-size: 20px; }
  .import-wrap { gap: 18px; }
}
