/* ==========================================================================
   Dictionary (v2) — a lexicon
   ========================================================================== */
.dict { display: grid; gap: clamp(1.5rem, 1rem + 3vw, 4rem); grid-template-columns: minmax(0, 1fr); align-items: start; padding-top: clamp(1.5rem, 1rem + 3vw, 4rem); }
@media (min-width: 1100px) { .dict--index, .dict--term { grid-template-columns: minmax(14rem, 17rem) minmax(0, 1fr); } }
@media (min-width: 1400px) { .dict--term { grid-template-columns: minmax(14rem, 17rem) minmax(0, 1fr) minmax(16rem, 21rem); } }

/* light reading mode — paper */
.dict[data-theme="light"] .dict-main { background: var(--paper); color: #140e0d; border-radius: var(--r-xl); padding: clamp(1.25rem, 1rem + 2vw, 3rem); --bone: #140e0d; --bone-2: #3a2d2a; --bone-3: #5f514c; --line: rgba(20,14,13,.12); --line-2: rgba(20,14,13,.2); --line-3: rgba(20,14,13,.35); --ink-1: #fff; --ink-2: #f3ebe1; --ink-3: #e6dccf; --flare-text: #a01623; }
.dict[data-theme="light"] .definition__text, .dict[data-theme="light"] .context-card__list dd, .dict[data-theme="light"] .totd__def { color: #221816 !important; }
.dict[data-theme="light"] .input { color: #140e0d; }
.dict[data-theme="light"] .dict-bar { background: rgba(233, 223, 211, 0.95); }
.dict[data-theme="light"] .code-badge { background: #140e0d; color: var(--paper); }
.dict[data-theme="light"] .btn:not(.btn--primary) { --btn-fg: #140e0d; }

.dict-rail { display: none; }
@media (min-width: 1100px) { .dict-rail { display: grid; gap: var(--s-7); position: sticky; top: calc(var(--head-h) + 28px); max-height: calc(100dvh - var(--head-h) - 48px); overflow-y: auto; padding-right: 6px; scrollbar-width: thin; } }
.dict-rail__h { font-family: var(--f-display); font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--bone-3); font-weight: 600; margin-bottom: 10px; }
.dict-rail .search .input { min-height: 48px; font-size: 15px; }
.dict-az { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dict-az a { display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; font-family: var(--f-display); font-weight: 600; font-size: 0.9rem; text-decoration: none; color: var(--bone-2); transition: background var(--t-fast), color var(--t-fast); }
.dict-az a:hover, .dict-az a.is-active { background: var(--flare); color: #fff; }
/* A–Z under the search bar: wraps into rows instead of a hidden side-scroller that looked cut off (2026-10-02) */
.dict-az--strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; }
@media (min-width: 1100px) { .dict-az--strip { grid-template-columns: repeat(27, minmax(0, 1fr)); } }
.dict-az--strip a { height: 40px; aspect-ratio: auto; border-radius: 10px; }
.dict-topics ul, .dict-collections ul { list-style: none; margin: 0; padding: 0; display: grid; }
.dict-topics a, .dict-collections a { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 40px; padding: 6px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--bone-2); font-size: 0.94rem; transition: color var(--t-fast); }
.dict-topics a:hover, .dict-collections a:hover { color: var(--bone); }
.dict-topics a[aria-current="page"] { color: var(--flare-text); }
.dict-topics small { font-family: var(--f-display); color: var(--bone-3); font-size: 0.76rem; }
.dict-topics .is-extra { display: none; }
.dict-topics.is-open .is-extra { display: block; }
.dict-topics .btn { margin-top: 10px; }
.dict-collections a { justify-content: flex-start; }
.dict-collections .i { color: var(--flare-text); }

.dict-main { min-width: 0; display: grid; gap: var(--s-6); align-content: start; }
.dict-head { display: grid; gap: var(--s-4); }
.dict-head__title { font-family: var(--f-display); font-weight: 600; font-size: var(--t-xxl); line-height: 0.86; letter-spacing: -0.05em; }
.dict-head__title .serif-it { color: var(--flare-text); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--f-display); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-3); }
.crumbs a { color: var(--bone-2); text-decoration: none; }
.crumbs a:hover { color: var(--bone); }

.dict-bar { position: sticky; top: calc(var(--head-h) + var(--safe-top) + 8px); z-index: var(--z-sticky); display: grid; gap: 12px; padding: 12px 0; background: rgba(8, 7, 7, 0.92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); transition: top var(--t-slow) var(--ease-out); }
body:has(.masthead.is-hidden) .dict-bar { top: calc(var(--safe-top) + 4px); }
.dict-bar__search .input { padding-right: 3rem; }
.dict-bar__kbd { position: absolute; right: 16px; }
.dict-bar__row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dict-bar__count { font-family: var(--f-display); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-3); }
.dict-bar .chip { cursor: pointer; min-height: 38px; }
.dict-tools .btn { min-height: 38px; }

.totd { display: grid; gap: 10px; padding: clamp(1.5rem, 1rem + 2vw, 3rem); border-radius: var(--r-xl); background: linear-gradient(160deg, var(--wine), var(--oxblood) 75%); text-decoration: none; transition: transform var(--t) var(--ease-out); }
.totd:hover { transform: translateY(-3px); }
.totd .tag { color: rgba(239,230,220,.8); }
.totd__name { font-family: var(--f-display); font-weight: 600; font-size: var(--t-xl); line-height: 0.88; letter-spacing: -0.045em; }
.totd__def { font-size: 1.2rem; line-height: 1.55; color: rgba(239,230,220,.92); max-width: 58ch; }

.letter-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; scroll-margin-top: calc(var(--head-h) + 180px); }
@media (min-width: 768px) { .letter-group { grid-template-columns: 6rem minmax(0, 1fr); gap: var(--col-gap); } }
.letter-group + .letter-group { margin-top: var(--s-9); }
.letter-group__letter { font-family: var(--f-display); font-weight: 700; font-size: clamp(3.5rem, 2.5rem + 3vw, 6rem); line-height: 0.8; letter-spacing: -0.05em; color: var(--flare); }
@media (min-width: 768px) { .letter-group__letter { position: sticky; top: calc(var(--head-h) + 200px); align-self: start; } }
.term-list { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.term-row { border-bottom: 1px solid var(--line); }
.term-row__link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 16px 0; text-decoration: none; }
@media (min-width: 1100px) { .term-row__link { grid-template-columns: minmax(12rem, 0.8fr) minmax(0, 1.6fr) auto; align-items: baseline; } .term-row__def { grid-column: 2; } .term-row .tag { grid-column: 3; grid-row: 1; } }
.term-row__name { font-family: var(--f-display); font-weight: 600; font-size: 1.2rem; letter-spacing: -0.015em; transition: color var(--t-fast); }
.term-row__link:hover .term-row__name { color: var(--flare-hi); }
.term-row.is-best .term-row__name { color: var(--flare-hi); }
.term-row__def { grid-column: 1 / -1; font-family: var(--f-read); color: var(--bone-2); font-size: 1.02rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.term-row .tag { grid-row: 1; grid-column: 2; align-self: center; font-size: 0.62rem; white-space: nowrap; color: var(--bone-3); }
@media (max-width: 479px) { .term-row .tag { display: none; } }

/* term page */
.term-head { display: grid; gap: var(--s-4); }
.term-head__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.term-head__title { font-family: var(--f-display); font-weight: 600; font-size: clamp(3.2rem, 1.2rem + 7vw, 8.5rem); line-height: 0.84; letter-spacing: -0.055em; overflow-wrap: anywhere; margin-block: var(--s-3); }
.definition { display: grid; gap: 8px; }
.definition + .definition { padding-top: var(--s-5); border-top: 1px solid var(--line); }
.definition__text { font-family: var(--f-read); font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2.1rem); line-height: 1.38; color: #f0e7de; max-width: 32ch; font-weight: 400; }
.context-card { display: grid; gap: var(--s-4); padding-top: var(--s-5); border-top: 2px solid var(--wine); }
.context-card__title { font-family: var(--f-display); font-size: 0.74rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--flare-text); font-weight: 600; }
.context-card__list { display: grid; gap: var(--s-4); margin: 0; }
.context-card__list > div { display: grid; gap: 2px; }
@media (min-width: 768px) { .context-card__list > div { grid-template-columns: 9rem minmax(0, 1fr); gap: var(--col-gap); } }
.context-card__list dt { font-family: var(--f-display); font-size: 0.7rem; font-weight: 600; color: var(--bone-3); text-transform: uppercase; letter-spacing: 0.14em; padding-top: 6px; }
.context-card__list dd { margin: 0; font-family: var(--f-read); font-size: 1.12rem; line-height: 1.6; color: #e6dcd2; max-width: 60ch; }
.context-card__pairs { display: grid; gap: 8px; padding-top: var(--s-3); }
.term-tags .chip .i { width: 12px; height: 12px; }
.term-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.term-actions [aria-pressed="true"] { --btn-bg: var(--bone); --btn-fg: #120d0c; --btn-bd: var(--bone); }
.term-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: var(--s-6); border-top: 1px solid var(--line); }
.term-pager a { display: flex; align-items: center; gap: 12px; padding: 14px 0; text-decoration: none; min-width: 0; }
.term-pager a span { display: grid; min-width: 0; overflow: hidden; }
.term-pager a span, .term-pager a span * { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.term-pager a:hover { color: var(--flare-hi); }
.term-pager small { font-family: var(--f-display); color: var(--bone-3); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; }
.term-pager .is-next { justify-content: flex-end; text-align: right; grid-column: 2; }
.dict-context { display: grid; gap: var(--s-7); align-content: start; }
@media (min-width: 1400px) { .dict-context { position: sticky; top: calc(var(--head-h) + 28px); } }
@media (min-width: 1100px) and (max-width: 1399.98px) { .dict--term .dict-context { grid-column: 2; } }
.related { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.related a { display: grid; gap: 3px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.related a:hover strong { color: var(--flare-hi); }
.related strong { font-family: var(--f-display); font-weight: 600; transition: color var(--t-fast); }
.related span { font-size: 0.86rem; color: var(--bone-3); line-height: 1.4; }
.dict-cta { padding: var(--s-6); border-radius: var(--r-xl); background: var(--ink-2); display: grid; gap: 10px; justify-items: start; color: var(--bone-2); }
.dress-grid { display: grid; gap: var(--s-7) var(--col-gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr)); }
.dress-grid .context-card { scroll-margin-top: 140px; }
.dress-grid .context-card:target { border-top-color: var(--flare); }

/* ==========================================================================
   Dictionary navigation upgrade (2026-10-08)
   - A–Z index rail on the right edge (all sizes): tap to jump, drag to scrub, live "you are here"
   - letter sections carry their term count
   - sticky search bar is opaque with a clear bottom edge (nothing bleeds through)
   ========================================================================== */
.dict-bar { background: var(--ink); border-bottom: 1px solid var(--line); box-shadow: 0 14px 24px -18px rgba(0,0,0,.9); padding-bottom: 10px; }
.dict[data-theme="light"] .dict-bar { background: var(--paper); border-bottom-color: rgba(20,14,13,.14); box-shadow: 0 14px 24px -20px rgba(20,14,13,.35); }
.dict-bar__count { min-height: 1.2em; }
.dict-topic-pick { flex: 1 1 12rem; max-width: 18rem; }
.dict-topic-pick .select { min-height: 40px; font-size: 0.95rem; }

.letter-group__letter { display: grid; gap: 6px; align-content: start; }
.letter-group__count { font-family: var(--f-display); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-3); line-height: 1.2; }
@media (max-width: 767.98px) { .letter-group__letter { display: flex; align-items: baseline; gap: 14px; font-size: 3rem; } }

/* room for the index rail */
.dict--index { padding-right: 34px; }
@media (min-width: 768px) { .dict--index { padding-right: 46px; } }

.az-index {
  position: fixed; z-index: calc(var(--z-sticky) + 1);
  right: calc(var(--safe-right) + 4px);
  top: calc(var(--head-h) + var(--safe-top) + 12px);
  bottom: calc(var(--safe-bottom) + 12px);
  width: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 6px 0; border-radius: 999px; touch-action: none; user-select: none; -webkit-user-select: none;
}
.az-index a { flex: 1 1 0; max-height: 26px; min-height: 13px; width: 100%; display: grid; place-items: center; font-family: var(--f-display); font-weight: 600; font-size: clamp(0.6rem, 0.4rem + 0.45vh, 0.78rem); color: var(--bone-2); text-decoration: none; border-radius: 8px; transition: color var(--t-fast), background var(--t-fast); }
.az-index a:hover { color: var(--bone); background: var(--hover); }
.az-index a[aria-disabled="true"] { color: var(--ink-4); pointer-events: none; }
.az-index a.is-active { color: #fff; background: var(--flare); }
.az-index a.is-empty:not([aria-disabled]) { color: var(--bone-3); opacity: .45; }
.az-index__top { flex: none !important; height: 26px; margin-bottom: 4px; color: var(--bone-3) !important; }
.az-index__top .i { width: 14px; height: 14px; }
.az-index.is-scrubbing { background: rgba(20, 16, 16, 0.85); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
@media (min-width: 768px) { .az-index { width: 36px; right: calc(var(--safe-right) + 8px); } }
/* phones: sit above the tab bar */
@media (max-width: 767.98px) { .az-index { bottom: calc(var(--tab-h, 58px) + var(--safe-bottom) + 10px); top: calc(var(--head-h) + var(--safe-top) + 8px); } }
/* desktop with the left rail: tuck the index against the content edge */
@media (min-width: 1100px) { .az-index { right: max(8px, calc((100vw - var(--w-max, 1440px)) / 2 - 44px)); } }
.az-bubble { position: fixed; z-index: calc(var(--z-sticky) + 2); right: 64px; top: 50%; width: 76px; height: 76px; margin-top: -38px; border-radius: 22px; display: grid; place-items: center; background: var(--flare); color: #fff; font-family: var(--f-display); font-weight: 700; font-size: 2.6rem; letter-spacing: -0.04em; opacity: 0; transform: scale(.9); transition: opacity 120ms, transform 120ms; pointer-events: none; }
.az-bubble.is-on { opacity: 1; transform: none; }
.dict[data-theme="light"] ~ .az-index a { color: var(--bone-2); }
@media print { .az-index, .az-bubble { display: none !important; } }

.dict-tools-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.dict-bar__count { margin: 2px 0 0; }
/* the chat launcher sits bottom-right: end the index above it */
.az-index { bottom: calc(var(--safe-bottom) + 100px); }
@media (max-width: 767.98px) { .az-index { bottom: calc(var(--tab-h, 58px) + var(--safe-bottom) + 84px); } }
/* light reading: chips keep real contrast on paper (2026-10-08) */
.dict[data-theme="light"] .chip--red { color: #8a1420; background: rgba(160, 22, 35, 0.1); border-color: rgba(160, 22, 35, 0.4); }
.dict[data-theme="light"] .chip { color: #2a1f1c; border-color: rgba(20, 14, 13, 0.25); }
.dict[data-theme="light"] .chip[aria-pressed="true"] { background: #140e0d; color: var(--paper); border-color: #140e0d; }
