/* =========================================================
   FutureMedia — Design tokens
   Palette: deep signal-navy base, violet→teal "waveform" gradient
   Type: Space Grotesk (display) / Inter (body) / JetBrains Mono (data)
   Signature: equalizer-bar loading state + gradient progress ring
   ========================================================= */

:root {
  --bg-0: #0a0d16;
  --bg-1: #0f1320;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-hi: #eef0f7;
  --text-mid: #a7acc2;
  --text-dim: #676e88;

  --violet: #7c6cf6;
  --teal: #17d9c4;
  --coral: #ff6b8b;

  --grad-signal: linear-gradient(120deg, var(--violet) 0%, var(--teal) 100%);
  --grad-signal-soft: linear-gradient(120deg, rgba(124, 108, 246, 0.18), rgba(23, 217, 196, 0.18));

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-card: 0 20px 60px -20px rgba(0, 0, 0, 0.55);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  color-scheme: dark;
}

body.theme-light {
  --bg-0: #f4f5fa;
  --bg-1: #ffffff;
  --surface: rgba(20, 24, 40, 0.035);
  --surface-strong: rgba(20, 24, 40, 0.06);
  --border: rgba(20, 24, 40, 0.08);
  --border-strong: rgba(20, 24, 40, 0.14);
  --text-hi: #171a26;
  --text-mid: #565c74;
  --text-dim: #8b90a3;
  --shadow-card: 0 20px 60px -24px rgba(30, 34, 60, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg-0);
  color: var(--text-hi);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- ambient background ---------- */

.mesh-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(45% 40% at 15% 10%, rgba(124, 108, 246, 0.20), transparent 60%),
    radial-gradient(40% 35% at 90% 20%, rgba(23, 217, 196, 0.14), transparent 60%),
    radial-gradient(50% 45% at 50% 100%, rgba(124, 108, 246, 0.10), transparent 60%);
  animation: meshDrift 24s ease-in-out infinite alternate;
}

@keyframes meshDrift {
  0%   { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(-2%, 1%, 0) scale(1.04); }
}

/* ---------- shell / layout ---------- */

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.rail {
  width: 88px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.rail-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--grad-signal);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a0d16;
  font-size: 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px -8px rgba(124, 108, 246, 0.6);
}

.rail-btn {
  width: 60px;
  padding: 10px 4px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.rail-btn i { font-size: 16px; }

.rail-btn:hover { background: var(--surface-strong); color: var(--text-mid); }

.rail-btn.is-active {
  color: var(--text-hi);
  background: var(--surface-strong);
}

.rail-btn.is-active i {
  background: var(--grad-signal);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.rail-spacer { flex: 1; }

.rail-theme { font-size: 15px; }

/* ---------- stage ---------- */

.stage {
  flex: 1;
  padding: 56px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}

.view { display: none; width: 100%; max-width: 560px; }
.view.is-active { display: block; }

.view-header { margin-bottom: 24px; }
.view-header h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 0;
}

/* ---------- hero ---------- */

.hero { text-align: center; margin-bottom: 34px; }

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  background: var(--grad-signal);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-tagline {
  margin: 0;
  color: var(--text-mid);
  font-size: 15px;
}

/* ---------- glass card ---------- */

.glass-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: var(--shadow-card);
  padding: 26px;
  margin-bottom: 18px;
}

/* ---------- form ---------- */

.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease;
}

.input-wrap:focus-within { border-color: var(--violet); }

.input-icon {
  padding-left: 15px;
  color: var(--text-dim);
  font-size: 13px;
}

.input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 13px 12px;
  font-size: 14.5px;
  color: var(--text-hi);
}

.platform-chip {
  margin-right: 10px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  background: var(--grad-signal-soft);
  color: var(--teal);
  white-space: nowrap;
}

.segmented {
  display: flex;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 9px 8px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}

.seg-btn.is-active {
  background: var(--grad-signal);
  color: #0a0d16;
  font-weight: 600;
}

.select-wrap {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.select-wrap select {
  width: 100%;
  appearance: none;
  border: none;
  background: transparent;
  padding: 13px 34px 13px 14px;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.select-caret {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
}

.btn-primary {
  position: relative;
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 15px;
  font-size: 15px;
  font-weight: 600;
  color: #0a0d16;
  background: var(--grad-signal);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin-top: 6px;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px -10px rgba(124, 108, 246, 0.55); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.7; cursor: progress; }

/* signature loading state: equalizer bars replace label */
.btn-wave {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}
.btn-wave i {
  width: 3px;
  background: #0a0d16;
  border-radius: 2px;
  animation: eqBar 0.9s ease-in-out infinite;
}
.btn-wave i:nth-child(1) { height: 40%; animation-delay: 0s; }
.btn-wave i:nth-child(2) { height: 100%; animation-delay: 0.1s; }
.btn-wave i:nth-child(3) { height: 60%; animation-delay: 0.2s; }
.btn-wave i:nth-child(4) { height: 90%; animation-delay: 0.3s; }
.btn-wave i:nth-child(5) { height: 50%; animation-delay: 0.4s; }

@keyframes eqBar {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

.btn-primary.is-loading .btn-label { display: none; }
.btn-primary.is-loading .btn-wave { display: flex; }

/* ---------- result card ---------- */

.result-card { display: flex; gap: 18px; }

.result-thumb {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-md);
  background: var(--grad-signal);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: rgba(10, 13, 22, 0.7);
}

.result-info { flex: 1; min-width: 0; }

.result-row-title { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }

.result-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
}

.result-value {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-row-title .result-value { font-size: 16px; font-weight: 600; white-space: normal; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin-bottom: 16px;
}

.result-cell { display: flex; flex-direction: column; gap: 3px; }

.btn-download { margin-top: 0; }

/* ---------- progress card ---------- */

.progress-card {
  display: flex;
  align-items: center;
  gap: 24px;
}

.progress-ring-wrap { position: relative; width: 120px; height: 120px; flex-shrink: 0; }

.progress-ring { width: 120px; height: 120px; transform: rotate(-90deg); }

.progress-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.progress-ring-fg {
  fill: none;
  stroke: url(#none);
  stroke: var(--teal);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.3s ease;
}

.progress-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
}

.progress-meta { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.progress-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--text-mid);
  font-family: var(--font-mono);
}

.progress-meta-row span:last-child { color: var(--text-hi); }

/* ---------- history ---------- */

.history-list { list-style: none; margin: 0; padding: 0; }

.history-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 0;
  font-size: 14px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--grad-signal-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
  font-size: 14px;
}

.history-info { flex: 1; min-width: 0; }
.history-title {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-sub { font-size: 12px; color: var(--text-dim); }

.history-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-strong); color: var(--text-hi); }

/* ---------- settings ---------- */

.settings-group-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.settings-row:last-child { border-bottom: none; }

.settings-row-input input {
  width: 55%;
  text-align: right;
  border: none;
  background: transparent;
  color: var(--text-mid);
  font-size: 13px;
  outline: none;
  font-family: var(--font-mono);
}

.segmented-sm { width: auto; }
.segmented-sm .seg-btn { padding: 7px 12px; }

.select-wrap-sm { width: 140px; }

.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 100px;
  transition: background 0.2s ease;
  cursor: pointer;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-hi);
  transition: transform 0.2s ease;
}
.toggle input:checked + .toggle-track { background: var(--grad-signal); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); background: #0a0d16; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  color: var(--text-hi);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 13.5px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 50;
}

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

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }

  .rail {
    width: 100%;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    order: 2;
    padding: 8px 10px;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 10;
  }

  .rail-logo { display: none; }
  .rail-spacer { display: none; }
  .rail-theme { margin-left: auto; }
  .rail-btn { width: auto; flex: 1; }

  .stage { order: 1; padding: 32px 16px 100px; }

  .hero-title { font-size: 34px; }

  .field-row { grid-template-columns: 1fr; }

  .result-card { flex-direction: column; }
  .result-thumb { width: 100%; height: 64px; }

  .progress-card { flex-direction: column; text-align: center; }
  .progress-meta-row { justify-content: center; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .mesh-bg, .btn-wave i { animation: none !important; }
}
