/* GlassLyrics control page -- mobile first, thumb-sized targets. */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* .gate and .candidates set display values that outrank the user agent's
   [hidden] { display: none }, so hidden panels would still render. */
[hidden] { display: none !important; }

:root {
  --bg: #0b0b0d;
  --surface: #17171b;
  --surface-2: #212127;
  --line: #2e2e36;
  --fg: #f2f2f4;
  --muted: #9b9ba6;
  --faint: #6a6a76;
  --accent: #6ee7a8;
  --accent-ink: #05261a;
  --warn: #f5b869;
  --danger: #ff8a8a;
  --radius: 14px;
}

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- layout */

.topbar { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 14px; }
.brand { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
summary.card-title { cursor: pointer; margin-bottom: 0; list-style: revert; }
details[open] summary.card-title { margin-bottom: 14px; }
.manual-body { display: grid; gap: 12px; }

/* ---------------------------------------------------------------- fields */

.search-grid { display: grid; gap: 12px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.field-narrow { max-width: 120px; }

.field { display: block; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field-label em { color: var(--faint); font-style: normal; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--fg);
  font: inherit;
  /* 16px minimum keeps iOS from zooming the viewport on focus. */
  font-size: 16px;
  padding: 12px;
}

textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }

input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* --------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 50px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: default; }

.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-secondary { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { min-height: 38px; padding: 8px 12px; font-size: 14px; }
.btn-wide { width: 100%; }

.transport { display: flex; gap: 10px; align-items: stretch; margin-bottom: 10px; }
.btn-round { flex: 0 0 84px; }
.btn-play { flex: 1; background: var(--accent); color: var(--accent-ink); border-color: transparent; font-size: 18px; min-height: 62px; }
.btn-play.is-playing { background: var(--surface-2); color: var(--fg); border-color: var(--line); }

/* ------------------------------------------------------------ candidates */

.candidates { list-style: none; margin-top: 12px; display: grid; gap: 8px; }

.candidate {
  width: 100%;
  text-align: left;
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}

.candidate-title { font-weight: 600; }
.candidate-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.candidate-tag { font-size: 12px; color: var(--faint); }
.candidate-tag.synced { color: var(--accent); }

/* --------------------------------------------------------------- now bar */

.now-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.now-title { font-size: 19px; font-weight: 700; }
.now-artist { color: var(--muted); }
.now-source { font-size: 12px; color: var(--faint); margin-top: 2px; }

.scrub { margin-bottom: 14px; }

.scrub-input {
  width: 100%;
  appearance: none;
  background: transparent;
  height: 32px;
  margin: 0;
}

.scrub-input::-webkit-slider-runnable-track { height: 6px; background: var(--surface-2); border-radius: 3px; }
.scrub-input::-moz-range-track { height: 6px; background: var(--surface-2); border-radius: 3px; }

.scrub-input::-webkit-slider-thumb {
  appearance: none;
  width: 26px; height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

.scrub-input::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); border: none; }

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

/* ------------------------------------------------------------------ sync */

.sync { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.sync-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.sync-label { font-size: 14px; color: var(--muted); }
.sync-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sync-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sync-row .btn { padding: 12px 4px; font-size: 15px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* ------------------------------------------------------------ lyric list */

.lyric-list {
  list-style: none;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lyric-line {
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--faint);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  gap: 10px;
}

.lyric-line .lt { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--faint); min-width: 42px; padding-top: 3px; }
.lyric-line.past { color: var(--muted); }
.lyric-line.active { background: var(--surface-2); color: var(--fg); font-weight: 600; }
.lyric-line.instrumental { font-style: italic; }

/* -------------------------------------------------------------- japanese */

.ja { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.ja-status { font-size: 13px; color: var(--faint); }
.ja-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.ja-row-label { font-size: 14px; color: var(--muted); flex: 0 0 auto; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

.seg {
  appearance: none;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 10px;
  min-height: 44px;
  cursor: pointer;
}

.seg:first-child { border-left: 0; }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg[disabled] { opacity: 0.4; cursor: not-allowed; }

#karaoke-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.sync-row-2 { grid-template-columns: repeat(2, 1fr); margin-top: 12px; }

/* --------------------------------------------------- selected-line editor */

.lyric-line.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.lyric-line .lx { flex: 1; min-width: 0; }
.lyric-line .lja { font-size: 11px; color: var(--faint); flex: 0 0 auto; padding-top: 4px; }

.line-actions { display: grid; gap: 8px; padding: 10px 8px 14px; }
.line-actions .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.line-actions .btn { min-height: 44px; font-size: 13px; padding: 10px 6px; }

.tokens { display: grid; gap: 8px; margin-top: 4px; }

.token {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.token.plain { opacity: 0.55; }
.token-surface { font-size: 20px; font-weight: 700; line-height: 1.2; }
.token-body { min-width: 0; display: grid; gap: 6px; }
.token-meta { font-size: 12px; color: var(--faint); }
.token-meta .gen { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.token-meta .tag { color: var(--accent); }
.token-meta .warn { color: var(--warn); }
.token-edit { display: flex; gap: 8px; }
.token-edit input { flex: 1; min-width: 0; font-size: 16px; padding: 10px; }
.token-edit .btn { min-height: 44px; padding: 8px 12px; font-size: 13px; flex: 0 0 auto; }

/* ---------------------------------------------------------- diagnostics */

/* Stacked on a phone: some diagnostic labels are long enough that a shared
   label column would squeeze the values into a two-word-wide ribbon. */
.diag { display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 13px; margin-bottom: 14px; }
.diag dt { color: var(--faint); }
.diag dd { color: var(--fg); word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; margin-bottom: 8px; }
@media (min-width: 560px) {
  .diag { grid-template-columns: minmax(0, 42%) 1fr; gap: 6px 14px; }
  .diag dd { margin-bottom: 0; }
}

/* ----------------------------------------------------------------- misc */

.status-line { font-size: 14px; color: var(--muted); margin-top: 10px; }
.status-line.error { color: var(--danger); }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; }
.warning { background: rgba(245, 184, 105, 0.12); border: 1px solid rgba(245, 184, 105, 0.35); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }

.pair-code { font-size: 40px; font-weight: 700; letter-spacing: 0.14em; text-align: center; font-variant-numeric: tabular-nums; }

.footnote { text-align: center; font-size: 13px; color: var(--faint); margin-top: 6px; }
.footnote a { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.gate { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.gate-card { width: 100%; display: grid; gap: 14px; }
.gate-title { font-size: 22px; text-align: center; }

@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }

/* ------------------------------------------------------- candidate ranking */

/* The record that was actually loaded, and the ones rejected as a different
   recording. Both are stated rather than implied: an automatic choice the
   wearer cannot see is an automatic choice they cannot correct. */
.candidate.is-selected { border-color: var(--accent); }
.candidate-mark {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.candidate.is-rejected { opacity: 0.55; }
.candidate-reject { margin-top: 6px; font-size: 12px; color: var(--warn); }

/* ------------------------------------------------------ plain manual mode */

.manual-offer { margin: 14px 0; display: grid; gap: 8px; }

.manual-live {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: grid;
  gap: 12px;
}
.manual-flag { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.manual-badge {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warn);
  color: #2a1a05;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.manual-current {
  font-size: 20px;
  line-height: 1.35;
  font-weight: 600;
  min-height: 1.35em;
  overflow-wrap: break-word;
}

/* ------------------------------------------------------------ Apple Music */

.apple-now { display: grid; gap: 12px; margin-top: 12px; }
.apple-head { display: flex; gap: 12px; align-items: center; }
.apple-art {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: var(--surface-2);
  object-fit: cover;
}
.apple-meta { min-width: 0; }
.apple-meta > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.apple-missing { margin: 10px 0 14px 18px; display: grid; gap: 6px; font-size: 13px; color: var(--warn); }
.apple-steps { margin: 10px 0 4px 18px; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.apple-steps strong { color: var(--fg); }
