:root {
  --bg: #050816;
  --panel: rgba(12, 18, 38, 0.74);
  --panel-strong: rgba(16, 24, 52, 0.92);
  --line: rgba(148, 163, 184, 0.22);
  --text: #eef6ff;
  --muted: #9fb2cc;
  --cyan: #45f3ff;
  --pink: #ff4fd8;
  --violet: #936bff;
  --green: #79ffb2;
  --danger: #ff6b8a;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
  --radius: 24px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 12% 0%, rgba(69, 243, 255, 0.18), transparent 33%),
    radial-gradient(circle at 88% 8%, rgba(255, 79, 216, 0.15), transparent 35%),
    linear-gradient(145deg, #030512 0%, #071225 44%, #050816 100%);
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.aurora {
  position: fixed;
  inset: auto;
  width: 42vw;
  height: 42vw;
  min-width: 360px;
  min-height: 360px;
  filter: blur(70px);
  opacity: 0.28;
  pointer-events: none;
  z-index: -3;
  animation: drift 12s ease-in-out infinite alternate;
}
.aurora-a { left: -8vw; top: 18vh; background: var(--cyan); }
.aurora-b { right: -10vw; bottom: 2vh; background: var(--pink); animation-delay: -5s; }
.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background-image:
    linear-gradient(rgba(69, 243, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 243, 255, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.75), transparent 88%);
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(5vw, -4vh, 0) scale(1.18); }
}

.app-header, .app-footer, .app-shell {
  width: min(1580px, calc(100% - 32px));
  margin: 0 auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 34px 0 22px;
}

.eyebrow, .panel-kicker {
  margin: 0 0 7px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-family: var(--mono);
  font-size: 0.76rem;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  text-shadow: 0 0 22px rgba(69, 243, 255, 0.16);
}
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -0.025em; }
h3 { margin: 0; font-size: 1rem; }
.subtitle { max-width: 780px; margin-bottom: 0; color: var(--muted); line-height: 1.55; }

.header-actions, .button-row, .upload-row, .download-actions, .selected-toolbar, .global-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}
.example-select {
  min-width: 230px;
  max-width: 280px;
}

.top-grid {
  display: grid;
  grid-template-columns: minmax(460px, 0.95fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.025)), var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(69,243,255,0.22), transparent 28%, transparent 72%, rgba(255,79,216,0.18));
  opacity: 0.28;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  padding: 1px;
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(159, 178, 204, 0.28);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  font-size: 0.78rem;
  font-family: var(--mono);
}
.status-pill.ok, .status-pill.accent { color: #d8fff0; border-color: rgba(121,255,178,.36); box-shadow: 0 0 18px rgba(121,255,178,.12); }
.status-pill.error { color: #ffe1e7; border-color: rgba(255,107,138,.45); }
.divider { height: 1px; margin: 18px 0; background: linear-gradient(90deg, transparent, var(--line), transparent); }

.file-btn, .primary-btn, .ghost-btn, .small-btn {
  border: 1px solid rgba(69, 243, 255, 0.28);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--text);
  background: rgba(69, 243, 255, 0.08);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.file-btn:hover, .primary-btn:hover, .ghost-btn:hover, .small-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(69, 243, 255, 0.7);
  box-shadow: 0 0 26px rgba(69, 243, 255, 0.16);
}
.primary-btn {
  border-color: rgba(255,79,216,.52);
  background: linear-gradient(135deg, rgba(69,243,255,.20), rgba(255,79,216,.24));
  font-weight: 800;
}
.ghost-btn { background: rgba(255,255,255,0.045); border-color: rgba(159,178,204,.28); }
.small-btn { padding: 8px 11px; font-size: .86rem; }
.glow-btn {
  border-color: rgba(255,79,216,.54);
  box-shadow: 0 0 18px rgba(255,79,216,.16), inset 0 0 12px rgba(69,243,255,.08);
}
.file-btn input { display: none; }

.score-render {
  min-height: 178px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(159,178,204,.18);
  border-radius: 18px;
  background: rgba(255,255,255,.91);
  color: #08111f;
  overflow: auto;
}
.compact-score { max-height: 260px; }
.selected-score { min-height: 320px; max-height: 460px; }
.score-render .placeholder {
  color: #5b6678;
  font-weight: 700;
}
.muted { color: var(--muted); font-size: 0.88rem; line-height: 1.45; margin: 10px 0 0; }

.settings-form { display: grid; gap: 14px; }
.control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.control, .duration-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(159,178,204,.16);
}
.control span, .duration-box label { color: #d9e7fb; font-size: .88rem; font-weight: 700; }
.control output { color: var(--cyan); font-family: var(--mono); font-size: .82rem; }
.control.slim { min-width: 160px; flex: 1 1 160px; }
input[type="range"] { width: 100%; accent-color: var(--cyan); }
input[type="number"], input[type="text"], select {
  width: 100%;
  border: 1px solid rgba(159,178,204,.22);
  border-radius: 12px;
  padding: 10px 11px;
  color: var(--text);
  background: rgba(3, 6, 18, 0.72);
  outline: none;
}
input:focus, select:focus { border-color: rgba(69,243,255,.65); box-shadow: 0 0 0 3px rgba(69,243,255,.10); }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d9e7fb;
  line-height: 1.35;
}
.checkbox-row input { accent-color: var(--pink); }
.message-box {
  min-height: 42px;
  border: 1px solid rgba(159,178,204,.16);
  border-radius: 16px;
  padding: 12px;
  color: var(--muted);
  background: rgba(0,0,0,.14);
  line-height: 1.45;
}
.message-box.error { color: #ffe1e7; border-color: rgba(255,107,138,.42); }
.message-box.ok { color: #dbfff0; border-color: rgba(121,255,178,.3); }

.results-panel { margin-top: 18px; }
.results-heading { align-items: center; }
.results-grid { display: grid; grid-template-columns: minmax(420px, .78fr) minmax(420px, 1fr); gap: 16px; }
.chart-card, .selected-score-card, .slider-card {
  border: 1px solid rgba(159,178,204,.16);
  border-radius: 20px;
  padding: 14px;
  background: rgba(0,0,0,.16);
}
.chart-card canvas { max-height: 270px; }
.slider-card { margin-top: 14px; }
.slider-card label { display: block; margin-bottom: 10px; color: #d9e7fb; font-weight: 800; }
.state-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .82rem;
}
.selected-toolbar { justify-content: space-between; margin-bottom: 12px; }
.app-footer { padding: 22px 0 34px; color: var(--muted); font-size: .84rem; text-align: center; }

@media (max-width: 1120px) {
  .top-grid, .results-grid { grid-template-columns: 1fr; }
  .app-header { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 680px) {
  .app-header, .app-footer, .app-shell { width: min(100% - 18px, 1580px); }
  .panel { padding: 14px; border-radius: 20px; }
  .control-grid { grid-template-columns: 1fr; }
  .download-actions, .header-actions, .button-row, .upload-row { width: 100%; }
  .download-actions button, .button-row button { flex: 1 1 100%; }
  h1 { font-size: 2.15rem; }
}
