@import url("https://fonts.googleapis.com/css2?family=Exo+2:wght@400;500;600;700;800&family=Rajdhani:wght@600;700&display=swap");

:root {
  --bg: #07131f;
  --bg-2: #0f2235;
  --panel: #0d1d2d;
  --panel-2: #11263a;
  --line: rgba(132, 198, 244, 0.3);
  --line-strong: rgba(132, 198, 244, 0.58);
  --text: #eef7ff;
  --muted: #b3c8da;
  --accent: #47e2c5;
  --accent-ink: #031511;
  --warm: #ffd17a;
  --danger: #ff7f90;
  --info: #79b9ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Exo 2", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 560px at 0% 0%, rgba(71, 226, 197, 0.14), transparent 62%),
    radial-gradient(760px 520px at 100% 0%, rgba(255, 209, 122, 0.1), transparent 60%),
    linear-gradient(155deg, var(--bg), var(--bg-2));
}

button,
select,
input,
textarea { font: inherit; }

button { cursor: pointer; }

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.offset-shell {
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 26px;
}

.offset-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.offset-back,
.load-state,
.compact-btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 19, 31, 0.78);
  color: var(--text);
  padding: 0 13px;
  font-weight: 700;
  text-decoration: none;
}

.compact-btn { min-height: 38px; }

.load-state {
  min-width: 84px;
  color: var(--warm);
}

.load-state[data-tone="ready"] { color: var(--accent); }
.load-state[data-tone="bad"] { color: var(--danger); }

.offset-title-block { min-width: 0; }

.offset-kicker,
.panel-label {
  margin: 0;
  color: var(--warm);
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

h1,
.song-readout h2 {
  margin: 0;
  font-family: "Rajdhani", "Exo 2", sans-serif;
}

h1 {
  font-size: 2.45rem;
  line-height: 1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.topbar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.language-control {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.language-control select {
  min-width: 130px;
  min-height: 40px;
}

.notice,
.access-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13, 29, 45, 0.96);
}

.notice {
  margin-bottom: 14px;
  padding: 11px 14px;
  color: var(--text);
  font-weight: 700;
}

.notice.bad { border-color: rgba(255, 127, 144, 0.65); color: var(--danger); }
.notice.good { border-color: rgba(71, 226, 197, 0.65); color: var(--accent); }

.access-panel {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 34px;
}

.access-panel h2 {
  margin: 8px 0;
  font-size: 1.9rem;
}

.access-panel p:last-child {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.google-signin { min-width: 280px; }

.offset-workbench {
  display: grid;
  grid-template-columns: minmax(312px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.offset-sidebar,
.lyrics-stage {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(155deg, rgba(17, 38, 58, 0.96), rgba(13, 29, 45, 0.98));
}

.offset-sidebar {
  display: grid;
  align-content: start;
  gap: 13px;
  padding: 16px;
}

.field-label,
.field-line { color: var(--muted); font-weight: 700; }

select,
input[type="range"] { width: 100%; }

select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(7, 19, 31, 0.86);
  color: var(--text);
  outline: none;
}

select { min-height: 42px; padding: 0 10px; }

.mode-tabs {
  display: flex;
  gap: 7px;
}

.offset-filter-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.filter-summary {
  min-height: 2.8em;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.filter-tab,
.mode-tab {
  min-height: 38px;
  border: 1px solid rgba(132, 198, 244, 0.28);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(7, 19, 31, 0.58);
  padding: 0 10px;
  font-weight: 800;
}

.filter-tab.is-active,
.mode-tab.is-active {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

select:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.song-readout {
  border: 1px solid rgba(71, 226, 197, 0.38);
  border-radius: 8px;
  padding: 14px;
  background: rgba(71, 226, 197, 0.065);
}

.song-artist,
.song-readout h2 { margin: 0; }
.song-artist { color: var(--muted); font-weight: 700; }

.song-readout h2 {
  margin-top: 4px;
  font-size: 1.8rem;
  line-height: 1.05;
}

.song-meta,
.field-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.song-meta {
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--warm);
  font-size: 0.9rem;
  font-weight: 700;
}

.song-meta .is-reported { color: var(--danger); }
.song-meta .is-clean { color: var(--muted); }
.song-meta .is-missing { color: var(--warm); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric-grid div {
  min-height: 72px;
  border: 1px solid rgba(132, 198, 244, 0.24);
  border-radius: 8px;
  padding: 10px;
  background: rgba(7, 19, 31, 0.5);
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-grid strong {
  display: block;
  margin-top: 5px;
  font-family: "Rajdhani", "Exo 2", sans-serif;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.transport-row,
.nudge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.nudge-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tool-btn,
.primary-btn,
.ghost-btn,
.save-btn {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: rgba(7, 19, 31, 0.74);
  font-weight: 800;
  transition: background-color 180ms ease-out, border-color 180ms ease-out, color 180ms ease-out;
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.ghost-btn { width: 100%; color: var(--warm); }

.save-btn {
  width: 100%;
  border-color: rgba(255, 209, 122, 0.72);
  background: rgba(255, 209, 122, 0.1);
  color: var(--warm);
}

.save-btn:not(:disabled) { background: var(--warm); color: #171105; }

.verify-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid rgba(132, 198, 244, 0.28);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(7, 19, 31, 0.55);
  font-weight: 800;
}

.verify-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.verify-toggle:has(input:disabled) { opacity: 0.56; }

button:disabled { cursor: default; opacity: 0.52; }
button:not(:disabled):hover { border-color: var(--accent); }

.slider-field,
.offset-tools,
.save-panel { display: grid; gap: 9px; }

.save-panel { border-top: 1px solid rgba(132, 198, 244, 0.22); padding-top: 12px; }

.save-state { color: var(--muted); font-variant-numeric: tabular-nums; }
.save-state[data-state="dirty"] { color: var(--warm); }
.save-state[data-state="saving"],
.save-state[data-state="verified"] { color: var(--accent); }
.save-state[data-state="bad"] { color: var(--danger); }
.save-state[data-state="conflict"] { color: var(--danger); }

input[type="range"] { accent-color: var(--accent); }

.lyrics-stage {
  display: grid;
  grid-template-rows: auto minmax(520px, calc(100vh - 230px));
  min-height: 740px;
  overflow: hidden;
}

.now-panel {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  background: rgba(7, 19, 31, 0.42);
}

.now-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.current-lyric {
  min-height: 54px;
  margin: 10px 0 0;
  font-size: 2.2rem;
  line-height: 1.22;
  font-weight: 800;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.next-lyric { min-height: 24px; margin: 10px 0 0; color: var(--muted); font-size: 1.05rem; }

.preview-panel,
.editor-panel { min-height: 0; }

.preview-panel { display: grid; }

.lyrics-list {
  min-height: 0;
  overflow: auto;
  padding: 12px 10px 28px;
  scroll-behavior: smooth;
}

.lyric-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px;
  background: transparent;
  color: rgba(238, 247, 255, 0.78);
}

.lyric-row.is-editable { grid-template-columns: minmax(0, 1fr) auto; }
.lyric-row:hover,
.lyric-row:focus-within { border-color: rgba(132, 198, 244, 0.3); background: rgba(132, 198, 244, 0.055); }
.lyric-row.is-active { border-color: var(--accent); background: rgba(71, 226, 197, 0.13); color: var(--text); }

.lyric-seek {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-columns: 84px 84px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 6px;
  padding: 4px 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  appearance: none;
}

.lyric-row time {
  color: var(--warm);
  font-family: "Rajdhani", "Exo 2", sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.lyric-row .adjusted-time { color: var(--accent); }
.lyric-text { min-width: 0; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.25; }
.line-nudge-controls { display: flex; align-items: center; gap: 6px; align-self: center; }
.line-nudge-btn {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  color: var(--warm);
  font-size: 1.2rem;
  line-height: 1;
}
.line-nudge-btn:not(:disabled):active { border-color: var(--warm); background: rgba(255, 209, 122, 0.14); }
.empty-state { padding: 28px; color: var(--muted); font-weight: 700; }

.editor-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: rgba(7, 19, 31, 0.28);
}

.editor-toolbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}

.editor-toolbar > div:first-child { display: grid; gap: 3px; }
.editor-hint { color: var(--muted); font-size: 0.86rem; }
.editor-hint.is-bad { color: var(--danger); }

.editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.editor-save-btn { width: auto; min-width: 116px; padding: 0 14px; }

.conflict-notice {
  border-bottom: 1px solid rgba(255, 127, 144, 0.58);
  background: rgba(255, 127, 144, 0.1);
  color: #ffd7dd;
  padding: 10px 14px;
  font-weight: 700;
}

.editor-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.raw-editor { min-width: 0; min-height: 0; display: grid; border-right: 1px solid var(--line); }

.raw-editor textarea {
  width: 100%;
  min-height: 100%;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 16px;
  color: #e8f6ff;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.94rem;
  line-height: 1.62;
  tab-size: 2;
}

.draft-preview { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }

.draft-preview-heading {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 13px;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 1260px) {
  .lyric-row.is-editable { grid-template-columns: minmax(0, 1fr); }
  .line-nudge-controls { justify-self: end; }
}

@media (max-width: 1020px) {
  .offset-topbar { grid-template-columns: auto minmax(0, 1fr); }
  .topbar-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 880px) {
  .offset-workbench { grid-template-columns: 1fr; }
  .lyrics-stage { min-height: 650px; grid-template-rows: auto minmax(430px, 62vh); }
  .access-panel { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 680px) {
  .offset-shell { padding: 12px 10px 20px; }
  .offset-topbar { grid-template-columns: 1fr; }
  .offset-back { justify-self: start; }
  .topbar-actions { align-items: stretch; }
  .language-control { flex: 1; }
  h1 { font-size: 2rem; }
  .access-panel { min-height: 230px; padding: 24px 18px; }
  .google-signin { min-width: 0; width: 100%; }
  .now-heading { align-items: flex-start; flex-direction: column; }
  .editor-toolbar { align-items: flex-start; flex-direction: column; }
  .editor-actions { justify-content: flex-start; }
  .editor-grid { grid-template-columns: 1fr; grid-template-rows: minmax(320px, 48vh) minmax(320px, 48vh); overflow: auto; }
  .raw-editor { border-right: 0; border-bottom: 1px solid var(--line); }
  .lyric-seek { grid-template-columns: 72px 72px minmax(0, 1fr); }
}

@media (max-width: 500px) {
  .metric-grid { grid-template-columns: 1fr; }
  .transport-row,
  .nudge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .current-lyric { font-size: 1.5rem; }
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; }
  .lyric-seek { grid-template-columns: 1fr; gap: 3px; }
}

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