:root {
  --paper: #f3ede0;
  --paper-deep: #ece3d1;
  --ink: #211c15;
  --ink-soft: #4a4237;
  --muted: #857a68;
  --muted-2: #857a68;
  --rule-red: #8c2f1b;
  --rule-red-soft: #b8543a;
  --gold: #9c7d2e;
  --line: #d9cdb3;
  --line-strong: #c3b493;
  --focus: #2f5f8a;

  --serif-display: "Libre Caslon Text", "Iowan Old Style", Georgia, serif;
  --serif-body: "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--serif-body);
}

body {
  background-image:
    radial-gradient(ellipse at top left, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(0,0,0,0.05), transparent 55%);
}

::selection { background: #d8c48b; color: var(--ink); }

a { color: inherit; }

button, input {
  font-family: inherit;
}

button:focus-visible,
input:focus-visible,
li:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- layout frame ---------- */

.frame {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 100vh;
}

.volume {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 0 28px 64px;
}

/* ---------- thumb index (the die-cut letter tabs on a real unabridged) ---------- */

.thumb-index {
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 96px 0 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
}
.thumb-index::-webkit-scrollbar { display: none; }

.thumb-tab {
  border: none;
  background: transparent;
  color: #cfc2a4;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 5px 0;
  cursor: pointer;
  position: relative;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  transition: background-color 120ms ease, color 120ms ease;
}

.thumb-tab:hover { color: var(--paper); background: rgba(255,255,255,0.06); }

.thumb-tab.is-active {
  color: var(--paper);
  background: var(--rule-red);
}

.thumb-tab.is-empty { color: #5a5346; cursor: default; }
.thumb-tab.is-empty:hover { background: transparent; color: #5a5346; }

/* ---------- masthead ---------- */

.masthead {
  padding-top: 40px;
  border-bottom: 3px double var(--line-strong);
  padding-bottom: 22px;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.masthead-title {
  font-family: var(--serif-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  margin: 6px 0 4px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.masthead-title em {
  font-style: italic;
  color: var(--rule-red);
  font-weight: 400;
}

.masthead-sub {
  margin: 0 0 20px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted-2);
}

.search-slip {
  display: flex;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  padding: 10px;
  box-shadow: 3px 3px 0 rgba(33,28,21,0.06);
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink);
  padding: 6px 8px;
}
.search-input::placeholder { color: #a89d87; }
.search-input:focus { outline: none; }

.slip-button {
  border: 1px solid var(--line-strong);
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}
.slip-button:hover { background: var(--ink); color: var(--paper); }

/* ---------- page / results / entry ---------- */

.page {
  display: grid;
  grid-template-columns: 220px minmax(0,1fr);
  gap: 32px;
  padding-top: 28px;
  align-items: start;
}

.results-rail {
  position: sticky;
  top: 28px;
  border-right: 1px solid var(--line);
  padding-right: 20px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}

.results-label {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.results-list li {
  padding: 5px 8px;
  margin: 1px -8px;
  font-size: 0.92rem;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
}
.results-list li:hover { background: var(--paper); }
.results-list li.is-active {
  background: var(--ink);
  color: var(--paper);
}
.results-list .r-word { font-weight: 600; }
.results-list .r-pos {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  margin-left: 6px;
}
.results-list li.is-active .r-pos { color: #cfc2a4; }

.entry-column { min-width: 0; }

.welcome {
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
  max-width: 62ch;
}

.welcome-drop {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

.drop-cap {
  float: left;
  font-family: var(--serif-display);
  font-size: 3.4rem;
  line-height: 0.8;
  padding: 4px 8px 0 0;
  color: var(--rule-red);
  font-weight: 700;
}

.welcome-note {
  font-size: 0.85rem;
  color: var(--muted-2);
  font-family: var(--mono);
  line-height: 1.6;
}
.welcome-note code {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1px 5px;
}

/* ---------- entries ---------- */

.entry-list { display: flex; flex-direction: column; gap: 30px; }

.entry {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 24px;
}
.entry:last-child { border-bottom: none; }

.entry-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 6px;
}

.entry-word {
  font-family: var(--serif-display);
  font-weight: 700;
  font-size: 2rem;
  color: var(--rule-red);
  letter-spacing: -0.01em;
}

.entry-pron {
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.entry-pos {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 1px 7px;
  border-radius: 2px;
  white-space: nowrap;
}

.entry-etym {
  font-size: 0.88rem;
  color: var(--muted-2);
  margin: 4px 0 14px;
  line-height: 1.55;
}
.entry-etym::before {
  content: "Etym. ";
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted-2);
  letter-spacing: 0.06em;
  margin-right: 2px;
}

.senses {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sense {
  display: flex;
  gap: 12px;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
}

.sense-num {
  flex: none;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--rule-red-soft);
  min-width: 1.4em;
  text-align: right;
  padding-top: 2px;
}

.sense-text { flex: 1; }

.lookup-popup {
  position: fixed;
  z-index: 1000;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  box-shadow: 4px 4px 0 rgba(33,28,21,0.12);
  padding: 12px 14px;
  max-width: 240px;
}

.lookup-popup-prompt {
  margin: 0 0 10px;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 0.98rem;
  color: var(--ink);
}

.lookup-popup-actions {
  display: flex;
  gap: 8px;
}

.lookup-popup-search,
.lookup-popup-cancel {
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
}

.lookup-popup-search {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.lookup-popup-search:hover { background: var(--rule-red); border-color: var(--rule-red); }

.lookup-popup-cancel {
  background: transparent;
  color: var(--ink-soft);
}
.lookup-popup-cancel:hover { background: var(--paper-deep); }

.entry-syn {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--paper);
  border-left: 3px solid var(--gold);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.entry-syn strong {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold);
  margin-bottom: 4px;
}

.empty-state {
  padding: 40px 0;
  color: var(--muted-2);
  font-style: italic;
}

/* ---------- footer ---------- */

.colophon {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted-2);
  line-height: 1.6;
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .page { grid-template-columns: 1fr; }
  .results-rail {
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 14px;
    max-height: 240px;
  }
}

@media (max-width: 620px) {
  .frame { grid-template-columns: 24px minmax(0,1fr); }
  .thumb-tab { font-size: 9px; }
  .volume { padding: 0 16px 48px; }
  .masthead-title { font-size: 2rem; }
  .entry-word { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
