/* ---------------------------------------------------------------------------
   Design System
   --------------------------------------------------------------------------- */

:root {
  --bg-base: #090909;
  --bg-elevated: #0e0e0e;
  --bg-surface: #141414;
  --bg-hover: #1a1a1a;

  --text-primary: #e8e8e8;
  --text-secondary: #9a9a9a;
  --text-tertiary: #6b6b6b;
  --text-muted: #4a4a4a;

  --accent: #c43a3a;
  --accent-dim: #8a2a2a;
  --accent-faint: #3a1515;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.1);

  --radius-sm: 3px;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */

.app-header {
  margin-bottom: var(--space-lg);
}

.app-title {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
}

.app-subtitle {
  margin-top: var(--space-xs);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 560px;
}

/* ---------------------------------------------------------------------------
   Tutorial
   --------------------------------------------------------------------------- */

.tutorial-section {
  margin-bottom: var(--space-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

.tutorial-header {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  background: transparent;
  border: none;
  transition: background 0.15s ease;
}

.tutorial-header:hover {
  background: var(--bg-hover);
}

.tutorial-header:focus-visible {
  outline: 2px solid var(--accent-dim);
  outline-offset: -2px;
}

.tutorial-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tutorial-toggle {
  width: 16px;
  height: 16px;
  position: relative;
  flex-shrink: 0;
  margin-left: var(--space-sm);
}

.tutorial-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-tertiary);
  border-bottom: 1.5px solid var(--text-tertiary);
  transform: translate(-50%, -60%) rotate(45deg);
  transition: transform 0.2s ease;
}

.tutorial-header[aria-expanded="true"] .tutorial-toggle::after {
  transform: translate(-50%, -40%) rotate(-135deg);
}

.tutorial-content {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  animation: fadeIn 0.2s ease;
}

.tutorial-content[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
}

.tutorial-block h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-sm);
}

.tutorial-block p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.tutorial-block ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.tutorial-block li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 12px;
  position: relative;
}

.tutorial-block li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 4px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 50%;
}

.quality-high,
.quality-medium,
.quality-low {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  font-family: var(--font-mono);
}

.quality-high {
  background: rgba(74, 138, 74, 0.12);
  color: #6abf6a;
}

.quality-medium {
  background: rgba(200, 160, 60, 0.12);
  color: #d4b44a;
}

.quality-low {
  background: rgba(196, 58, 58, 0.12);
  color: #d06060;
}

/* ---------------------------------------------------------------------------
   Drop Zone
   --------------------------------------------------------------------------- */

.drop-zone {
  border: 1px dashed var(--border);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--bg-elevated);
  position: relative;
}

.drop-zone:hover {
  border-color: var(--accent-dim);
  background: var(--bg-surface);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  pointer-events: none;
}

.drop-primary {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.drop-secondary {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------------------
   Status
   --------------------------------------------------------------------------- */

.status {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: var(--space-md);
  min-height: 20px;
}

.status.active {
  color: var(--text-primary);
}

.status.error {
  color: #e06060;
  padding: var(--space-sm) var(--space-md);
  background: rgba(196, 58, 58, 0.08);
  border-left: 2px solid var(--accent);
}

/* ---------------------------------------------------------------------------
   Progress
   --------------------------------------------------------------------------- */

.progress-container {
  background: var(--bg-surface);
  height: 3px;
  margin-top: var(--space-sm);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.progress-text {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------------------
   Results
   --------------------------------------------------------------------------- */

.results {
  margin-top: var(--space-lg);
}

/* Quality Verdict */
.quality-verdict {
  margin-bottom: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.verdict-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.verdict-badge.excellent {
  background: rgba(74, 138, 74, 0.15);
  color: #6abf6a;
  border: 1px solid rgba(74, 138, 74, 0.25);
}

.verdict-badge.good {
  background: rgba(108, 160, 108, 0.15);
  color: #7aba7a;
  border: 1px solid rgba(108, 160, 108, 0.25);
}

.verdict-badge.fair {
  background: rgba(200, 160, 60, 0.15);
  color: #d4b44a;
  border: 1px solid rgba(200, 160, 60, 0.25);
}

.verdict-badge.poor {
  background: rgba(196, 58, 58, 0.15);
  color: #d06060;
  border: 1px solid rgba(196, 58, 58, 0.25);
}

.verdict-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.verdict-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Metadata Bar */
.metadata-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md) var(--space-xl);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  border-top: none;
  background: var(--bg-elevated);
}

.metadata-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metadata-group .metadata-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.metadata-group .metadata-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Spectrogram Stage */
.spectrogram-stage {
  background: #000;
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-bottom: none;
  padding: var(--space-lg) var(--space-md) var(--space-md);
  position: relative;
}

#spectrogram-container {
  position: relative;
  background: #000;
  padding: 0 56px 28px 64px;
}

.freq-marker {
  position: absolute;
  left: 8px;
  width: 50px;
  text-align: right;
  font-size: 10px;
  color: var(--text-tertiary);
  padding-right: 8px;
  font-family: var(--font-mono);
}

.freq-line {
  position: absolute;
  left: 64px;
  right: 56px;
  height: 1px;
  background: rgba(255, 60, 60, 0.08);
  pointer-events: none;
}

.db-scale {
  position: absolute;
  right: 4px;
  top: 0;
  height: 512px;
  width: 46px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-tertiary);
  padding: 4px 0;
  font-family: var(--font-mono);
}

#spectrogram-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  width: 100%;
  height: 512px;
  background: #000;
}

/* Audio Player */
.audio-player {
  border: 1px solid var(--border-subtle);
  border-top: none;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-elevated);
}

.play-button {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.play-button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.play-button:focus-visible {
  outline: 2px solid var(--accent-dim);
  outline-offset: 2px;
}

.play-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.audio-progress {
  flex: 1;
  height: 4px;
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-radius: 1px;
}

.audio-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
}

.audio-progress:focus-visible {
  outline: 2px solid var(--accent-dim);
  outline-offset: 2px;
}

.audio-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  min-width: 90px;
  text-align: right;
  flex-shrink: 0;
}

/* Buttons */
.btn-secondary {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  margin-top: var(--space-lg);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--accent-dim);
  color: var(--text-primary);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--accent-dim);
  outline-offset: 2px;
}

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

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .container {
    padding: var(--space-md);
  }

  .metadata-bar {
    gap: var(--space-sm) var(--space-md);
  }

  #spectrogram-container {
    padding: 0 40px 24px 52px;
  }

  .freq-marker {
    left: 4px;
    width: 42px;
    font-size: 9px;
  }

  .db-scale {
    width: 36px;
    font-size: 8px;
  }

  .tutorial-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}
