:root {
  --eink-paper: #d8d3c5;
  --eink-paper-raised: #e5e0d4;
  --eink-ink: #292a26;
  --eink-muted: #65665f;
  --eink-bronze: #735f36;
  --eink-line: rgba(53, 54, 49, .28);
}

.eink-toggle {
  position: fixed;
  z-index: 10000;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #f0d48c;
  border: 1px solid rgba(226, 177, 73, .58);
  border-radius: 50%;
  background: rgba(12, 10, 7, .88);
  box-shadow: 0 7px 22px rgba(0, 0, 0, .38), inset 0 1px rgba(255, 237, 188, .12);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 160ms ease, color 160ms ease, background-color 160ms ease;
}

.eink-toggle:hover { transform: translateY(-2px); }
.eink-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.eink-toggle svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.eink-toggle .eink-fill { fill: currentColor; stroke: none; opacity: .92; }

html[data-reading-tone="eink"] {
  color-scheme: light;
}

html[data-reading-tone="eink"] body {
  color: var(--eink-ink) !important;
  background: var(--eink-paper) !important;
}

html[data-reading-tone="eink"] body::before,
html[data-reading-tone="eink"] body::after {
  opacity: 0 !important;
  background: none !important;
}

html[data-reading-tone="eink"] .eink-toggle {
  color: var(--eink-paper-raised);
  border-color: #4d4e48;
  background: #30312d;
  box-shadow: 0 5px 14px rgba(50, 50, 44, .22);
}

html[data-reading-tone="eink"] .page,
html[data-reading-tone="eink"] .hero,
html[data-reading-tone="eink"] .page-viewport,
html[data-reading-tone="eink"] .page-stage {
  background: transparent !important;
}

html[data-reading-tone="eink"] .search-shell,
html[data-reading-tone="eink"] .search-box,
html[data-reading-tone="eink"] .context-menu,
html[data-reading-tone="eink"] .waiting-room,
html[data-reading-tone="eink"] .info,
html[data-reading-tone="eink"] .info-card,
html[data-reading-tone="eink"] .word-count,
html[data-reading-tone="eink"] footer {
  color: var(--eink-ink) !important;
  border-color: var(--eink-line) !important;
  background: rgba(229, 224, 212, .72) !important;
  box-shadow: none !important;
}

/* Главная страница в режиме электронных чернил остаётся цельным листом:
   без прямоугольных подложек вокруг поиска и нижней навигации. */
html[data-reading-tone="eink"] .hero > .search-stage .search-shell,
html[data-reading-tone="eink"] .hero > .search-stage .search-box,
html[data-reading-tone="eink"] .hero > .footer {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

html[data-reading-tone="eink"] .hero > .search-stage .search-form {
  background: transparent !important;
  border-color: rgba(53, 54, 49, .34) !important;
}

html[data-reading-tone="eink"] .hero > .search-stage .motto {
  color: #675537 !important;
  -webkit-text-fill-color: #675537 !important;
  text-shadow: none !important;
}

html[data-reading-tone="eink"] .search-form,
html[data-reading-tone="eink"] .search-input,
html[data-reading-tone="eink"] input,
html[data-reading-tone="eink"] select,
html[data-reading-tone="eink"] button:not(.eink-toggle) {
  color: var(--eink-ink) !important;
  border-color: var(--eink-line) !important;
  background-color: transparent !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

html[data-reading-tone="eink"] .search-input::placeholder { color: #74756d !important; }

html[data-reading-tone="eink"] .results {
  color: var(--eink-ink) !important;
}

html[data-reading-tone="eink"] .result-card,
html[data-reading-tone="eink"] .empty-card,
html[data-reading-tone="eink"] .word-page .card,
html[data-reading-tone="eink"] .word-page .word-menu {
  color: var(--eink-ink) !important;
  border-color: var(--eink-line) !important;
  background: rgba(229, 224, 212, .82) !important;
  box-shadow: 0 9px 28px rgba(65, 62, 51, .1) !important;
}

html[data-reading-tone="eink"] .word-page h1,
html[data-reading-tone="eink"] .word-page h2 { color: #594a2f !important; text-shadow: none !important; }
html[data-reading-tone="eink"] .word-page .source,
html[data-reading-tone="eink"] .word-page .meta,
html[data-reading-tone="eink"] .word-page .crumb { color: var(--eink-muted) !important; }
html[data-reading-tone="eink"] .word-page .form { color: #4c4d47 !important; border-color: var(--eink-line) !important; background: rgba(255,255,255,.16) !important; }
html[data-reading-tone="eink"] .word-page .word-language-switch,
html[data-reading-tone="eink"] .word-page .word-menu-toggle { color: var(--eink-ink) !important; border-color: var(--eink-line) !important; background: rgba(229,224,212,.9) !important; box-shadow: none !important; }
html[data-reading-tone="eink"] .word-page .word-menu { background: var(--eink-paper-raised) !important; }
html[data-reading-tone="eink"] .word-page .word-menu a { color: var(--eink-ink) !important; }
html[data-reading-tone="eink"] .word-page .word-menu .pending,
html[data-reading-tone="eink"] .word-page .word-menu small,
html[data-reading-tone="eink"] .word-page .word-menu .close { color: var(--eink-muted) !important; }
html[data-reading-tone="eink"] .word-page .word-language-switch strong { color: var(--eink-bronze) !important; }

/* Word cards keep their exact typography and geometry in reading mode.
   Only ink, paper, borders and shadows change. */
html[data-reading-tone="eink"] .word-page .answer,
html[data-reading-tone="eink"] .word-page .card {
  color: var(--eink-ink) !important;
  border-color: var(--eink-line) !important;
  background: rgba(229, 224, 212, .72) !important;
  box-shadow: none !important;
}

html[data-reading-tone="eink"] .word-page .answer-text,
html[data-reading-tone="eink"] .word-page .meanings,
html[data-reading-tone="eink"] .word-page .meanings li,
html[data-reading-tone="eink"] .word-page .examples,
html[data-reading-tone="eink"] .word-page .examples li,
html[data-reading-tone="eink"] .word-page dd,
html[data-reading-tone="eink"] .word-page details {
  color: var(--eink-ink) !important;
}

html[data-reading-tone="eink"] .word-page .answer-label,
html[data-reading-tone="eink"] .word-page .verified,
html[data-reading-tone="eink"] .word-page .section-kicker,
html[data-reading-tone="eink"] .word-page dt,
html[data-reading-tone="eink"] .word-page .form small {
  color: var(--eink-muted) !important;
}

html[data-reading-tone="eink"] .word-page h3,
html[data-reading-tone="eink"] .word-page summary,
html[data-reading-tone="eink"] .word-page code,
html[data-reading-tone="eink"] .word-page .sense-number,
html[data-reading-tone="eink"] .word-page .verified::before {
  color: var(--eink-bronze) !important;
}

html[data-reading-tone="eink"] .word-page .meanings li,
html[data-reading-tone="eink"] .word-page .research {
  border-color: var(--eink-line) !important;
}

html[data-reading-tone="eink"] .word-page .form-analysis {
  color: var(--eink-ink) !important;
  border-color: var(--eink-bronze) !important;
  background: rgba(115, 95, 54, .07) !important;
}

html[data-reading-tone="eink"] .result-word,
html[data-reading-tone="eink"] .result-word a {
  color: #594a2f !important;
  text-shadow: none !important;
}

html[data-reading-tone="eink"] .result-status,
html[data-reading-tone="eink"] .result-meta,
html[data-reading-tone="eink"] .source-note,
html[data-reading-tone="eink"] .empty-card,
html[data-reading-tone="eink"] .voice-status,
html[data-reading-tone="eink"] .hotkey {
  color: var(--eink-muted) !important;
  text-shadow: none !important;
}

html[data-reading-tone="eink"] .result-list,
html[data-reading-tone="eink"] .result-list li,
html[data-reading-tone="eink"] .result-card p {
  color: var(--eink-ink) !important;
}

html[data-reading-tone="eink"] .form-chip {
  color: #4c4d47 !important;
  border-color: rgba(61, 61, 55, .25) !important;
  background: rgba(255, 255, 255, .16) !important;
}

html[data-reading-tone="eink"] .language-switch,
html[data-reading-tone="eink"] .voice-feedback {
  color: var(--eink-muted) !important;
  border-color: var(--eink-line) !important;
  background: rgba(216, 211, 197, .9) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

html[data-reading-tone="eink"] .language-switch [aria-current="page"],
html[data-reading-tone="eink"] .language-switch a:hover,
html[data-reading-tone="eink"] .menu-icon,
html[data-reading-tone="eink"] .small-diamond,
html[data-reading-tone="eink"] .axis-star {
  color: var(--eink-bronze) !important;
  text-shadow: none !important;
}

html[data-reading-tone="eink"] .menu-item:hover,
html[data-reading-tone="eink"] .menu-item:focus-visible {
  background: rgba(74, 68, 54, .08) !important;
}

html[data-reading-tone="eink"] .language-block,
html[data-reading-tone="eink"] .russian-prefix,
html[data-reading-tone="eink"] .author,
html[data-reading-tone="eink"] .metal-word,
html[data-reading-tone="eink"] .search-caption,
html[data-reading-tone="eink"] .page-heading,
html[data-reading-tone="eink"] .toc-page,
html[data-reading-tone="eink"] a {
  color: var(--eink-bronze) !important;
  text-shadow: none !important;
  filter: none !important;
}

html[data-reading-tone="eink"] .metal-word {
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: var(--eink-bronze) !important;
  -webkit-text-stroke: 0 !important;
}

html[data-reading-tone="eink"] svg,
html[data-reading-tone="eink"] .glyph-line,
html[data-reading-tone="eink"] .glyph-line-thin {
  stroke: currentColor;
  filter: none !important;
}

html[data-reading-tone="eink"] .lexis-divider,
html[data-reading-tone="eink"] .ornament-divider {
  opacity: .42 !important;
  filter: grayscale(1) sepia(.2) contrast(.82) !important;
}

html[data-reading-tone="eink"] .book-page {
  color: var(--eink-ink) !important;
  border-color: var(--eink-line) !important;
  background: var(--eink-paper-raised) !important;
  box-shadow: 0 10px 34px rgba(65, 62, 51, .12) !important;
}

html[data-reading-tone="eink"] .view-toolbar {
  color: var(--eink-ink) !important;
  border-color: var(--eink-line) !important;
  background: rgba(216, 211, 197, .94) !important;
  box-shadow: none !important;
}

html[data-reading-tone="eink"] .leader {
  border-color: rgba(65, 65, 59, .34) !important;
  opacity: .7;
}

/* Table of contents: every word is graphite ink; bronze is reserved for
   the heading, printed page numbers, and the active hover state. */
html[data-reading-tone="eink"] #rio-content-page .toc-entry,
html[data-reading-tone="eink"] #rio-content-page .toc-line,
html[data-reading-tone="eink"] #rio-content-page .toc-text,
html[data-reading-tone="eink"] #rio-content-page .toc-entry [lang],
html[data-reading-tone="eink"] #rio-content-page .toc-entry i,
html[data-reading-tone="eink"] #rio-content-page .toc-entry strong,
html[data-reading-tone="eink"] #rio-content-page .appendix-heading,
html[data-reading-tone="eink"] #rio-content-page .appendix-block {
  color: var(--eink-ink) !important;
  text-shadow: none !important;
}

html[data-reading-tone="eink"] #dictionary-body-range,
html[data-reading-tone="eink"] #dictionary-body-range > span,
html[data-reading-tone="eink"] #dictionary-body-range [lang],
html[data-reading-tone="eink"] #rio-content-page .appendix-heading,
html[data-reading-tone="eink"] #rio-content-page .appendix-heading strong,
html[data-reading-tone="eink"] #rio-content-page .appendix-heading [lang] {
  color: #3f403b !important;
  text-shadow: none !important;
}

html[data-reading-tone="eink"] #rio-content-page .toc-page {
  color: var(--eink-bronze) !important;
}

html[data-reading-tone="eink"] #rio-content-page a.toc-line:hover,
html[data-reading-tone="eink"] #rio-content-page a.toc-line:focus-visible,
html[data-reading-tone="eink"] #rio-content-page a.toc-line:hover .toc-text,
html[data-reading-tone="eink"] #rio-content-page a.toc-line:focus-visible .toc-text {
  color: var(--eink-bronze) !important;
}

html[data-reading-tone="eink"] * {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  caret-color: var(--eink-ink);
}

@media (max-width: 600px) {
  .eink-toggle { width: 46px; height: 46px; right: 13px; bottom: 15px; }
  .eink-toggle svg { width: 25px; height: 25px; }
}

@media print {
  .eink-toggle { display: none !important; }
}
