/* === Neo-BW Theme Tokens === */
:root {
  --bg: #0A0A0A;
  --surface: #111111;
  --surface-2: #161616;
  --surface-3: #1A1A1A;
  --text: #F5F5F5;
  --muted: #B3B3B3;
  --border: rgba(245,245,245,0.12);
  --primary: #FFFFFF;
  --primary-contrast: #0A0A0A;
  --accent: #A3FF12;
  --accent-dim: rgba(163,255,18,0.15);
  --accent-glow: rgba(163,255,18,0.35);
  --danger: #FF3B30;
  --success: #34C759;
  --warning: #FFCC00;
  --live-red: #FF3B30;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-1: 0 10px 30px rgba(0,0,0,0.45);
  --shadow-2: 0 24px 80px rgba(0,0,0,0.60);
  --ring: rgba(163,255,18,0.45);

  --glass-bg: rgba(17,17,17,0.72);
  --glass-border: rgba(245,245,245,0.08);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Scanline texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.015) 2px,
    rgba(255,255,255,0.015) 4px
  );
}

/* Glassmorphism utility */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
}

/* === AppBar — ON AIR Studio Header === */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  min-height: 64px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.appbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

/* ON AIR / READY badge */
.badge-onair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  color: var(--live-red);
  background: rgba(255,59,48,0.12);
  border: 1px solid rgba(255,59,48,0.25);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  min-height: 28px;
  transition: all 0.3s ease;
}
.badge-onair .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live-red);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
.badge-onair.ready {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(163,255,18,0.25);
}
.badge-onair.ready .dot {
  background: var(--accent);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.appbar-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: 0.02em;
}
.appbar-title span { color: var(--accent); font-weight: 800; }

.appbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.appbar-clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
  min-width: 44px;
  text-align: right;
}
.appbar-right a {
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: color 0.16s ease-out;
}
.appbar-right a:hover { color: var(--accent); }

/* === Main === */
.main {
  flex: 1;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* === Category Channel Strip === */
.chips {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease-out;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
}
.chip .chip-icon { font-size: 15px; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
  background: var(--accent);
  color: var(--primary-contrast);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 16px var(--accent-glow);
}

/* === Action Section — Horizontal + Mic === */
.action-section {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 24px;
}

.btn {
  min-height: 48px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.16s ease-out;
  font-family: var(--font-sans);
  position: relative;
  overflow: hidden;
}
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--primary-contrast);
  flex: 1;
  flex-direction: column;
  gap: 2px;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-primary .btn-sub {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.7;
  display: block;
}

.btn-mic {
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease-out;
  position: relative;
  flex-shrink: 0;
}
.btn-mic:hover { border-color: var(--accent); }
.btn-mic.listening {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  animation: glow-ring 1.5s ease-in-out infinite;
}
@keyframes glow-ring {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-glow); }
  50% { box-shadow: 0 0 0 8px rgba(163,255,18,0.15); }
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); }

/* Voice status */
.voice-status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
  margin-bottom: 8px;
}
.voice-status:empty { display: none; }
.voice-status.listening { color: var(--accent); }
.voice-status.error { color: var(--danger); }

/* === Loading — 3-Step Progress === */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 48px 16px;
}

.loading-steps {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 360px;
}
.loading-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  position: relative;
}
.loading-step .step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}
.loading-step.active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary-contrast);
  box-shadow: 0 0 16px var(--accent-glow);
  animation: step-pulse 1.5s ease-in-out infinite;
}
.loading-step.done .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary-contrast);
}
@keyframes step-pulse {
  0%, 100% { box-shadow: 0 0 16px var(--accent-glow); }
  50% { box-shadow: 0 0 24px rgba(163,255,18,0.5); }
}

.loading-step .step-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.3s ease;
}
.loading-step.active .step-label,
.loading-step.done .step-label { color: var(--accent); }

/* Connector line between steps */
.loading-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  position: relative;
  top: -12px;
  z-index: 1;
  transition: background 0.3s ease;
}
.loading-connector.done { background: var(--accent); }

/* Typewriter loading text */
.loading-typewriter {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
}
.loading-typewriter .cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 0.8s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* === Custom Audio Player === */
.audio-player {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.audio-player audio { display: none; }

.player-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.player-play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.16s ease-out;
  color: var(--primary-contrast);
  font-size: 22px;
}
.player-play-btn:hover { filter: brightness(1.1); transform: scale(1.04); }
.player-play-btn:active { transform: scale(0.96); }

/* Equalizer bars */
.equalizer {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
  flex: 1;
}
.eq-bar {
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.3;
  height: 6px;
  transition: height 0.15s ease;
}
.equalizer.playing .eq-bar {
  opacity: 1;
  animation: eq-bounce 0.6s ease-in-out infinite alternate;
}
.equalizer.playing .eq-bar:nth-child(1) { animation-delay: 0s; }
.equalizer.playing .eq-bar:nth-child(2) { animation-delay: 0.1s; }
.equalizer.playing .eq-bar:nth-child(3) { animation-delay: 0.2s; }
.equalizer.playing .eq-bar:nth-child(4) { animation-delay: 0.15s; }
.equalizer.playing .eq-bar:nth-child(5) { animation-delay: 0.05s; }

@keyframes eq-bounce {
  0% { height: 6px; }
  100% { height: 28px; }
}

/* Speed control */
.player-speed {
  display: flex;
  gap: 4px;
}
.speed-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 28px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease-out;
}
.speed-btn:hover { border-color: var(--accent); color: var(--text); }
.speed-btn.active {
  background: var(--accent);
  color: var(--primary-contrast);
  border-color: var(--accent);
  font-weight: 700;
}

/* Progress bar */
.player-progress {
  margin-bottom: 8px;
}
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}
.player-time {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* === Script Section — Accordion === */
.script-section {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
}
.script-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  cursor: pointer;
  min-height: 56px;
  user-select: none;
}
.script-header:hover { background: rgba(255,255,255,0.03); }
.script-header h3 { font-size: 16px; font-weight: 600; }
.script-toggle {
  font-size: 14px;
  color: var(--muted);
  transition: transform 0.3s ease-out;
}
.script-toggle.open { transform: rotate(180deg); }
.script-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out, padding 0.3s ease-out;
  padding: 0 16px;
}
.script-body.open {
  max-height: 5000px;
  padding: 0 16px 16px;
}
.script-label {
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 16px 0 8px;
}
.script-line {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 4px;
  padding-left: 8px;
  border-left: 2px solid transparent;
  transition: border-color 0.3s ease;
}
.script-line.highlight {
  border-left-color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 0 4px 4px 0;
}
.script-line .lang-tag {
  font-size: 10px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
  font-family: var(--font-mono);
}

/* === Headlines === */
.headlines-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.headline-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: all 0.2s ease-out;
  opacity: 0;
  transform: translateY(12px);
  animation: card-enter 0.4s ease-out forwards;
}
.headline-card:hover {
  border-color: rgba(163,255,18,0.2);
  transform: translateY(-1px);
}

@keyframes card-enter {
  to { opacity: 1; transform: translateY(0); }
}

.headline-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.headline-rank {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--primary-contrast);
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.headline-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  flex: 1;
}
.headline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Hot score visualization */
.score-bar-container {
  display: flex;
  align-items: center;
  gap: 6px;
}
.score-bar-track {
  width: 48px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease-out;
}
.score-bar-fill.hot-high { background: var(--accent); }
.score-bar-fill.hot-mid { background: var(--warning); }
.score-bar-fill.hot-low { background: var(--muted); }

.headline-score {
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 11px;
}

.headline-time {
  font-size: 11px;
  color: var(--muted);
}

.headline-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}
.headline-link:hover { text-decoration: underline; }
.headline-why {
  font-size: 12px;
  color: var(--warning);
  margin-top: 8px;
  font-style: italic;
}

/* === Toast — Slide Down + Icon === */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  z-index: 100;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.toast .toast-icon { font-size: 16px; flex-shrink: 0; }
.toast.error { border-color: var(--danger); }
.toast.error .toast-icon::before { content: '\2717'; color: var(--danger); }
.toast.success { border-color: var(--success); }
.toast.success .toast-icon::before { content: '\2713'; color: var(--success); }

/* === Empty State — Studio Standby === */
.empty-state {
  text-align: center;
  padding: 56px 16px;
  color: var(--muted);
}
.empty-state .icon-container {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim), rgba(163,255,18,0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  position: relative;
  font-size: 32px;
}
.empty-state .icon-container::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent-dim);
  animation: standby-pulse 3s ease-in-out infinite;
}
@keyframes standby-pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.06); }
}

.empty-state .title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state .desc { font-size: 14px; line-height: 1.6; }

/* === Session History === */
.history-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.history-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.16s ease-out;
}
.history-card:hover { border-color: var(--accent); }
.history-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.history-info {
  flex: 1;
  min-width: 0;
}
.history-info .h-cat {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.history-info .h-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.history-replay {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 32px;
  white-space: nowrap;
  transition: all 0.16s ease-out;
}
.history-replay:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* === Ripple Effect === */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transform: scale(0);
  animation: ripple-expand 0.5s ease-out;
  pointer-events: none;
}
@keyframes ripple-expand {
  to { transform: scale(4); opacity: 0; }
}

/* === Copy Button === */
.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 32px;
}
.btn-copy:hover { color: var(--text); border-color: var(--text); }

/* === Utility === */
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* === Safe Area === */
@supports (padding: max(0px)) {
  .appbar {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .main {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}
