:root {
  color-scheme: dark;
  --gold: #c9a45c;
  --gold-bright: #e6c780;
  --gold-dim: #7d6636;
  --bg-deep: #110d08;
  --bg-stone: #1c1610;
  --panel-top: rgba(61, 49, 31, 0.55);
  --panel-bottom: rgba(20, 16, 11, 0.82);
  --panel-flat: rgba(32, 26, 18, 0.6);
  --border-gold: rgba(201, 164, 92, 0.35);
  --border-gold-strong: rgba(201, 164, 92, 0.75);
  --text-parchment: #ece2c8;
  --text-muted: #a89a7d;
  --text-dim: #756a53;
  --shadow: rgba(0, 0, 0, 0.55);
  --focus-ring: rgba(201, 164, 92, 0.35);
}

* { box-sizing: border-box; }

::selection {
  background: var(--gold-dim);
  color: var(--text-parchment);
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 6px; border: 2px solid var(--bg-deep); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

body {
  margin: 0;
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  color: var(--text-parchment);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(120, 96, 52, 0.22), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(0, 0, 0, 0.65), transparent 65%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0px, rgba(255, 255, 255, 0.015) 1px, transparent 1px, transparent 3px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--bg-stone), var(--bg-deep) 40%);
  background-attachment: fixed;
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(17, 13, 8, 0.97), rgba(17, 13, 8, 0.94) 80%, rgba(17, 13, 8, 0.85));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border-gold);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 0.55rem 1rem;
  z-index: 10;
}

.site-header::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-dim) 15%, var(--gold-bright) 50%, var(--gold-dim) 85%, transparent);
}

.header-inner {
  position: relative;
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}

.logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

.controls {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  flex: 1;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 620px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  translate: 0 -50%;
  width: 1rem;
  height: 1rem;
  fill: var(--gold-dim);
  pointer-events: none;
}

#q {
  width: 100%;
  padding: 0.65rem 0.9rem 0.65rem 2.4rem;
  font-family: "EB Garamond", serif;
  font-size: 1rem;
  color: var(--text-parchment);
  background: var(--panel-flat);
  border: 1px solid var(--border-gold);
  border-radius: 999px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#q:focus, .select-wrap.is-focus select {
  outline: none;
  border-color: var(--border-gold-strong);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

#q::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.select-wrap {
  position: relative;
  min-width: 200px;
  max-width: 280px;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 0.9rem;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--gold);
  border-bottom: 1.5px solid var(--gold);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select-wrap select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 0.65rem 2.1rem 0.65rem 1rem;
  font-family: "EB Garamond", serif;
  font-size: 0.95rem;
  color: var(--text-parchment);
  background: var(--panel-flat);
  border: 1px solid var(--border-gold);
  border-radius: 999px;
  cursor: pointer;
}

.select-wrap select:focus {
  outline: none;
  border-color: var(--border-gold-strong);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

main#results {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.result {
  position: relative;
  background: linear-gradient(160deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 1.2rem 1.3rem 1.35rem;
  text-align: center;
  box-shadow: 0 6px 20px var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.result::before, .result::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  background: var(--gold);
  transform: rotate(45deg);
  opacity: 0.6;
}

.result::before { top: -3px; left: -3px; }
.result::after { top: -3px; right: -3px; }

.result .text {
  font-family: "Cinzel", "EB Garamond", serif;
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--text-parchment);
  margin-bottom: 0.35rem;
}

.result .meta {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  margin-bottom: 1rem;
  word-break: break-all;
}

.result .takes {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  border-top: 1px solid var(--border-gold);
  padding-top: 0.9rem;
}

.take {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
}

.take .label {
  font-family: "EB Garamond", serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.take.no-audio {
  flex-direction: row;
  justify-content: center;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.9rem;
  padding: 0.3rem 0;
}

.player {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.player audio { display: none; }

.play-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-gold-strong);
  background: transparent;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.play-btn:hover { border-color: var(--gold-bright); }
.play-btn:active { transform: scale(0.94); }

.play-btn.is-playing {
  background: var(--gold);
}

.play-btn svg {
  width: 12px;
  height: 12px;
  fill: var(--gold);
}

.play-btn.is-playing svg { fill: var(--bg-deep); }
.play-btn svg:last-child { display: none; }
.play-btn.is-playing svg:first-child { display: none; }
.play-btn.is-playing svg:last-child { display: block; }

.seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold) var(--progress, 0%), rgba(255, 255, 255, 0.14) var(--progress, 0%), rgba(255, 255, 255, 0.14) 100%);
  cursor: pointer;
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid var(--bg-deep);
  margin-top: -4px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid var(--bg-deep);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.seek::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.seek::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--gold);
}

.vol-btn, .dl-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.vol-btn svg, .dl-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.vol-btn:hover, .dl-btn:hover {
  color: var(--gold-bright);
  background: rgba(201, 164, 92, 0.1);
}

.vol-btn svg:last-child { display: none; }
.vol-btn.is-muted svg:first-child { display: none; }
.vol-btn.is-muted svg:last-child { display: block; }

#scroll-sentinel {
  height: 1px;
}

#status {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 1.5rem;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; }
  .logo { height: 28px; }
  main#results { grid-template-columns: 1fr; padding: 1.5rem 1rem 3rem; }
}
