/* Karaoke Automation — shared styles (dark, minimal, no framework) */

:root {
  --bg: #101216;
  --panel: #191c22;
  --panel-2: #20242c;
  --border: #2c313b;
  --text: #e8eaee;
  --muted: #9aa1ad;
  --accent: #1b5cf2;
  --accent-soft: #2c6cf51a;
  --good: #2fb46a;
  --bad: #e35b5b;
  --warn: #d9a13b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); }

.page { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px #0005;
}
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }

label { display: block; color: var(--muted); margin: 10px 0 4px; }

input[type="text"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input[type="file"] { color: var(--muted); }

button {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 7px;
  height: 34px;
  padding: 0 14px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { background: #2f6bf5; }
button:disabled { opacity: .45; cursor: default; }
button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
button.ghost:hover { background: var(--panel-2); border-color: #3d4452; }
button.danger {
  background: transparent; color: var(--bad); border-color: transparent;
}
button.danger:hover { background: #e35b5b18; border-color: var(--bad); }
button.small { height: 28px; padding: 0 11px; font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 12px;
     text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover td { background: #ffffff06; }

/* jobs table: long titles truncate; actions pinned right, never wrapping */
.job-title {
  display: inline-block; max-width: 420px; vertical-align: middle;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
td.actions-cell button { margin-left: 8px; }

.status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.status.queued    { background: #3a3f4a; }
.status.aligning  { background: #274b9c; }
.status.rendering { background: #6a4d9c; }
.status.ready     { background: #1d5c39; }
.status.failed    { background: #6b2a2a; }

.err { color: var(--bad); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* login */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-box { width: 330px; }
.login-box h1 { font-size: 18px; margin: 0 0 16px; text-align: center; }

/* ============ editor ============ */
.editor-body { display: flex; flex-direction: column; height: 100vh; }
.editor-main {
  flex: 1; overflow-y: auto;
  padding: 18px 22px 40px;
  display: flex; flex-direction: column; gap: 16px;
  max-width: 1500px; margin: 0 auto; width: 100%;
}

.appbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.appbar-back {
  font-size: 18px; padding: 2px 10px; border-radius: 6px;
  color: var(--text);
}
.appbar-back:hover { background: var(--panel-2); text-decoration: none; }
.appbar-title { font-weight: 600; display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; background: var(--panel-2);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  user-select: none;
  box-shadow: 0 1px 3px #0005;
}

/* review banner: the dual-model disagreement workflow */
.flag-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, #d9a13b12, transparent 70%);
  border: 1px solid #d9a13b45;
  border-radius: 12px;
  padding: 10px 16px;
}
.flag-banner .fb-icon {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: #d9a13b22; color: var(--warn);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.flag-banner .fb-text b { color: var(--warn); }
.flag-banner .fb-sub { color: var(--muted); font-size: 12.5px; }

/* inline suggestion card in the inspector */
.suggestion {
  display: inline-flex; align-items: center; gap: 10px;
  background: #d9a13b10;
  border: 1px solid #d9a13b45;
  border-radius: 8px;
  padding: 3px 6px 3px 12px;
}
.suggestion .s-label { color: var(--warn); font-size: 12.5px; }
.suggestion strong { font-variant-numeric: tabular-nums; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px;
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; }

/* true 16:9 viewport — framing matches the rendered video exactly */
#preview-wrap { display: flex; justify-content: center; flex: none; }
#preview {
  aspect-ratio: 16 / 9;
  height: min(38vh, 340px);
  max-width: 100%;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  background-size: cover;        /* same cover-crop as the ffmpeg render */
  background-position: center;
}
#previewVideo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;   /* identical cover-crop to the render */
}
#previewLine {
  position: absolute;
  z-index: 2;
  font-weight: 700; white-space: nowrap;
  max-width: 94%; overflow: hidden;
  /* the sung portion is painted by a gradient set from JS */
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: font-size .15s;
}
#previewNext {
  position: absolute; right: 12px; bottom: 6px;
  z-index: 2;
  color: #ffffff88; font-size: 12px;
  text-shadow: 0 1px 2px #000;
}

/* slim render progress bar under the app bar */
#renderBar {
  height: 3px; background: transparent; flex: none;
  display: none;
}
#renderBar.active { display: block; background: var(--panel-2); }
#renderBarFill {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: width .4s ease;
}
#renderBarFill.indeterminate {
  width: 30% !important;
  animation: slide 1.2s linear infinite;
}
@keyframes slide {
  from { margin-left: -30%; }
  to   { margin-left: 100%; }
}

.transport {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.transport .play {
  width: 42px; height: 42px; border-radius: 50%;
  font-size: 15px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.transport .time { font-variant-numeric: tabular-nums; min-width: 150px; }
.tlabel { color: var(--muted); font-size: 12px; }
.vsep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
button.icon { width: 30px; padding: 4px 0; text-align: center; }

.switch {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.switch input { display: none; }
.switch span {
  width: 30px; height: 16px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  position: relative; transition: background .15s;
}
.switch span::after {
  content: ""; position: absolute; top: 1px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: all .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 14px; background: #fff; }

#wave { display: block; width: 100%; height: 120px; cursor: crosshair; }
#words { display: block; width: 100%; height: 150px; cursor: default; }

/* timeline scrollbar (client request: must be able to scroll the timeline) */
#tl-scroll {
  overflow-x: scroll; overflow-y: hidden;
  height: 14px; margin-top: 4px;
}
#tl-scroll-inner { height: 1px; }
#tl-scroll::-webkit-scrollbar { height: 10px; }
#tl-scroll::-webkit-scrollbar-track { background: var(--panel-2); border-radius: 5px; }
#tl-scroll::-webkit-scrollbar-thumb { background: #4a5160; border-radius: 5px; }
#tl-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.inspector {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 40px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
#inspectorControls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inspector input[type="number"] { width: 84px; }

kbd {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; font-size: 11.5px; color: var(--muted);
}

#lines-panel { max-height: 320px; overflow-y: auto; }
.line-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 3px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.line-row:hover { background: var(--accent-soft); border-color: var(--border); }
.line-row.active { background: var(--accent-soft); border-color: var(--accent); }
.line-row .t {
  color: var(--muted); font-size: 12px; margin-right: 12px;
  font-variant-numeric: tabular-nums; min-width: 58px;
}
.line-actions {
  margin-left: auto; display: inline-flex; gap: 6px; opacity: .55;
}
.line-row:hover .line-actions, .line-row.active .line-actions { opacity: 1; }
.danger-icon:hover { color: var(--bad); border-color: var(--bad); }

/* video style panel */
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 18px;
  padding: 4px 2px;
}
.style-field label {
  display: block; color: var(--muted); font-size: 12px; margin: 0 0 5px;
}
.style-field.wide { grid-column: 1 / -1; }
.style-field input[type="color"] {
  width: 100%; height: 34px; padding: 2px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer;
}

.word-chip {
  display: inline-block; padding: 0 4px; border-radius: 4px; cursor: pointer;
}
.word-chip:hover { background: var(--panel-2); }
.word-chip.selected { background: var(--accent); color: #fff; }
.word-chip.flagged { color: var(--warn); font-weight: 600; }
.word-chip.flagged::before { content: "⚠"; font-size: 10px; margin-right: 2px; }

.help-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.help-table td:first-child { color: var(--muted); white-space: nowrap; }

dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 18px;
  min-width: 400px;
}
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 10px; font-size: 15px; }

/* tap mode overlay */
#tapOverlay {
  position: fixed; inset: 0; z-index: 60;
  background: #000c;
  display: flex; align-items: center; justify-content: center;
}
.tap-card {
  width: min(760px, 92vw);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px 26px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 18px 60px #000a;
}
.tap-head { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.tap-now {
  font-size: clamp(26px, 4.5vw, 40px); font-weight: 700; line-height: 1.3;
  text-align: center; min-height: 1.4em; color: var(--text);
}
.tap-next { text-align: center; color: var(--muted); min-height: 1.2em; }
.tap-hints {
  display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--border); padding-top: 12px;
}
.tap-hints kbd {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 7px; font-size: 12px;
}
