:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --field: #faf9f7;
  --border: #e7e5e0;
  --text: #1b1a18;
  --muted: #8b8880;
  --footnote: #767370;
  --ink: #1b1a18;
  --ink-hover: #34322e;
  --on-ink: #ffffff;
  --accent: #b4794a;
  --accent-strong: #9c6538;
  --ring: rgba(180, 121, 74, 0.3);
  --shadow: 0 1px 2px rgba(27, 26, 24, 0.04), 0 12px 32px rgba(27, 26, 24, 0.08);
  --radius: 16px;
}

:root[data-theme="dark"] {
  --bg: #15141a;
  --surface: #1e1d24;
  --field: #26252d;
  --border: #332f3a;
  --text: #ecebe8;
  --muted: #908c99;
  --footnote: #908c99;
  --ink: #e9e7e2;
  --ink-hover: #ffffff;
  --on-ink: #1b1a18;
  --accent: #c98a52;
  --accent-strong: #d99a62;
  --ring: rgba(201, 138, 82, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 36px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  padding-bottom: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app {
  position: relative;
  z-index: 1;
  margin: auto;
  width: 100%;
  max-width: 420px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Fondo: se dibuja sobre el color de body y por debajo de la tarjeta. */
.viz {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.viz.is-visible {
  opacity: 0.45;
}

.app__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.app__title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app__subtitle {
  margin: 5px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.app__actions {
  display: flex;
  flex: none;
  gap: 8px;
}

/* Modo visualizador: la interfaz desaparece y solo queda el fondo animado. */
body.is-focus .app,
body.is-focus .footer {
  display: none;
}

body.is-focus .viz.is-visible {
  opacity: 1;
}

.focus-hud {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.focus-hud[hidden] {
  display: none;
}

.focus-hud__now {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.controls__row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

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

.field__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.field__row {
  display: flex;
  gap: 8px;
}

.field__row input {
  flex: 1;
  min-width: 0;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

input[type="number"]:focus-visible,
input[type="text"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(27, 26, 24, 0.25);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(27, 26, 24, 0.25);
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--ring);
}

input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px var(--ring);
}

.button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

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

.button--primary {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--on-ink);
  background: var(--ink);
}

.button--primary:hover {
  background: var(--ink-hover);
}

.button--primary:active {
  transform: translateY(1px);
}

.button--primary.is-playing {
  background: var(--accent);
}

.button--primary.is-playing:hover {
  background: var(--accent-strong);
}

.button--icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  font-size: 1rem;
  line-height: 1;
  background: var(--field);
  border-color: var(--border);
}

.button--icon:hover {
  background: var(--border);
}

.lineup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
}

.lineup__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lineup__item {
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.history {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.history__title {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.history__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.history__item {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.history__item.is-current {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.history__play,
.history__copy {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.history__play {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  overflow: hidden;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.history__copy {
  padding: 0 10px;
  font-size: 0.85rem;
  border-left: 1px solid var(--border);
}

.history__copy:hover,
.history__copy.is-copied {
  color: var(--text);
  background: var(--border);
}

.history__play:focus-visible,
.history__copy:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.footer {
  position: relative;
  z-index: 1;
  padding-top: 24px;
  text-align: center;
}

.footer__link {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--footnote);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer__link:hover,
.footer__link:focus-visible {
  color: var(--accent-strong);
  text-decoration: underline;
}
