/* Li Zhi Player — samizdat / printed-zine aesthetic */

:root {
  --ink: #0f0d0b;
  --ink-2: #2a2520;
  --ink-3: #554c44;
  --paper: #f2ede4;
  --paper-2: #e8e0d1;
  --paper-3: #dcd2bf;
  --amber: #b8732a;
  --amber-deep: #8a4f17;
  --blood: #7a1f1f;
  --rule: #1a1713;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  background: var(--paper);
  color: var(--ink);
  font-feature-settings: "palt";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
  letter-spacing: 0.01em;
}

/* Paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(139,79,23,0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(15,13,11,0.03) 0%, transparent 35%);
  z-index: 1;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.06 0 0 0 0.15 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.35;
  mix-blend-mode: multiply;
  z-index: 2;
}

.mono { font-family: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace; font-feature-settings: "tnum"; }
.vert { writing-mode: vertical-rl; text-orientation: mixed; }

/* App shell */
.app {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 80px 340px 1fr 360px;
  grid-template-rows: 1fr 92px;
  height: 100vh;
  gap: 0;
}

/* Left gutter - masthead */
.gutter {
  grid-row: 1 / 3;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0 16px;
  background: var(--paper);
  position: relative;
}
.gutter .mast-cn {
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.3em;
  margin-top: 8px;
  writing-mode: vertical-rl;
}
.gutter .mast-en {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  margin-top: 24px;
  color: var(--ink-3);
}
.gutter .mast-no {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  margin-top: auto;
  writing-mode: vertical-rl;
}
.gutter .stamp {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) rotate(-12deg);
  border: 2px solid var(--blood);
  color: var(--blood);
  padding: 4px 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  border-radius: 2px;
  opacity: 0.75;
}

/* Albums column */
.albums {
  grid-row: 1;
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  padding: 24px 20px 24px 24px;
  background: var(--paper);
}
.albums-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 16px;
}
.albums-head .title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.1em;
}
.albums-head .count {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
}
.album-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 6px;
  cursor: pointer;
  border-bottom: 1px dashed rgba(26,23,19,0.25);
  transition: background 120ms ease;
  position: relative;
}
.album-row:hover { background: var(--paper-2); }
.album-row.selected {
  background: var(--ink);
  color: var(--paper);
}
.album-row.selected .album-year,
.album-row.selected .album-tag,
.album-row.selected .album-n { color: var(--paper-2); }
.album-row.selected::before {
  content: "▸";
  position: absolute; left: -14px; top: 50%;
  transform: translateY(-50%);
  color: var(--amber);
  font-size: 12px;
}
.album-cover {
  width: 52px; height: 52px;
  background-size: cover; background-position: center;
  filter: grayscale(100%) contrast(1.1);
  border: 1px solid var(--ink);
}
.album-row.selected .album-cover { filter: none; border-color: var(--paper); }
.album-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-wrap: pretty;
}
.album-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 3px;
  letter-spacing: 0.05em;
}
.album-year { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-3); }
.album-n { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--ink-3); }

/* Main stage */
.stage {
  grid-row: 1;
  overflow-y: auto;
  padding: 40px 56px;
  position: relative;
  background:
    linear-gradient(var(--paper), var(--paper));
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  padding-bottom: 18px;
  border-bottom: 3px double var(--ink);
  gap: 32px;
}
.stage-head {
  flex-wrap: wrap;
}
.stage-head .album-art {
  width: 180px; height: 180px;
  flex-shrink: 0;
  background-size: cover; background-position: center;
  border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  filter: grayscale(10%) contrast(1.05);
  position: relative;
}
.stage-head .album-art::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent 0, transparent 8px,
    rgba(255,255,255,0.02) 8px, rgba(255,255,255,0.02) 16px
  );
}
.stage-head .info {
  flex: 1 1 320px;
  min-width: 0;
}
.stage-head .kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--amber-deep);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.stage-head h1 {
  margin: 0;
  font-size: clamp(28px, 3.6vw, 52px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  text-wrap: balance;
  overflow-wrap: break-word;
  word-break: break-word;
}
.stage-head .sub {
  margin-top: 14px;
  display: flex;
  gap: 18px;
  align-items: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.stage-head .sub .dot { color: var(--amber); }
.stage-head .tag {
  display: inline-block;
  border: 1px solid var(--ink);
  padding: 3px 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.stage-head .blurb {
  margin-top: 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 56ch;
  font-style: italic;
}

/* Tracklist */
.tracklist {
  display: flex;
  flex-direction: column;
}
.tl-head {
  display: grid;
  grid-template-columns: 44px 1fr 90px 70px 50px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding: 6px 0;
  border-bottom: 1px solid var(--ink);
}
.track {
  display: grid;
  grid-template-columns: 44px 1fr 90px 70px 50px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px dashed rgba(26,23,19,0.2);
  cursor: pointer;
  transition: background 120ms ease, padding 160ms ease;
  position: relative;
}
.track:hover {
  background: var(--paper-2);
  padding-left: 10px;
}
.track.playing {
  background: var(--ink);
  color: var(--paper);
  padding-left: 10px;
}
.track.playing::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--amber);
}
.track .num {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
}
.track.playing .num { color: var(--amber); }
.track .name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.track .dur {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--ink-3);
  text-align: right;
}
.track.playing .dur { color: var(--paper-2); }
.track .src {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.track.playing .src { color: var(--amber); }

.track .bars {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  height: 12px;
}
.track .bars span {
  width: 2px;
  background: var(--amber);
  animation: eq 0.9s ease-in-out infinite;
}
.track .bars span:nth-child(2) { animation-delay: 0.15s; }
.track .bars span:nth-child(3) { animation-delay: 0.3s; }
.track .bars span:nth-child(4) { animation-delay: 0.45s; }
@keyframes eq {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}

.track .play-icon {
  opacity: 0;
  color: var(--amber-deep);
  font-size: 14px;
  transition: opacity 120ms ease;
}
.track:hover .play-icon { opacity: 1; }

/* Offline-cache button at tail of each track row */
.track-cache-btn {
  background: transparent;
  border: 1px solid rgba(26,23,19,0.22);
  color: var(--ink-3);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 2px;
  padding: 0;
  margin-right: 4px;
  transition: background 120ms, color 120ms, border-color 120ms, opacity 120ms;
  justify-self: end;
}
.track-cache-btn:hover {
  background: var(--paper-3);
  border-color: var(--ink);
  color: var(--ink);
}
/* Cached state is the sole "已下载" signal: still recedes from the
   download affordance (no border / background), but legible on its own.
   Hover/press reveals the destructive intent. */
.track-cache-btn.cached {
  border-color: transparent;
  background: transparent;
  color: var(--amber-deep);
  opacity: 0.72;
}
.track-cache-btn.cached svg { width: 12px; height: 12px; }
.track-cache-btn.cached:hover {
  opacity: 1;
  background: var(--blood);
  border-color: var(--blood);
  color: var(--paper);
}
.track-cache-btn.busy {
  border-color: var(--amber);
  color: var(--amber-deep);
  background: var(--paper);
}
.track.playing .track-cache-btn {
  border-color: rgba(242,237,228,0.4);
  color: var(--paper-2);
}
.track.playing .track-cache-btn.cached {
  border-color: transparent;
  color: var(--amber);
  opacity: 0.85;
}
.track.playing .track-cache-btn:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

/* Conic progress ring drawn via CSS gradients */
.cache-prog {
  width: 22px; height: 22px;
  border-radius: 50%;
  background:
    conic-gradient(var(--amber) var(--p, 0%), rgba(26,23,19,0.15) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.cache-prog::before {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--paper);
  border-radius: 50%;
}
.track.playing .cache-prog::before { background: var(--ink); }
.cache-prog-n {
  position: relative;
  font-size: 8px;
  font-weight: 700;
  color: var(--ink);
  z-index: 1;
}
.track.playing .cache-prog-n { color: var(--paper); }

/* Global "download every album" button in the albums column */
.all-dl-btn {
  display: flex;
  width: 100%;
  margin: 4px 0 14px;
  padding: 9px 10px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  transition: background 120ms, color 120ms, transform 120ms, box-shadow 120ms;
}
.all-dl-btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--amber-deep);
}
.all-dl-btn.busy {
  background: var(--amber);
  border-color: var(--amber-deep);
  box-shadow: 3px 3px 0 var(--amber-deep);
}
.all-dl-btn.busy:hover {
  background: var(--blood);
  color: var(--paper);
  border-color: var(--blood);
  box-shadow: 3px 3px 0 var(--ink);
}
.all-dl-btn.done {
  background: var(--ink);
  color: var(--amber);
  cursor: default;
  box-shadow: 3px 3px 0 var(--amber-deep);
}
.all-dl-btn:disabled { opacity: 0.95; }

/* Album-level download button on the stage header */
.album-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.album-dl-btn {
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.album-dl-btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--amber-deep);
}
.album-dl-btn.busy {
  background: var(--amber);
  border-color: var(--amber-deep);
  box-shadow: 3px 3px 0 var(--amber-deep);
}
.album-dl-btn.done {
  background: var(--ink);
  color: var(--amber);
  cursor: default;
  box-shadow: 3px 3px 0 var(--amber-deep);
}
.album-dl-btn:disabled { opacity: 0.9; }
.album-dl-meta {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* Storage quota bar in the notes panel */
.quota-bar {
  height: 4px;
  background: var(--paper-3);
  border: 1px solid var(--ink-3);
  margin-top: 8px;
  position: relative;
}
.quota-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--amber);
}
.cache-clear-btn {
  margin-top: 14px;
  background: var(--paper);
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 7px 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 120ms, color 120ms;
}
.cache-clear-btn:hover:not(:disabled) {
  background: var(--blood);
  border-color: var(--blood);
  color: var(--paper);
}
.cache-clear-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Build / version stamp at the foot of the 档案 tab */
.version-line {
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px dashed var(--ink-3);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.version-line .version-tag {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.15em;
  border: 1px solid var(--ink);
  padding: 2px 8px;
  background: var(--paper);
}

/* Right column - queue + lyrics-column */
.rail {
  grid-row: 1;
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  background: var(--paper-2);
  overflow: hidden;
}
.rail-tabs {
  display: flex;
  border-bottom: 2px solid var(--ink);
}
.rail-tab {
  flex: 1;
  padding: 16px 12px;
  background: transparent;
  border: none;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  border-right: 1px solid var(--rule);
  transition: all 120ms;
}
.rail-tab:last-child { border-right: none; }
.rail-tab.active {
  background: var(--ink);
  color: var(--paper);
}
.rail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.queue-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  padding: 10px 6px;
  cursor: pointer;
  border-bottom: 1px dashed rgba(26,23,19,0.2);
  align-items: center;
  font-size: 13px;
}
.queue-item:hover { background: var(--paper-3); }
.queue-item.current { background: var(--ink); color: var(--paper); }
.queue-item.current .qm { color: var(--paper-2); }
.queue-item .qn {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--ink-3);
}
.queue-item.current .qn { color: var(--amber); }
.queue-item .qt { font-weight: 600; }
.queue-item .qm {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}

/* Lyric-style vertical poem column */
.poem {
  font-size: 18px;
  line-height: 2;
  letter-spacing: 0.1em;
  writing-mode: vertical-rl;
  height: 100%;
  padding: 12px 20px;
  font-weight: 500;
}
.poem .line { margin-left: 20px; }
.poem .line.strong { font-weight: 900; color: var(--blood); }

/* About / notes panel */
.notes h3 {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ink-3);
}
.notes h3:first-child { margin-top: 0; }
.notes p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  margin: 6px 0;
}
.notes .stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--ink);
  border: 1px solid var(--ink);
  margin-top: 8px;
}
.notes .stat {
  background: var(--paper);
  padding: 10px 12px;
}
.notes .stat .k {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.notes .stat .v {
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 700;
  margin-top: 2px;
}

/* Transport bar */
.transport {
  grid-column: 2 / 5;
  grid-row: 2;
  border-top: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  align-items: center;
  padding: 0 28px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  gap: 24px;
  position: relative;
  z-index: 40;
}
.transport::before {
  content: "";
  position: absolute;
  top: -2px; left: 0; right: 0;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--ink) 0, var(--ink) 6px,
    var(--amber) 6px, var(--amber) 12px
  );
  clip-path: polygon(0 0, 100% 0, 100% 2px, 0 2px);
}
.t-now {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
}
.t-now .mini-art {
  width: 56px; height: 56px;
  background-size: cover; background-position: center;
  border: 1px solid var(--paper);
  flex-shrink: 0;
  filter: grayscale(30%);
}
.t-now .mini-art.spinning {
  border-radius: 50%;
  animation: spin 6s linear infinite;
  background-color: #111;
  position: relative;
}
.t-now .mini-art.spinning::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 10px; height: 10px;
  background: var(--amber);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px var(--ink);
}
@keyframes spin { to { transform: rotate(360deg); } }

.t-now .t-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-now .t-album {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--paper-2);
  opacity: 0.7;
  margin-top: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.t-buttons {
  display: flex;
  align-items: center;
  gap: 24px;
}
.t-btn {
  background: transparent;
  border: none;
  color: var(--paper);
  cursor: pointer;
  padding: 6px;
  opacity: 0.8;
  transition: opacity 120ms, transform 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
}
.t-btn:hover { opacity: 1; transform: scale(1.08); }
.t-btn.active { color: var(--amber); opacity: 1; }
.t-btn.play {
  width: 48px; height: 48px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  opacity: 1;
}
.t-btn.play:hover { background: var(--amber); border-color: var(--amber); color: var(--ink); }

.t-progress {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--paper-2);
}
.t-bar {
  flex: 1;
  height: 3px;
  background: rgba(242,237,228,0.2);
  position: relative;
  cursor: pointer;
}
.t-bar .fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--amber);
}
.t-bar .buf {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: rgba(242,237,228,0.3);
}
.t-bar .knob {
  position: absolute; top: 50%;
  width: 10px; height: 10px;
  background: var(--paper);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 120ms;
}
.t-bar:hover .knob { opacity: 1; }

.t-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
}
.t-vol {
  display: flex; align-items: center; gap: 10px;
  width: 140px;
}
.t-vol .vbar {
  flex: 1;
  height: 2px;
  background: rgba(242,237,228,0.2);
  position: relative;
  cursor: pointer;
}
.t-vol .vfill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--paper);
}

/* Icons */
.ico { width: 18px; height: 18px; display: inline-block; }
.ico-lg { width: 22px; height: 22px; }

/* Search — framed card with inset ink border */
.search-box {
  margin: 0 0 18px;
  padding: 0 10px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: box-shadow 120ms ease, transform 120ms ease, background 120ms ease;
  position: relative;
}
.search-box::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid var(--ink-3);
  pointer-events: none;
  opacity: 0.35;
}
.search-box:hover { background: var(--paper-2); }
.search-box:focus-within {
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--amber-deep);
  transform: translate(-1px, -1px);
}
.search-box:focus-within::before { border-color: var(--amber-deep); opacity: 1; }
.search-ico {
  color: var(--ink-3);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 1;
}
.search-box:focus-within .search-ico { color: var(--amber-deep); }
.search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  padding: 0;
  letter-spacing: 0.04em;
  caret-color: var(--blood);
  z-index: 1;
}
.search-input::placeholder {
  color: var(--ink-3);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-kbd {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--ink);
  border-bottom-width: 2px;
  padding: 3px 6px 2px;
  color: var(--ink);
  background: var(--paper-2);
  letter-spacing: 0;
  flex-shrink: 0;
  z-index: 1;
  border-radius: 2px;
}
.search-clear {
  background: var(--ink);
  border: none;
  color: var(--paper);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 1;
  border-radius: 50%;
  width: 20px; height: 20px;
  justify-content: center;
}
.search-clear:hover { background: var(--blood); }

.search-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 6px;
  cursor: pointer;
  border-bottom: 1px dashed rgba(26,23,19,0.22);
  transition: background 120ms ease;
}
.search-row:hover { background: var(--paper-2); }
.search-row.playing {
  background: var(--ink);
  color: var(--paper);
}
.search-row.playing .search-meta,
.search-row.playing .search-n { color: var(--paper-2); }
.search-cover {
  width: 40px; height: 40px;
  background-size: cover; background-position: center;
  filter: grayscale(100%) contrast(1.1);
  border: 1px solid var(--ink);
}
.search-row.playing .search-cover { filter: none; border-color: var(--paper); }
.search-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-n {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--ink-3);
}
.search-empty {
  padding: 40px 12px;
  text-align: center;
  border: 1px dashed var(--ink-3);
  margin-top: 8px;
}
mark.hl {
  background: var(--amber);
  color: var(--ink);
  padding: 0 2px;
  font-weight: 700;
}
.search-row.playing mark.hl { background: var(--amber); color: var(--ink); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--ink); }

/* Tweaks panel override */
.tweak-panel-override {
  font-family: "Noto Serif SC", serif;
}

/* Theme variants */
body[data-theme="midnight"] {
  --ink: #f0ebe0;
  --ink-2: #c5b9a4;
  --ink-3: #7a6f5c;
  --paper: #100d0a;
  --paper-2: #1a1612;
  --paper-3: #24201a;
  --amber: #d99545;
  --amber-deep: #b8732a;
  --blood: #c94545;
  --rule: #2a241c;
}
body[data-theme="midnight"]::after {
  mix-blend-mode: screen;
  opacity: 0.12;
}
body[data-theme="blood"] {
  --paper: #f2e8e0;
  --paper-2: #eaddcf;
  --paper-3: #d9c4b0;
  --amber: #8a1f1f;
  --amber-deep: #5a1010;
  --blood: #3a0808;
}

/* Focus view — when active, hide side panels */
body[data-focus="1"] .albums,
body[data-focus="1"] .rail,
body[data-focus="1"] .gutter { display: none; }
body[data-focus="1"] .app {
  grid-template-columns: 1fr;
}
body[data-focus="1"] .transport {
  grid-column: 1 / 2;
}

/* Mobile topbar + drawer — hidden on desktop */
.mobile-topbar { display: none; }
.mobile-backdrop { display: none; }

/* Responsive */
@media (max-width: 1440px) {
  .app { grid-template-columns: 72px 300px 1fr 320px; }
  .stage { padding: 32px 40px; }
}
@media (max-width: 1280px) {
  .app { grid-template-columns: 64px 260px 1fr 280px; }
  .stage { padding: 24px 28px; }
  .stage-head .album-art { width: 140px; height: 140px; box-shadow: 5px 5px 0 var(--ink); }
  .stage-head { gap: 20px; margin-bottom: 24px; }
  .track .name { font-size: 16px; }
  .tl-head, .track { grid-template-columns: 36px 1fr 70px 60px 40px; }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: 56px 240px 1fr 0px; }
  .rail { display: none; }
  .transport { grid-column: 2 / 4; grid-template-columns: 240px 1fr 240px; padding: 0 20px; }
}

/* ---- MOBILE (tablet portrait + phones) ---- */
@media (max-width: 820px) {
  body { overflow: hidden; position: fixed; width: 100%; }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: calc(56px + env(safe-area-inset-top, 0px)) 1fr calc(150px + env(safe-area-inset-bottom, 0px));
    height: 100dvh;
    height: 100vh;
  }

  /* Mobile topbar */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: env(safe-area-inset-top, 0px) 10px 0;
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
    z-index: 20;
    grid-column: 1 / -1;
    grid-row: 1;
    position: relative;
  }
  .mobile-topbar::after {
    content: "";
    position: absolute;
    bottom: -6px; left: 0; right: 0; height: 5px;
    background: repeating-linear-gradient(90deg,
      var(--paper) 0, var(--paper) 6px,
      var(--amber) 6px, var(--amber) 12px);
    clip-path: polygon(0 0, 100% 0, 100% 1px, 0 1px);
    opacity: 0.4;
  }
  .mobile-btn {
    background: transparent;
    border: 1px solid var(--ink);
    color: var(--ink);
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    border-radius: 2px;
  }
  .mobile-btn:active { background: var(--ink); color: var(--paper); }
  .mobile-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
  }
  .mobile-title-cn {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.3em;
    padding-left: 0.3em;
  }
  .mobile-title-en {
    font-size: 9px;
    letter-spacing: 0.25em;
    color: var(--ink-3);
    margin-top: 3px;
  }

  /* Hide desktop gutter */
  .gutter { display: none; }

  /* Stage takes the middle row.
     Bottom padding has to clear the floating transport card (~124px tall,
     16px lifted from screen bottom) plus safe-area, otherwise the last few
     tracks scroll under the floating transport. */
  .stage {
    grid-column: 1;
    grid-row: 2;
    padding: 20px 18px calc(160px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .stage-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 14px;
  }
  .stage-head .album-art {
    width: 160px; height: 160px;
    box-shadow: 4px 4px 0 var(--ink);
    align-self: center;
  }
  .stage-head .info { flex: 1 1 auto; width: 100%; }
  .stage-head h1 { font-size: 34px; }
  .stage-head .kicker { font-size: 10px; letter-spacing: 0.25em; }
  .stage-head .sub { flex-wrap: wrap; gap: 10px; font-size: 10px; }
  .stage-head .blurb { font-size: 13px; line-height: 1.65; }

  .tl-head, .track { grid-template-columns: 30px 1fr 50px 48px; }
  .tl-head > :nth-child(3), .track .src { display: none; }
  .tl-head > :nth-child(4) { grid-column: 3; }
  .tl-head > :last-child { display: none; }
  .track .play-icon { display: none; }
  .track-cache-btn { width: 32px; height: 32px; margin-right: 6px; }
  .track-cache-btn.cached svg { width: 12px; height: 12px; }
  .cache-prog { width: 22px; height: 22px; }
  .cache-prog-n { font-size: 8px; }
  .album-dl-btn { padding: 10px 14px; font-size: 10px; }
  .album-actions { width: 100%; }
  .track { padding: 12px 0; min-height: 48px; }
  /* iOS holds :hover/:active sticky after a tap; if those reset background
     they paint over .playing's black, leaving paper-coloured text invisible
     on a paper background until the user moves their finger. */
  .track:not(.playing):hover { padding-left: 0; background: transparent; }
  .track:not(.playing):active { background: var(--paper-2); }
  .track .name { font-size: 16px; }

  /* Drawers — albums (left) + rail (right) */
  .albums,
  .rail {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    bottom: 0;
    width: min(86vw, 360px);
    z-index: 30;
    background: var(--paper);
    border: none;
    transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 0 40px rgba(0,0,0,0.3);
    display: block;
  }
  .albums {
    left: 0;
    transform: translateX(-105%);
    border-right: 1px solid var(--ink);
    padding: 20px 18px calc(160px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .rail {
    right: 0;
    transform: translateX(105%);
    border-left: 1px solid var(--ink);
    display: flex;
    flex-direction: column;
  }
  .rail .rail-body {
    padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px));
  }
  .app[data-drawer="albums"] .albums { transform: translateX(0); }
  .app[data-drawer="rail"] .rail { transform: translateX(0); }

  .mobile-backdrop {
    display: block;
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    bottom: 0;
    left: 0; right: 0;
    background: rgba(15, 13, 11, 0.45);
    z-index: 25;
    animation: fadeIn 200ms ease;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  /* Touch targets */
  .album-row { padding: 12px 6px; min-height: 56px; }
  .queue-item { padding: 14px 6px; min-height: 48px; }
  .rail-tab { padding: 14px 10px; font-size: 12px; }
  .search-row { padding: 12px 6px; min-height: 56px; }

  /* TRANSPORT — floating card on mobile.
     Pulled out of the grid via position: fixed because iOS Safari was
     not honoring margins on the stretched grid item, leaving the card
     glued to the cell edges. Explicit left/right/bottom dodges the
     ambiguity and keeps the float deterministic across engines. */
  .transport {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    grid-column: unset;
    grid-row: unset;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
    margin: 0;
    padding: 14px 16px 16px;
    align-items: stretch;
    border-top: none;
    border: 1px solid rgba(242, 237, 228, 0.08);
    border-radius: 14px;
    box-shadow:
      0 6px 22px rgba(15, 13, 11, 0.32),
      0 2px 6px rgba(15, 13, 11, 0.18);
    z-index: 40;
  }
  /* Hide the amber stripe at top — clashes with rounded card corners */
  .transport::before { display: none; }
  .t-now {
    order: 1;
    gap: 12px;
  }
  .t-now .mini-art { width: 44px; height: 44px; }
  .t-now .t-title { font-size: 14px; }
  .t-now .t-album { font-size: 9px; }
  /* Squeeze transport controls + progress into one row below now-playing */
  .t-center {
    order: 2;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
  }
  .t-buttons { gap: 6px; flex-shrink: 0; }
  .t-buttons .t-btn { padding: 4px; }
  .t-buttons .t-btn:not(.play) svg { width: 18px; height: 18px; }
  .t-buttons > :nth-child(1),
  .t-buttons > :nth-child(5) { display: none; } /* hide shuffle & repeat on narrow */
  .t-btn.play { width: 40px; height: 40px; }
  .t-progress {
    flex: 1;
    gap: 8px;
    font-size: 9px;
  }
  .t-progress > span:first-child { width: 34px; }
  .t-progress > span:last-child { width: 34px; }
  .t-bar { height: 4px; }
  .t-bar .knob { opacity: 1; width: 12px; height: 12px; }

  .t-right { display: none; } /* volume + focus hidden on mobile */

  /* toast */
  .toast { bottom: calc(170px + env(safe-area-inset-bottom, 0px)); font-size: 10px; padding: 8px 14px; }

  /* Focus mode on mobile: keep drawers hidden */
  body[data-focus="1"] .mobile-topbar { display: flex; }
}

/* Tiny phones */
@media (max-width: 380px) {
  .stage-head h1 { font-size: 28px; }
  .stage-head .album-art { width: 140px; height: 140px; }
  .track .name { font-size: 15px; }
  .mobile-title-cn { font-size: 18px; }
}

/* Show extra transport controls on slightly larger phones */
@media (min-width: 480px) and (max-width: 820px) {
  .t-buttons > :nth-child(1),
  .t-buttons > :nth-child(5) { display: flex; }
}

/* Tracklist columns on narrow */
.track .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Loading indicator on transport */
.loading-stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  animation: loading 1.4s linear infinite;
  opacity: 0;
  pointer-events: none;
}
.loading-stripe.active { opacity: 1; }
@keyframes loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Service-worker update banner — sticky bookmark in bottom-right */
.update-banner {
  position: fixed;
  right: 24px;
  bottom: 120px;
  z-index: 60;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 12px 14px 12px 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: min(360px, calc(100vw - 24px));
  animation: ubIn 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.update-banner .ub-stamp {
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%) rotate(-12deg);
  background: var(--blood);
  color: var(--paper);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  padding: 4px 8px;
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
.update-banner .ub-body {
  flex: 1;
  min-width: 0;
}
.update-banner .ub-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.1;
}
.update-banner .ub-sub {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-top: 4px;
}
.update-banner .ub-cta {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 120ms;
  flex-shrink: 0;
}
.update-banner .ub-cta:hover {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}
.update-banner .ub-x {
  background: transparent;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.update-banner .ub-x:hover { color: var(--blood); }
@keyframes ubIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@media (max-width: 820px) {
  .update-banner {
    right: 12px;
    left: 12px;
    bottom: calc(180px + env(safe-area-inset-bottom, 0px));
    min-width: 0;
    max-width: none;
    padding-left: 46px;
    box-shadow: 4px 4px 0 var(--ink);
  }
  .update-banner .ub-title { font-size: 13px; }
  .update-banner .ub-cta { padding: 7px 10px; font-size: 10px; }
}

/* Confirm modal — samizdat replacement for window.confirm */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 13, 11, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalBd 180ms ease;
}
@keyframes modalBd { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 32px 26px 22px;
  max-width: 440px;
  width: 100%;
  animation: modalIn 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modalIn {
  from { transform: translateY(20px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--ink-3);
  pointer-events: none;
  opacity: 0.35;
}
.modal-stamp {
  position: absolute;
  top: -14px;
  left: 18px;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.25em;
  padding: 5px 10px;
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 var(--amber-deep);
  transform: rotate(-3deg);
  z-index: 1;
}
.modal-stamp.danger {
  background: var(--blood);
  border-color: var(--blood);
  box-shadow: 2px 2px 0 var(--ink);
}
.modal-title {
  margin: 4px 0 14px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.25;
  position: relative;
  z-index: 1;
}
.modal-body {
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
  margin: 0 0 24px;
  position: relative;
  z-index: 1;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.modal-btn {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform 120ms, box-shadow 120ms, background 120ms, color 120ms;
}
.modal-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--amber-deep);
}
.modal-btn:active {
  transform: translate(0, 0);
  box-shadow: 2px 2px 0 var(--ink);
}
.modal-btn-confirm {
  background: var(--ink);
  color: var(--paper);
}
.modal-btn-confirm:hover {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}
.modal-btn-confirm.danger {
  background: var(--blood);
  border-color: var(--blood);
  color: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
}
.modal-btn-confirm.danger:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--blood);
  box-shadow: 4px 4px 0 var(--blood);
}
@media (max-width: 820px) {
  .modal { padding: 28px 20px 18px; box-shadow: 6px 6px 0 var(--ink); }
  .modal-title { font-size: 17px; }
  .modal-body { font-size: 12px; }
  .modal-btn { padding: 9px 12px; font-size: 10px; letter-spacing: 0.15em; }
  .modal-actions { gap: 8px; }
}

/* Error toast */
.toast {
  position: fixed;
  bottom: 108px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blood);
  color: var(--paper);
  padding: 10px 18px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  z-index: 200;
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  animation: toastIn 300ms ease;
}
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
