:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --sunken: #eceef2;
  --text: #1c1d21;
  --muted: #6b707a;
  --faint: #8b909a;
  --line: #e4e6eb;
  --hover: rgba(20, 22, 28, 0.06);
  --pressed: rgba(20, 22, 28, 0.1);
  --focus: #2563eb;
  --primary: #2f6fed;
  --primary-hover: #1d5fe0;
  --primary-press: #1a54c7;
  --live: #e11d48;
  --next: #2563eb;
  --shadow: 0 10px 30px rgba(20, 22, 28, 0.12);
  --radius: 10px;
  color-scheme: light;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
html[data-theme="dark"] {
  --bg: #121316;
  --surface: #1c1d22;
  --sunken: #16171c;
  --text: #f3f4f6;
  --muted: #a1a1aa;
  --faint: #8b909a;
  --line: #2e3038;
  --hover: rgba(255, 255, 255, 0.06);
  --pressed: rgba(255, 255, 255, 0.1);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.ghost {
  border: 0; background: transparent; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; color: var(--text); line-height: 1.2;
}
.ghost:hover { background: var(--hover); }
.ghost:active { background: var(--pressed); }
.ghost:disabled { opacity: 0.38; cursor: default; }
.ghost[aria-pressed="true"] { background: var(--sunken); }
kbd, .kbd {
  font-family: inherit; font-size: 11px; font-weight: 650;
  border: 1px solid var(--line); background: var(--surface);
  border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 5px; min-width: 1.3em; text-align: center; color: var(--muted);
}
.banner {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #1c1d22; color: #fff; font-size: 14px;
}
.banner[hidden] { display: none; }
.banner button {
  border: 0; background: transparent; color: #fff; border-radius: 8px; padding: 6px 10px;
}
.banner button:hover { background: rgba(255,255,255,0.12); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 32px; height: 32px; border-radius: 8px; background: var(--sunken);
  display: grid; place-items: center; color: var(--text); flex: none;
}
.service-name {
  border: 0; background: transparent; font-weight: 700; font-size: 15px;
  padding: 2px 4px; border-radius: 6px; width: 180px; max-width: 36vw;
}
.service-name:hover { background: var(--hover); }
.date { color: var(--muted); font-size: 12px; padding-left: 4px; }
.top-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.switch {
  border: 0; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 5px 4px 12px; font-weight: 650; background: var(--sunken); color: var(--muted);
}
.switch[aria-checked="true"] { background: #ff4d6a; color: #fff; }
.knob { width: 22px; height: 22px; border-radius: 99px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.workspace {
  display: grid; grid-template-columns: 236px minmax(0, 1fr) 252px;
  min-height: 0;
}
.sidebar, .rail { min-height: 0; overflow: auto; padding: 12px; }
.sidebar { background: var(--bg); border-right: 1px solid var(--line); }
.rail { border-left: 1px solid var(--line); background: var(--bg); }
.section { margin-bottom: 16px; }
.section-h {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 4px 6px; border-radius: 8px;
}
.section-h:hover { background: var(--hover); }
.passages { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.passage {
  display: grid; grid-template-columns: 1fr auto auto; gap: 4px; align-items: center;
  border-radius: 10px; padding: 8px 8px 8px 10px; position: relative;
}
.passage.is-live { background: var(--surface); box-shadow: 0 1px 2px rgba(20,22,28,.06), 0 0 0 1px var(--line); }
.passage-main {
  border: 0; background: transparent; text-align: left; padding: 0; min-width: 0; border-radius: 8px;
}
.passage-title { display: block; font-weight: 680; font-size: 14px; }
.passage-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.live-flag { color: var(--live); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.live-flag:before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--live); }
.empty { color: var(--faint); font-size: 13px; margin: 4px 8px 8px; }
.add {
  border: 0; background: transparent; color: var(--muted); padding: 6px 8px; border-radius: 8px; font-weight: 600;
}
.add:hover { background: var(--hover); color: var(--text); }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 12px 12px 8px; gap: 8px; }
.controls { display: flex; gap: 10px; align-items: center; }
.versions { display: flex; background: var(--sunken); border-radius: 10px; padding: 3px; gap: 2px; }
.versions button {
  border: 0; background: transparent; border-radius: 8px; padding: 7px 12px; font-weight: 700; color: var(--muted);
}
.versions button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.search { position: relative; flex: 1; min-width: 0; }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--faint); }
#ref-input {
  width: 100%; height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 42px 0 38px;
}
#ref-input:focus { border-color: #93b4f8; outline: 2px solid rgba(37,99,235,.35); outline-offset: 0; }
.search .slash {
  position: absolute; right: 10px; top: 10px; pointer-events: none;
}
.primary {
  height: 42px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--primary);
  color: #fff; font-weight: 700;
}
.primary:hover { background: var(--primary-hover); }
.primary:active { background: var(--primary-press); }
.primary:disabled { opacity: 0.45; }
.listbox {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  border: 1px solid var(--line); margin: 0; padding: 6px; list-style: none; max-height: 320px; overflow: auto;
}
.listbox[hidden] { display: none; }
.listbox li {
  border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; cursor: pointer;
}
.listbox li[aria-selected="true"], .listbox li:hover { background: var(--hover); }
.s-ref { font-weight: 700; }
.s-snip { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: 14px; }
.status .ref { font-weight: 750; }
.muted { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--live); display: inline-block; }
.dot.off { background: var(--faint); }
.spacer { flex: 1; }
.icon-btn {
  width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; }
.stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.frame {
  border: 2px solid var(--live); border-radius: 16px; padding: 10px; background: var(--surface);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.frame.is-quiet { border-color: var(--line); }
#preview-slide { width: 100%; height: 100%; border-radius: 8px; }
.rail h2 { margin: 14px 0 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
.rail h2:first-child { margin-top: 2px; }
.next-card { border-radius: 10px; overflow: hidden; background: var(--sunken); aspect-ratio: 16/9; }
#next-slide { width: 100%; height: 100%; }
.next-cap { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.quick { display: flex; flex-direction: column; align-items: stretch; }
.quick .ghost { justify-content: space-between; padding: 8px 8px; }
.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; }
.style-btn {
  border: 0; background: transparent; border-radius: 10px; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.style-btn:hover { background: var(--hover); }
.style-btn[aria-checked="true"] .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus); }
.swatch {
  width: 100%; aspect-ratio: 1.15; border-radius: 8px; display: grid; place-items: center;
  font-weight: 750; border: 1px solid rgba(0,0,0,.06);
}
.swatch.bible { background: #f4efe6; color: #1a1612; font-family: "EB Garamond", serif; }
.swatch.modern { background: #141416; color: #fff; }
.swatch.cream { background: #f7f3eb; color: #1a1612; }
.swatch.white { background: #fff; color: #161616; }
.swatch.midnight { background: #0b0e14; color: #f4f7fb; font-family: "Literata", serif; }
.swatch.vivid { background: linear-gradient(135deg, #6d28d9, #db2777); color: #fff; }
.style-name { font-size: 11px; color: var(--muted); }
.footer {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px; align-items: end; padding: 8px 14px 12px;
  border-top: 1px solid var(--line); background: var(--bg);
}
.film-h { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; min-width: 0; }
.film-h strong { font-size: 13px; }
.film-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.thumb { border: 0; background: transparent; padding: 0; text-align: left; width: 148px; flex: none; border-radius: 8px; }
.thumb-slide { height: 84px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; }
.thumb.is-live .thumb-slide { border-color: var(--live); }
.thumb.is-next .thumb-slide { border-color: var(--next); }
.thumb-cap { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-cap .mark { font-weight: 750; }
.thumb.is-live .mark { color: var(--live); }
.thumb.is-next .mark { color: var(--next); }
.keyguide {
  border-left: 1px solid var(--line); padding: 4px 4px 4px 14px;
  display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; min-width: 168px;
}
.keyguide div { display: flex; align-items: center; gap: 6px; }
.menu {
  position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 8px; min-width: 220px;
}
.menu[hidden] { display: none; }
.menu button { width: 100%; text-align: left; }
.menu label { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px; font-size: 13px; }
.menu input[type="range"] { width: 110px; }
.hint { color: var(--muted); font-size: 12px; padding: 0 8px 8px; }
.tip {
  position: fixed; z-index: 80; display: flex; align-items: center; gap: 8px;
  background: #1c1d22; color: #fff; border-radius: 8px; padding: 6px 8px 6px 10px;
  font-size: 13px; font-weight: 550; box-shadow: 0 8px 24px rgba(0,0,0,.22);
  pointer-events: none; white-space: nowrap;
}
.tip[hidden] { display: none; }
.tip kbd { background: #2c2e36; color: #fff; border: 0; border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.remove {
  border: 0; background: transparent; color: var(--faint); border-radius: 6px; width: 22px; height: 22px;
}
.remove:hover, .remove:focus-visible { background: var(--hover); color: var(--text); }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar, .rail { border: 0; max-height: none; }
  .sidebar { border-bottom: 1px solid var(--line); }
  body { height: auto; }
  .stage { min-height: 240px; }
}
@media (max-width: 720px) {
  .controls { flex-wrap: wrap; }
  .search { min-width: 100%; order: 3; }
  .footer { grid-template-columns: 1fr; }
  .keyguide { border-left: 0; border-top: 1px solid var(--line); padding: 8px 0 0; }
  .top-actions .ghost span.label { display: none; }
}
