:root {
  --blue: #4b2d0f;
  --teal: #6d4a1f;
  --panel: #c9b180;
  --paper: #ead9ac;
  --ink: #1f1308;
  --muted: #60451f;
  --edge-dark: #3a220c;
  --edge-light: #fff1c7;
  --gold: #c8942e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--teal);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
select,
input,
textarea {
  color: var(--ink);
  font: inherit;
}

button,
select,
input,
textarea,
.raised {
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  background: var(--paper);
}

button {
  min-height: 36px;
  padding: 4px 14px;
  cursor: pointer;
}

button:disabled {
  color: #888;
  cursor: default;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.titlebar {
  align-items: center;
  background: var(--blue);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  color: white;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
}

.titlebar > div:first-child {
  align-items: center;
  display: flex;
  gap: 14px;
}

.app-mark {
  background: var(--gold);
  border: 2px solid var(--gold);
  display: block;
  height: 52px;
  object-fit: cover;
  width: 52px;
}

.app-mark-link {
  display: block;
  line-height: 0;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

.titlebar p {
  font-family: "Courier New", monospace;
  font-size: 14px;
  margin: 3px 0 0;
}

.source-stats {
  font-family: "Courier New", monospace;
  font-size: 18px;
  white-space: nowrap;
}

.header-tools {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.account-status {
  align-items: center;
  display: flex;
  gap: 8px;
}

.account-status a,
.account-status button,
.button-link {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  color: var(--ink);
  font-weight: 700;
  padding: 7px 12px;
  text-decoration: none;
}

.account-status span {
  color: white;
  font-family: "Courier New", monospace;
}

.account-status button {
  min-height: 32px;
}

.title-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.title-actions a {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  color: var(--ink);
  font-weight: 700;
  padding: 7px 12px;
  text-decoration: none;
}

.settings-menu {
  position: relative;
}

.settings-menu summary {
  align-items: center;
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 18px;
  height: 36px;
  justify-content: center;
  list-style: none;
  width: 38px;
}

.settings-menu summary::-webkit-details-marker {
  display: none;
}

.settings-panel {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  color: var(--ink);
  display: grid;
  gap: 6px;
  min-width: 170px;
  padding: 10px;
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 30;
}

.settings-panel strong {
  color: var(--blue);
}

.settings-panel button {
  min-height: 30px;
  padding: 3px 8px;
  text-align: left;
}

.workspace {
  background: var(--panel);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  margin-top: 12px;
  min-height: calc(100vh - 122px);
  padding: 16px;
}

.app-footer {
  align-items: center;
  color: white;
  display: flex;
  flex-wrap: wrap;
  font-family: "Courier New", monospace;
  font-size: 13px;
  gap: 8px 14px;
  justify-content: space-between;
  padding: 10px 2px 0;
}

.app-footer a {
  color: white;
}

.footer-brand {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  text-decoration: none;
}

.footer-brand img {
  border: 1px solid var(--edge-light);
  height: 18px;
  image-rendering: pixelated;
  width: 18px;
}

.footer-brand span {
  font-weight: 700;
  margin: 0;
}

.footer-meta {
  color: #f2dfaa;
  flex: 1 1 260px;
  font-size: 12px;
  text-align: center;
}

.footer-nav {
  align-items: center;
  display: inline-flex;
  justify-content: flex-end;
}

.footer-nav span {
  margin: 0 4px;
}

.mission-strip {
  align-items: center;
  background: white;
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.mission-strip strong {
  color: var(--blue);
  white-space: nowrap;
}

.document-page {
  display: grid;
  gap: 14px;
}

.document-hero,
.timeline-year {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  padding: 16px;
}

.document-hero h2,
.timeline-year h2 {
  color: var(--blue);
  margin: 0 0 8px;
}

.document-hero p,
.timeline-year p {
  line-height: 1.45;
}

.quarter-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.quarter-grid.compact {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  margin-top: 12px;
}

.roadmap-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.timeline-list {
  display: grid;
  gap: 0;
  margin-top: 12px;
}

.timeline-node {
  display: grid;
  gap: 14px;
  grid-template-columns: 140px minmax(0, 1fr);
  padding: 0 0 18px;
  position: relative;
}

.timeline-node::before {
  background: var(--blue);
  border: 2px solid var(--edge-dark);
  content: "";
  height: 12px;
  left: 128px;
  position: absolute;
  top: 5px;
  width: 12px;
}

.timeline-node::after {
  background: var(--edge-dark);
  content: "";
  left: 134px;
  position: absolute;
  top: 21px;
  bottom: 0;
  width: 2px;
}

.timeline-node:last-child::after {
  display: none;
}

.timeline-node time {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 15px;
  line-height: 1.4;
  padding-right: 20px;
}

.timeline-node h3 {
  color: var(--blue);
  margin: 0 0 4px;
}

.timeline-node p {
  margin: 0;
}

.panel ul {
  margin: 0;
  padding-left: 18px;
}

.panel li {
  line-height: 1.4;
  margin-bottom: 6px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  background: white;
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

th,
td {
  border: 1px solid var(--edge-dark);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--blue);
  color: white;
}

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

.metric-grid div {
  background: white;
  border: 1px solid var(--edge-dark);
  display: grid;
  gap: 4px;
  padding: 12px;
}

.metric-grid strong {
  color: var(--blue);
  font-size: 28px;
}

.metric-grid span {
  color: var(--muted);
  font-family: "Courier New", monospace;
}

.conclusion {
  background: white;
}

.about-page blockquote {
  background: white;
  border-left: 4px solid var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.4;
  margin: 0 0 12px;
  padding: 12px 14px;
}

.about-page .lead {
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  margin: 4px 0 10px;
}

.about-values strong {
  font-size: 20px;
}

.compact-values {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.plain-list {
  margin: 0;
  padding-left: 20px;
}

.plain-list li {
  line-height: 1.45;
  margin-bottom: 6px;
}

.account-page {
  display: grid;
  justify-items: center;
}

.account-card {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  max-width: 520px;
  padding: 18px;
  width: 100%;
}

.account-card h2 {
  color: var(--blue);
  margin-bottom: 12px;
}

.account-form {
  display: grid;
  gap: 12px;
}

.account-form label span {
  color: var(--blue);
  font-size: 14px;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check-row input {
  min-height: 0;
  width: auto;
}

.account-message,
.muted-copy {
  color: var(--muted);
  font-family: "Courier New", monospace;
}

.topics-page {
  display: grid;
  gap: 14px;
}

.topics-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(190px, 260px) 1fr;
}

.topic-index,
.topic-detail {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  padding: 14px;
}

.topic-index h2,
.topic-heading h2 {
  color: var(--blue);
  margin: 0;
}

.topic-list,
.topic-verses {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.topic-button,
.topic-verse {
  background: white;
  border: 1px solid var(--edge-dark);
  color: var(--ink);
  display: block;
  min-height: 0;
  padding: 9px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.topic-button.is-active,
.topic-button:hover,
.topic-verse:hover {
  background: #f8f1df;
}

.topic-button strong,
.topic-button span,
.topic-verse strong,
.topic-verse span {
  display: block;
}

.topic-button span,
.topic-heading span {
  color: var(--muted);
  font-family: "Courier New", monospace;
  margin-top: 4px;
}

.topic-heading {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.primary-search {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  margin-bottom: 10px;
  position: relative;
}

.primary-search[hidden] {
  display: none;
}

.primary-search-results {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  grid-column: 1 / -1;
  max-height: 310px;
  overflow: auto;
  padding: 8px;
}

.primary-search-results[hidden] {
  display: none;
}

.primary-results-title {
  color: var(--muted);
  font-family: "Courier New", monospace;
  margin-bottom: 6px;
}

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

.primary-result {
  background: white;
  border: 1px solid var(--edge-dark);
  display: block;
  font: inherit;
  min-height: 0;
  padding: 7px;
  text-align: left;
  width: 100%;
}

.primary-result strong,
.primary-result span {
  display: block;
}

.primary-result:hover {
  background: #f8f1df;
}

.control-panel {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(160px, 1fr) 110px auto;
  margin-bottom: 12px;
}

label {
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 4px;
}

.compact-field span,
.search-field span {
  height: 0;
  overflow: hidden;
  position: absolute;
  width: 0;
}

.icon-button {
  font-size: 22px;
  line-height: 1;
  min-height: 36px;
  min-width: 38px;
  padding: 2px 10px;
}

select,
input,
textarea {
  background: white;
  min-height: 36px;
  padding: 4px 8px;
  width: 100%;
}

.chapter-title {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 15px;
  margin: 8px 0 12px;
}

.status-line {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 16px;
  margin: 8px 0 12px;
}

.verse-list {
  display: grid;
  gap: 10px;
}

.verse-list.is-searching {
  max-height: min(62vh, 720px);
  overflow: auto;
  padding-right: 6px;
}

.verse-card {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  cursor: pointer;
  padding: 12px;
  transition: background 130ms linear;
}

.verse-card.is-expanded {
  background: #ececec;
  cursor: default;
}

.verse-header {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.verse-reference {
  color: var(--blue);
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 4px;
}

.verse-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.35;
}

.verse-badges {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  min-width: 80px;
}

.badge {
  background: white;
  border: 1px solid var(--edge-dark);
  color: var(--muted);
  display: inline-block;
  font-family: "Courier New", monospace;
  padding: 3px 7px;
}

.icon-badge {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 28px;
  min-width: 34px;
  padding: 2px 6px;
  white-space: nowrap;
}

.connection-badge {
  color: var(--blue);
  font-weight: 800;
  min-width: 42px;
  text-align: center;
  white-space: nowrap;
}

.precept-link {
  color: var(--blue);
  font-family: "Courier New", monospace;
  font-weight: 700;
}

.muted-link {
  color: var(--muted);
  font-weight: 400;
}

.study-panel {
  border-top: 1px solid var(--edge-dark);
  display: grid;
  gap: 12px;
  margin-top: 12px;
  max-height: 560px;
  overflow: auto;
  padding-top: 12px;
}

.precept-searchbar {
  background: white;
  border: 1px solid var(--edge-dark);
  padding: 10px;
}

.precept-searchbar label {
  display: grid;
  gap: 6px;
}

.precept-searchbar span {
  color: var(--blue);
  font-size: 16px;
  font-weight: 800;
}

.live-results {
  margin-top: 8px;
  max-height: 240px;
}

.study-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.study-section {
  background: white;
  border: 1px solid var(--edge-dark);
  padding: 10px;
}

.study-section h3 {
  color: var(--blue);
  font-size: 16px;
  margin: 0 0 8px;
}

.section-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--blue);
  display: flex;
  font-weight: 800;
  justify-content: space-between;
  min-height: 0;
  padding: 0;
  width: 100%;
}

.section-toggle strong {
  background: var(--paper);
  border: 1px solid var(--edge-dark);
  color: var(--blue);
  display: inline-grid;
  font-family: "Courier New", monospace;
  font-size: 18px;
  height: 24px;
  line-height: 1;
  place-items: center;
  width: 24px;
}

.suggestions-section {
  grid-column: 1 / -1;
}

.study-section p {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  line-height: 1.35;
  margin: 0;
}

.panel {
  background: var(--paper);
  border: 2px solid;
  border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);
  padding: 12px;
}

.panel h3 {
  color: var(--blue);
  margin: 0 0 10px;
}

.related-list {
  display: grid;
  gap: 8px;
}

.potential-list {
  margin-top: 10px;
}

.show-more {
  margin-top: 8px;
  min-height: 30px;
  padding: 3px 9px;
}

.related-item {
  background: white;
  border: 1px solid var(--edge-dark);
  color: var(--ink);
  cursor: pointer;
  display: block;
  font: inherit;
  min-height: 0;
  padding: 8px;
  text-align: left;
  width: 100%;
}

.precept-item {
  padding-right: 24px;
  position: relative;
}

.precept-item:hover {
  background: #f8f1df;
}

.remove-precept {
  border-width: 1px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  min-height: 16px;
  padding: 0;
  position: absolute;
  right: 5px;
  top: 5px;
  width: 16px;
}

.related-item strong {
  color: var(--blue);
  display: block;
}

.open-hint {
  color: var(--muted);
  display: block;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-style: normal;
  margin-top: 6px;
}

.source-badge {
  background: var(--paper);
  border: 1px solid var(--edge-dark);
  color: var(--muted);
  display: inline-block;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: 400;
  margin-left: 5px;
  padding: 1px 4px;
  vertical-align: middle;
}

.candidate-item em {
  background: var(--paper);
  border: 1px solid var(--edge-dark);
  color: var(--muted);
  display: inline-block;
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-style: normal;
  margin: 6px 5px 0 0;
  padding: 2px 5px;
}

.match-badges {
  display: block;
}

.suggestions-section {
  background: #f8f1df;
}

.suggestions-section:not(.is-open) {
  background: white;
}

.suggestions-section .related-item {
  background: #fffdf5;
}

.suggestions-section .related-item span:not(.match-badges) {
  font-size: 0.95em;
}

.search-results {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
}

.search-result {
  background: white;
  border: 1px solid var(--edge-dark);
  cursor: pointer;
  display: block;
  font: inherit;
  min-height: 0;
  padding: 7px;
  text-align: left;
  width: 100%;
}

.search-result strong,
.search-result span,
.search-result em {
  display: block;
}

.search-result em {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-style: normal;
  margin-top: 5px;
}

.search-result:hover,
.related-item:hover {
  background: #eef2ff;
}

.note-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 8px;
  }

  .titlebar,
  .titlebar > div:first-child,
  .mission-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-stats {
    white-space: normal;
  }

  .title-actions {
    align-items: start;
    justify-items: start;
  }

  .control-panel,
  .quarter-grid,
  .quarter-grid.compact,
  .roadmap-grid,
  .metric-grid,
  .topics-layout,
  .study-grid {
    grid-template-columns: 1fr;
  }

  .timeline-node {
    grid-template-columns: 1fr;
    padding-left: 24px;
  }

  .timeline-node::before {
    left: 0;
  }

  .timeline-node::after {
    left: 6px;
  }

  .verse-header {
    display: grid;
  }

  .verse-badges {
    justify-content: flex-start;
  }

  .chapter-title {
    text-align: left;
  }

  .app-footer,
  .footer-nav {
    justify-content: flex-start;
  }

  .footer-meta {
    flex-basis: 100%;
    order: 3;
    text-align: left;
  }
}
