:root {
  color-scheme: dark;
  --ink: #f7f4ec;
  --muted: #a9b6b7;
  --quiet: #6f7e82;
  --panel: #12191d;
  --panel-2: #172226;
  --panel-3: #202b2f;
  --line: #2d3b3f;
  --teal: #24b8a6;
  --gold: #f0b75a;
  --coral: #f2765d;
  --blue: #6ea8fe;
  --violet: #a48cff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --stage-bg: url("assets/worship-light.png");
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: #0b1013;
  color: var(--ink);
}

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

button,
label.file-button {
  -webkit-tap-highlight-color: transparent;
}

[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;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background:
    linear-gradient(90deg, rgba(36, 184, 166, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(240, 183, 90, 0.05), transparent 42%),
    #0b1013;
}

.side-rail {
  min-height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(12, 18, 21, 0.92);
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal), var(--gold));
  color: #071113;
  font-weight: 900;
  box-shadow: 0 10px 32px rgba(36, 184, 166, 0.2);
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  font-size: 0.98rem;
  line-height: 1.15;
}

.brand-lockup span {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

.rail-nav {
  display: grid;
  gap: 7px;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.rail-link svg,
.icon-button svg,
.soft-button svg,
.primary-action svg,
.go-live-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.rail-link.is-active,
.rail-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.rail-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.host-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(36, 184, 166, 0.14);
}

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

.topbar {
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 21, 0.82);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(18px);
}

.service-title {
  display: grid;
  gap: 4px;
}

.service-title label,
.editor-form span,
.bible-search span,
.theme-controls span {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

.service-title input {
  width: min(100%, 460px);
  background: transparent;
  color: var(--ink);
  border: 0;
  outline: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 800;
  letter-spacing: 0;
}

.run-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.run-status span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #172126;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.run-status span:last-child {
  color: #09211f;
  background: var(--teal);
  border-color: var(--teal);
  font-weight: 800;
}

.top-actions,
.icon-strip,
.form-actions,
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(360px, 1.18fr) minmax(360px, 1fr);
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.panel {
  min-width: 0;
  min-height: calc(100vh - 102px);
  background: rgba(18, 25, 29, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-heading {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.panel-heading h1,
.panel-heading h2 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  font-weight: 800;
}

.primary-action,
.soft-button,
.icon-button,
.go-live-button {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  color: var(--ink);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.primary-action {
  min-height: 42px;
  padding: 0 14px;
  background: var(--teal);
  color: #061412;
  font-weight: 900;
}

.primary-action:hover,
.go-live-button:hover {
  transform: translateY(-1px);
}

.soft-button,
.icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.soft-button {
  padding: 0 12px;
  color: var(--muted);
}

.soft-button:hover,
.icon-button:hover,
.segment:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--panel-3);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.icon-button.large {
  width: 48px;
  min-height: 48px;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.service-list,
.library-list,
.bible-result,
.media-grid {
  padding: 12px;
}

.service-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 198px);
  overflow-y: auto;
  overflow-x: hidden;
}

.service-item,
.song-card,
.slide-card {
  border: 1px solid var(--line);
  background: #121b1f;
  border-radius: var(--radius);
}

.service-item {
  width: 100%;
  padding: 12px;
  color: var(--ink);
  display: grid;
  grid-template-columns: auto minmax(76px, 1fr) auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}

.service-item:hover,
.service-item.is-active {
  border-color: rgba(36, 184, 166, 0.55);
  background: #16272a;
}

.service-number {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(240, 183, 90, 0.14);
  color: var(--gold);
  font-weight: 900;
  font-size: 0.78rem;
}

.service-copy {
  min-width: 0;
}

.service-copy,
.service-number {
  border: 0;
  cursor: pointer;
}

.service-copy {
  color: inherit;
  background: transparent;
  text-align: left;
  padding: 0;
}

.service-copy strong,
.song-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-copy span,
.song-card span,
.bible-meta,
.media-name {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

.type-pill {
  color: #061412;
  background: var(--gold);
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.service-tools {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  gap: 4px;
}

.service-tools .icon-button {
  width: 28px;
  min-height: 28px;
}

.service-tools svg {
  width: 15px;
  height: 15px;
}

.segmented {
  background: #0d1316;
  border: 1px solid var(--line);
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-radius: var(--radius);
  min-width: 224px;
}

.segment {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 32px;
  border-radius: 6px;
  cursor: pointer;
}

.segment.is-active {
  color: #061412;
  background: var(--gold);
  font-weight: 900;
}

.tab-pane {
  display: none;
}

.tab-pane.is-active {
  display: block;
}

.search-row {
  margin: 12px;
  min-height: 44px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d1316;
}

.search-row svg {
  width: 18px;
  color: var(--quiet);
}

.search-row input,
.bible-search input,
.bible-search select,
.editor-form input,
.editor-form select,
.editor-form textarea,
.theme-controls select,
.theme-controls input[type="range"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #0d1316;
  color: var(--ink);
  border-radius: var(--radius);
  outline: none;
}

.search-row input {
  border: 0;
  background: transparent;
  min-height: 42px;
}

.library-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 288px;
  overflow-y: auto;
  overflow-x: hidden;
}

.song-card {
  padding: 12px;
  display: grid;
  gap: 12px;
  min-height: 128px;
}

.song-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tag-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tag {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 0.68rem;
}

.editor-form {
  border-top: 1px solid var(--line);
  padding: 14px;
  display: grid;
  gap: 12px;
}

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

.editor-form label,
.bible-search label,
.theme-controls label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.editor-form input,
.editor-form select,
.bible-search input,
.bible-search select,
.theme-controls select {
  min-height: 40px;
  padding: 0 10px;
}

.editor-form textarea {
  padding: 10px;
  resize: vertical;
  min-height: 152px;
  line-height: 1.5;
}

.bible-search {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 130px auto;
  align-items: end;
  gap: 10px;
}

.bible-result {
  display: grid;
  gap: 10px;
}

.scripture-card {
  border: 1px solid var(--line);
  background: #10191d;
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.scripture-card p {
  margin: 0;
  color: #d9e1de;
  line-height: 1.55;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.media-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 118px;
  background: #10191d;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr auto;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.media-tile.is-active {
  border-color: var(--gold);
}

.media-thumb {
  min-height: 88px;
  background-size: cover;
  background-position: center;
}

.media-name {
  padding: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-well {
  margin: 0 12px 14px;
  min-height: 92px;
  border: 1px dashed #405055;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.upload-well svg {
  width: 24px;
  height: 24px;
}

.upload-well input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.live-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.stage-preview-shell {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.stage-canvas {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(4, 9, 11, 0.28), rgba(4, 9, 11, 0.34)),
    var(--stage-bg) center / cover no-repeat;
  color: #fff;
  isolation: isolate;
}

.preview-canvas {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.stage-content {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8%;
  text-align: center;
  z-index: 2;
}

.stage-content.align-left {
  place-items: center start;
  text-align: left;
}

.stage-content.align-right {
  place-items: center end;
  text-align: right;
}

.stage-title {
  max-width: 13ch;
  font-weight: 900;
  font-size: clamp(2rem, 6vw, 7rem);
  line-height: 0.96;
  text-transform: uppercase;
}

.stage-text {
  max-width: min(88vw, 34ch);
  font-size: var(--output-size, 56px);
  line-height: 1.12;
  font-weight: 800;
  text-shadow: 0 5px 24px rgba(0, 0, 0, 0.75);
  white-space: pre-line;
}

.preview-canvas .stage-text {
  max-width: min(94%, 32ch);
  font-size: clamp(0.82rem, 1.25vw, 1.15rem);
  line-height: 1.15;
}

.preview-canvas .stage-content {
  padding: 6% 7% 15%;
}

.preview-canvas .stage-ref {
  bottom: 5%;
  font-size: clamp(0.62rem, 0.9vw, 0.75rem);
}

.stage-ref {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 6%;
  z-index: 3;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(0.78rem, 1.6vw, 1.2rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stage-logo {
  width: min(18vw, 160px);
  height: min(18vw, 160px);
  display: grid;
  place-items: center;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.92);
  color: #09211f;
  font-size: min(8vw, 72px);
  font-weight: 950;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.34);
}

.stage-canvas.is-blank .stage-content,
.stage-canvas.is-blank .stage-ref {
  opacity: 0;
}

.stage-canvas.is-black {
  background: #000;
}

.stage-canvas.is-black .stage-content,
.stage-canvas.is-black .stage-ref {
  opacity: 0;
}

.transport {
  justify-content: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.go-live-button {
  min-height: 48px;
  min-width: 150px;
  padding: 0 18px;
  background: var(--coral);
  color: #230503;
  font-weight: 950;
}

.slide-strip {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  max-height: 250px;
}

.slide-card {
  min-height: 96px;
  padding: 10px;
  color: var(--muted);
  background: #10191d;
  cursor: pointer;
  text-align: left;
}

.slide-card.is-active {
  border-color: rgba(240, 183, 90, 0.72);
  color: var(--ink);
}

.slide-card span {
  display: block;
  color: var(--gold);
  font-weight: 900;
  font-size: 0.7rem;
  margin-bottom: 6px;
}

.slide-card p {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.34;
  font-size: 0.82rem;
}

.theme-controls {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1.2fr 0.8fr auto;
  gap: 10px;
  align-items: end;
}

.theme-controls input[type="color"] {
  width: 48px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  padding: 3px;
}

.stage-shell {
  width: 100vw;
  height: 100vh;
  background: #000;
  overflow: hidden;
}

.output-canvas {
  width: 100vw;
  height: 100vh;
}

.output-canvas .stage-content {
  padding: 7vw;
}

.output-canvas .stage-text {
  max-width: min(88vw, 34ch);
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  min-height: 120px;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .brand-lockup div:not(.brand-mark),
  .rail-link span,
  .host-note,
  .rail-footer .primary-action span {
    display: none;
  }

  .side-rail {
    align-items: center;
  }

  .rail-link,
  .rail-footer .primary-action {
    width: 48px;
    padding: 0;
    justify-content: center;
  }

  .workspace-grid {
    grid-template-columns: minmax(250px, 0.88fr) minmax(360px, 1.12fr);
  }

  .live-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .side-rail {
    position: static;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .rail-nav {
    display: flex;
  }

  .rail-footer {
    margin-left: auto;
    margin-top: 0;
  }

  .topbar,
  .workspace-grid,
  .bible-search,
  .theme-controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
  }

  .workspace-grid {
    padding: 10px;
  }

  .panel {
    min-height: auto;
  }

  .library-list,
  .media-grid,
  .slide-strip,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stage-text {
    font-size: clamp(2rem, 11vw, 4rem);
  }
}
