:root {
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #171a21;
  --panel-2: #1f232d;
  --panel-3: #252a35;
  --line: #323846;
  --muted: #9aa4b2;
  --text: #e6edf3;
  --accent: #3794ff;
  --accent-2: #4ec9b0;
  --warning: #cca700;
  --danger: #f85149;
  --ready: #238636;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 1px solid #2f6ea3;
  background: #0e639c;
  color: #fff;
  min-height: 32px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  background: #1177bb;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  border-color: var(--line);
  background: var(--panel-3);
}

.secondary-link {
  align-items: center;
  background: var(--panel-3);
  border: 1px solid var(--line);
  color: #fff;
  display: inline-flex;
  min-height: 32px;
  padding: 0 12px;
  text-decoration: none;
}

button.danger {
  border-color: #7d2b2b;
  background: #5f1f1f;
}

.workbench {
  display: grid;
  grid-template-columns: 48px 1fr;
  min-height: 100vh;
}

.activity-bar {
  background: #0c0e13;
  border-right: 1px solid #242936;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 8px;
}

.activity-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.activity-button.is-active {
  color: #fff;
  border-left: 2px solid var(--accent);
  background: #151922;
}

.shell {
  display: grid;
  grid-template-rows: 34px 1fr 24px;
  min-height: 100vh;
}

.titlebar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #10131a;
  border-bottom: 1px solid #242936;
  color: var(--muted);
  font-size: 12px;
  padding: 0 12px;
}

.statusbar {
  background: #0e639c;
  border: 0;
  color: #fff;
}

.statusbar-group {
  display: flex;
  gap: 16px;
}

.main-grid {
  display: grid;
  grid-template-columns: 240px minmax(620px, 1fr) 390px;
  min-height: 0;
}

body.is-sermon-editor .main-grid {
  grid-template-columns: 1fr;
}

body.is-sermon-editor .activity-bar,
body.is-sermon-editor .sidebar,
body.is-sermon-editor .statusbar {
  display: none;
}

body.is-sermon-editor .workbench {
  grid-template-columns: 1fr;
}

body.is-sermon-editor .shell {
  grid-template-rows: 34px 1fr;
}

body.is-sermon-editor .detail-drawer {
  display: none;
}

.sidebar,
.detail-drawer {
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
  overflow: auto;
}

.detail-drawer {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.sidebar-section {
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.sidebar-title,
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-item {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item.is-active {
  background: #263247;
}

.editor {
  display: grid;
  grid-template-rows: 36px 1fr 160px;
  min-height: 0;
  background: #11141b;
}

.editor[hidden],
.sermon-editor-page[hidden] {
  display: none;
}

.sermon-editor-page {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  background: #11141b;
}

.sermon-editor-header {
  align-items: center;
  background: #151922;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto minmax(220px, 0.45fr) minmax(520px, 1fr) auto;
  gap: 14px;
  padding: 8px 14px;
}

.sermon-editor-header h1 {
  font-size: 18px;
}

.sermon-header-fields {
  align-items: end;
  display: grid;
  grid-template-columns: 140px 130px minmax(180px, 1fr) minmax(180px, 1fr) minmax(220px, 1.2fr);
  gap: 8px;
}

.sermon-header-fields .field {
  margin-bottom: 0;
}

.sermon-header-fields input,
.sermon-header-fields select {
  height: 32px;
}

.sermon-editor-layout {
  display: grid;
  grid-template-rows: 1fr;
  min-height: 0;
  overflow: hidden;
}

.sermon-editor-meta {
  display: none;
}

.sermon-editor-split {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

.sermon-editor-split.has-preview {
  grid-template-columns: minmax(520px, 1fr) minmax(480px, 0.86fr);
}

.sermon-editor-pane,
.sermon-preview-pane {
  display: grid;
  grid-template-rows: 42px 1fr;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.sermon-preview-pane {
  border-right: 0;
}

.pane-toolbar {
  align-items: center;
  background: #151922;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
}

#editor-sermon-body {
  border: 0;
  height: 100%;
  min-height: 0;
  resize: none;
  font-family: Consolas, "Courier New", monospace;
  font-size: 16px;
  line-height: 1.6;
  padding: 22px;
}

.editor-tabs,
.bottom-tabs {
  display: flex;
  align-items: end;
  background: #151922;
  border-bottom: 1px solid var(--line);
}

.editor-tab,
.bottom-tab {
  min-height: 35px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #171b24;
  color: var(--muted);
}

.editor-tab.is-active,
.bottom-tab.is-active {
  background: #1e222d;
  color: #fff;
  border-top: 1px solid var(--accent);
}

.surface {
  min-height: 0;
  overflow: auto;
  background: #1b1f29;
}

.view-panel {
  padding: 16px;
}

.surface-toolbar,
.drawer-header,
.drawer-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 600;
}

h2 {
  font-size: 18px;
  font-weight: 600;
}

h3 {
  font-size: 14px;
}

.toolbar-actions,
.button-row,
.drawer-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 32px;
  padding: 0;
  font-size: 22px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
}

.calendar-weekdays span {
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #151922;
  color: var(--muted);
  padding: 8px;
  font-size: 12px;
}

.calendar-grid {
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.day-cell {
  min-height: 128px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #1d222d;
  padding: 8px;
  text-align: left;
  color: var(--text);
}

.day-cell:hover,
.day-cell.is-selected {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  background: #22304a;
}

.day-cell.is-muted {
  color: #6f7a89;
  background: #171b23;
}

.day-number {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.lesson-preview {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.lesson-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  border: 1px solid #3c4658;
  background: #252b38;
  color: #c8d1dc;
  padding: 2px 6px;
  font-size: 11px;
}

.thumb {
  width: 100%;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.status-pill {
  color: #fff;
  font-size: 10px;
  padding: 2px 5px;
  text-transform: uppercase;
}

.status-planned {
  background: #49515f;
}

.status-idea {
  background: #6b4d9f;
}

.status-drafting {
  background: #8a6a00;
}

.status-ready {
  background: #1f6f43;
}

.status-preached {
  background: #365f9f;
}

.open-sermon-link {
  border: 1px solid #3c4658;
  background: #151b26;
  color: #8cc8ff;
  justify-self: start;
  min-height: 24px;
  padding: 0 7px;
  font-size: 11px;
}

.series-list {
  display: grid;
  gap: 6px;
}

.series-item {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  min-height: 30px;
  text-align: left;
  width: 100%;
}

.series-item.is-active {
  background: #263247;
  color: #fff;
}

.week-list,
.archive-list,
.file-list {
  display: grid;
  gap: 8px;
}

.week-row,
.archive-item,
.file-item {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: #1f2530;
  padding: 10px;
}

.file-item {
  grid-template-columns: 92px 1fr auto;
}

.row-title {
  font-weight: 600;
}

.row-meta {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.field span,
.search-field span {
  color: var(--muted);
  font-size: 12px;
}

.field.compact input,
.field.compact select {
  height: 30px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #3b4252;
  background: #10141d;
  color: var(--text);
  padding: 7px 9px;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

.search-field {
  display: grid;
  gap: 5px;
  width: 330px;
}

.field-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
}

.drawer-form,
.upload-panel {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.graphic-preview {
  min-height: 74px;
  border: 1px dashed #3b4252;
  background: #10141d;
  margin-bottom: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.graphic-preview img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
}

.lesson-files {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 12px;
}

.format-reference {
  border: 1px solid var(--line);
  background: #11141b;
  margin-bottom: 12px;
}

.format-reference .drawer-subhead {
  margin: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

#format-reference-body {
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  color: #d7dde7;
}

#format-reference-body h3,
#format-reference-body h4 {
  margin: 10px 0 8px;
}

#format-reference-body h3:first-child {
  margin-top: 0;
}

#format-reference-body p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 8px;
}

#format-reference-body table {
  border-collapse: collapse;
  margin: 8px 0 14px;
  width: 100%;
}

#format-reference-body th,
#format-reference-body td {
  border: 1px solid var(--line);
  padding: 7px;
  text-align: left;
  vertical-align: top;
}

#format-reference-body th {
  background: #202632;
  color: #fff;
}

#format-reference-body code {
  background: #0d1118;
  border: 1px solid #303746;
  color: #f2d17b;
  padding: 1px 4px;
}

.format-bullet::before {
  content: "- ";
}

.sermon-preview-shell {
  border: 1px solid var(--line);
  background: #11141b;
  margin-bottom: 12px;
}

.sermon-preview-shell .drawer-subhead {
  margin: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.sermon-preview {
  background: #f8f7f2;
  color: #222;
  margin: 12px;
  padding: 22px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid #d2cfc6;
  font-family: Georgia, "Times New Roman", serif;
}

.editor-preview {
  height: calc(100% - 24px);
  max-height: none;
}

.sermon-preview h1 {
  color: #1c1c1c;
  font-size: 30px;
  text-align: left;
  border-bottom: 1px solid #c8c5bc;
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.sermon-preview h2 {
  color: #262626;
  font-size: 21px;
  margin: 18px 0 6px;
}

.sermon-preview h3 {
  color: #383838;
  font-size: 17px;
  margin: 14px 0 6px;
}

.sermon-preview p,
.sermon-preview blockquote,
.sermon-callout p,
.sermon-bullet p {
  line-height: 1.5;
}

.sermon-preview p {
  margin: 0 0 10px;
  font-size: 16px;
}

.sermon-reference {
  color: #595959;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 8px;
}

.sermon-preview blockquote {
  background: #eeeee8;
  border: 1px solid #dad8cf;
  margin: 0 0 10px;
  padding: 10px 14px;
  font-size: 16px;
}

.sermon-callout {
  background: #faf3dd;
  border: 1px solid #e2c67b;
  margin: 0 0 10px;
  padding: 10px 14px;
}

.sermon-callout span {
  color: #6f5218;
  display: block;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
}

.sermon-callout p {
  color: #322814;
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.sermon-bullet {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

.sermon-bullet span {
  color: #373737;
  font-size: 18px;
}

.sermon-bullet p {
  margin: 0;
}

.sermon-preview hr {
  border: 0;
  border-top: 1px solid #c8c5bc;
  margin: 16px 0;
}

.lesson-file {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  background: #1d222d;
  padding: 8px;
}

.lesson-file a,
.file-item a {
  color: #8cc8ff;
  text-decoration: none;
}

.bottom-panel {
  border-top: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
}

.message-log {
  padding: 10px;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  max-height: 124px;
  overflow: auto;
}

.status-counts {
  display: grid;
  gap: 6px;
}

.count-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.modal-overlay {
  align-items: center;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 20;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  padding: 16px;
  width: min(520px, calc(100vw - 40px));
}

.modal-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-copy {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 14px;
}

.upload-modal-panel input[type="file"] {
  margin-bottom: 12px;
}

.syntax-help-panel {
  width: min(860px, calc(100vw - 60px));
}

.syntax-help-body {
  max-height: 70vh;
  overflow: auto;
}

.syntax-help-body h3,
.syntax-help-body h4 {
  margin: 12px 0 8px;
}

.syntax-help-body h3:first-child {
  margin-top: 0;
}

.syntax-help-body p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 8px;
}

.syntax-help-body table {
  border-collapse: collapse;
  margin: 8px 0 14px;
  width: 100%;
}

.syntax-help-body th,
.syntax-help-body td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.syntax-help-body th {
  background: #202632;
  color: #fff;
}

.syntax-help-body code {
  background: #0d1118;
  border: 1px solid #303746;
  color: #f2d17b;
  padding: 1px 4px;
}
