:root {
  --bg: #17171b;
  --panel: #1d1d22;
  --panel-deep: #24242a;
  --panel-soft: #303038;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-dark: rgba(0, 0, 0, 0.55);
  --ink: #e6dfd5;
  --muted: #b8b0a6;
  --gold: #c6974e;
  --gold-hover: #d6aa63;
  --danger: #b85c5c;
  --shadow-room: 0 16px 32px rgba(0, 0, 0, 0.26);
  --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 24px rgba(0, 0, 0, 0.18);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.6;
}

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

button,
select {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold-hover);
  outline-offset: 2px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #2b2b31;
  color: var(--ink);
  box-shadow: none;
  font-weight: bold;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

button:hover,
button:focus,
button.current,
.chapter-button.active,
.journal-tab.active,
.tab.active,
.bible-card-button.active {
  background: var(--gold);
  color: #111;
  border-color: rgba(0, 0, 0, 0.45);
  box-shadow: none;
}

button.quiet {
  width: auto;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--gold);
}

button.danger,
.danger {
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-deep);
  color: var(--ink);
  padding: 0.58rem 0.7rem;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
}

.login-shell {
  padding: 18px 24px 0;
}

.login-card {
  width: min(1200px, 100%);
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(29, 29, 34, 0.96);
  box-shadow: var(--shadow-room);
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(420px, 2fr);
  gap: 0.9rem;
  align-items: end;
}

.login-card h1 {
  margin: 0;
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: normal;
  line-height: 1.05;
}

.login-fields {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 0.6rem;
  align-items: end;
}

.login-field {
  display: grid;
  gap: 0.25rem;
}

.login-field .field-label {
  margin: 0;
}

.login-card .message {
  grid-column: 1 / -1;
  margin: 0.15rem 0 0;
}

.message {
  margin: 1rem 0 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-deep);
  color: var(--muted);
  padding: 0.75rem;
}

.message[data-type="error"] {
  border-color: var(--danger);
  color: #f0c2c2;
}

.message[data-type="info"] {
  border-color: var(--gold);
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px 18px;
  align-items: end;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 23, 27, 0.96);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 12px 28px rgba(0,0,0,0.22);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.site-header h1 {
  margin: 0;
  color: var(--gold);
  font-size: 2.4rem;
  font-weight: normal;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: bold;
}

.subhead {
  max-width: 48rem;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  font-style: italic;
  line-height: 1.6;
}

.header-actions,
.draft-actions,
.companion-actions,
.task-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.header-actions {
  justify-content: flex-end;
}

.session-label {
  color: var(--muted);
  font-size: 0.96rem;
  white-space: nowrap;
}

.autosave-status,
.autosave-note {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.autosave-status {
  border: 1px solid var(--border);
  background: var(--panel-deep);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
}

.autosave-status.dirty {
  color: var(--gold);
}

.journal-tabs {
  width: min(1720px, calc(100% - 48px));
  margin: 18px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  border-bottom: 0;
}

.journal-tab {
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  border-radius: 999px;
  padding: 0 18px;
}

.studio-shell {
  width: min(1720px, calc(100% - 48px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(250px, 18rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 18px 0 44px;
  align-items: start;
}

.studio-shell.toc-collapsed {
  grid-template-columns: minmax(0, 1fr) auto;
}

.toc-sidebar {
  position: sticky;
  top: 14px;
}

.toc-collapsed-rail {
  position: sticky;
  top: 14px;
}

.toc-collapsed-rail button {
  height: auto;
  min-height: 13rem;
  max-height: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 14px 8px;
}

.studio-pages {
  min-width: 0;
}

.studio-page {
  display: none;
}

.studio-page.active {
  display: block;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(29, 29, 34, 0.96);
  box-shadow: var(--shadow-soft);
  padding: 1.1rem;
}

.panel + .panel {
  margin-top: 1rem;
}

.panel-heading,
.bible-card-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.panel h2 {
  margin: 0;
  color: var(--gold);
  font-size: 1.35rem;
  font-weight: normal;
  line-height: 1.2;
}

.field-label {
  display: block;
  margin: 0.78rem 0 0.3rem;
  color: var(--gold);
  font-weight: bold;
}

.chapter-list,
.comment-list,
.task-list,
.bible-card-list {
  display: grid;
  gap: 0.6rem;
}

.chapter-button,
.comment-card,
.task-card,
.companion-output,
.bible-card {
  border: 1px solid var(--border);
  background: var(--panel-deep);
  border-radius: 18px;
  box-shadow: none;
  padding: 0.8rem;
}

.chapter-button {
  display: grid;
  width: 100%;
  height: auto;
  min-height: 54px;
  max-height: none;
  gap: 0.15rem;
  text-align: left;
  justify-content: stretch;
  box-shadow: none;
}

.draft-column,
.studio-pages {
  min-width: 0;
}

.draft-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.chapter-title-input {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--gold);
  padding: 0.1rem 0;
  font-size: 1.65rem;
  font-weight: normal;
}

.autosave-note {
  margin: 0.35rem 0 0;
}

.draft-editor {
  min-height: 62vh;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #24242a;
  box-shadow: none;
  font-size: 1.08rem;
  padding: 1rem 1.1rem;
}

.notes-panel {
  margin-top: 1rem;
}

.comment-card blockquote {
  margin: 0 0 0.65rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--gold);
  color: var(--muted);
  font-style: italic;
}

.comment-card textarea {
  min-height: 4.5rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin: 0.7rem 0;
}

.tab {
  padding: 0 8px;
}

.bible-card-list {
  align-self: start;
}

.bible-workspace {
  display: grid;
  grid-template-columns: minmax(13rem, 18rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.bible-card-button {
  display: grid;
  align-content: start;
  justify-content: stretch;
  gap: 0.2rem;
  height: auto;
  min-height: 4.35rem;
  max-height: none;
  text-align: left;
  border-radius: 18px;
}

.bible-card-button small {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  font-weight: normal;
  line-height: 1.25;
}

.bible-card-button.active small {
  color: #332615;
}

.card-title-input {
  color: var(--gold);
  font-size: 1.12rem;
  font-weight: bold;
}

.bible-card textarea {
  min-height: 4.6rem;
}

.companion-actions {
  margin: 0.7rem 0;
}

.companion-output {
  min-height: 8rem;
  color: var(--muted);
}

.companion-output h3 {
  margin: 0 0 0.5rem;
  color: var(--gold);
  font-weight: normal;
}

.companion-output ul {
  margin: 0;
  padding-left: 1.1rem;
}

.task-entry {
  align-items: stretch;
}

.task-entry button {
  flex: 0 0 auto;
}

.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: start;
}

.task-card.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.empty-state,
.meta-row {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.meta-row {
  font-size: 0.82rem;
}

@media (max-width: 980px) {
  .studio-shell {
    grid-template-columns: 1fr;
  }

  .studio-shell.toc-collapsed {
    grid-template-columns: 1fr;
  }

  .toc-sidebar,
  .toc-collapsed-rail {
    position: static;
  }

  .toc-collapsed-rail button {
    width: 100%;
    min-height: 38px;
    writing-mode: horizontal-tb;
  }

  .bible-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .site-header,
  .draft-toolbar {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions,
  .draft-actions,
  .companion-actions,
  .task-entry {
    flex-direction: column;
    align-items: stretch;
  }

  .studio-shell {
    width: min(100% - 24px, 100%);
    padding: 24px 0 36px;
  }

  .journal-tabs {
    width: min(100% - 24px, 100%);
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.2rem;
  }

  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .login-card,
  .login-fields {
    grid-template-columns: 1fr;
  }
}
