:root {
  --vellum: #f6f0e4;
  --paper: #fffaf0;
  --paper-soft: #fbf4e8;
  --ink: #1c2421;
  --muted: #6e675c;
  --rule: #d8c7aa;
  --blue: #17385f;
  --red: #8f2f2f;
  --green: #315b4b;
  --shadow: 0 22px 60px rgba(37, 30, 20, .16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(143, 47, 47, .06) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(23, 56, 95, .04) 1px, transparent 1px) 0 0 / 42px 42px,
    radial-gradient(circle at 18% 10%, rgba(184, 135, 58, .12), transparent 28%),
    var(--vellum);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
textarea {
  font: inherit;
}

.page {
  width: min(1380px, calc(100vw - 48px));
  margin: 24px auto;
  min-height: calc(100vh - 48px);
  background: rgba(255, 250, 240, .88);
  border: 1px solid rgba(122, 91, 50, .24);
  box-shadow: var(--shadow);
}

.app-header {
  min-height: 86px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 22px 28px;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 252, 244, .78);
}

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

.brand-mark {
  width: 46px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--red);
  color: var(--red);
  background: linear-gradient(180deg, #fff8e8, #f0dfbd);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
}

.brand-copy strong {
  display: block;
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3vw, 48px);
  font-weight: 500;
  line-height: 1.02;
}

.brand-copy small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  min-height: 40px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  background: transparent;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .18s ease, background-color .18s ease, color .18s ease;
}

.button.primary {
  color: #fffdf7;
  background: var(--blue);
}

.button:hover,
.scope-list button:hover,
.word-row button:hover {
  transform: translateY(-1px);
}

.button:active,
.scope-list button:active,
.word-row button:active {
  transform: translateY(0);
}

.app-grid {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 342px;
  min-height: calc(100vh - 134px);
}

.left-rail {
  padding: 22px 18px;
  border-right: 1px solid var(--rule);
  background: rgba(238, 227, 207, .45);
}

.right-rail {
  padding: 22px 18px;
  border-left: 1px solid var(--rule);
  background: rgba(255, 252, 244, .62);
}

.center-workspace {
  min-width: 0;
  padding: 26px;
}

.kicker {
  display: block;
  color: var(--red);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

h2 {
  margin: 0;
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 500;
  line-height: 1.08;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.source-card,
.scope-card,
.passage-card,
.coverage-card,
.parse-card,
.tutor-card,
.notice-card,
.upload-card,
.review-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 250, 240, .92);
}

.source-card,
.scope-card {
  padding: 14px;
}

.scope-card {
  margin-top: 18px;
}

.source-card h2 {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 800;
}

.source-card p,
.source-notice {
  margin: 6px 0 0;
  font-size: 12px;
}

.source-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(216, 199, 170, .8);
  font-size: 13px;
}

.source-row:first-of-type {
  margin-top: 10px;
}

.source-row b,
.mode-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(49, 91, 75, .35);
  color: var(--green);
  background: rgba(49, 91, 75, .07);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper-soft);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.segmented button.is-active {
  color: #fffdf7;
  background: var(--red);
}

.source-notice {
  border: 1px solid rgba(143, 47, 47, .32);
  background: rgba(143, 47, 47, .06);
  border-radius: 8px;
  padding: 10px;
  color: #612323;
}

.upload-panel {
  margin-top: 10px;
}

.upload-panel label {
  display: block;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 7px;
}

.upload-panel textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  padding: 10px;
  font-family: "SBL Hebrew", "Ezra SIL", "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.55;
}

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

.scope-list button {
  width: 100%;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(255, 250, 240, .72);
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background-color .18s ease;
}

.scope-list button.active {
  border-color: var(--red);
  color: var(--red);
  background: #fff8e8;
  font-weight: 800;
}

.scope-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.study-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}

.passage-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
}

.passage-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--red);
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.card-header p {
  margin: 6px 0 0;
  font-size: 13px;
}

.hebrew-line {
  direction: rtl;
  text-align: right;
  margin: 18px 0 0;
  padding: 18px 0 10px;
  border-top: 1px solid rgba(216, 199, 170, .85);
  border-bottom: 1px solid rgba(216, 199, 170, .85);
  color: #111816;
  font-family: "SBL Hebrew", "Ezra SIL", "Times New Roman", serif;
  font-size: clamp(32px, 4.1vw, 50px);
  line-height: 1.55;
}

.word-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.word-row button {
  min-height: 44px;
  border: 1px solid rgba(23, 56, 95, .24);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--blue);
  padding: 8px 10px;
  direction: rtl;
  cursor: pointer;
  font-family: "SBL Hebrew", "Ezra SIL", "Times New Roman", serif;
  font-size: 20px;
  transition: transform .18s ease, border-color .18s ease, color .18s ease;
}

.word-row button.is-selected {
  border-color: var(--red);
  color: var(--red);
  box-shadow: inset 0 -3px 0 rgba(143, 47, 47, .16);
}

.coverage-card {
  padding: 18px;
}

.meter {
  height: 8px;
  background: #eadfc9;
  border-radius: 999px;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 58%;
  height: 100%;
  background: var(--green);
}

.metric {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding-top: 11px;
  margin-top: 10px;
  border-top: 1px solid rgba(216, 199, 170, .8);
  color: var(--muted);
  font-size: 13px;
}

.metric b {
  color: var(--ink);
}

.study-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  margin-top: 18px;
}

.parse-card,
.tutor-card,
.notice-card,
.upload-card,
.review-card {
  padding: 18px;
}

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

.parse-grid article {
  min-height: 74px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 255, 255, .42);
  padding: 12px;
}

.parse-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

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

.reader-notes {
  margin-top: 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 255, 255, .35);
  padding: 16px;
}

.reader-notes p,
.tutor-card p,
.notice-card p,
.upload-card p {
  margin: 0;
  font-size: 14px;
}

.tutor-card h2,
.upload-card h2 {
  font-size: 22px;
}

.tutor-message {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid rgba(216, 199, 170, .82);
  border-radius: 8px;
  background: #fffdf7;
  font-size: 13px;
  line-height: 1.55;
}

.notice-card {
  border-color: rgba(143, 47, 47, .32);
  background: rgba(143, 47, 47, .06);
}

.notice-card p {
  color: #612323;
}

.upload-card {
  margin-top: 16px;
  border-style: dashed;
  border-color: rgba(23, 56, 95, .45);
  text-align: center;
  background: rgba(23, 56, 95, .04);
}

.review-card {
  margin-top: 16px;
}

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

.review-list article {
  display: grid;
  gap: 6px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  padding: 12px;
}

.review-list b {
  font-size: 13px;
}

.review-list span {
  color: var(--muted);
  font-size: 12px;
}

footer {
  width: min(1380px, calc(100vw - 48px));
  margin: 0 auto 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

  .right-rail {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }

  .study-top,
  .study-bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page,
  footer {
    width: 100%;
    margin: 0;
    border-left: 0;
    border-right: 0;
  }

  .app-header {
    grid-template-columns: 1fr;
  }

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

  .app-grid {
    grid-template-columns: 1fr;
  }

  .left-rail,
  .right-rail {
    border: 0;
    border-top: 1px solid var(--rule);
  }

  .center-workspace {
    padding: 18px;
  }

  .parse-grid {
    grid-template-columns: 1fr;
  }

  .brand-copy strong {
    font-size: clamp(28px, 9vw, 38px);
  }
}
