/* =============================================================================
 *  ui/reader.css
 *  Reader, new look (html.nr). Loaded last on reader/page8.html, after the
 *  older sheets (tts-ui.css, reader-layout.css and the page's own styles),
 *  many of which use !important. Every rule here is scoped to html.nr, so the
 *  older look comes back by removing that one class.
 *
 *  Layout: top bar / text with the meaning panel beside it / voice bar.
 *  Phones (700px and under, the same break the page's scripts use): the text
 *  scrolls in .wrapper, the panel is a sheet from the bottom, the voice bar
 *  stays at the bottom.
 * ========================================================================== */

/* ---------- tokens: the older parts read --theme-* and a few short names
   that the reading theme script writes inline; in the new look they follow
   Daylight / Night instead. ---------- */
html.nr {
  --theme-background: var(--page) !important; --theme-text: var(--ink) !important;
  --theme-muted: var(--muted) !important; --theme-panel: var(--surface) !important;
  --theme-surface: var(--surface) !important; --theme-page: var(--page) !important;
  --theme-border: var(--line) !important; --theme-accent: var(--brand) !important;
  --theme-selected: var(--brand) !important; --theme-font: var(--ui) !important;
  --red: var(--brand) !important; --text-dim: var(--muted) !important;
  --line-soft: var(--line) !important; --surface-raised: var(--surface) !important;
  --tts-current-bg: #F2E3AE; --tts-current-ink: var(--ink); --tts-sentence-bg: transparent;
  --nr-bar: 64px; --nr-voice: 76px; --nr-panel: 380px;
  --nr-panel-text: var(--panel-font-size, 15px);   /* Settings > Meaning panel text (rekhytThemeV1.panelFontSize) */
}
html.nr:not([data-style="night"]) { --text: #3A3350 !important; --line: #E6E0EE !important; --surface: #FFFFFF !important; }
html.nr[data-style="night"] {
  --text: #DDD6F0 !important; --line: rgba(255, 255, 255, .10) !important; --surface: #221A3C !important;
  --tts-current-bg: rgba(242, 227, 174, .26);
}
html.nr, html.nr body { height: 100%; margin: 0; overflow: hidden; background: var(--page) !important; color: var(--text) !important; font: 400 16px/1.6 var(--ui); }
html.nr body { display: block !important; }
html.nr #Matrix { display: none !important; }

/* ---------- top bar ---------- */
html.nr body #ui-bar {
  position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: auto !important;
  width: 100% !important; height: var(--nr-bar) !important; min-height: var(--nr-bar) !important;
  display: flex !important; flex-wrap: nowrap !important; align-items: center; gap: 14px !important;
  margin: 0 !important; padding: 0 20px !important; overflow: visible !important; transform: none !important;
  background: var(--surface) !important; border: 0 !important; border-bottom: 1px solid var(--line) !important;
  border-radius: 0 !important; box-shadow: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  z-index: 1000 !important; font-family: var(--ui);
}
html.nr .nr-back {
  display: inline-flex; align-items: center; gap: 7px; flex: none; height: 38px; padding: 0 10px 0 6px;
  border-radius: 10px; color: var(--text); font: 500 15px/1 var(--ui); text-decoration: none; white-space: nowrap;
}
html.nr .nr-back svg { width: 18px; height: 18px; }
html.nr .nr-back:hover { background: var(--surface-2); color: var(--brand); }
html.nr .nr-title { display: flex; flex-direction: column; justify-content: center; flex: 1 1 auto; min-width: 0; margin-left: 6px; }
html.nr body #ui-filename {
  display: block !important; flex: none !important; order: 0 !important; max-width: 100% !important; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink) !important; font: 600 16px/1.3 var(--ui) !important; letter-spacing: 0; background: none !important;
}
html.nr .nr-where { color: var(--muted); font: 400 13px/1.35 var(--ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.nr .nr-where:empty { display: none; }
html.nr .nr-tools { display: flex; align-items: center; gap: 10px; flex: none; margin-left: auto; }
html.nr .nr-pop { position: relative; }
html.nr body .nr-tool, html.nr body #navToggle {
  display: inline-flex !important; align-items: center; justify-content: center; gap: 6px;
  width: auto !important; height: 38px !important; min-height: 38px; padding: 0 14px !important; margin: 0;
  border: 1px solid var(--line) !important; border-radius: 10px !important; background: var(--surface) !important;
  color: var(--ink) !important; font: 500 14.5px/1 var(--ui) !important; letter-spacing: 0; text-transform: none;
  white-space: nowrap; cursor: pointer; box-shadow: none !important;
}
html.nr body .nr-tool:hover, html.nr body .nr-tool[aria-expanded="true"] { border-color: var(--brand) !important; color: var(--brand) !important; }
html.nr body #nrTextBtn { width: 44px !important; padding: 0 !important; font: 500 16px/1 var(--read) !important; }
html.nr .nr-mean svg { width: 14px; height: 14px; color: var(--muted); }
html.nr .nr-mean-code { display: none; }
html.nr body #navToggle { background: var(--ink) !important; border-color: var(--ink) !important; color: var(--page) !important; font-weight: 600 !important; }
html.nr body #navToggle:hover, html.nr body #navToggle[aria-expanded="true"] { background: var(--brand) !important; border-color: var(--brand) !important; color: var(--brand-ink) !important; }
html.nr #navToggle svg { width: 16px; height: 16px; }

/* small drop-downs: Aa and Meanings in */
html.nr .nr-menu {
  position: absolute; z-index: 1100; top: calc(100% + 8px); right: 0; min-width: 250px; max-height: min(420px, calc(100dvh - 90px)); overflow: auto;
  padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); color: var(--text);
}
html.nr .nr-text-menu { width: 290px; padding: 14px 16px; display: grid; gap: 14px; }
html.nr .nr-text-menu[hidden], html.nr .nr-menu[hidden] { display: none !important; }
html.nr .nr-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font: 500 14.5px var(--ui); color: var(--ink); }
html.nr .nr-steps { display: inline-flex; align-items: center; gap: 4px; }
html.nr .nr-steps output { min-width: 34px; text-align: center; color: var(--muted); font: 500 14px var(--ui); font-variant-numeric: tabular-nums; }
html.nr body .nr-steps button { width: 40px; height: 34px; padding: 0; border: 1px solid var(--line) !important; border-radius: 9px !important; background: var(--surface) !important; color: var(--ink) !important; font: 500 14px var(--read) !important; cursor: pointer; }
html.nr body .nr-steps button:hover { border-color: var(--brand) !important; color: var(--brand) !important; }
html.nr body .nr-steps button:disabled { opacity: .4; cursor: default; }
html.nr .nr-seg { display: inline-flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--surface-2); }
html.nr body .nr-seg button { height: 30px; padding: 0 12px; border: 0 !important; border-radius: 8px !important; background: transparent !important; color: var(--text) !important; font: 500 13.5px var(--ui) !important; cursor: pointer; }
html.nr body .nr-seg button[aria-pressed="true"] { background: var(--surface) !important; color: var(--ink) !important; box-shadow: 0 1px 3px rgba(36, 27, 61, .14) !important; font-weight: 600 !important; }
html.nr .nr-list { width: 250px; }
html.nr body .nr-list button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0 !important; border-radius: 9px !important; background: transparent !important; color: var(--ink) !important;
  font: 400 15px var(--ui) !important; text-align: left; cursor: pointer;
}
html.nr body .nr-list button:hover { background: var(--surface-2) !important; }
html.nr body .nr-list button[aria-checked="true"] { color: var(--brand) !important; font-weight: 600 !important; }
html.nr .nr-list button small { color: var(--muted); font-size: 12.5px; letter-spacing: .06em; }

/* More: the reader's own menu, as a drop-down under the button */
html.nr body #ui-menu {
  display: none !important; position: absolute !important; z-index: 1100 !important; top: calc(var(--nr-bar) - 6px) !important; right: 20px !important; left: auto !important; bottom: auto !important;
  width: 300px !important; max-height: calc(100dvh - var(--nr-bar) - 16px) !important; overflow-y: auto !important;
  flex-direction: column; align-items: stretch; gap: 2px; padding: 8px !important; margin: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface) !important; box-shadow: var(--shadow);
  opacity: 1 !important; visibility: visible !important; transform: none !important; pointer-events: auto !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}
html.nr body #ui-bar.nav-open #ui-menu, html.nr body #ui-menu.nav-open { display: flex !important; }
html.nr body #ui-menu > * { pointer-events: auto; }
html.nr body #ui-menu .reader-nav { display: flex !important; flex-direction: column; gap: 2px; width: 100%; margin: 0; }
html.nr body #ui-menu .reader-nav a, html.nr body #ui-menu .reader-nav button, html.nr body #ui-menu > .ui-btn,
html.nr body #ui-menu > #tts-btn, html.nr body #ui-menu .auto-learn-control .ui-btn {
  display: flex !important; align-items: center; justify-content: space-between; gap: 10px;
  width: 100% !important; height: auto !important; min-height: 44px !important; padding: 0 14px !important; margin: 0 !important;
  border: 0 !important; border-radius: 10px !important; background: transparent !important; box-shadow: none !important;
  color: var(--ink) !important; font: 500 15.5px/1.25 var(--ui) !important; letter-spacing: 0 !important; text-transform: none !important;
  text-align: left; text-decoration: none; white-space: normal; cursor: pointer; transition: background-color .12s;
}
html.nr body #ui-menu .reader-nav a:hover, html.nr body #ui-menu .reader-nav button:hover, html.nr body #ui-menu > .ui-btn:hover,
html.nr body #ui-menu > #tts-btn:hover, html.nr body #ui-menu .auto-learn-control .ui-btn:hover { background: var(--surface-2) !important; color: var(--ink) !important; }
html.nr body #ui-menu #tts-btn:disabled { opacity: .45; cursor: default; }
html.nr #ui-menu .nr-count, html.nr #ui-menu #deckCount { color: var(--muted); font-weight: 400; font-size: 14px; opacity: 1; }
html.nr #ui-menu .nr-sep { flex: none; height: 1px; margin: 6px 10px; background: var(--line); }
html.nr body #ui-menu .auto-learn-control { position: relative; display: flex !important; flex-direction: row; width: 100%; }
html.nr body #ui-menu .experimental-label { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); font: 600 10.5px/1 var(--ui); letter-spacing: .1em; }
html.nr body #autoLearnToggle[aria-pressed="true"] { color: var(--brand) !important; box-shadow: none !important; }
html.nr body #ui-menu #account-link { color: var(--brand) !important; }
html.nr body #ui-menu #lang-picker { display: none !important; }

/* ---------- the page: text beside the meaning panel, voice bar under both ---------- */
html.nr body > .wrapper, html.nr .wrapper {
  position: fixed !important; inset: var(--nr-bar) 0 0 0 !important; width: auto !important; height: auto !important; min-height: 0 !important; max-width: none !important;
  display: grid !important; grid-template-columns: minmax(0, 1fr) var(--nr-panel) !important; grid-template-rows: minmax(0, 1fr) auto !important;
  gap: 0 !important; margin: 0 !important; padding: 0 !important; overflow: hidden !important; background: var(--page) !important; flex: none !important;
}
html.nr .wrapper.the_left { grid-template-columns: minmax(0, 1fr) 62% !important; }
html.nr .wrapper.the_mid { grid-template-columns: minmax(0, 1fr) 45% !important; }
html.nr .wrapper.the_right { grid-template-columns: minmax(0, 1fr) 0 !important; }
html.nr .wrapper.the_right .box-right-1, html.nr .wrapper.the_right .box-right-2, html.nr .wrapper.collapsed_up .box-right-2 { display: none !important; }

html.nr body .wrapper .container-left {
  grid-column: 1 !important; grid-row: 1 !important; display: flex !important; flex-direction: column; min-width: 0; min-height: 0 !important;
  height: auto !important; max-height: none !important; margin: 0 !important; padding: 0 !important; overflow: hidden !important;
  border: 0 !important; border-radius: 0 !important; background: var(--page) !important; box-shadow: none !important;
}
html.nr body .wrapper .container-left > .page {
  flex: 1 1 auto; min-height: 0 !important; width: 100% !important; height: auto !important; margin: 0 !important; padding: 0 !important;
  border: 0 !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; display: flex; flex-direction: column;
}
html.nr .container-left .chapter-title, html.nr #title, html.nr .container-left .divider { display: none !important; }
html.nr body .container-left #content {
  flex: 1 1 auto !important; min-height: 0; width: 100% !important; max-width: none !important; margin: 0 !important;
  padding: 44px max(28px, calc((100% - var(--reading-max-width)) / 2)) 48px !important; overflow-y: auto !important; overflow-x: hidden;
  background: transparent !important; color: var(--ink) !important;
  font-family: var(--reading-font) !important; font-style: var(--reading-font-style); font-size: var(--reading-font-size) !important; line-height: var(--reading-line-height) !important;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
html.nr .container-left #content::-webkit-scrollbar { width: 10px; }
html.nr .container-left #content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
html.nr #content p { margin: 0 0 1.05em; }
html.nr .reader-word { font-family: inherit !important; color: inherit; border-radius: 4px; }

/* page turning, under the text */
html.nr body .container-left #controls {
  display: flex !important; align-items: center; justify-content: center; gap: 14px; flex: none; width: 100%; max-width: none; height: auto !important; min-height: 0 !important;
  margin: 0 !important; padding: 10px 16px !important; border: 0 !important; border-top: 1px solid var(--line) !important; background: var(--page) !important; position: static !important;
}
html.nr body #controls .key {
  display: inline-grid !important; place-items: center; width: 38px !important; height: 38px !important; min-height: 0 !important; padding: 0;
  border: 1px solid var(--line) !important; border-radius: 50% !important; background: var(--surface) !important;
  color: var(--ink) !important; font: 500 16px/1 var(--ui) !important; cursor: pointer; user-select: none;
}
html.nr body #controls .key:hover { border-color: var(--brand) !important; color: var(--brand) !important; background: var(--surface) !important; box-shadow: none !important; }
html.nr body #page-number { min-width: 76px !important; color: var(--muted) !important; font: 500 14px/1 var(--ui) !important; letter-spacing: 0 !important; text-align: center; font-variant-numeric: tabular-nums; }
html.nr body #restore-reading-position {
  max-width: 260px !important; min-height: 34px; padding: 6px 12px !important; border: 1px solid var(--line) !important; border-radius: 999px !important;
  background: var(--surface) !important; color: var(--brand) !important; font: 500 13px/1.3 var(--ui) !important; cursor: pointer;
}

/* words: the one being spoken is softly marked; saved words carry a quiet
   underline; the word just tapped gets the outline from the plan */
html.nr .reader-word.is-sentence { background-color: var(--tts-sentence-bg); }
html.nr .reader-word.is-speaking { background-color: var(--tts-current-bg) !important; color: var(--tts-current-ink) !important; box-shadow: 0 0 0 2px var(--tts-current-bg) !important; }
html.nr .reader-word.was-spoken { opacity: .72; }
html.nr body .reader-word.word-clicked {
  color: inherit !important; background: transparent !important; text-shadow: none !important;
  box-shadow: inset 0 -2px 0 rgba(var(--brand-rgb), .42) !important;
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--brand) 42%, transparent) !important; border-radius: 0;
}
html.nr body .reader-word.nr-current { background: var(--brand-soft) !important; box-shadow: 0 0 0 1.5px var(--brand) !important; border-radius: 4px; text-shadow: none !important; }
html.nr .reader-word:hover { background-color: rgba(var(--brand-rgb), .09); background-color: color-mix(in srgb, var(--brand) 9%, transparent); }
html.nr body .reader-word.reader-translation { color: var(--brand) !important; text-shadow: none !important; background: var(--brand-soft) !important; }
html.nr body .dictionary-clickable-word:hover, html.nr body .dictionary-clickable-word.dictionary-remembered {
  color: var(--brand) !important; background: var(--brand-soft) !important; box-shadow: none !important; text-shadow: none !important;
}

/* ---------- the meaning panel ---------- */
html.nr body .wrapper .box-right-1 {
  grid-column: 2 !important; grid-row: 1 !important; display: flex !important; flex-direction: column; min-width: 0; min-height: 0 !important;
  height: auto !important; max-height: none !important; margin: 0 !important; padding: 0 !important; overflow: hidden !important;
  border: 0 !important; border-left: 1px solid var(--line) !important; border-radius: 0 !important; background: var(--surface) !important; box-shadow: none !important;
  font-family: var(--ui);
}
html.nr body .box-right-1 > .tabs {
  display: flex !important; gap: 22px !important; flex: none; margin: 0 !important; padding: 0 22px !important; min-height: 0 !important;
  border: 0 !important; border-bottom: 1px solid var(--line) !important; background: transparent !important;
}
html.nr body .tabs .tabButton, html.nr body .tabs .tabButton.is-active {
  flex: none !important; align-self: stretch !important; height: auto !important; min-height: 0 !important; margin: 0 0 -1px !important; padding: 15px 0 13px !important;
  border: 0 !important; border-bottom: 2px solid transparent !important; border-left: 0 !important; border-radius: 0 !important;
  background: none !important; box-shadow: none !important; color: var(--muted) !important;
  font: 500 14px/1.2 var(--ui) !important; letter-spacing: 0 !important; text-transform: none !important; cursor: pointer;
}
html.nr body .tabs .tabButton:hover { color: var(--ink) !important; background: none !important; border-bottom-color: var(--line) !important; }
html.nr body .tabs .tabButton.is-active { color: var(--ink) !important; border-bottom-color: var(--brand) !important; font-weight: 600 !important; }
html.nr body .box-right-1 > .tabContent {
  flex: 1 1 auto; min-height: 0 !important; max-height: none !important; overflow-y: auto; padding: 20px 22px 24px !important;
  background: transparent !important; color: var(--text) !important; font: 400 var(--nr-panel-text)/1.6 var(--ui); scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
html.nr body .box-right-1 > #tab1 { padding: 0 !important; }
html.nr body #tab2 { background: transparent !important; }
html.nr .tab-hint { margin: 8px 0 0; color: var(--muted) !important; font: 400 var(--nr-panel-text)/1.6 var(--ui); }

/* meaning entry: the word in the book face, its kind in small capitals, then
   definitions, examples in italics, and the listen buttons */
html.nr body #tab2 .dictionary-toolbar {
  position: sticky; top: -20px; z-index: 15; display: flex; align-items: center; gap: 6px; margin: -20px -22px 18px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
html.nr body #tab2 .dictionary-toolbar button {
  display: inline-grid; place-items: center; min-width: 32px; width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--line) !important; border-radius: 8px !important; background: var(--surface) !important; color: var(--text) !important;
  font: 500 15px/1 var(--ui) !important; cursor: pointer;
}
html.nr body #tab2 .dictionary-toolbar button:hover:not(:disabled) { border-color: var(--brand) !important; color: var(--brand) !important; }
html.nr body #tab2 .dictionary-toolbar button:disabled { opacity: .35; }
html.nr #tab2 .dictionary-toolbar-title { color: var(--muted); font: 500 13.5px/1.2 var(--ui); }
html.nr #tab2 .dictionary-language-selector { display: none !important; }
/* before any word is looked up there is nothing to go back to, close or read */
html.nr #tab2 .dictionary-toolbar:has(+ .tab-hint:last-child) { display: none; }
html.nr body #tab2 .dictionary-entry h2 {
  margin: 2px 0 6px !important; color: var(--ink) !important; font: 600 30px/1.15 var(--read) !important; letter-spacing: -.005em; text-transform: none !important;
}
html.nr body #tab2 .dictionary-sense-group { margin: 14px 0 0; padding: 0; border: 0; background: none; }
html.nr body #tab2 .dictionary-sense-group h3 { margin: 16px 0 6px; color: var(--muted) !important; font: 600 12px/1.3 var(--ui) !important; letter-spacing: .12em; text-transform: uppercase; }
html.nr body #tab2 .dictionary-pos-link { padding: 0; border: 0 !important; background: none !important; color: var(--muted) !important; font: inherit !important; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
html.nr body #tab2 .dictionary-pos-link:hover { color: var(--brand) !important; text-decoration: underline; }
html.nr body #tab2 .dictionary-section { margin: 0 0 14px; color: var(--text) !important; }
html.nr body #tab2 .dictionary-section strong { display: block; margin: 0 0 6px; color: var(--muted) !important; font: 600 12px/1.3 var(--ui) !important; letter-spacing: .1em; text-transform: uppercase; }
html.nr body #tab2 .dictionary-section p, html.nr body #tab2 .dictionary-section li { color: var(--text) !important; font: 400 var(--nr-panel-text)/1.55 var(--ui) !important; }
html.nr #tab2 .dictionary-section ol, html.nr #tab2 .dictionary-section ul { margin: 0; padding-left: 20px; }
html.nr #tab2 .dictionary-section li + li { margin-top: 6px; }
html.nr body #tab2 .dictionary-tags span {
  display: inline-block; margin: 0 6px 4px 0; padding: 2px 8px; border: 0 !important; border-radius: 6px !important;
  background: var(--surface-2) !important; color: var(--muted) !important; font: 600 11.5px/1.5 var(--ui) !important; letter-spacing: .08em; text-transform: uppercase;
}
html.nr body #tab2 .dictionary-examples blockquote {
  margin: 0 0 10px !important; padding: 2px 0 2px 14px !important; border: 0 !important; border-left: 2px solid var(--line) !important; border-radius: 0 !important;
  background: none !important; color: var(--ink) !important; font: italic 400 var(--nr-panel-text)/1.5 var(--read) !important;
}
html.nr body #tab2 .dictionary-examples blockquote div { margin-top: 3px; color: var(--muted) !important; font: italic 400 calc(var(--nr-panel-text) - 1px)/1.45 var(--read) !important; }
html.nr body #tab2 em { color: var(--text) !important; }
html.nr body #tab2 code { color: var(--brand) !important; background: var(--brand-soft); padding: 0 4px; border-radius: 4px; }
html.nr body .dictionary-audio-button, html.nr body #tab2 .dictionary-audio-button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; margin: 0 6px 6px 0; padding: 0 12px !important;
  border: 1px solid var(--line) !important; border-radius: 9px !important; background: var(--surface) !important;
  color: var(--ink) !important; font: 500 13.5px/1 var(--ui) !important; cursor: pointer; box-shadow: none !important;
}
html.nr body .dictionary-audio-button:hover { border-color: var(--brand) !important; color: var(--brand) !important; }
html.nr .dictionary-pair-message { border-color: var(--line); border-radius: 12px; color: var(--muted); font: 400 calc(var(--nr-panel-text) - 1px)/1.55 var(--ui); }
html.nr .dictionary-pair-message strong { color: var(--ink); }
html.nr .french-translations { border-color: var(--line); border-radius: 12px; background: var(--page); }
html.nr .french-translations h3 { color: var(--muted); font: 600 12px/1.3 var(--ui); letter-spacing: .1em; }
html.nr .translation-language strong { color: var(--ink); }
html.nr .translation-chip { border-color: var(--line); border-radius: 999px; padding: 2px 9px; font: 400 13.5px/1.5 var(--ui); }
html.nr .translation-chip:hover { border-color: var(--brand); color: var(--brand); }
html.nr .translation-sense { color: var(--muted); }
html.nr .personal-dictionary-entry { border-color: var(--line); border-radius: 12px; background: var(--page); }
html.nr .personal-dictionary-entry h3 { color: var(--ink); font: 600 13px/1.3 var(--ui); letter-spacing: .06em; }
html.nr .personal-entry-hint, html.nr .personal-entry-status, html.nr .personal-entry-meta label, html.nr .personal-entry-badge { font-family: var(--ui); color: var(--muted); }
html.nr body .personal-definition-input, html.nr body .personal-entry-meta input { border: 1px solid var(--line) !important; border-radius: 9px !important; background: var(--surface) !important; color: var(--ink) !important; font-family: var(--ui) !important; }
html.nr body .personal-entry-actions button { min-height: 36px; padding: 0 12px; border: 1px solid var(--line) !important; border-radius: 9px !important; background: var(--surface) !important; color: var(--ink) !important; font: 500 13.5px/1 var(--ui) !important; }
html.nr body .personal-entry-actions button:hover { border-color: var(--brand) !important; color: var(--brand) !important; }

/* chat about this page */
html.nr body #chatHistory { padding: 18px 20px !important; border: 0 !important; border-radius: 0 !important; background: transparent !important; color: var(--text) !important; }
html.nr body .speechBubble, html.nr body #chatHistory .speechBubble {
  margin: 0 0 10px !important; padding: 10px 40px 10px 14px !important; border: 0 !important; border-radius: 14px !important;
  background: var(--page) !important; color: var(--ink) !important; font: 400 var(--nr-panel-text)/1.55 var(--ui) !important;
  box-shadow: inset 0 0 0 1px var(--line) !important;
}
html.nr body .speechBubble.user, html.nr body #chatHistory .speechBubble.user { margin-left: auto !important; background: var(--brand-soft) !important; box-shadow: none !important; }
html.nr .chat-status { color: var(--muted); font: 400 12.5px var(--ui); }
html.nr body .chat-speak { border: 1px solid var(--line) !important; background: var(--surface) !important; color: var(--text) !important; }
html.nr body #tab1 .chatbox { padding: 12px 16px !important; margin: 0 !important; border-top: 1px solid var(--line) !important; background: var(--surface) !important; }
html.nr body #userInput, html.nr body .chatbox input {
  border: 1px solid var(--line) !important; border-radius: 10px !important; background: var(--page) !important; color: var(--ink) !important;
  font: 400 15px/20px var(--ui) !important; box-shadow: none !important;
}
html.nr body #userInput:focus { border-color: var(--brand) !important; outline: none; }
html.nr body #userInput::placeholder, html.nr body .chatbox input::placeholder { color: var(--muted) !important; }
html.nr body #tab1 .chatbox button, html.nr body #chat_history, html.nr body #sendBtn {
  height: 38px !important; min-height: 38px; padding: 0 14px !important; border: 1px solid var(--line) !important; border-radius: 10px !important;
  background: var(--surface) !important; color: var(--ink) !important; font: 500 14px/1 var(--ui) !important; box-shadow: none !important;
}
html.nr body #sendBtn { background: var(--brand) !important; border-color: var(--brand) !important; color: var(--brand-ink) !important; font-weight: 600 !important; }
html.nr body #sendBtn:hover { background: var(--brand-hover) !important; }

/* ---------- voice bar ---------- */
html.nr body .wrapper .box-right-2 {
  grid-column: 1 / -1 !important; grid-row: 2 !important; position: relative !important; display: flex !important; align-items: center !important; justify-content: flex-start !important;
  gap: 18px !important; height: var(--nr-voice) !important; min-height: var(--nr-voice) !important; margin: 0 !important; padding: 0 24px !important;
  border: 0 !important; border-top: 1px solid var(--line) !important; border-radius: 0 !important; background: var(--surface) !important; box-shadow: none !important;
  font-family: var(--ui);
}
html.nr .box-right-2 > div:first-child { display: flex !important; align-items: center !important; gap: 6px !important; flex: none; width: auto !important; max-width: none !important; }
html.nr body .box-right-2 .buttonsound {
  display: inline-grid !important; place-items: center; width: 40px !important; min-width: 40px !important; height: 40px !important; min-height: 0 !important; padding: 0 !important;
  border: 0 !important; border-radius: 50% !important; background: transparent !important; color: var(--ink) !important; box-shadow: none !important; cursor: pointer;
}
html.nr body .box-right-2 .buttonsound:hover { background: var(--surface-2) !important; }
html.nr body .box-right-2 .buttonsound:disabled { opacity: .4; cursor: default; }
html.nr .box-right-2 .buttonsound i { display: none !important; }
html.nr body .box-right-2 #backwardBtn::after, html.nr body .box-right-2 #forwardBtn::after, html.nr body .box-right-2 #playPauseBtn::after {
  content: "" !important; display: block; width: 20px; height: 20px; background: currentColor;
  -webkit-mask: var(--nr-ico) center / contain no-repeat; mask: var(--nr-ico) center / contain no-repeat;
}
html.nr #backwardBtn { --nr-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 5h2.2v14H6zM19 5.6v12.8L9.4 12z'/%3E%3C/svg%3E"); }
html.nr #forwardBtn { --nr-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.8 5H18v14h-2.2zM5 5.6v12.8l9.6-6.4z'/%3E%3C/svg%3E"); }
html.nr #playPauseBtn { --nr-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8.5 5.2v13.6L19 12z'/%3E%3C/svg%3E"); }
html.nr #playPauseBtn.is-playing { --nr-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 5h3.6v14H7zM13.4 5H17v14h-3.6z'/%3E%3C/svg%3E"); }
html.nr body .box-right-2 #playPauseBtn { width: 50px !important; min-width: 50px !important; height: 50px !important; background: var(--brand) !important; color: var(--brand-ink) !important; }
html.nr body .box-right-2 #playPauseBtn:hover { background: var(--brand-hover) !important; }
html.nr body .box-right-2 #playPauseBtn::after { width: 22px; height: 22px; }
html.nr .nr-track { position: relative; flex: 1 1 auto; min-width: 60px; height: 24px; cursor: pointer; }
html.nr .nr-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 4px; background: var(--line); }
html.nr .nr-track i { position: absolute; left: 0; top: 50%; height: 4px; margin-top: -2px; width: 0; border-radius: 4px; background: var(--brand); transition: width .25s linear; }
html.nr .nr-track:focus-visible { outline-offset: 4px; }
html.nr body .nr-speed, html.nr body .nr-voice {
  flex: none; height: 34px; padding: 0 10px; border: 0 !important; border-radius: 8px !important; background: transparent !important;
  color: var(--text) !important; font: 500 14px/1 var(--ui) !important; white-space: nowrap; cursor: pointer; box-shadow: none !important;
}
html.nr body .nr-speed { min-width: 52px; font-variant-numeric: tabular-nums; }
html.nr body .nr-speed:hover, html.nr body .nr-voice:hover { background: var(--surface-2) !important; color: var(--brand) !important; }
html.nr .nr-voice:empty { display: none; }
html.nr .nr-auto { flex: none; color: var(--muted); font-size: 14px; white-space: nowrap; }
/* no voice for this language: say so on every screen size instead of a silent grey button */
html.nr body .nr-voice.is-none { display: block !important; flex: 0 1 auto; min-width: 0; height: auto; padding: 4px 6px; color: var(--muted) !important; font-size: 13.5px !important; line-height: 1.3 !important; white-space: normal; text-align: right; cursor: default; opacity: 1; }
html.nr body .nr-voice.is-none:hover { background: transparent !important; color: var(--muted) !important; }

/* ---------- smaller windows ---------- */
@media (max-width: 1100px) { html.nr { --nr-panel: 340px; } html.nr .nr-auto { display: none; } }
@media (max-width: 900px) and (min-width: 701px) {
  html.nr { --nr-panel: 300px; }
  html.nr .nr-voice { display: none; }
  html.nr .nr-mean-long { display: none; }
}

/* ---------- phones ---------- */
@media (max-width: 700px) {
  html.nr { --nr-bar: 56px; --nr-voice: 68px; }
  html.nr body #ui-bar { gap: 6px !important; padding: 0 8px !important; }
  html.nr .nr-back { width: 40px; padding: 0; justify-content: center; }
  html.nr .nr-back span, html.nr .nr-mean-long, html.nr #nrMeanName, html.nr .nr-more-word { display: none; }
  html.nr .nr-mean-code { display: inline; }
  html.nr .nr-title { margin-left: 0; }
  html.nr body #ui-filename { font-size: 15px !important; }
  html.nr .nr-where { font-size: 12.5px; }
  html.nr .nr-tools { gap: 6px; }
  html.nr body .nr-tool { padding: 0 10px !important; }
  html.nr body #nrTextBtn { width: 40px !important; }
  html.nr body #navToggle { width: 40px !important; padding: 0 !important; }
  html.nr .nr-pop { position: static; }
  html.nr .nr-menu { position: fixed; top: calc(var(--nr-bar) + 6px); left: 8px; right: 8px; width: auto; min-width: 0; }
  html.nr body #ui-menu { position: fixed !important; top: calc(var(--nr-bar) + 6px) !important; left: 8px !important; right: 8px !important; width: auto !important; max-height: calc(100dvh - var(--nr-bar) - 20px) !important; }

  /* the text scrolls in .wrapper between the bars (the page's own phone layout) */
  html.nr body > .wrapper, html.nr .wrapper {
    display: block !important; inset: var(--nr-bar) 0 calc(var(--nr-voice) + env(safe-area-inset-bottom, 0px)) 0 !important;
    overflow-y: auto !important; overflow-x: hidden !important; z-index: 1 !important;
  }
  html.nr body .wrapper .container-left { display: block !important; height: auto !important; overflow: visible !important; padding: 0 !important; }
  html.nr body .wrapper .container-left > .page { display: block; }
  html.nr body .container-left #content { overflow: visible !important; padding: 26px 22px 30px !important; font-size: var(--reading-font-size) !important; }
  html.nr body .container-left #controls { padding: 12px 16px 16px !important; }
  html.nr body #controls .key { width: 46px !important; height: 46px !important; }

  /* the meaning panel is a sheet from the bottom (it opens itself on a tap) */
  html.nr body .wrapper .box-right-1 {
    position: fixed !important; left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    height: min(74dvh, 640px) !important; max-height: calc(100dvh - var(--nr-bar) - 10px) !important;
    border: 1px solid var(--line) !important; border-bottom: 0 !important; border-radius: 18px 18px 0 0 !important;
    box-shadow: 0 -12px 40px rgba(36, 27, 61, .18) !important; z-index: 1200 !important;
  }
  html.nr body .box-right-1 > .tabs { padding: 0 54px 0 18px !important; position: relative; }
  html.nr body #mobilePanelClose {
    display: inline-grid !important; place-items: center; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; padding: 0; border: 1px solid var(--line) !important; border-radius: 50% !important;
    background: var(--surface) !important; color: var(--ink) !important; font: 400 22px/1 var(--ui) !important;
  }
  html.nr body .box-right-1 > .tabContent { padding: 18px 18px calc(22px + env(safe-area-inset-bottom, 0px)) !important; }
  html.nr body #tab2 .dictionary-toolbar { top: -18px; margin: -18px -18px 16px; padding: 10px 14px; }

  /* the voice bar: buttons and speed; the line on its top edge shows where the voice is */
  html.nr body .wrapper .box-right-2 {
    position: fixed !important; left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important; width: 100% !important;
    height: auto !important; min-height: var(--nr-voice) !important; padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    justify-content: space-between !important; gap: 10px !important; z-index: 1100 !important; box-shadow: none !important;
  }
  html.nr .box-right-2 > div:first-child { order: 1; }
  html.nr .nr-track { position: absolute; left: 0; right: 0; top: -1px; height: 3px; min-width: 0; }
  html.nr .nr-track::before { top: 0; margin: 0; height: 3px; border-radius: 0; background: transparent; }
  html.nr .nr-track i { top: 0; margin: 0; height: 3px; border-radius: 0 3px 3px 0; }
  html.nr .nr-voice, html.nr .nr-auto { display: none; }
  html.nr .nr-speed { order: 2; }
  html.nr body .nr-voice.is-none { order: 3; }
}

/* ---------- phones turned sideways: wide but short ----------
   A phone on its side is wider than 700px, so it got the computer layout:
   two tall bars and a row of page arrows, which left room for 1 to 3 lines
   of the book. Here the bars are slimmer and the page arrows scroll with the
   text (as on a phone held upright). The meaning panel stays beside the text. */
@media (orientation: landscape) and (max-height: 500px) {
  html.nr { --nr-bar: 50px; --nr-voice: 54px; }
  html.nr .nr-back, html.nr body .nr-tool, html.nr body #navToggle { height: 36px !important; min-height: 36px; }
  html.nr body #ui-filename { font-size: 15px !important; }
  html.nr .nr-where { font-size: 12.5px; }
  html.nr body .box-right-2 #playPauseBtn { width: 42px !important; min-width: 42px !important; height: 42px !important; }
  html.nr body .box-right-2 #backwardBtn, html.nr body .box-right-2 #forwardBtn { width: 38px !important; min-width: 38px !important; height: 38px !important; }
}
@media (orientation: landscape) and (max-height: 500px) and (min-width: 701px) {
  html.nr body #ui-bar { gap: 10px !important; padding: 0 14px !important; }
  html.nr body:not(.minimalist-reader) .wrapper .container-left { display: block !important; overflow-x: hidden !important; overflow-y: auto !important; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  html.nr body:not(.minimalist-reader) .wrapper .container-left > .page { display: block; }
  html.nr body:not(.minimalist-reader) .container-left #content { overflow: visible !important; padding-top: 18px !important; padding-bottom: 20px !important; }
  html.nr body:not(.minimalist-reader) .container-left #controls { padding: 2px 16px 14px !important; border-top: 0 !important; }
  html.nr body .wrapper .box-right-2 { padding: 0 18px !important; gap: 14px !important; }
  html.nr body .tabs .tabButton, html.nr body .tabs .tabButton.is-active { padding: 11px 0 9px !important; }
  html.nr body .box-right-1 > .tabContent { padding: 14px 18px 18px !important; }
  html.nr body #tab2 .dictionary-toolbar { top: -14px; margin: -14px -18px 14px; padding: 8px 14px; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 700px) {
  html.nr body .container-left #content { padding-top: 16px !important; padding-bottom: 18px !important; }
}

/* ---------- small things that float over the page ---------- */
/* the "Activity not saved yet" note sits above the voice bar, not on it */
html.nr body #analyticsRecordingStatus { bottom: calc(var(--nr-voice) + 12px + env(safe-area-inset-bottom, 0px)) !important; }
html.nr body.minimalist-reader #analyticsRecordingStatus { bottom: 56px !important; }
html.nr body #contextMenu {
  min-width: 200px; padding: 6px !important; border: 1px solid var(--line) !important; border-radius: 12px !important;
  background: var(--surface) !important; color: var(--ink) !important; box-shadow: var(--shadow) !important; font: 500 14.5px/1.3 var(--ui) !important;
}
html.nr body #contextMenu > div[id] { padding: 9px 12px !important; border-radius: 8px; color: var(--ink) !important; background: transparent !important; font: inherit !important; }
html.nr body #contextMenu > div[id]:hover { background: var(--surface-2) !important; color: var(--ink) !important; box-shadow: none !important; }
html.nr body #translateLanguages button { border-radius: 8px !important; font: 500 13.5px var(--ui) !important; }
html.nr #readerNoteDialog, html.nr #autoLearnOverlay { background: rgba(var(--ink-rgb), .45); background: color-mix(in srgb, var(--ink) 45%, transparent); }
html.nr .reader-note-card, html.nr .auto-learn-card { border-radius: 18px; box-shadow: var(--shadow); font-family: var(--ui); }
html.nr .reader-note-head h2, html.nr .auto-learn-head h2 { color: var(--ink); font: 600 17px/1.3 var(--ui); letter-spacing: 0; text-transform: none; }
html.nr #readerNoteQuote { border-left-color: var(--brand); background: var(--brand-soft); font-family: var(--read); }
html.nr #readerNoteMeta, html.nr .auto-learn-sub, html.nr .auto-learn-cue, html.nr #autoLearnFeedback { font-family: var(--ui); }
html.nr body #readerNoteSave, html.nr body #autoLearnSubmit { background: var(--brand) !important; border-color: var(--brand) !important; color: var(--brand-ink) !important; }
html.nr body .reader-note-actions button, html.nr body .auto-learn-actions button { border-radius: 10px !important; font: 500 14.5px var(--ui) !important; }
html.nr body .reader-note-actions .note-delete { color: #B4443B !important; }
html.nr[data-style="night"] body .reader-note-actions .note-delete { color: #FF9C93 !important; }
/* Minimal: only the text, centred, with the page number in the corner and the
   small × to leave (the reader's own distraction-free mode) */
html.nr body #minimalistExit { color: var(--ink) !important; }
html.nr body.minimalist-reader #ui-bar, html.nr body.minimalist-reader .wrapper .box-right-1, html.nr body.minimalist-reader .wrapper .box-right-2 { display: none !important; }
html.nr body.minimalist-reader > .wrapper { inset: 0 !important; display: block !important; overflow: hidden !important; }
html.nr body.minimalist-reader .wrapper .container-left { display: flex !important; flex-direction: column; height: 100dvh !important; overflow: hidden !important; }
html.nr body.minimalist-reader .wrapper .container-left > .page {
  display: flex !important; flex-direction: column; width: min(100%, var(--reading-max-width)) !important; height: 100% !important;
  margin: 0 auto !important; padding: clamp(42px, 8vh, 100px) clamp(24px, 6vw, 76px) 0 !important;
}
html.nr body.minimalist-reader .container-left #content { flex: 1 1 auto !important; min-height: 0; padding: 0 0 13vh !important; overflow-y: auto !important; scrollbar-width: none; }
html.nr body.minimalist-reader .container-left #content::-webkit-scrollbar { display: none; }
html.nr body.minimalist-reader .container-left .chapter-title, html.nr body.minimalist-reader #title {
  display: block !important; padding: 0 0 clamp(26px, 6vh, 70px) !important; color: var(--muted) !important; font: 400 15px/1.3 var(--reading-font) !important;
}
html.nr body.minimalist-reader .container-left #controls {
  position: fixed !important; left: auto !important; right: clamp(18px, 5vw, 60px) !important; bottom: max(18px, env(safe-area-inset-bottom)) !important;
  display: block !important; width: auto !important; padding: 0 !important; border: 0 !important; background: transparent !important; z-index: 80;
}
html.nr body.minimalist-reader #controls .key { display: none !important; }
html.nr body.minimalist-reader #page-number { min-width: 0 !important; opacity: .7; }

/* Round 3: the free account card for guests after 10 tapped words (page8 noteGuestTap)
   and the credit line under a quick meaning (tts-dictionary-ui.js renderQuick). */
.guest-signup-card {
  margin: 0 0 14px; padding: 14px 16px;
  border: 1px solid var(--brand, #6B52B3); border-radius: 12px;
  background: var(--brand-soft, #EEE8FA); color: var(--ink, #241B3D);
  font: 400 14.5px/1.5 var(--ui, system-ui, sans-serif); text-align: left;
}
.guest-signup-card strong { display: block; margin-bottom: 4px; font-size: 15.5px; color: var(--ink, #241B3D); }
.guest-signup-card p { margin: 0 0 10px; color: var(--text, #3A3350); }
.guest-signup-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
/* reader/style.css gives every link "margin: 1rem; font-size: 2rem; bold", so links here reset it */
.guest-signup-card .guest-signup-join {
  display: inline-flex; align-items: center; min-height: 40px; margin: 0; padding: 0 16px; border-radius: 10px;
  background: var(--brand, #6B52B3); color: var(--brand-ink, #fff) !important;
  font: 600 14.5px/1 var(--ui, system-ui, sans-serif); text-decoration: none;
}
.guest-signup-card .guest-signup-join:hover { background: var(--brand-hover, #5A43A0); }
.guest-signup-card .guest-signup-later {
  min-height: 40px; padding: 0 14px; border: 1px solid var(--line, #E6E0EE); border-radius: 10px;
  background: transparent; color: var(--ink, #241B3D); font: 600 14px/1 var(--ui, system-ui, sans-serif); cursor: pointer;
}
.dictionary-quick-note { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted, #6B6480); }
.dictionary-quick-note a { margin: 0; color: var(--brand, #6B52B3); font: inherit !important; text-decoration: underline; letter-spacing: 0; }
.dictionary-quick-note .dictionary-audio-button { margin-top: 6px; }
