:root {
  color-scheme: light;
  --ink: #202a25;
  --muted: #4b5e54;
  --page: #f3f4ee;
  --surface: #fffefa;
  --inset: #edf2eb;
  --accent: #20594d;
  --accent-dark: #183c38;
  --accent-soft: #dcebe1;
  --line: #d7dfd4;
  --control: #8e9f94;
  --gold: #d7b889;
  --row-size: 45px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font: 1rem/1.5 system-ui, -apple-system, sans-serif;
}
main { width: min(1120px, calc(100% - clamp(28px, 8vw, 110px))); margin: clamp(20px, 4vw, 52px) auto 64px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: Georgia, serif; }
h1 { font: 400 clamp(3.25rem, 7.5vw, 6rem)/.98 Georgia, serif; letter-spacing: -.045em; }
h2 { font-size: clamp(1.48rem, 3.3vw, 1.95rem); line-height: 1.2; letter-spacing: -.024em; font-weight: 500; }
h3 { font-size: 1.22rem; line-height: 1.25; font-weight: 600; }
[lang="he"], .hebrew { font-family: "Noto Serif Hebrew", "Times New Roman", "Arial Hebrew", serif; }

.masthead {
  --banner-width: min(1160px, calc(100vw - clamp(40px, 5vw, 96px)));
  width: var(--banner-width);
  margin-inline: calc((100% - var(--banner-width)) / 2);
  isolation: isolate;
  overflow: hidden;
  position: relative;
  min-height: clamp(210px, 19vw, 280px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr);
  border: 1px solid #244e45;
  border-radius: 14px;
  background: var(--accent-dark);
  color: #fff7e6;
  box-shadow: 0 10px 28px #172f2926;
}
.masthead::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid #d7b88975;
  border-radius: 7px;
  pointer-events: none;
}
.masthead-copy { z-index: 1; align-self: center; padding: clamp(28px, 3.8vw, 54px); padding-inline-end: clamp(20px, 3.4vw, 42px); }
.masthead-description { max-width: 35ch; margin-top: 20px; color: #e4e6d8; }
.masthead-description::before { content: ""; display: block; width: 44px; height: 1px; background: var(--gold); margin: 0 0 16px; }
.masthead-photo { position: relative; min-width: 0; min-height: 0; }
.masthead-photo img { position: absolute; width: 100%; height: 100%; inset: 0; object-fit: cover; object-position: 64% 52%; }
.masthead-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--accent-dark) 0%, #183c3880 12%, transparent 48%); }
@media (min-width: 601px) {
  .masthead h1 { width: max-content; max-width: calc(100vw - 120px); }
}
@media (min-width: 601px) and (max-width: 625px) {
  .masthead-description { min-height: calc(6rem + 17px); }
}

.card {
  margin-top: 19px;
  padding: clamp(15px, 2.7vw, 25px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 3px 12px #20372a09;
  min-width: 0;
}
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px 18px; margin-bottom: 15px; }
.muted { color: var(--muted); }
.quiet-link { color: var(--accent); font-size: .9rem; font-weight: 650; text-underline-offset: .17em; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
label { display: block; font-size: .88rem; font-weight: 650; margin-bottom: 5px; }
input, textarea, select, button { font: inherit; }
button, select { cursor: pointer; }
button, input, textarea, select {
  color: var(--ink);
  border-radius: 8px;
  border: 1px solid var(--control);
  background: #fffefb;
}
button { min-height: 42px; padding: 6px 12px; }
button:disabled { opacity: .48; cursor: default; }
select, input, textarea { min-height: 47px; width: 100%; min-width: 0; padding: 8px 11px; }
select { appearance: none; padding-right: 35px; background-image: linear-gradient(45deg, transparent 50%, #426155 50%), linear-gradient(135deg, #426155 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; font-size: 1.2rem; line-height: 1.4; display: block; min-height: 48px; }
textarea:dir(rtl) { text-align: right; font: 1.4rem/1.3 "Noto Serif Hebrew", "Times New Roman", serif; }
:focus-visible { outline: 3px solid #267759; outline-offset: 3px; }
.primary {
  min-height: 48px;
  color: #fffdfa;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
  padding-inline: 25px;
}
@media (hover: hover) {
  button:hover:not(:disabled) { box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 50%, transparent); }
  .primary:hover:not(:disabled) { background: #16463c; }
}
.search-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(136px, .34fr) auto; gap: 12px; align-items: end; }
.search-footer { display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap; margin-top: 12px; }
.total-button { display: inline-flex; gap: 8px; align-items: center; font-size: .9rem; min-height: 37px; padding: 4px 11px; border-color: #b6cabb; background: var(--inset); color: var(--accent-dark); }
.total-button strong { font-size: 1.19rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chevron { display: inline-block; margin: 0 .1em .17em .2em; width: .43em; height: .43em; border-bottom: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg); }
[aria-expanded="true"] > .chevron { transform: rotate(225deg); margin-bottom: -.08em; }
.text-button { border: 0; min-height: 32px; padding: 2px 6px; background: transparent; color: var(--accent); text-underline-offset: .17em; text-decoration: underline; font-weight: 650; }
.status { margin-top: 8px; font-size: .92rem; color: var(--muted); }
.status:empty { display: none; }
.status.error { color: #a12928; }
.summary-line { margin-top: 4px; font-size: .9rem; font-variant-numeric: tabular-nums; }
.results-heading button, .reading-actions button, .step-controls button { font-size: .9rem; }
.result-options { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.result-option { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; min-height: 42px; white-space: nowrap; }
.result-option input { width: 1.05rem; height: 1.05rem; min-height: 0; margin: 0; accent-color: var(--accent); }
.filters { border: 1px solid var(--line); background: var(--inset); border-radius: 9px; display: flex; align-items: end; gap: 12px; flex-wrap: wrap; padding: 12px; margin: 0 0 13px; }
.filters input { width: 8.5rem; min-height: 42px; }
.filters p { padding-bottom: 8px; font-size: .88rem; }
.match-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 0 18px; }
.match-finder { flex: 1 1 220px; min-width: 0; margin-bottom: 12px; }
.match-finder input { min-height: 42px; }
.suggested-match { min-width: 0; max-width: 100%; margin-bottom: 12px; }
.suggested-match p { margin-bottom: 5px; font-size: .88rem; font-weight: 650; }
.suggested-match button {
  display: flex;
  gap: 4px 10px;
  flex-wrap: wrap;
  align-items: center;
  max-width: 100%;
  background: var(--inset);
  border-color: #b6cabb;
  color: var(--accent-dark);
  font-size: .88rem;
}
.suggested-match bdi { min-width: 0; font-size: 1.28rem; line-height: 1.2; overflow-wrap: anywhere; }
.result-scroll {
  overflow: auto;
  max-height: min(calc(var(--row-size) * 11 + 1px), 66vh);
  border: 1px solid var(--line);
  border-radius: 10px;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #9eb4a3 var(--inset);
}
table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-variant-numeric: tabular-nums; }
th, td { padding: 0 12px; text-align: left; }
th { position: sticky; z-index: 1; top: 0; background: var(--inset); border-bottom: 1px solid #c7d5c9; font-size: .89rem; }
th:first-child { width: 42%; }
th:nth-child(2) { width: 32%; }
th:nth-child(3) { width: 16%; }
th:nth-child(4) { width: 10%; }
th button { color: var(--accent-dark); min-height: var(--row-size); padding: 0; border: 0; background: transparent; text-align: inherit; font-weight: 700; }
.sort-mark { color: var(--muted); font-size: .82em; }
.short-count { display: none; }
td { height: var(--row-size); border-bottom: 1px solid var(--line); font-size: .93rem; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: #f7f9f4; }
tbody tr[aria-selected="true"] td { background: var(--accent-soft); }
tbody tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 var(--accent); }
tbody tr { cursor: pointer; }
@media (hover: hover) {
  tbody tr:hover:not([aria-selected="true"]) td { background: var(--inset); }
}
.numeric { text-align: right; }
.match-button { width: 100%; text-align: right; color: var(--ink); font-size: 1.25rem; line-height: 1.25; padding: 5px 0; border: 0; background: transparent; min-height: var(--row-size); overflow-wrap: anywhere; }
.match-button:hover:not(:disabled), .rank-button:hover:not(:disabled) { box-shadow: none; }
.reference-extra { color: var(--muted); margin-inline-start: 4px; font-size: .83rem; white-space: nowrap; }
.empty { padding: 16px; background: #f5f8f2; border: 1px solid var(--line); border-radius: 9px; }

.passage-heading { align-items: flex-start; }
.step-controls { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.step-controls span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .87rem; }
.reference-bar { border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px 15px; flex-wrap: wrap; }
.reference { font-weight: 700; }
.reference-bar .quiet-link { margin-inline-start: auto; }
#occurrence-control { display: flex; align-items: center; gap: 8px; }
#occurrence-control label { margin: 0; }
#occurrence { width: auto; max-width: min(52vw, 260px); min-height: 38px; font-size: .88rem; }
.passage-reading { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; }
.verse { padding: 13px 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 24px; }
.verse + .verse { border-top: 1px solid var(--line); }
.verse.focus { background: #f7f9f3; }
.verse-reference { grid-column: 1 / -1; color: var(--muted); font-size: .86rem; font-weight: 650; }
.verse-hebrew { font: 1.45rem/1.7 "Noto Serif Hebrew", "Times New Roman", serif; color: #3b4b42; overflow-wrap: anywhere; }
.verse-english { align-self: center; color: #2e3c33; }
.verse-hebrew .hit { font-weight: 800; color: #080b09; background: #dbeadf; border-radius: 3px; box-shadow: 2px 0 #dbeadf, -2px 0 #dbeadf; }
.dictionary-lookup { margin-top: 5px; font-size: .87rem; }
.dictionary-lookup a bdi { font-size: 1.05rem; }
.verse-word { display: inline; border-radius: 3px; }
.verse-word[role="button"] { cursor: pointer; }
.verse-word[role="button"]:hover { text-decoration: underline; text-underline-offset: .12em; }
.verse-word.explored { color: #172a22; background: #eed9ac; box-shadow: 2px 0 #eed9ac, -2px 0 #eed9ac; }
.reading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; }
.explore { margin-top: 10px; background: #fcf8ed; border: 1px solid #e6d8b8; border-radius: 8px; padding: 12px; }
#explore-value { font-size: 1rem; font-weight: 700; }
#explore-value bdi { font-size: 1.18rem; }
#return-search, #search-tanach { margin-top: 6px; }
.match-calculation { margin-top: 16px; }
summary { color: var(--accent); font-weight: 700; cursor: pointer; }
summary:hover { text-decoration: underline; }
.calculation { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; align-items: flex-start; }
.calculation-word { padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: #f5f8f2; }
.calculation-word h3 { font: 1rem/1.4 system-ui, sans-serif; font-weight: 650; margin-bottom: 5px; }
.calculation-word h3 bdi { font-size: 1.21rem; }
.calculation-letters { display: flex; gap: 5px; flex-wrap: wrap; }
.calculation-letter { text-align: center; display: grid; min-width: 54px; grid-template-columns: auto auto; gap: 0 4px; justify-content: center; padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font-size: .89rem; }
.calculation-letter bdi { font-size: 1.12rem; }
.calculation-letter small { grid-column: 1 / -1; color: var(--muted); font-size: .74rem; }
.source-example { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.method { padding-block: 15px; }
.method-copy { margin-top: 14px; max-width: 78ch; }
.method-copy h3 { margin-top: 14px; }
.method-copy p { margin-top: 5px; }

@media (max-width: 730px) {
  th, td { padding-inline: 8px; }
  th:nth-child(2) { width: 30%; }
  th:nth-child(3) { width: 17%; }
  th:nth-child(4) { width: 11%; }
}
@media (max-width: 600px) {
  main { margin-top: 12px; }
  .masthead { --banner-width: calc(100vw - 24px); grid-template-columns: 1fr; min-height: 175px; }
  .masthead-photo { position: absolute; inset: 0; z-index: -1; }
  .masthead-photo img { object-position: 65% 55%; }
  .masthead-photo::after { background: linear-gradient(90deg, #183c38 5%, #183c38ed 38%, #183c3880 74%, #183c381f); }
  .masthead-copy { padding: 26px; }
  .masthead-description { max-width: 26ch; margin-top: 14px; }
  .masthead-description::before { display: none; }
}
@media (max-width: 520px) {
  main { width: calc(100% - 26px); }
  .search-fields { grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  .query-field { grid-column: 1 / -1; }
  .section-heading { align-items: flex-start; }
  .results-heading { flex-wrap: wrap; gap: 5px 12px; }
  .result-options { justify-content: flex-start; }
  .results-heading button { padding-inline: 8px; font-size: .82rem; }
  .filters { padding: 8px; }
  .filters input { width: 7rem; }
  .wide-count { display: none; }
  .short-count { display: inline; }
  th:first-child { width: 39%; }
  th:nth-child(2) { width: 29%; }
  th:nth-child(3), th:nth-child(4) { width: 16%; }
  th, td { padding-inline: 6px; }
  th, td { font-size: .82rem; }
  .match-button { font-size: 1.15rem; }
  .passage-heading { flex-wrap: wrap; }
  .verse { grid-template-columns: 1fr; padding: 11px; gap: 3px; }
  .verse-english { padding-top: 6px; }
  .reference-bar .quiet-link { margin-inline-start: 0; }
}
@media (max-width: 360px) {
  .masthead h1 { width: max-content; margin-inline-start: min(0px, calc(100vw - 338px)); }
}
