/* Lumenary — layout: dictionary masthead with search, sticky A–Z bar,
   entry column + reference sidebar. Palette drawn from the cyanotype
   (Prussian blue on silver-white paper) with a darkroom-safelight red. */
:root {
  --paper: #f4f6f9;
  --surface: #ffffff;
  --ink: #142231;
  --muted: #586779;
  --rule: #d8dfe8;
  --prussian: #1d4a73;
  --prussian-deep: #11304e;
  --on-prussian: #f1f5fa;
  --link: #1d5a92;
  --safelight: #b3352a;
  --plain: #246a5b;
  --amber: #e2a33b;
  --mark: #fde7a6;
  --focus: #e2a33b;

  --f-head: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --f-ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-ipa: "Gentium Book Plus", "Charis SIL", "Doulos SIL", "Lucida Sans Unicode", serif;

  --s-1: 0.8125rem; --s0: 1rem; --s1: 1.125rem; --s2: 1.375rem; --s3: 1.75rem; --s4: 2.25rem;
  --radius: 6px;
  --maxw: 1180px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d141c; --surface: #141e29; --ink: #e5ebf2; --muted: #9aa8b8; --rule: #253445;
    --prussian: #163a5c; --prussian-deep: #0b2238; --on-prussian: #e9f0f8; --link: #8cc0f0;
    --safelight: #ff8a7a; --plain: #6fd0b6; --amber: #f0b552; --mark: #5a4613; --focus: #f0b552;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d141c; --surface: #141e29; --ink: #e5ebf2; --muted: #9aa8b8; --rule: #253445;
  --prussian: #163a5c; --prussian-deep: #0b2238; --on-prussian: #e9f0f8; --link: #8cc0f0;
  --safelight: #ff8a7a; --plain: #6fd0b6; --amber: #f0b552; --mark: #5a4613; --focus: #f0b552;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 72px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--s0)/1.6 var(--f-ui);
  -webkit-text-size-adjust: 100%;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--prussian-deep);
}
a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: 500 0.75rem var(--f-ui); padding: 0 0.35em; border: 1px solid currentColor; border-radius: 3px; opacity: 0.85; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; z-index: 50; background: var(--surface); padding: 0.5rem 1rem; }
.skip:focus { left: max(16px, env(safe-area-inset-left, 0px)); }

.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- Masthead ---------- */
.masthead { background: var(--prussian-deep); color: var(--on-prussian); }
.masthead-inner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem;
  padding-block: 1.25rem 0.75rem;
}
.logo { display: inline-flex; align-items: center; gap: 0.75rem; color: var(--on-prussian); text-decoration: none; }
.logo:hover .logo-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.15em; }
.logo-mark { width: 46px; height: 46px; flex: none; }
.logo-text { display: flex; flex-direction: column; line-height: 1.05; }
.logo-name { font: 700 var(--s3)/1 var(--f-head); letter-spacing: -0.01em; }
.logo-sub { font: 500 0.75rem/1.4 var(--f-ui); text-transform: uppercase; letter-spacing: 0.14em; opacity: 0.8; margin-top: 0.3rem; }

.search { flex: 1 1 320px; position: relative; display: flex; min-width: 0; max-width: 640px; margin-left: auto; }
.search input {
  flex: 1; min-width: 0; height: 52px; padding: 0 1rem;
  font: 400 var(--s1) var(--f-ui); color: var(--ink); background: var(--surface);
  border: 2px solid transparent; border-right: 0; border-radius: var(--radius) 0 0 var(--radius);
}
.search input:focus { outline: none; border-color: var(--amber); }
.search-btn {
  width: 56px; height: 52px; display: grid; place-items: center; border: 0;
  background: var(--amber); color: #1a1405; border-radius: 0 var(--radius) var(--radius) 0;
}
.search-btn svg { width: 22px; height: 22px; }
.search-hint { position: absolute; right: 68px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--s-1); pointer-events: none; }
.search input:focus ~ .search-hint, .search input:not(:placeholder-shown) ~ .search-hint { display: none; }
.strap { margin: 0; padding-block: 0.25rem 1.25rem; font: 400 var(--s0)/1.5 var(--f-head); opacity: 0.88; max-width: 70ch; text-wrap: balance; }

/* ---------- A–Z bar ---------- */
.azbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--prussian); color: var(--on-prussian);
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.azbar-inner { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding-block: 6px; }
.azbar-inner::-webkit-scrollbar { display: none; }
.azbar a, .azbar span {
  flex: 1 0 auto; min-width: 32px; text-align: center; padding: 0.35rem 0.25rem;
  font: 600 var(--s0)/1 var(--f-head); color: var(--on-prussian); text-decoration: none; border-radius: 4px;
}
.azbar a:hover, .azbar a[aria-current="true"] { background: var(--amber); color: #1a1405; }
.azbar span { opacity: 0.35; }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2.5rem;
  padding-block: 2rem 4rem; align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .side { order: -1; }
  .side .panel:not(.wotd):not(.topics-panel) { display: none; }
}
.entries { min-width: 0; outline: none; }
.results-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; margin-bottom: 1.5rem; }
.status { margin: 0; color: var(--muted); font-size: var(--s-1); }
.status strong { color: var(--ink); }
.sense-switch { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; background: var(--surface); }
.sense-switch button {
  border: 0; background: none; padding: 0.35rem 0.85rem; border-radius: 999px;
  font: 500 var(--s-1) var(--f-ui); color: var(--muted);
}
.sense-switch button[aria-checked="true"] { background: var(--prussian); color: var(--on-prussian); }

/* ---------- Letter groups ---------- */
.letter { margin: 0 0 1rem; display: flex; align-items: baseline; gap: 1rem; }
.letter h2 { margin: 0; font: 700 var(--s4)/1 var(--f-head); color: var(--prussian); }
:root[data-theme="dark"] .letter h2 { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .letter h2 { color: var(--link); } }
.letter::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.group { margin-bottom: 2.75rem; }
.group-entries { display: flex; flex-direction: column; gap: 1rem; }

/* ---------- Entry (dictionary card) ---------- */
.entry {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1rem; scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 64px);
}
.entry.is-target { box-shadow: 0 0 0 3px var(--amber); }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; }
.hw { margin: 0; font: 700 var(--s3)/1.15 var(--f-head); letter-spacing: -0.01em; color: var(--ink); }
.hw a { color: inherit; text-decoration: none; }
.hw a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.pos { font: italic 400 var(--s1) var(--f-head); color: var(--safelight); }
.gr { font: 400 var(--s-1) var(--f-ui); color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; margin-top: 0.35rem; font-size: var(--s-1); color: var(--muted); }
.region { font: 600 0.6875rem var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-right: 0.3rem; }
.ipa { font: 400 var(--s1) var(--f-ipa); color: var(--ink); }
.variant em, .abbr em { font-style: normal; font-weight: 600; color: var(--ink); }
.cat-link {
  margin-left: auto; font: 600 0.6875rem var(--f-ui); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--prussian); background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 0.15rem 0.6rem;
}
:root[data-theme="dark"] .cat-link { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cat-link { color: var(--link); } }
.cat-link:hover { border-color: currentColor; }

.sense { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.25rem 1rem; padding-block: 0.9rem; border-top: 1px solid var(--rule); margin-top: 0.9rem; }
.sense + .sense { margin-top: 0; }
.sense-body { min-width: 0; }
.tag {
  display: inline-block; font: 600 0.6875rem/1.2 var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.3rem 0.5rem; border-radius: 4px; border: 1px solid currentColor; align-self: start; justify-self: start;
}
.tag-plain { color: var(--plain); }
.tag-tech { color: var(--safelight); }
.def { margin: 0; font: 600 var(--s1)/1.5 var(--f-head); max-width: 68ch; }
.eg { margin: 0.4rem 0 0; padding-left: 1rem; position: relative; font: italic 400 var(--s0)/1.55 var(--f-head); color: var(--muted); max-width: 68ch; }
.eg::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.sense-tech .def { font-weight: 400; }
@media (max-width: 560px) {
  .sense { grid-template-columns: minmax(0, 1fr); }
  .entry { padding: 1rem 1rem 0.75rem; }
  .cat-link { margin-left: 0; }
}

.entry-foot { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; padding-top: 0.75rem; border-top: 1px solid var(--rule); font-size: var(--s-1); }
.see { margin: 0; color: var(--muted); min-width: 0; }
.see b { font-weight: 600; color: var(--ink); margin-right: 0.35rem; }
.see a { font-weight: 500; }
.see a + a::before { content: "·"; color: var(--muted); display: inline-block; margin: 0 0.45rem; text-decoration: none; }
.copy-link { border: 0; background: none; color: var(--muted); font-size: var(--s-1); padding: 0.25rem 0; text-decoration: underline; text-underline-offset: 0.18em; }
.copy-link:hover { color: var(--ink); }

body[data-sense="plain"] .sense-tech, body[data-sense="tech"] .sense-plain { display: none; }

mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

.empty { background: var(--surface); border: 1px dashed var(--rule); border-radius: var(--radius); padding: 2rem 1.5rem; }
.empty h2 { margin: 0 0 0.5rem; font: 700 var(--s2) var(--f-head); }
.empty p { margin: 0.25rem 0; color: var(--muted); }

/* ---------- Sidebar ---------- */
.side { display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 64px); min-width: 0; }
@media (max-width: 900px) { .side { position: static; } }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.15rem 1.15rem; }
.panel-h { margin: 0 0 0.75rem; font: 600 0.75rem var(--f-ui); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.panel p { margin: 0 0 0.5rem; font-size: var(--s-1); }
.wotd { background: var(--prussian-deep); border-color: var(--prussian-deep); color: var(--on-prussian); }
.wotd .panel-h { color: var(--amber); }
.wotd-term { display: block; font: 700 var(--s2)/1.2 var(--f-head); color: var(--on-prussian); text-decoration: none; }
.wotd-term:hover { text-decoration: underline; }
.wotd-pos { font: italic 400 var(--s0) var(--f-head); opacity: 0.8; }
.wotd-def { margin: 0.5rem 0 0; font: 400 var(--s0)/1.5 var(--f-head); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 0.3rem 0.7rem;
  font: 500 var(--s-1) var(--f-ui); color: var(--ink); display: inline-flex; gap: 0.35rem; align-items: baseline;
}
.chip span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.75rem; }
.chip[aria-pressed="true"] { background: var(--prussian); border-color: var(--prussian); color: var(--on-prussian); }
.chip[aria-pressed="true"] span { color: var(--on-prussian); opacity: 0.75; }

.key { margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.65rem; font-size: var(--s-1); }
.key div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.75rem; align-items: baseline; }
.key dt { margin: 0; }
.key dd { margin: 0; color: var(--muted); }
.key .ipa { font-size: var(--s0); }
.btn-ghost { width: 100%; border: 1px solid var(--prussian); color: var(--prussian); background: none; border-radius: var(--radius); padding: 0.55rem 0.75rem; font-weight: 500; }
:root[data-theme="dark"] .btn-ghost { color: var(--link); border-color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-ghost { color: var(--link); border-color: var(--link); } }
.btn-ghost:hover { background: var(--prussian); color: var(--on-prussian); }

.email-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.email { font: 600 var(--s0) var(--f-ui); word-break: break-all; user-select: all; }
.copy-email { border: 1px solid var(--rule); background: var(--paper); border-radius: 4px; padding: 0.15rem 0.55rem; font-size: 0.75rem; }

/* ---------- Footer & toast ---------- */
.footer { background: var(--prussian-deep); color: var(--on-prussian); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; justify-content: space-between; padding-block: 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); font-size: var(--s-1); }
.footer p { margin: 0; }
.footer a { color: var(--on-prussian); }
.footer-brand a { font: 700 var(--s0) var(--f-head); }

.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; border-radius: var(--radius);
  font-size: var(--s-1); z-index: 20; max-width: calc(100% - 32px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .entry.is-target { transition: box-shadow 0.3s; }
}
.strap-link { color: var(--amber); font-family: var(--f-ui); font-size: var(--s-1); font-weight: 600; white-space: nowrap; }
