:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #000000;
  --muted: #6b7080;
  --line: #e4e0d6;
  --accent: #D46D7A;
  --accent-2: #d46d7a;
  --chip: #fbeff8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 60px;
  flex: 1 0 auto;
}

/* Before the first search, the search box is centered vertically; results push it to the top. */
body.home main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 18px 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .05);
}

.row {
  display: flex;
  gap: 8px;
}

input[type=text] {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: "SBL Hebrew", "Ezra SIL", "Taamey Frank CLM",
    "David", "Times New Roman", serif;
}

input[type=text]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  padding: 10px 18px;
  border-radius: 10px;
  border: 0;
  background: var(--accent-2);
  color: var(--card);
  cursor: pointer;
  font-weight: 600;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 400;
  padding: 6px 10px;
  font-size: 13px;
}

/* Icon-only buttons: line icons drawn in the button's text colour. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row .icon-btn {
  padding: 0 16px;
}

.opts-dialog {
  width: min(720px, calc(100% - 32px));
  max-height: calc(100% - 64px);
  padding: 16px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
}

.opts-dialog::backdrop {
  background: rgba(0, 0, 0, .35);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.close-btn {
  font-size: 20px;
  line-height: 1;
  padding: 2px 10px;
}

.opt-group {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
}

.opts-dialog .opt-group:first-of-type {
  border-top: 0;
  margin-top: 6px;
  padding-top: 0;
}

.results-count {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 4px;
  text-align: center;
}

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

.opt-group h3 {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--accent);
}

.opt-group h3 span {
  margin-inline-start: 6px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.filter-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 8px;
}

.filter-row[hidden] {
  display: none;
}

.filter-label {
  flex: none;
  width: 92px;
  font-size: 13px;
  line-height: 1.2;
}

.filter-label small {
  display: block;
  font-size: 11px;
}

.filter-empty {
  margin: 8px 0 0;
  font-size: 13px;
  font-style: italic;
}

.opts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 12px;
  margin-top: 10px;
}

.opts-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
}

.opts-grid select,
.opts-grid input {
  font: inherit;
  font-size: 14px;
  height: 34px;
  flex: none;
  padding: 0 8px;
  border-radius: 8px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filters label {
  background: var(--chip);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.status {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.error {
  color: #c0392b;
}

.entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  margin: 14px 0;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.hw {
  font-family: "SBL Hebrew", "Ezra SIL", "Taamey Frank CLM", "David", serif;
  font-size: 32px;
  line-height: 1.2;
  direction: rtl;
}

.hw small {
  font-size: 16px;
  color: var(--muted);
  margin-inline-start: 8px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}

.chip {
  background: var(--bg);
  font-weight: 400;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13px;
}

.chip b {
  color: var(--muted);
  font-weight: 500;
}

.note {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
}

.refs a,
.entry a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.entry a:hover {
  text-decoration: underline;
}

.refs {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

[dir=rtl],
.he {
  font-family: "SBL Hebrew", "Ezra SIL", "David", serif;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 16px;
}

footer p {
  margin: 0 auto;
  max-width: 720px;
  line-height: 1.5;
}

footer a {
  color: inherit;
}

/* Entry cards */
.source+.source {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.source h4 {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: bold;
  font-size: 14px;
}

/* Usage and Source lines read like the definition, with a bold label. */
.source .field {
  margin-top: 6px;
}

.source .field>b {
  font-weight: 700;
}

.bdb .sense {
  margin: 4px 0 4px 14px;
}

.bdb .stem {
  font-weight: 700;
  color: var(--accent);
}

.bdb .pos,
.bdb .asp {
  color: var(--muted);
}

.bdb .hom {
  font-size: 12px;
  color: var(--muted);
}

.bdb .ref {
  color: var(--accent);
}

.bdb .ref[title],
.bdb .pos[title],
.bdb abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: help;
}

.entry [data-bdb],
.entry [data-strong],
.entry [data-entry] {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.entry [data-bdb]:hover,
.entry [data-strong]:hover,
.entry [data-entry]:hover {
  text-decoration: underline;
}