/* Needle Drop — record-sleeve palette */
:root {
  --sleeve: #1d1219;      /* deep plum-brown record sleeve */
  --sleeve-2: #2a1b24;    /* raised surfaces */
  --groove: #0f0a0d;      /* vinyl */
  --paper: #f1e7d6;       /* liner-note paper text */
  --paper-dim: #b9a99a;
  --sticker: #e9b740;     /* price-sticker mustard, primary */
  --teal: #5d9c93;        /* faded sleeve teal, secondary */
  --rose: #e07a6a;        /* errors */
  --line: rgba(241, 231, 214, 0.14);
  --display: "Shrikhand", Georgia, serif;
  --body: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --r-sm: 6px;
  --r-md: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, #3a2230 0%, transparent 60%),
    var(--sleeve);
  color: var(--paper);
  font: 400 1rem/1.55 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
}
body.player-open { padding-bottom: calc(330px + env(safe-area-inset-bottom)); }
a { color: var(--sticker); }
img { display: block; }
:focus-visible { outline: 2px solid var(--sticker); outline-offset: 3px; border-radius: 4px; }

/* Header */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  max-width: 44rem; margin: 0 auto; padding: 1.1rem 1.25rem 0.5rem;
}
.wordmark {
  font: 400 1.75rem/1 var(--display);
  color: var(--sticker);
  text-decoration: none;
  transform: rotate(-3deg);
  display: inline-block;
}
.tabs { display: flex; gap: 0.25rem; }
.tabs a {
  color: var(--paper-dim); text-decoration: none; font-weight: 500;
  padding: 0.4rem 0.7rem; border-radius: 999px;
}
.tabs a[aria-current="page"] { color: var(--sleeve); background: var(--paper); }

.page { max-width: 44rem; margin: 0 auto; padding: 0.5rem 1.25rem 3rem; }
.page-title, .prompt { font: 400 2rem/1.15 var(--display); margin: 1.25rem 0 0.75rem; }
.prompt { text-align: center; font-size: clamp(1.7rem, 6vw, 2.4rem); }

/* Buttons */
.btn {
  font: 600 0.95rem/1 var(--body); border: 0; cursor: pointer;
  padding: 0.8rem 1.1rem; border-radius: var(--r-sm); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.btn-primary { background: var(--sticker); color: #2a1a07; }
.btn-primary:hover { background: #f3c859; }
.btn-primary:disabled { opacity: 0.5; cursor: progress; }
.btn-quiet { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.btn-quiet:hover { box-shadow: inset 0 0 0 1px var(--paper-dim); }
.icon-btn {
  background: none; border: 0; color: var(--paper-dim); cursor: pointer;
  width: 2.5rem; height: 2.5rem; border-radius: 50%; font-size: 1rem;
}
.icon-btn:hover { color: var(--paper); background: var(--sleeve-2); }

/* The record — the one bold thing */
.disc {
  --size: min(72vw, 300px);
  width: var(--size); height: var(--size);
  margin: 1.25rem auto 0.75rem; display: grid; place-items: center;
  border: 0; padding: 0; cursor: pointer; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 34%, rgba(255,255,255,0.05) 34.5% 35%, transparent 35.5%),
    repeating-radial-gradient(circle, #171014 0 2px, #0c080a 2px 4px),
    var(--groove);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45), inset 0 0 0 6px #120c10;
  position: relative;
  transition: transform 200ms ease;
}
.disc::after { /* light sheen across the grooves */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 30deg, transparent 0 8%, rgba(255,255,255,0.10) 12%, transparent 18% 58%, rgba(255,255,255,0.07) 62%, transparent 68%);
  pointer-events: none;
}
.disc:active { transform: scale(0.98); }
.disc-label {
  width: 38%; height: 38%; border-radius: 50%;
  background: var(--sticker); color: #2a1a07;
  display: grid; place-items: center; text-align: center; position: relative; z-index: 1;
  box-shadow: inset 0 0 0 3px rgba(42,26,7,0.25);
}
.disc-label::after { /* spindle hole */
  content: ""; position: absolute; width: 7%; height: 7%; border-radius: 50%;
  background: var(--sleeve); top: 46.5%; left: 46.5%;
}
.disc-label-text { font: 400 clamp(0.85rem, 3.4vw, 1.05rem)/1.1 var(--display); padding: 0 0.4rem; white-space: nowrap; font-size: clamp(0.8rem, 2.6vw, 1rem); transform: translateY(-1.15em); }
.disc.recording .disc-label { background: var(--rose); }
.disc.recording, .mini-disc.playing { animation: spin 1.8s linear infinite; }
.disc.recording .disc-label-text { animation: spin 1.8s linear infinite reverse; }
.disc-still { --size: 140px; cursor: default; margin-bottom: 1.5rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.rec-status { text-align: center; color: var(--paper-dim); margin: 0 auto 1.5rem; max-width: 30rem; min-height: 1.5em; }

/* Query */
.query label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.query-row { display: flex; gap: 0.5rem; align-items: stretch; }
textarea, input[type="password"] {
  width: 100%; font: 400 1.05rem/1.4 var(--body); color: var(--paper);
  background: var(--sleeve-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0.75rem 0.85rem; resize: vertical;
}
textarea::placeholder { color: #7c6a72; font-style: italic; }
textarea:focus, input:focus { outline: none; border-color: var(--sticker); }
.take { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; flex-wrap: wrap; }
.take audio { flex: 1 1 14rem; height: 2.4rem; }
.error { color: var(--rose); font-weight: 500; }

/* Results: sleeves in a crate */
.results { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.15rem; }
.result-btn, .track-play, .found {
  width: 100%; display: flex; align-items: center; gap: 0.9rem;
  background: none; border: 0; color: inherit; font: inherit; text-align: left;
  padding: 0.55rem; border-radius: var(--r-sm); cursor: pointer;
}
.result-btn:hover, .track-play:hover, .found:hover { background: var(--sleeve-2); }
.result-btn img, .track-play img, .art-blank {
  width: 56px; height: 56px; object-fit: cover; border-radius: 3px; flex: none;
  box-shadow: 3px 3px 0 #0c080a; background: var(--sleeve-2);
}
.result-btn strong, .track-text strong { display: block; font-weight: 600; }
.result-btn span span, .track-text span { color: var(--paper-dim); }
.snippet { display: block; color: var(--paper-dim); font-size: 0.9rem; margin-top: 0.15rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.results-empty { color: var(--paper-dim); padding: 0.5rem; }

/* History */
.log { list-style: none; padding: 0; margin: 0; }
.log-entry { padding: 1rem 0; border-bottom: 1px solid var(--line); display: grid; gap: 0.5rem; }
.log-when { display: flex; gap: 0.6rem; align-items: center; color: var(--paper-dim); font-size: 0.9rem; }
.badge { font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; }
.badge-sung { background: var(--teal); color: #0d1f1c; }
.badge-typed { box-shadow: inset 0 0 0 1px var(--line); color: var(--paper); }
.log-query { margin: 0; font-size: 1.1rem; }
.log-query-none, .log-miss { color: var(--paper-dim); font-style: italic; margin: 0; }
.log-entry audio { width: 100%; max-width: 24rem; height: 2.4rem; }
.found { padding: 0.35rem; margin-left: -0.35rem; width: auto; }
.found img { width: 36px; height: 36px; border-radius: 3px; }
.found strong { color: var(--sticker); font-weight: 600; margin-right: 0.3rem; }
.pager { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1.5rem; }
.empty { color: var(--paper-dim); font-size: 1.05rem; }

/* Playlist */
.playlist-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.share { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.share-hint { color: var(--paper-dim); margin-top: 0; }
.tracklist { list-style: none; padding: 0; margin: 1rem 0 0; counter-reset: none; }
.track { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.track-no { width: 1.6rem; text-align: right; color: var(--paper-dim); font-variant-numeric: tabular-nums; flex: none; }
.track-text { min-width: 0; }
.track-text strong, .track-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* Login */
.login-form { max-width: 20rem; margin: 2rem auto; display: grid; gap: 0.6rem; }

/* Player: a bottom sheet */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--sleeve-2); border-top: 1px solid var(--line);
  box-shadow: 0 -16px 40px rgba(0,0,0,0.45);
  padding: 0.75rem max(1rem, calc((100vw - 44rem) / 2)) calc(0.75rem + env(safe-area-inset-bottom));
}
.player-head { display: flex; align-items: center; gap: 0.75rem; }
.mini-disc {
  width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: repeating-radial-gradient(circle, #171014 0 2px, #0c080a 2px 4px);
}
.mini-disc img { width: 46%; height: 46%; border-radius: 50%; object-fit: cover; }
.player-meta { flex: 1; min-width: 0; }
.player-title, .player-artist { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-title { font-weight: 600; }
.player-artist { color: var(--paper-dim); font-size: 0.9rem; }
.player-note { color: var(--paper-dim); margin: 0.5rem 0 0; }
.video { margin: 0.6rem auto 0; aspect-ratio: 16 / 9; width: min(100%, 400px); }
.video:empty { display: none; }
.video iframe { width: 100%; height: 100%; border: 0; border-radius: var(--r-sm); }
#player-add.added { background: var(--teal); color: #0d1f1c; box-shadow: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 1rem; transform: translate(-50%, -150%);
  background: var(--paper); color: var(--sleeve); padding: 0.6rem 1rem; border-radius: 999px;
  font-weight: 600; transition: transform 200ms ease, visibility 0s 200ms; z-index: 20; pointer-events: none;
  visibility: hidden; white-space: nowrap; max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform 200ms ease; }

@media (max-width: 480px) {
  .query-row { flex-direction: column; }
  .page-title { font-size: 1.7rem; }
  .masthead { padding-top: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .disc.recording, .mini-disc.playing, .disc.recording .disc-label-text { animation: none; }
  .toast, .disc { transition: none; }
}
