:root {
  color-scheme: light;
  --app-bg: #f5ecdc;
  --chrome: rgba(255, 248, 237, 0.88);
  --surface: #fff9ef;
  --surface-2: #f1dfc5;
  --reader-surface: #fffaf1;
  --text: #211914;
  --muted: #796a5a;
  --line: rgba(60, 40, 24, 0.14);
  --accent: #a65320;
  --accent-strong: #74320e;
  --danger: #a33428;
  --tab-bg: rgba(33, 25, 20, 0.08);
  --shadow: 0 22px 60px rgba(74, 42, 20, 0.20);
  --cupertino-pane-background: var(--surface);
  --cupertino-pane-color: var(--text);
  --cupertino-pane-border-radius: 28px;
  --cupertino-pane-move-background: var(--line);
  --cupertino-pane-shadow: 0 -18px 55px rgba(0, 0, 0, 0.26);
  --reader-font-size: 20px;
  --reader-line-height: 1.65;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-light {
  color-scheme: light;
  --app-bg: #f4f6fb;
  --chrome: rgba(255, 255, 255, 0.9);
  --surface: #ffffff;
  --surface-2: #e7ecf7;
  --reader-surface: #ffffff;
  --text: #151922;
  --muted: #657084;
  --line: rgba(31, 42, 68, 0.14);
  --accent: #315fcb;
  --accent-strong: #173d99;
  --tab-bg: rgba(21, 25, 34, 0.07);
  --shadow: 0 22px 60px rgba(30, 42, 70, 0.16);
}

body.theme-dark {
  color-scheme: dark;
  --app-bg: #11100f;
  --chrome: rgba(29, 26, 23, 0.9);
  --surface: #1d1a17;
  --surface-2: #30271d;
  --reader-surface: #171411;
  --text: #f3e8d8;
  --muted: #b9aa98;
  --line: rgba(255, 239, 214, 0.14);
  --accent: #f0a35c;
  --accent-strong: #ffd0a0;
  --danger: #ff8b7c;
  --tab-bg: rgba(255, 239, 214, 0.08);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #15100d;
  color: var(--text);
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
}

button,
label,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

code {
  border-radius: 0.45rem;
  background: var(--tab-bg);
  padding: 0.08rem 0.3rem;
}

.app-shell {
  position: relative;
  width: min(100vw, 430px);
  height: min(100svh, 920px);
  min-height: min(680px, 100svh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 34px;
  background:
    radial-gradient(circle at 20% -10%, rgba(255, 203, 139, 0.32), transparent 18rem),
    var(--app-bg);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

.app-shell.auth-required {
  grid-template-rows: minmax(0, 1fr);
}

.app-shell.auth-required .top-bar,
.app-shell.auth-required .main-panel,
.app-shell.auth-required .bottom-nav {
  display: none;
}

.app-shell:not(.auth-required) .auth-screen {
  display: none;
}

.auth-screen {
  display: grid;
  align-items: center;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}

.auth-card {
  display: grid;
  gap: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.auth-card p:not(.eyebrow),
.status-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 0.65rem;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.register-panel {
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.register-panel summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 900;
}

.top-bar {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  min-height: 68px;
  padding: calc(env(safe-area-inset-top) + 0.65rem) 1rem 0.65rem;
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
  backdrop-filter: blur(20px);
  transition: transform 220ms ease, opacity 220ms ease;
  will-change: transform;
}

.top-title {
  min-width: 0;
}

.top-actions {
  display: flex;
  gap: 0.45rem;
}

.top-bar h1,
.panel-heading h2,
.import-card h2,
.sheet-card h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.top-bar h1 {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.12rem;
  font-weight: 850;
}

.top-bar .eyebrow {
  margin: 0 0 0.12rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 0.28rem;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.progress-label {
  width: max-content;
  max-width: 100%;
  margin-top: 0.25rem;
  border-radius: 999px;
  background: var(--tab-bg);
  color: var(--muted);
  padding: 0.42rem 0.62rem;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.chrome-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--tab-bg);
  color: var(--text);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  touch-action: manipulation;
}

.chrome-button[disabled] {
  opacity: 0.32;
}

.main-panel {
  min-height: 0;
  overflow: hidden;
}

.screen {
  display: none;
  height: 100%;
  overflow: hidden;
}

.screen.active {
  display: block;
}

.empty-reader,
.reader-shell,
#libraryScreen,
#wordsScreen,
#settingsScreen {
  width: 100%;
  height: 100%;
}

.empty-reader {
  display: grid;
  align-items: stretch;
  padding: 0.85rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.import-card {
  display: grid;
  align-content: start;
  gap: 0.9rem;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.import-card::before {
  content: "BL";
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 1.45rem;
  background: var(--text);
  color: var(--surface);
  font-size: 1.2rem;
  font-weight: 950;
  letter-spacing: -0.08em;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.20);
}

.import-card h2 {
  max-width: 16rem;
  font-size: 1.85rem;
  line-height: 0.98;
}

.import-card p:not(.eyebrow),
.setup-note p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.file-picker,
.tool-button,
.bottom-nav button,
.icon-button {
  min-height: 46px;
  border-radius: 999px;
  touch-action: manipulation;
}

.file-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.25rem;
  background: var(--text);
  color: var(--surface);
  font-weight: 900;
  padding: 0.9rem 1rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.local-books {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.4rem;
}

.local-books .eyebrow {
  margin-top: 0.4rem;
}

.local-books button {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.38);
  color: var(--text);
  padding: 0.7rem;
  text-align: left;
}

.local-books button::before {
  content: "FB2";
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.85rem;
  background: var(--accent);
  color: #fff8ed;
  font-size: 0.68rem;
  font-weight: 950;
}

.reader-shell {
  display: grid;
  grid-template-rows: 3px minmax(0, 1fr) auto;
  background: var(--reader-surface);
}

.gutter-nav {
  display: none;
}

.app-shell.reading-active {
  display: block;
  height: 100dvh;
  min-height: 100dvh;
}

.app-shell.reading-active .main-panel {
  height: 100dvh;
}

.app-shell.reading-active #readerScreen,
.app-shell.reading-active .reader-shell,
.app-shell.reading-active .reader-viewport {
  height: 100dvh;
}

.app-shell.reading-active .reader-shell {
  position: relative;
  display: block;
}

.app-shell.reading-active .progress-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  height: 3px;
}

.app-shell.reading-active .bookmark-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 4.4rem);
  z-index: 3;
}

.app-shell.reading-active .top-bar,
.app-shell.reading-active .bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
}

.app-shell.reading-active .top-bar {
  top: 0;
}

.app-shell.reading-active .bottom-nav {
  bottom: 0;
}

.app-shell.reading-active.chrome-hidden .top-bar {
  transform: translateY(-105%);
  opacity: 0;
  pointer-events: none;
}

.app-shell.reading-active.chrome-hidden .bottom-nav {
  transform: translateY(105%);
  opacity: 0;
  pointer-events: none;
}

.app-shell.reading-active.chrome-hidden .bookmark-list {
  transform: translateY(105%);
  opacity: 0;
  pointer-events: none;
}

.reader-tools,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.reader-tools {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
  backdrop-filter: blur(20px);
}

.tool-button,
.icon-button {
  background: var(--tab-bg);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 850;
  padding: 0.66rem 0.85rem;
}

.tool-button.accent {
  background: var(--accent);
  color: #fff8ed;
}

.tool-button.danger {
  color: var(--danger);
}

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.progress-track {
  overflow: hidden;
  background: var(--line);
}

#progressFill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 180ms ease;
}

.reader-viewport {
  min-height: 0;
  overflow: hidden;
  background: var(--reader-surface);
}

.foliate-reader {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.bookmark-list {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--line);
  background: var(--chrome);
  -webkit-overflow-scrolling: touch;
  transition: transform 220ms ease, opacity 220ms ease;
}

.bookmark-list:empty {
  display: none;
}

.bookmark-list button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0.42rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 800;
}

#libraryScreen,
#wordsScreen,
#settingsScreen {
  display: none;
  overflow: auto;
  padding: 0.85rem 0.85rem 1rem;
  -webkit-overflow-scrolling: touch;
}

#libraryScreen.active,
#wordsScreen.active,
#settingsScreen.active {
  display: block;
}

.library-panel {
  display: grid;
  gap: 0.9rem;
}

.upload-button {
  position: relative;
  display: grid;
  place-items: center;
  white-space: nowrap;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.book-library {
  display: grid;
  gap: 1rem;
}

.book-group {
  display: grid;
  gap: 0.65rem;
}

.book-group h3 {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.book-card {
  display: grid;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  padding: 0.95rem;
  text-align: left;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
}

.book-card.active {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 16%, transparent);
}

.book-card h4 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.18;
}

.book-card .meta,
.book-card .stats {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.book-progress {
  overflow: hidden;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--tab-bg);
}

.book-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.panel-heading {
  padding: 0.25rem 0.1rem 0.8rem;
}

.word-actions {
  display: flex;
  gap: 0.45rem;
}

.panel-heading h2 {
  font-size: 1.55rem;
}

.text-input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  padding: 0.82rem 0.95rem;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 83, 32, 0.14);
}

.word-list {
  display: grid;
  gap: 0.72rem;
  margin-top: 0.8rem;
}

.word-card,
.setup-note,
.settings-form label {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
}

.word-card {
  padding: 0.95rem;
}

.word-card h3 {
  margin: 0;
  padding-right: 4.4rem;
  font-size: 1.1rem;
  line-height: 1.18;
}

.word-card .translation {
  margin: 0.24rem 0 0;
  color: var(--accent-strong);
  font-weight: 900;
}

.word-card .meta,
.word-card .context,
.empty-state {
  color: var(--muted);
  line-height: 1.45;
}

.word-card .context {
  margin: 0.7rem 0 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--line);
  font-size: 0.9rem;
}

.delete-word {
  float: right;
  min-height: 34px;
  border-radius: 999px;
  background: var(--tab-bg);
  color: var(--danger);
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 850;
}

.settings-form,
.setup-note {
  display: grid;
  gap: 0.75rem;
}

.settings-form label {
  display: grid;
  gap: 0.5rem;
  color: var(--muted);
  font-weight: 850;
  padding: 0.85rem;
}

.settings-form .checkbox-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.settings-form .checkbox-row input {
  width: 1.35rem;
  height: 1.35rem;
  accent-color: var(--accent);
}

.settings-form input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.setup-note {
  margin-top: 0.75rem;
  padding: 0.95rem;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.install-card.installed .tool-button,
.install-card .tool-button:disabled {
  opacity: 0.45;
}

.install-help {
  margin-top: -0.25rem;
  font-size: 0.88rem;
}

.bottom-nav {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  padding: 0.48rem 0.7rem calc(env(safe-area-inset-bottom) + 0.58rem);
  border-top: 1px solid var(--line);
  background: var(--chrome);
  backdrop-filter: blur(22px);
  transition: transform 220ms ease, opacity 220ms ease;
  will-change: transform;
}

.bottom-nav button {
  display: grid;
  place-items: center;
  min-height: 46px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.bottom-nav button.active {
  background: var(--text);
  color: var(--surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.lookup-sheet {
  width: 100%;
  height: 100%;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.lookup-pane-wrapper .pane {
  max-width: min(100vw, 430px) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--line);
  border-bottom: 0;
}

.lookup-pane-wrapper .draggable {
  background: var(--surface);
  border-radius: var(--cupertino-pane-border-radius) var(--cupertino-pane-border-radius) 0 0;
}

.lookup-pane-wrapper .move {
  background: color-mix(in srgb, var(--text) 22%, transparent) !important;
}

.lookup-pane-wrapper .backdrop {
  backdrop-filter: blur(3px);
}

.sheet-card {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.75rem;
  padding: 1.35rem 1rem calc(env(safe-area-inset-bottom) + 1rem);
}

.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sheet-title-row h2 {
  font-size: 1.4rem;
}

.lookup-body {
  min-height: 0;
  overflow-y: auto;
  color: var(--muted);
  line-height: 1.48;
  -webkit-overflow-scrolling: touch;
}

.lookup-hero,
.lookup-section {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-2));
  padding: 0.95rem;
}

.lookup-hero {
  margin-bottom: 0.75rem;
  background:
    radial-gradient(circle at 12% 0, color-mix(in srgb, var(--accent) 22%, transparent), transparent 9rem),
    var(--surface);
}

.lookup-kicker,
.lookup-section-title {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lookup-hero h3 {
  margin: 0.25rem 0 0;
  color: var(--text);
  font-size: clamp(1.45rem, 8vw, 2.15rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.lookup-body .primary-translation {
  margin: 0.45rem 0 0;
  color: var(--accent-strong);
  font-size: 1.24rem;
  font-weight: 950;
}

.lookup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.8rem;
}

.lookup-chips span {
  border-radius: 999px;
  background: var(--tab-bg);
  color: var(--muted);
  padding: 0.34rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 850;
}

.lookup-section {
  margin-top: 0.65rem;
}

.lookup-section p {
  margin: 0.42rem 0 0;
}

.context-block {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.55;
}

.context-block mark {
  border-radius: 0.38rem;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: var(--text);
  padding: 0.02rem 0.16rem;
}

.alternatives-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.alternatives-list div {
  display: grid;
  gap: 0.12rem;
  border-radius: 16px;
  background: var(--tab-bg);
  padding: 0.65rem;
}

.alternatives-list strong {
  color: var(--text);
}

.alternatives-list span {
  color: var(--muted);
  font-size: 0.9rem;
}

.lookup-body dl {
  display: grid;
  grid-template-columns: minmax(5.2rem, 0.34fr) 1fr;
  gap: 0.48rem 0.7rem;
}

.lookup-body dt {
  color: var(--text);
  font-weight: 900;
}

.lookup-body dd {
  margin: 0;
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

@media (min-width: 900px), (min-width: 700px) and (min-height: 980px) {
  body {
    display: block;
    background: var(--app-bg);
  }

  .app-shell,
  .app-shell.reading-active {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-screen {
    place-items: center;
  }

  .auth-card {
    width: min(32rem, calc(100vw - 2rem));
  }

  .top-bar {
    grid-template-columns: 60px minmax(0, 1fr) auto;
    min-height: 82px;
    padding: calc(env(safe-area-inset-top) + 0.9rem) clamp(1.4rem, 3vw, 2.5rem) 0.9rem;
  }

  .top-bar h1 {
    font-size: clamp(1.25rem, 1.7vw, 1.85rem);
  }

  .top-actions {
    gap: 0.65rem;
  }

  .chrome-button {
    width: 56px;
    height: 56px;
    font-size: 1.85rem;
  }

  .progress-label {
    font-size: 0.84rem;
  }

  .app-shell.reading-active .main-panel {
    height: auto;
    min-height: 0;
  }

  .app-shell.reading-active #readerScreen,
  .app-shell.reading-active .reader-shell,
  .app-shell.reading-active .reader-viewport {
    height: 100%;
  }

  .app-shell.reading-active .reader-shell {
    display: grid;
    grid-template-rows: 3px minmax(0, 1fr) auto;
  }

  .app-shell.reading-active .progress-track {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    height: 3px;
  }

  .app-shell.reading-active .top-bar,
  .app-shell.reading-active .bottom-nav {
    position: relative;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .app-shell.reading-active .bookmark-list {
    position: relative;
    bottom: auto;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .reader-shell {
    position: relative;
  }

  .reader-viewport {
    width: 100%;
  }

  .gutter-nav {
    position: absolute;
    top: 3px;
    bottom: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    width: max(92px, calc((100vw - 820px) / 2));
    border-radius: 0;
    background: transparent;
    color: color-mix(in srgb, var(--text) 38%, transparent);
    font-size: clamp(2.4rem, 4vw, 4.5rem);
    font-weight: 300;
    transition: background 160ms ease, color 160ms ease;
  }

  .gutter-nav:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--accent);
  }

  .gutter-nav:disabled {
    opacity: 0.18;
  }

  .gutter-left {
    left: 0;
  }

  .gutter-right {
    right: 0;
  }

  .bottom-nav {
    width: min(42rem, calc(100vw - 2rem));
    margin: 0 auto calc(env(safe-area-inset-bottom) + 0.7rem);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.55rem;
  }

  .bottom-nav button {
    min-height: 52px;
    font-size: 0.88rem;
  }

  .empty-reader,
  #libraryScreen,
  #wordsScreen,
  #settingsScreen {
    max-width: 1120px;
    margin: 0 auto;
    padding: clamp(1.2rem, 2vw, 2rem);
  }

  .import-card {
    min-height: auto;
    width: min(42rem, 100%);
    justify-self: center;
    align-self: center;
    padding: clamp(1.8rem, 3vw, 3rem);
  }

  .import-card h2 {
    max-width: 24rem;
    font-size: clamp(2.2rem, 4vw, 3.8rem);
  }

  .settings-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .word-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .book-library {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .book-group {
    align-content: start;
  }

  .panel-heading h2 {
    font-size: clamp(1.8rem, 2.4vw, 2.4rem);
  }
}

@media (max-width: 520px) {
  body {
    display: block;
    overflow: hidden;
    background: var(--app-bg);
  }

  .app-shell {
    width: 100vw;
    height: 100svh;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 370px) {
  .top-bar {
    padding-inline: 0.8rem;
  }

  .reader-tools {
    gap: 0.35rem;
    padding-inline: 0.55rem;
  }

  .tool-button {
    padding-inline: 0.62rem;
    font-size: 0.78rem;
  }

}
