@font-face {
  font-family: "Bricolage";
  src: url("fonts/bricolage.woff2") format("woff2-variations"), url("fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --plum: #2b1330;
  --plum-deep: #1c0a20;
  --plum-raised: #3a1d40;
  --vinyl: #151014;
  --label: #f4b63f;
  --ink: #7a1f2b;
  --paper: #f7ece0;
  --muted: #bc9db7;
  --danger: #ff8a7a;

  --rec: min(74vw, 340px, 44dvh);
  --ease-out: cubic-bezier(.2, .9, .25, 1);
  --ease-pop: cubic-bezier(.2, .9, .25, 1.18);

  color-scheme: dark;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Bricolage", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  font-variation-settings: "opsz" 16;
  color: var(--paper);
  background:
    radial-gradient(120% 70% at 50% 28%, #4a2150 0%, transparent 60%),
    var(--plum);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }

:focus-visible { outline: 3px solid var(--paper); outline-offset: 3px; }

a { color: var(--label); }

code {
  font-family: inherit;
  font-variation-settings: "wdth" 85;
  word-break: break-all;
}

/* ---------- Screens ---------- */

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  min-height: 60px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.icon-btn:active { background: rgba(247, 236, 224, .1); }
.icon-btn svg, .ctl svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Buttons ---------- */

.btn-primary {
  border: 0;
  border-radius: 999px;
  background: var(--label);
  color: var(--ink);
  font-weight: 760;
  font-variation-settings: "opsz" 24;
  padding: 15px 26px;
  transition: transform .12s, filter .12s;
}
.btn-primary:active { transform: translateY(1px) scale(.99); filter: brightness(.94); }
.btn-primary:disabled { opacity: .5; }
.btn-big {
  width: min(100%, 360px);
  font-size: 19px;
  padding: 18px 28px;
}

.btn-secondary {
  border: 1.5px solid rgba(247, 236, 224, .35);
  background: transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
}

.btn-small {
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--plum);
  font-weight: 700;
  font-size: 15px;
  padding: 9px 16px;
  white-space: nowrap;
}

.btn-link {
  border: 0;
  background: none;
  padding: 6px 4px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 15px;
}

/* ---------- The record ---------- */

.record {
  position: relative;
  display: block;
  width: var(--rec);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 23%, rgba(0,0,0,.55) 23.2% 24.2%, transparent 24.6%),
    repeating-radial-gradient(circle, #1d171b 0 1px, var(--vinyl) 1.2px 3.2px);
  box-shadow:
    inset 0 0 0 calc(var(--rec) * .012) #0b080a,
    inset 0 0 0 calc(var(--rec) * .03) #1b1519,
    0 30px 60px -20px rgba(0, 0, 0, .7),
    0 0 0 1px rgba(255, 255, 255, .04);
  flex-shrink: 0;
}

/* Lichtreflex auf dem Vinyl. Bleibt stehen, während sich das Etikett dreht */
.record::after {
  content: "";
  position: absolute;
  inset: 3%;
  border-radius: 50%;
  background: conic-gradient(from 20deg,
    transparent 0deg, rgba(255,255,255,.10) 22deg, transparent 50deg,
    transparent 180deg, rgba(255,255,255,.07) 205deg, transparent 235deg);
  pointer-events: none;
  z-index: 3;
}

.spinner {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 50%;
  animation: spin 1.333s linear infinite;
  animation-play-state: paused;
}
.is-playing .spinner { animation-play-state: running; }

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

.label {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  border-radius: 50%;
  background: var(--label);
  color: var(--ink);
}

.label--back {
  width: 46%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 0 calc(var(--rec) * .012) rgba(122, 31, 43, .25);
}

/* Der Haken des Fragezeichens. Das Mittelloch der Platte ist sein Punkt */
.label-q {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--ink);
  stroke-width: 8.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.label-side, .label-rpm {
  position: absolute;
  font-size: calc(var(--rec) * .036);
  font-weight: 650;
  line-height: 1;
}
.label-side { top: 63%; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.label-rpm { top: 76%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-weight: 520; }

.spindle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--rec) * .039);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--plum-deep);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.8);
  z-index: 2;
}
.record--play.is-revealed .spindle { opacity: 0; }

/* Aufgedecktes Etikett */
.label--front {
  width: 90%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15% 15% 13%;
  text-align: center;
  transform: translate(-50%, -50%) scale(.511);
  opacity: 0;
  visibility: hidden;
  z-index: 2;
  box-shadow:
    inset 0 0 0 calc(var(--rec) * .02) var(--label),
    inset 0 0 0 calc(var(--rec) * .024) rgba(122, 31, 43, .35);
  transition: transform .6s var(--ease-pop), opacity .25s, visibility 0s .6s;
}

.is-revealed .label--front {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
  transition: transform .6s var(--ease-pop), opacity .2s, visibility 0s;
}

.lf-title {
  font-size: calc(var(--rec) * .066);
  font-weight: 750;
  font-stretch: 88%;
  font-variation-settings: "opsz" 32;
  line-height: 1.08;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: balance;
  max-width: 100%;
}

.lf-artist {
  margin-top: .35em;
  font-size: calc(var(--rec) * .047);
  font-weight: 520;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 92%;
}

.lf-hole {
  display: block;
  width: calc(var(--rec) * .032);
  aspect-ratio: 1;
  margin: calc(var(--rec) * .035) 0 calc(var(--rec) * .018);
  border-radius: 50%;
  background: var(--plum-deep);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.8);
  flex-shrink: 0;
}

.lf-year {
  font-size: calc(var(--rec) * .25);
  font-weight: 800;
  font-stretch: 75%;
  font-variation-settings: "opsz" 96;
  line-height: .88;
  letter-spacing: -.01em;
  font-variant-numeric: lining-nums;
}

.lf-title, .lf-artist, .lf-year {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .3s, transform .4s var(--ease-out);
}
.is-revealed .lf-title  { opacity: 1; transform: none; transition-delay: .22s; }
.is-revealed .lf-artist { opacity: 1; transform: none; transition-delay: .3s; }
.is-revealed .lf-year   { opacity: 1; transform: none; transition-delay: .4s; }

.lf-year.is-updated { animation: nudge .5s var(--ease-pop); }
@keyframes nudge { 40% { transform: scale(1.08); } }

.record--play { cursor: pointer; }
.record--play:active:not(.is-revealed) { transform: scale(.985); }
.record--play.is-loading .label-q { animation: blink 1.1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Home ---------- */

.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 0 24px 40px;
  text-align: center;
}

.record--home { --rec: min(62vw, 300px, 36dvh); }

.wordmark {
  margin: 6px 0 4px;
  font-size: min(23vw, 112px);
  font-weight: 800;
  font-stretch: 75%;
  font-variation-settings: "opsz" 96;
  line-height: .8;
  letter-spacing: -.015em;
  color: var(--paper);
}

.device-line {
  margin: 0;
  min-height: 1.4em;
  max-width: 34ch;
  font-size: 15px;
  color: var(--muted);
}
.device-line .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--label);
  vertical-align: 1px;
}
.device-line .dot--off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

/* ---------- Play ---------- */

.play {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 0 22px 22px;
}

.below-record {
  min-height: 52px;
  text-align: center;
}

.reveal-hint {
  margin: 4px 0 0;
  font-size: 16px;
  color: var(--muted);
}

.year-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  column-gap: 10px;
  font-size: 14px;
  color: var(--muted);
}
.year-meta .btn-link { font-size: 14px; }

.year-edit {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.year-edit input {
  width: 6.5em;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(247, 236, 224, .3);
  background: var(--plum-deep);
  color: var(--paper);
}

.notice {
  width: min(100%, 380px);
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--plum-raised);
  border-left: 4px solid var(--label);
  font-size: 15px;
}
.notice p { margin: 0 0 10px; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice.is-error { border-left-color: var(--danger); }

.transport {
  width: min(100%, 360px);
  margin-top: auto;
}

.progress {
  height: 4px;
  border-radius: 2px;
  background: rgba(247, 236, 224, .16);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--label);
  border-radius: 2px;
}

.times {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
  margin-top: 6px;
}

.ctl {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.ctl:active { background: rgba(247, 236, 224, .1); }
.ctl text {
  font-size: 6.4px;
  font-weight: 700;
  fill: currentColor;
  stroke: none;
  font-family: "Bricolage", sans-serif;
}
.ctl--main {
  width: 72px;
  height: 72px;
  background: var(--paper);
  color: var(--plum);
}
.ctl--main:active { background: var(--paper); transform: scale(.96); }
.ctl--main svg { width: 30px; height: 30px; stroke-width: 2.6; }
.ctl--main .i-play { fill: currentColor; stroke-width: 1.5; margin-left: 4px; }
.ctl--main .i-play { display: none; }
.is-paused .ctl--main .i-play { display: block; }
.is-paused .ctl--main .i-pause { display: none; }
.ctl:disabled { opacity: .35; }

/* ---------- Scanner ---------- */

.screen--scan {
  position: fixed;
  inset: 0;
  padding: 0;
  background: #000;
  z-index: 10;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar--scan .icon-btn { background: rgba(28, 10, 32, .55); }
.topbar--scan .icon-btn[aria-pressed="true"] { background: var(--label); color: var(--ink); }

.viewfinder {
  position: relative;
  width: min(68vw, 300px, 46dvh);
  aspect-ratio: 1;
  margin: auto;
  border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(28, 10, 32, .62);
}
.viewfinder i {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 5px solid var(--label);
}
.viewfinder i:nth-child(1) { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 22px; }
.viewfinder i:nth-child(2) { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 22px; }
.viewfinder i:nth-child(3) { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 22px; }
.viewfinder i:nth-child(4) { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 22px; }
.viewfinder.is-hit i { border-color: var(--paper); }

.scan-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 24px 34px;
  text-align: center;
}
.scan-hint {
  margin: 0;
  max-width: 32ch;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(28, 10, 32, .82);
  font-weight: 560;
}
.scan-hint.is-error { color: var(--label); }
.scan-bottom .btn-link { color: var(--paper); opacity: .8; }

.manual {
  display: flex;
  gap: 8px;
  width: min(100%, 380px);
}
.manual input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 0;
  background: var(--paper);
  color: var(--plum);
}

/* ---------- Setup ---------- */

.setup {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 44px 24px 40px;
}
.setup-title {
  margin: 0 0 14px;
  font-size: 46px;
  font-weight: 800;
  font-stretch: 75%;
  font-variation-settings: "opsz" 96;
  line-height: .95;
}
.setup-intro { margin: 0 0 28px; color: var(--muted); }

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 22px;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 46px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--label);
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
}
.steps p, .steps label { display: block; margin: 0 0 10px; }

.copybox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border-radius: 12px;
  background: var(--plum-deep);
  font-size: 15px;
}
.copybox code { flex: 1; }

.setup input, .sheet input[type="text"], .sheet select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(247, 236, 224, .25);
  background: var(--plum-deep);
  color: var(--paper);
}
.setup input:focus, .sheet input:focus, .sheet select:focus { border-color: var(--label); outline: none; }

.msg { margin: 20px 0 0; min-height: 1.4em; color: var(--muted); }
.msg.is-error { color: var(--danger); }

/* ---------- Settings sheet ---------- */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--plum-raised);
  color: var(--paper);
}
.sheet::backdrop { background: rgba(14, 4, 16, .6); }
.sheet[open] { animation: sheet-in .32s var(--ease-out); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

.sheet-inner { padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-right: -10px;
}
.sheet h2 {
  margin: 10px 0;
  font-size: 30px;
  font-weight: 800;
  font-stretch: 78%;
  font-variation-settings: "opsz" 72;
}

.sheet fieldset {
  margin: 0;
  padding: 16px 0;
  border: 0;
  border-top: 1px solid rgba(247, 236, 224, .12);
  display: grid;
  gap: 8px;
}
.sheet legend {
  float: left;
  width: 100%;
  margin-bottom: 6px;
  font-weight: 720;
  font-size: 18px;
}
.sheet .btn-link, .sheet .btn-secondary { justify-self: start; }

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.opt input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: var(--label);
  flex-shrink: 0;
  margin: 0;
}
.opt--switch { justify-content: space-between; align-items: flex-start; gap: 18px; }
.opt--switch span { font-size: 15px; line-height: 1.35; }
.opt--switch input {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: rgba(247, 236, 224, .2);
  position: relative;
  transition: background .2s;
}
.opt--switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform .2s var(--ease-out);
}
.opt--switch input:checked { background: var(--label); }
.opt--switch input:checked::after { transform: translateX(20px); background: var(--ink); }

.small { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--paper);
  color: var(--plum);
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  z-index: 50;
}

/* ---------- Kleine Displays ---------- */

@media (max-height: 640px) {
  .play { gap: 8px; }
  .controls { gap: 20px; }
  .ctl--main { width: 62px; height: 62px; }
  .btn-big { padding: 15px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .label--front, .is-revealed .label--front,
  .lf-title, .lf-artist, .lf-year { transition: opacity .2s; }
  .sheet[open], .lf-year.is-updated, .record--play.is-loading .label-q { animation: none; }
}
