:root {
  --system-font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: #0c0c0c;
  color: #eee;
  font-family: var(--system-font);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body { margin: 0; }

a { color: inherit; text-decoration: none; }

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--t-ink, #eee);
  outline-offset: 3px;
}

/* Home */

.home {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(24px, 3.5vw, 48px) 24px 32px;
}

.logo {
  width: min(150px, 100%);
  opacity: .9;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .16em;
}

.logo img { display: block; width: 100%; height: auto; }

.album-grid, .library-note {
  width: min(74vw, 960px, 100%);
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: clamp(14px, 1.6vw, 26px) clamp(10px, 1.8vw, 28px);
  margin-top: 24px;
}

.album-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  border-radius: 3px;
}

.album-art {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 3px;
  background: #181818;
  opacity: .72;
  transition: opacity .2s;
}

.album-card:hover .album-art,
.album-card:focus-visible .album-art { opacity: 1; }

.album-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  padding: 8%;
  border: 1px solid #30302e;
  background: linear-gradient(150deg, #292927, #141414 72%);
  opacity: .9;
}

.album-placeholder .album-label { font-size: clamp(8px, 1.5vw, 10px); }

.album-placeholder .album-name {
  display: block;
  font-size: clamp(10px, 2vw, 16px);
}

.album-label {
  font-family: var(--system-font);
  font-size: 10px;
  letter-spacing: .14em;
  opacity: .62;
}

.album-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: keep-all;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.4;
  opacity: .85;
}

.library-note {
  margin-top: 20px;
  color: #bdbdbd;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.6;
}

.library-note summary { cursor: pointer; }

.library-note ul { padding-inline-start: 20px; }

/* Shared album and typing layout */

.themed {
  --gutter: clamp(24px, 3.6vw, 72px);
  --rule: color-mix(in srgb, var(--t-ink) 22%, transparent);
  position: relative;
  isolation: isolate;
  overflow: clip;
  background: var(--t-base);
  color: var(--t-ink);
  font-family: var(--t-font);
  font-weight: var(--t-weight);
}

.cover, .veil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

.cover {
  inset-inline-start: 44%;
  width: 56%;
  object-fit: cover;
  filter: blur(var(--t-blur));
  mask-image: linear-gradient(90deg, transparent, #000 30%);
}

.cover-placeholder {
  background: radial-gradient(ellipse at 85% 45%,
    color-mix(in srgb, var(--t-accent) 25%, var(--t-base)), var(--t-base) 75%);
  filter: none;
}

.veil {
  background: linear-gradient(90deg, var(--t-base) 40%, transparent 85%),
    color-mix(in srgb, var(--t-base) 18%, transparent);
}

.view-nav { padding: 16px var(--gutter) 8px; }

.back {
  display: inline-block;
  padding: 4px 0;
  font: 12px var(--system-font);
  opacity: .75;
}

.back:hover { opacity: 1; }

/* Track list */

.album-view {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.album-content {
  align-self: center;
  width: 56%;
  min-width: 0;
  padding: 26px var(--gutter) 68px;
}

.album-content h1 {
  margin: 6px 0 22px;
  font-size: calc(var(--t-scale) * clamp(26px, 2.36vw, 41.6px));
  font-weight: inherit;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

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

.songs li { border-top: 1px solid var(--rule); }

.songs li:last-child { border-bottom: 1px solid var(--rule); }

.song {
  display: grid;
  grid-template-columns: 2ch minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 14px;
  padding: 11px 12px;
  font-size: calc(var(--t-scale) * clamp(17px, 1.545vw, 27.2px));
  overflow-wrap: anywhere;
}

.song:hover, .song:focus-visible {
  background: color-mix(in srgb, var(--t-accent) 16%, transparent);
}

.song-number, .song-duration {
  font: 11px var(--system-font);
  font-variant-numeric: tabular-nums;
  opacity: .62;
}

/* Lyric sheet */

.typing-view {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.sheet {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 62%;
  padding: 14px var(--gutter);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-content { margin-block: auto; }

.sheet-title {
  margin: 0 0 12px;
  font: 10px var(--system-font);
  letter-spacing: .14em;
  opacity: .7;
  overflow-wrap: anywhere;
}

.lyric-lines { display: grid; gap: 4px; }

.lyric-line, .target {
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lyric-line { padding: 4px 12px; }

.lyric-line.past, .lyric-line.ahead {
  font-size: calc(var(--t-scale) * clamp(13px, 1.182vw, 20.8px));
}

.lyric-line.past { opacity: .38; }

.lyric-line.audible {
  padding-block: 6px;
  margin-block: 4px;
  font-size: calc(var(--t-scale) * clamp(20px, 1.818vw, 32px));
}

.lyric-line.ahead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  opacity: .7;
}

.ahead-tag {
  color: var(--t-accent);
  font: 10px var(--system-font);
  white-space: nowrap;
}

.lyric-line.stanza-start, .input-box.stanza-start { margin-top: 12px; }

.input-box {
  display: grid;
  gap: 3px;
  width: 78%;
  margin-top: 4px;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: color-mix(in srgb, var(--t-base) 60%, transparent);
  font-size: calc(var(--t-scale) * clamp(15px, 1.364vw, 24px));
}

.input-box.waiting { border-color: var(--t-accent); }

.lyric-input {
  width: 100%;
  min-width: 0;
  padding: 2px 0;
  line-height: 1.25;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  caret-color: var(--t-accent);
}

/* The box border already marks the field; keep focus as an accent underline instead of a heavy outline. */
.lyric-input:focus-visible { outline: none; border-bottom-color: var(--t-accent); }
.input-box:focus-within { border-color: color-mix(in srgb, var(--t-accent) 55%, var(--rule)); }

.input-hint {
  font: 9.5px/1.4 var(--system-font);
  opacity: .72;
}

.faint { opacity: .42; }
.ghost { opacity: .32; }
.wrong { color: var(--t-error); }

.composing {
  text-decoration: underline var(--t-accent);
  text-underline-offset: .22em;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-inline-end: -2px;
  vertical-align: -.12em;
  background: var(--t-accent);
  visibility: hidden;
}

.input-box:focus-within .caret {
  visibility: visible;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.future {
  margin: 7px 0 0 12px;
  font-size: 12px;
  letter-spacing: .24em;
  opacity: .32;
}

.completion { margin-top: 18px; }

.completion-title {
  margin: 0 0 12px;
  font-size: calc(var(--t-scale) * clamp(20px, 1.818vw, 32px));
}

.completion-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.completion-actions > * {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  font: 12px var(--system-font);
}

.restart {
  color: var(--t-base);
  background: var(--t-accent);
  cursor: pointer;
}

/* Playback HUD */

.hud {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 12px;
  padding: 12px var(--gutter) 16px;
  font: 11px var(--system-font);
}

.pill {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  white-space: nowrap;
}

.retry {
  background: var(--t-accent);
  color: var(--t-base);
  cursor: pointer;
}

.hud-time { font-variant-numeric: tabular-nums; white-space: nowrap; }

.hud-title {
  max-width: 24vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track {
  position: relative;
  height: 3px;
  border-radius: 2px;
  background: var(--rule);
}

.track-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--t-accent);
}

.track-tick, .track-limit {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 9px;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--t-ink) 45%, transparent);
}

.track-limit {
  width: 2px;
  height: 13px;
  background: var(--t-accent);
  opacity: .65;
}

@media (width < 720px) {
  .album-grid, .library-note { width: 100%; }

  .cover {
    inset-inline-start: 0;
    width: 100%;
    mask-image: none;
  }

  .veil {
    background: linear-gradient(
      90deg,
      color-mix(in srgb, var(--t-base) 94%, transparent),
      color-mix(in srgb, var(--t-base) 84%, transparent)
    );
  }

  .album-content, .sheet, .input-box { width: 100%; }

  .hud {
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 8px;
  }

  .track { grid-column: 1 / -1; grid-row: 2; }
  .hud-title { justify-self: end; max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .input-box:focus-within .caret { animation: none; }
  .album-art { transition: none; }
}
