/* Design Tokens & CSS Variables */
:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.75);
  --border-color: rgba(255, 255, 255, 0.1);
  --primary-color: #6366f1;
  --primary-glow: #818cf8;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --radius-lg: 16px;
  --radius-md: 10px;
  --font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  padding: 2rem 1rem;
}

/* Background Glowing Orbs */
.background-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(6, 182, 212, 0.1) 40%, rgba(11, 15, 25, 0) 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(40px);
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-cyan));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.logo-area h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 400;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--accent-emerald);
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Main Cards */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Config Grid */
.config-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1.2rem;
}

@media (max-width: 768px) {
  .config-grid {
    grid-template-columns: 1fr;
  }
}

.config-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.label-with-value {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.val-badge {
  font-size: 0.78rem;
  color: var(--accent-cyan);
  font-weight: 600;
  background: rgba(6, 182, 212, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

select, input[type="range"], textarea {
  width: 100%;
  font-family: inherit;
}

select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

input[type="range"] {
  accent-color: var(--primary-color);
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  cursor: pointer;
}

/* Presets */
.presets-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.preset-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

/* Text Input Container */
.input-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

textarea {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 1rem;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 140px;
  outline: none;
  transition: var(--transition-fast);
}

textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  text-decoration: underline;
}

.text-btn:hover {
  color: var(--text-main);
}

/* Action Buttons */
.action-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.primary-btn, .secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.6rem;
  border-radius: var(--radius-md);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-color), #4f46e5);
  border: none;
  color: #fff;
  flex: 2;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.35);
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(99, 102, 241, 0.5);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  flex: 1;
}

.secondary-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Player & Visualizer */
.player-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem;
  background: rgba(15, 23, 42, 0.8);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.player-container.hidden {
  display: none;
}

audio {
  width: 100%;
  height: 42px;
}

/* Waveform Animation */
.waveform-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 40px;
}

.waveform-box .bar {
  width: 5px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 4px;
  transition: height 0.2s ease;
}

.waveform-box.playing .bar {
  animation: wave 1.2s ease-in-out infinite alternate;
}

.waveform-box.playing .bar:nth-child(1) { animation-delay: 0.1s; }
.waveform-box.playing .bar:nth-child(2) { animation-delay: 0.3s; }
.waveform-box.playing .bar:nth-child(3) { animation-delay: 0.5s; }
.waveform-box.playing .bar:nth-child(4) { animation-delay: 0.2s; }
.waveform-box.playing .bar:nth-child(5) { animation-delay: 0.6s; }
.waveform-box.playing .bar:nth-child(6) { animation-delay: 0.4s; }
.waveform-box.playing .bar:nth-child(7) { animation-delay: 0.1s; }
.waveform-box.playing .bar:nth-child(8) { animation-delay: 0.3s; }
.waveform-box.playing .bar:nth-child(9) { animation-delay: 0.5s; }
.waveform-box.playing .bar:nth-child(10) { animation-delay: 0.2s; }

@keyframes wave {
  0% { height: 6px; background: var(--primary-color); }
  100% { height: 36px; background: var(--accent-cyan); }
}

/* API Guide Card */
.api-doc-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.api-doc-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.code-box {
  background: #090d16;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.copy-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-main);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--primary-color);
}

pre {
  padding: 1rem;
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.85rem;
  color: #e2e8f0;
  line-height: 1.5;
}

/* Footer */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding-bottom: 1rem;
}
