:root {
  --bg: #f4efe6;
  --surface: #faf8f3;
  --surface-alt: #ede6da;
  --border: #dfd8ca;
  --border-strong: #c9c0af;
  --ink: #1e1d1a;
  --ink-muted: #6b655b;
  --accent: #c84b31;
  --accent-hover: #b03d25;
  --accent-soft: #f5e2dd;
  --live: #3f6a4f;
  --live-soft: #e1ece4;
  --shadow: 0 8px 24px rgba(30, 29, 26, 0.06);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

.app-shell {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Cabecera */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 6px var(--surface), inset 0 0 0 8px var(--accent);
}

.brand-title {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.live-pill[data-state="playing"] {
  background: var(--live-soft);
  border-color: rgba(63, 106, 79, 0.28);
  color: var(--live);
}

.live-pill[data-state="playing"] .live-dot {
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(63, 106, 79, 0.2);
}

.live-pill[data-state="loading"] {
  background: var(--accent-soft);
  border-color: rgba(200, 75, 49, 0.25);
  color: var(--accent);
}

.live-pill[data-state="loading"] .live-dot {
  background: var(--accent);
}

.live-pill[data-state="error"] {
  background: #f8e1e1;
  border-color: rgba(180, 45, 45, 0.3);
  color: #9e2626;
}

.live-pill[data-state="error"] .live-dot {
  background: #9e2626;
}

/* Tarjeta principal del reproductor */
.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

.format-badge {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.event-tag {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.station-name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.track-title {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.15;
  color: var(--ink);
  word-break: break-word;
}

.track-artist {
  margin: 2px 0 0;
  font-size: 0.98rem;
  color: var(--ink-muted);
}

.ai-notice {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
}

.ai-notice-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  flex-shrink: 0;
}

/* Barra de progreso */
.progress-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s linear;
}

.progress-times {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.track-category {
  font-family: "DM Sans", sans-serif;
  font-size: 0.75rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Controles */
.player-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 4px;
}

.play-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.1s ease;
  box-shadow: 0 4px 12px rgba(200, 75, 49, 0.28);
}

.play-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.play-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.play-btn:disabled {
  background: var(--border-strong);
  box-shadow: none;
  cursor: not-allowed;
}

.play-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.play-btn .icon-pause,
.play-btn .spinner {
  display: none;
}

.play-btn[data-state="playing"] .icon-play {
  display: none;
}

.play-btn[data-state="playing"] .icon-pause {
  display: block;
}

.play-btn[data-state="loading"] .icon-play,
.play-btn[data-state="loading"] .icon-pause {
  display: none;
}

.play-btn[data-state="loading"] .spinner {
  display: block;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.volume-control {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.mute-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mute-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.mute-btn.is-muted .vol-waves {
  opacity: 0.25;
}

.volume-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

.status-feedback {
  margin: 0;
  font-size: 0.82rem;
  color: #9e2626;
  min-height: 1.1em;
}

.status-feedback:empty {
  display: none;
}

/* Emisoras y formulario */
.stations-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.toggle-form-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.toggle-form-btn:hover {
  background: var(--surface-alt);
}

.add-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
}

.optional {
  color: var(--ink-muted);
  font-weight: 400;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
}

.field input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn-primary,
.btn-secondary {
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-secondary {
  background: var(--surface-alt);
  color: var(--ink);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

/* Lista de emisoras */
.station-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.station-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 8px 6px 6px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.station-item.is-active {
  border-color: var(--accent);
  background: #fffcf8;
}

.station-select {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: inherit;
}

.station-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.station-item-name {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-item.is-active .station-item-name {
  color: var(--accent);
}

.station-type-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.66rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--ink-muted);
  flex-shrink: 0;
}

.station-item-url {
  font-size: 0.76rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.delete-btn:hover {
  background: #f8e1e1;
  color: #9e2626;
}

.delete-btn svg {
  width: 17px;
  height: 17px;
}

.empty-state {
  text-align: center;
  padding: 24px 16px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.empty-state p {
  margin: 0 0 12px;
}

@media (max-width: 420px) {
  .app-shell {
    padding: 16px 12px 32px;
  }

  .player-card {
    padding: 16px;
  }

  .track-title {
    font-size: 1.5rem;
  }
}

