/* ==========================================================================
   Audio Host — one stylesheet for every page.
   Theme: deep blue, iOS-like surfaces, generous touch targets.
   ========================================================================== */

:root {
  --ink-900: #050f1d;
  --ink-800: #0a1c33;
  --ink-700: #102844;
  --ink-600: #17385c;
  --line: rgba(140, 180, 230, 0.14);
  --text: #e9f1fb;
  --muted: #91a8c6;
  --accent: #4da3ff;
  --accent-soft: rgba(77, 163, 255, 0.16);
  --danger: #ff8497;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --bar-height: 56px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% -10%, #123253 0%, transparent 60%),
    var(--ink-900);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2 { font-weight: 650; letter-spacing: -0.025em; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.05rem; }
p { margin: 0; }

a { color: var(--accent); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Page shell and transitions
   -------------------------------------------------------------------------- */
.page {
  width: min(680px, 100%);
  margin: 0 auto;
  padding: calc(var(--bar-height) + var(--safe-top) + 20px) 20px calc(40px + var(--safe-bottom));
  animation: page-in 0.32s var(--ease) both;
  display: flex;
  justify-content: center;
}

.body--lock .page { padding-top: 0; }

@keyframes page-in {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: none; }
}

@keyframes page-in-right {
  from { opacity: 0.4; transform: translate3d(28px, 0, 0); }
  to { opacity: 1; transform: none; }
}

@keyframes page-out-right {
  to { opacity: 0; transform: translate3d(40px, 0, 0); }
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: calc(var(--bar-height) + var(--safe-top));
  padding: var(--safe-top) 20px 0;
  background: rgba(8, 24, 43, 0.72);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-right: auto;
}

.brand__mark { width: 26px; height: 26px; display: block; }

.topbar__links { display: flex; gap: 22px; }

.topbar__links a {
  color: var(--muted);
  font-weight: 550;
  padding: 6px 2px;
  transition: color 0.2s ease;
}

.topbar__links a:hover,
.topbar__links a[aria-current="page"] { color: var(--text); }

.burger {
  display: none;
  width: 40px; height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.burger__bar {
  display: block;
  width: 20px; height: 2px;
  margin: 4px auto;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.28s var(--ease), opacity 0.2s ease;
}

.burger[aria-expanded="true"] .burger__bar:first-child { transform: translateY(3px) rotate(45deg); }
.burger[aria-expanded="true"] .burger__bar:last-child { transform: translateY(-3px) rotate(-45deg); }

.menu {
  position: fixed;
  z-index: 19;
  inset: calc(var(--bar-height) + var(--safe-top)) 0 auto 0;
  display: flex;
  flex-direction: column;
  padding: 6px 20px 14px;
  background: rgba(8, 24, 43, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  transform-origin: top center;
  animation: menu-in 0.24s var(--ease) both;
}

.menu[hidden] { display: none; }

.menu a {
  color: var(--text);
  font-weight: 550;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.menu a:last-child { border-bottom: 0; }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

/* Back arrow (mobile only) */
.back {
  position: fixed;
  z-index: 21;
  top: calc(var(--safe-top) + 12px);
  left: 12px;
  display: none;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
  background: rgba(16, 40, 68, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.body--standalone .back { display: flex; }

.back svg { width: 12px; height: 20px; }
.back:active { transform: scale(0.92); }

/* --------------------------------------------------------------------------
   Password page
   -------------------------------------------------------------------------- */
.body--lock { display: grid; place-items: center; min-height: 100dvh; }

.lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  width: min(340px, 86vw);
  text-align: center;
  transition: opacity 0.4s ease, transform 0.5s var(--ease), filter 0.4s ease;
}

.lock__logo { width: 74px; height: 74px; }

.lock__form { display: flex; flex-direction: column; gap: 12px; width: 100%; }

.is-unlocking .lock { opacity: 0; transform: scale(1.08); filter: blur(6px); }

.field {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: rgba(16, 40, 68, 0.75);
  color: var(--text);
  font: inherit;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.field::placeholder { color: var(--muted); }
.field:focus { border-color: var(--accent); background: rgba(20, 48, 80, 0.9); outline: none; }

.button {
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius-m);
  background: var(--accent);
  color: #04182f;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.15s var(--ease), filter 0.2s ease;
}

.button:hover { filter: brightness(1.06); }
.button:active { transform: scale(0.97); }
.button[disabled] { opacity: 0.55; cursor: default; }

.lock__message {
  min-height: 1.4em;
  color: var(--danger);
  font-size: 0.9rem;
}

.lock__form.is-wrong { animation: shake 0.4s ease; }

@keyframes shake {
  10%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(6px); }
  50% { transform: translateX(-6px); }
}

/* iPhone-style unlock */
.veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: radial-gradient(90% 70% at 50% 40%, #14395f 0%, var(--ink-900) 70%);
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.veil__lock { width: 62px; height: 78px; transform: scale(0.9); }
.veil__shackle { transform-origin: 24px 24px; }

.is-unlocking .veil { animation: veil-in 0.9s var(--ease) forwards; }
.is-unlocking .veil__lock { animation: lock-pop 0.9s var(--ease) forwards; }
.is-unlocking .veil__shackle { animation: shackle-open 0.55s var(--ease) 0.12s forwards; }

@keyframes veil-in {
  0% { opacity: 0; }
  18% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes lock-pop {
  0% { transform: scale(0.8); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.9); opacity: 0; }
}

@keyframes shackle-open {
  to { transform: translateY(-7px) rotate(-26deg); }
}

/* --------------------------------------------------------------------------
   Collection / playlist
   -------------------------------------------------------------------------- */
.collection__head { margin-bottom: 22px; }
.collection__head p { color: var(--muted); font-size: 0.92rem; margin-top: 4px; }
.prose, .collection { width: 90%; }

.tracklist { list-style: none; margin: 0; padding: 0; }

.tracklist__item + .tracklist__item { border-top: 1px solid var(--line); }

.track {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-m);
  color: var(--text);
  transition: background 0.18s ease, transform 0.18s var(--ease);
}

.track:hover { background: rgba(23, 56, 92, 0.5); }
.track:active { transform: scale(0.985); }

.track__title {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track__chevron { width: 9px; height: 15px; color: var(--muted); }

.cover {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  width: 52px;
  padding: 4px;
  border-radius: var(--radius-s);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
  overflow: hidden;
  word-break: break-word;
  color: #eaf4ff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.cover--large {
  width: min(78vw, 340px);
  border-radius: var(--radius-l);
  font-size: clamp(1.5rem, 7vw, 2.4rem);
  padding: 18px;
  box-shadow: 0 24px 60px rgba(2, 10, 22, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.cover--0 { background: linear-gradient(150deg, #1d4f8c, #0e2743); }
.cover--1 { background: linear-gradient(150deg, #2b6fb5, #123152); }
.cover--2 { background: linear-gradient(150deg, #14496f, #0a2036); }
.cover--3 { background: linear-gradient(150deg, #3f7fc4, #16304f); }
.cover--4 { background: linear-gradient(150deg, #1b5f8f, #0d2b47); }
.cover--5 { background: linear-gradient(150deg, #24578f, #0f2338); }

.empty { color: var(--muted); padding: 28px 0; }

/* --------------------------------------------------------------------------
   Player
   -------------------------------------------------------------------------- */
.player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
}

.player__title {
  font-size: 1.35rem;
  max-width: 100%;
  overflow-wrap: break-word;
}

.player__status { min-height: 1.2em; color: var(--muted); font-size: 0.85rem; }

.scrubber { width: min(100%, 340px); }

.scrubber__range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

.scrubber__range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--accent) calc(var(--progress, 0) * 100%),
    rgba(147, 169, 198, 0.28) calc(var(--progress, 0) * 100%)
  );
}

.scrubber__range::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(147, 169, 198, 0.28);
}

.scrubber__range::-moz-range-progress {
  height: 5px;
  border-radius: 3px;
  background: var(--accent);
}

.scrubber__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.scrubber__range::-moz-range-thumb {
  width: 14px; height: 14px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.scrubber__times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  align-items: center;
  gap: 26px;
}

.control {
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s ease;
}

.control svg { width: 28px; height: 28px; }
.control:hover { background: var(--accent-soft); }
.control:active { transform: scale(0.9); }

.control--primary {
  width: 74px; height: 74px;
  background: var(--accent);
  color: #04182f;
  box-shadow: 0 10px 30px rgba(77, 163, 255, 0.28);
}

.control--primary:hover { background: #62aeff; }
.control--primary svg { width: 32px; height: 32px; }

.control__icon--pause { display: none; }
.is-playing .control__icon--play { display: none; }
.is-playing .control__icon--pause { display: block; }

.linkbutton {
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 40, 68, 0.6);
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s var(--ease);
}

.linkbutton:hover { background: rgba(23, 56, 92, 0.85); }
.linkbutton:active { transform: scale(0.96); }

/* --------------------------------------------------------------------------
   Prose, upload form, notices
   -------------------------------------------------------------------------- */
.prose { display: flex; flex-direction: column; gap: 14px; max-width: 60ch; }
.prose p { color: var(--muted); }

.upload { display: flex; flex-direction: column; gap: 18px; }
.upload__subhead { color: var(--muted); margin-top: 10px; }

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: rgba(16, 40, 68, 0.45);
}

.form__label { font-size: 0.85rem; color: var(--muted); }
.form .field { text-align: left; }
.form__hint { color: var(--muted); font-size: 0.8rem; }
.form .button { margin-top: 8px; }

.field--file { padding: 12px 14px; }
.field--file::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-m);
  font-size: 0.92rem;
}

.notice--ok { background: var(--accent-soft); color: var(--text); }
.notice--error { background: rgba(255, 132, 151, 0.14); color: var(--danger); }

.tracklist--compact .track { grid-template-columns: 44px 1fr; }
.tracklist--compact .cover { width: 44px; font-size: 0.65rem; }

/* --------------------------------------------------------------------------
   Responsive rules
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .topbar__links { display: none; }
  .burger { display: block; }

  /* Player, About, Upload: the bar is replaced by a back arrow. */
  .body--detail .topbar,
  .body--detail .menu { display: none; }

  .body--detail .back { display: flex; }

  .body--detail .page {
    padding-top: calc(var(--safe-top) + 68px);
    animation: page-in-right 0.34s var(--ease) both;
  }

  .body--detail.is-leaving .page {
    animation: page-out-right 0.26s var(--ease) forwards;
  }

  .cover--large { width: min(82vw, 320px); }
  .controls { gap: 18px; }
}

@media (min-width: 768px) {
  .menu { display: none; }
  h1 { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
