:root {
  --reader-brand: #d99a5a;
  --reader-accent: #d99a5a;
  --reader-brand-dark: #9e6531;
  --reader-ink: #171717;
  --reader-muted: #858895;
  --reader-soft: #f8f1eb;
  --reader-line: rgba(217, 154, 90, 0.25);
  --reader-panel: rgba(255, 255, 255, 0.94);
}

* {
  box-sizing: border-box;
}

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

body.reader-body {
  margin: 0;
  font-family: "Inter", Arial, sans-serif;
  color: var(--reader-ink);
  background: #ffffff;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.reader-product-switch,
.reader-language-switcher {
  position: fixed;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(217, 154, 90, 0.24);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 24px rgba(36, 28, 16, 0.06);
  backdrop-filter: blur(8px);
}

.reader-product-switch {
  top: 18px;
  left: 18px;
}

.reader-language-switcher {
  top: 18px;
  right: 18px;
}

.reader-product-current,
.reader-product-link,
.reader-language-option {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 12px;
  border: none;
  color: rgba(21, 21, 21, 0.7);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.reader-product-current,
.reader-language-option.is-active {
  color: #ffffff;
  background: var(--reader-brand);
}

.reader-product-link:hover,
.reader-product-link:focus-visible,
.reader-language-option:hover,
.reader-language-option:focus-visible {
  color: #111111;
  background: rgba(217, 154, 90, 0.12);
  outline: none;
}

.reader-access-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 58px 20px 92px;
  background: #ffffff;
}

.reader-access-panel {
  width: fit-content;
  max-width: calc(100vw - 40px);
  min-height: min(420px, calc(100vh - 170px));
  display: grid;
  justify-items: center;
  align-content: start;
  padding-top: clamp(18px, 9vh, 72px);
  text-align: center;
}

.reader-eyebrow {
  margin: 0 0 10px;
  color: var(--reader-brand-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.reader-access-panel h1 {
  width: 100%;
  margin: 0;
  color: var(--reader-muted);
  font-size: clamp(1.12rem, 2vw, 1.34rem);
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: 0;
  white-space: nowrap;
}

.reader-access-mark {
  width: 46px;
  height: auto;
  margin: clamp(54px, 10vh, 72px) 0 10px;
}

.reader-access-form {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.reader-access-form label {
  color: var(--reader-muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.reader-access-form input {
  width: 9ch;
  min-width: 80px;
  max-width: min(270px, calc(100vw - 52px));
  height: 30px;
  border: none;
  border-bottom: 1px solid var(--reader-muted);
  border-radius: 0;
  padding: 0 4px;
  color: var(--reader-ink);
  background: transparent;
  outline: none;
  text-align: center;
  font-size: 0.82rem;
  transition: width 0.16s ease, border-color 0.16s ease;
}

.reader-access-form input::placeholder {
  color: rgba(133, 136, 149, 0.26);
}

.reader-access-form input:focus {
  border-bottom-color: var(--reader-brand);
}

.reader-code-submit,
.reader-question-form button,
.reader-chat-header button,
.reader-logout-form button {
  border: none;
  cursor: pointer;
  font-weight: 800;
}

.reader-code-submit {
  width: 24px;
  height: 24px;
  padding: 0;
  color: var(--reader-muted);
  background: transparent;
  font-size: 1.28rem;
  line-height: 1;
}

.reader-code-submit:hover,
.reader-code-submit:focus-visible {
  color: var(--reader-brand);
  outline: none;
}

.reader-auth-links {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: clamp(74px, 13vh, 92px);
  padding: 0;
}

.reader-auth-links a {
  color: var(--reader-brand);
  font-size: 0.8rem;
  text-decoration: none;
}

.reader-error {
  margin: 0;
  color: #9b2f1f;
  font-size: 0.78rem;
  font-weight: 600;
}

.reader-signoff {
  position: fixed;
  left: 28px;
  bottom: 34px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

.reader-signoff-logo {
  width: 116px;
  height: auto;
  display: block;
}

.reader-signoff-mail {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.reader-signoff-mail a {
  color: #111111;
  text-decoration: none;
}

.reader-signoff-mail span {
  color: var(--reader-brand);
}

.reader-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(360px, 1fr) minmax(250px, 300px);
  background: #ffffff;
}

.reader-sidebar,
.reader-overview {
  background: var(--reader-soft);
}

.reader-sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 30px 30px 28px;
}

.reader-mark {
  display: inline-flex;
  width: 42px;
}

.reader-mark img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.reader-nav-block {
  color: var(--reader-muted);
}

.reader-nav-block summary {
  cursor: pointer;
  color: var(--reader-muted);
  font-size: 0.9rem;
  list-style-position: outside;
}

.reader-search {
  width: 100%;
  height: 32px;
  margin: 18px 0 12px;
  border: 1px solid var(--reader-brand);
  border-radius: 4px;
  padding: 0 8px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
  font-size: 0.84rem;
}

.reader-chat-list,
.reader-book-list {
  display: grid;
  gap: 4px;
}

.reader-chat-item,
.reader-book-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 4px 7px 18px;
  color: var(--reader-muted);
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
}

.reader-chat-item:hover,
.reader-book-item:hover,
.reader-chat-item.is-active,
.reader-book-item.is-active {
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.68);
}

.reader-chat-item span,
.reader-book-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-book-nav {
  margin-top: auto;
}

.reader-logout-form button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--reader-line);
  border-radius: 999px;
  color: rgba(23, 23, 23, 0.56);
  background: rgba(255, 255, 255, 0.68);
}

.reader-chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 38px clamp(26px, 6vw, 90px) 42px;
}

.reader-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.reader-chat-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.reader-chat-header button {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--reader-brand-dark);
  background: rgba(217, 154, 90, 0.12);
}

.reader-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 42px 0 22px;
}

.reader-empty-state {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  color: var(--reader-muted);
}

.reader-empty-state img {
  width: 56px;
  opacity: 0.92;
}

.reader-empty-state h2 {
  margin: 18px 0 8px;
  color: var(--reader-ink);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
}

.reader-empty-state p {
  max-width: 520px;
  margin: 0;
  line-height: 1.5;
}

.reader-starter-questions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.reader-starter-questions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--reader-line);
  border-radius: 999px;
  color: rgba(23, 23, 23, 0.72);
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.reader-message {
  display: flex;
  flex-direction: column;
  margin: 0 0 18px;
}

.reader-message.is-user {
  justify-content: flex-end;
  align-items: flex-end;
}

.reader-message.is-bot {
  align-items: flex-start;
}

.reader-bubble {
  max-width: min(680px, 82%);
  border-radius: 20px;
  padding: 14px 16px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.reader-message.is-user .reader-bubble {
  color: #111111;
  background: #f0e7de;
}

.reader-message.is-bot .reader-bubble {
  border: 1px solid var(--reader-line);
  background: rgba(255, 255, 255, 0.92);
}

.reader-message.is-bot .reader-bubble.has-rich-text {
  white-space: normal;
}

.reader-bubble.has-rich-text p {
  margin: 0 0 10px;
}

.reader-bubble.has-rich-text p:last-child,
.reader-bubble.has-rich-text ul:last-child,
.reader-bubble.has-rich-text ol:last-child {
  margin-bottom: 0;
}

.reader-bubble.has-rich-text ul,
.reader-bubble.has-rich-text ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}

.reader-bubble.has-rich-text li {
  margin: 4px 0;
  padding-left: 2px;
}

.reader-message.is-pending .reader-bubble {
  color: rgba(23, 23, 23, 0.58);
  animation: readerThinking 1.1s ease-in-out infinite;
}

.reader-message.is-error .reader-bubble {
  border-color: rgba(166, 54, 43, 0.3);
  color: #7b2d24;
  background: rgba(255, 246, 244, 0.95);
}


.reader-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.reader-message-actions button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--reader-line);
  border-radius: 6px;
  color: rgba(23, 23, 23, 0.72);
  background: #ffffff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.reader-message-actions button:hover {
  border-color: rgba(23, 23, 23, 0.2);
  color: #171717;
}

.reader-message-actions .reader-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  padding: 0;
}

.reader-message-actions .reader-icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reader-message-actions .reader-icon-button.is-copied {
  color: #1f7a4d;
  border-color: rgba(31, 122, 77, 0.24);
  background: rgba(31, 122, 77, 0.08);
}

@keyframes readerThinking {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.reader-question-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: min(620px, 100%);
  justify-self: center;
}

.reader-question-form input {
  height: 38px;
  border: 2px solid var(--reader-brand);
  border-radius: 6px;
  padding: 0 14px;
  outline: none;
}

.reader-question-form button {
  height: 38px;
  min-width: 86px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--reader-brand);
}

.reader-overview {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 42px 34px;
  text-align: center;
  color: var(--reader-muted);
}

.reader-overview-label {
  margin: 0 0 26px;
}

.reader-cover {
  width: min(128px, 50%);
  aspect-ratio: 0.72;
  object-fit: cover;
  margin-bottom: 24px;
  box-shadow: 0 18px 45px rgba(41, 29, 16, 0.14);
}

.reader-overview h2 {
  margin: 0;
  color: var(--reader-ink);
  font-size: 1.35rem;
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.reader-overview > p {
  margin-top: 8px;
}

.reader-facts {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 34px 0;
}

.reader-facts span,
.reader-overview-section h3 {
  display: block;
  color: var(--reader-muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.reader-facts strong {
  display: block;
  margin-top: 8px;
  color: var(--reader-ink);
  font-size: 0.98rem;
}

.reader-overview-sections {
  width: 100%;
  display: grid;
  gap: 10px;
  justify-items: center;
  margin-top: 28px;
}

.reader-overview-carousel {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.reader-overview-section {
  width: 100%;
  margin-top: 0;
}

.reader-overview-card {
  width: 100%;
  height: 220px;
  min-height: 220px;
  display: grid;
  grid-template-rows: 24px minmax(0, 1fr);
  align-items: start;
  padding: 20px 20px 18px;
  overflow: hidden;
  background: transparent;
}

.reader-overview-card h3 {
  min-height: 24px;
  margin: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.reader-overview-card p {
  align-self: start;
}

.reader-overview-section p {
  margin: 10px 0 0;
  color: var(--reader-muted);
  line-height: 1.45;
  text-align: center;
}

.reader-overview-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 30px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(23, 23, 23, 0.08);
  border-radius: 50%;
  color: var(--reader-muted);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transform: translateY(-50%);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}

.reader-overview-nav-prev {
  left: -36px;
}

.reader-overview-nav-next {
  right: -36px;
}

.reader-overview-nav span {
  display: block;
  translate: 0 -1px;
  font-size: 1.45rem;
  line-height: 1;
}

.reader-overview-nav:hover,
.reader-overview-nav:focus-visible {
  border-color: rgba(36, 107, 90, 0.28);
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
  transform: translateY(calc(-50% - 1px));
}

.reader-overview-nav:disabled {
  opacity: 0.35;
  cursor: default;
  transform: translateY(-50%);
}

.reader-overview-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.reader-overview-dot {
  width: 7px;
  height: 7px;
  border: 0;
  border-radius: 50%;
  background: rgba(120, 128, 151, 0.32);
  cursor: pointer;
}

.reader-overview-dot.is-active {
  background: var(--reader-brand);
}

@media (max-width: 980px) {
  .reader-app {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .reader-overview {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: flex-start;
    gap: 22px;
    text-align: left;
    padding: 22px 28px;
  }

  .reader-overview-label {
    display: none;
  }

  .reader-cover {
    width: 80px;
    margin: 0;
  }

  .reader-facts,
  .reader-overview-section {
    margin: 0;
  }
}

@media (max-width: 720px) {
  .reader-product-switch {
    top: 14px;
    left: 14px;
    max-width: calc(100vw - 132px);
    gap: 4px;
    padding: 5px;
  }

  .reader-language-switcher {
    top: 14px;
    right: 14px;
    gap: 4px;
    padding: 5px;
  }

  .reader-product-current,
  .reader-product-link,
  .reader-language-option {
    min-height: 28px;
    padding: 0 9px;
    font-size: 0.66rem;
  }

  .reader-access-shell {
    padding: 74px 18px 118px;
  }

  .reader-access-panel {
    width: fit-content;
    max-width: calc(100vw - 40px);
    min-height: calc(100vh - 192px);
    padding-top: clamp(24px, 10vh, 70px);
  }

  .reader-access-panel h1 {
    font-size: 1.2rem;
  }

  .reader-auth-links {
    margin-top: 62px;
  }

  .reader-signoff {
    left: 16px;
    bottom: 16px;
  }

  .reader-signoff-logo {
    width: 82px;
  }

  .reader-signoff-mail {
    font-size: 0.72rem;
  }

  .reader-app {
    display: flex;
    min-height: 100dvh;
    flex-direction: column;
  }

  .reader-sidebar {
    display: block;
    padding: 18px;
  }

  .reader-mark {
    margin-bottom: 14px;
  }

  .reader-nav-block {
    margin-top: 12px;
  }

  .reader-book-nav {
    margin-top: 12px;
  }

  .reader-chat-panel {
    min-height: 68vh;
    padding: 22px 18px 24px;
  }

  .reader-chat-header {
    align-items: center;
  }

  .reader-chat-header h1 {
    font-size: 1.5rem;
  }

  .reader-empty-state h2 {
    font-size: 2.35rem;
  }

  .reader-bubble {
    max-width: 94%;
  }

  .reader-overview {
    display: grid;
    grid-template-columns: 74px 1fr;
  }

  .reader-overview-sections,
  .reader-overview-section,
  .reader-facts {
    grid-column: 1 / -1;
  }
}

/* AI Reader workspace states */
.reader-app {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  grid-template-columns: 300px minmax(420px, 1fr) 300px;
  background: #ffffff;
}

.reader-sidebar {
  position: relative;
  padding: 28px 30px 30px;
}

.reader-mark {
  position: absolute;
  top: 28px;
  left: 30px;
  width: 42px;
  z-index: 3;
}

.reader-nav-block {
  width: 180px;
  color: var(--reader-muted);
  font-size: 0.8rem;
}

.reader-nav-block summary {
  width: max-content;
  max-width: 100%;
  color: var(--reader-muted);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.25;
  list-style-position: outside;
}

.reader-nav-block summary::marker {
  font-size: 0.72rem;
}

.reader-search {
  width: 170px;
  height: 29px;
  margin: 16px 0 12px;
  border: 1px solid var(--reader-brand);
  border-radius: 3px;
  padding: 0 6px;
  color: var(--reader-muted);
  background: #ffffff;
  font-size: 0.72rem;
}

.reader-search::placeholder {
  color: rgba(133, 136, 149, 0.9);
}

.reader-chat-list,
.reader-book-list {
  display: grid;
  gap: 8px;
}

.reader-folder-title,
.reader-chat-placeholder,
.reader-chat-item,
.reader-book-child {
  min-height: 17px;
  border: 0;
  padding: 0;
  color: var(--reader-muted);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
}

.reader-folder-title {
  padding-left: 14px;
}

.reader-folder-title::before {
  content: "⌄";
  margin-right: 7px;
  color: var(--reader-muted);
  font-size: 0.75rem;
}

.reader-chat-placeholder,
.reader-chat-item,
.reader-book-child {
  padding-left: 35px;
}

.reader-chat-item,
.reader-book-child {
  cursor: pointer;
}

.reader-chat-item:hover,
.reader-book-child:hover,
.reader-chat-item.is-active,
.reader-book-child.is-active {
  color: var(--reader-ink);
  background: transparent;
}

.reader-empty-list {
  margin: 0;
  padding-left: 18px;
  color: var(--reader-muted);
  font-size: 0.78rem;
}

.reader-logout-form {
  display: none;
}

.reader-chat-header {
  display: none;
}

.reader-app:not(.has-selected-book) {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
}

.reader-app:not(.has-selected-book) .reader-sidebar {
  position: static;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: #ffffff;
}

.reader-app:not(.has-selected-book) .reader-mark {
  top: 29px;
  left: 29px;
}

.reader-app:not(.has-selected-book) .reader-chat-nav {
  position: fixed;
  top: 43px;
  left: 91px;
  z-index: 4;
}

.reader-app:not(.has-selected-book) .reader-book-nav {
  position: fixed;
  left: 91px;
  bottom: 50px;
  z-index: 4;
  display: flex;
  flex-direction: column-reverse;
}

.reader-app:not(.has-selected-book) .reader-book-nav .reader-search {
  margin-top: 0;
}

.reader-app:not(.has-selected-book) .reader-book-nav[open] {
  width: 220px;
}

.reader-app:not(.has-selected-book) .reader-chat-panel,
.reader-app:not(.has-selected-book) .reader-overview {
  display: none;
}

.reader-app.has-selected-book {
  display: grid;
}

.reader-app.has-selected-book .reader-sidebar,
.reader-app.has-selected-book .reader-overview {
  background: var(--reader-soft);
}

.reader-app.has-selected-book .reader-chat-nav {
  margin-top: 12px;
  margin-left: 62px;
}

.reader-app.has-selected-book .reader-book-nav {
  margin-top: auto;
  margin-left: 62px;
  display: flex;
  flex-direction: column-reverse;
}

.reader-app.has-selected-book .reader-book-nav:not([open]) .reader-search,
.reader-app.has-selected-book .reader-book-nav:not([open]) .reader-book-list {
  display: none;
}

.reader-app.has-selected-book .reader-chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 0 0 45px;
}

.reader-app.has-selected-book .reader-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 0 clamp(32px, 7vw, 88px) 22px;
}

.reader-app.has-selected-book .reader-empty-state {
  min-height: 100%;
}

.reader-app.has-selected-book .reader-empty-state h2 {
  margin-top: 18px;
  font-size: clamp(2rem, 3.2vw, 3rem);
  letter-spacing: -0.06em;
  line-height: 0.98;
}

.reader-app.has-selected-book .reader-question-form {
  width: min(398px, calc(100% - 48px));
  grid-template-columns: 1fr;
  gap: 0;
  justify-self: center;
}

.reader-app.has-selected-book .reader-question-form input {
  height: 38px;
  border: 2px solid var(--reader-brand);
  border-radius: 5px;
  padding: 0 18px;
  text-align: center;
  font-size: 0.7rem;
}

.reader-app.has-selected-book .reader-question-form button {
  display: none;
}

.reader-app.has-selected-book .reader-overview {
  display: flex;
  padding: 43px 34px 42px;
}

.reader-app.has-selected-book .reader-overview-label {
  margin: 0 0 27px;
  font-size: 0.82rem;
}

.reader-app.has-selected-book .reader-cover {
  width: 128px;
  margin-bottom: 31px;
}

.reader-app.has-selected-book .reader-overview h2,
.reader-app.has-selected-book #reader-book-author,
.reader-app.has-selected-book .reader-facts strong,
.reader-app.has-selected-book .reader-overview-section p {
  display: none;
}

.reader-app.has-selected-book .reader-facts {
  margin: 0;
}

.reader-app.has-selected-book .reader-facts span,
.reader-app.has-selected-book .reader-overview-section h3 {
  font-size: 0.74rem;
  font-weight: 400;
}

.reader-app.has-selected-book .reader-overview-section {
  margin-top: 86px;
}

@media (max-width: 980px) {
  .reader-app {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .reader-app.has-selected-book .reader-overview {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 96px 1fr 1fr;
    align-items: start;
    text-align: center;
  }

  .reader-app.has-selected-book .reader-overview-label {
    display: block;
    grid-column: 1 / -1;
  }

  .reader-app.has-selected-book .reader-cover {
    width: 80px;
  }
}

@media (max-width: 720px) {
  .reader-app:not(.has-selected-book) .reader-mark {
    top: 24px;
    left: 24px;
  }

  .reader-app:not(.has-selected-book) .reader-chat-nav {
    top: 39px;
    left: 86px;
  }

  .reader-app:not(.has-selected-book) .reader-book-nav {
    left: 86px;
    bottom: 42px;
  }

  .reader-app.has-selected-book {
    display: flex;
    min-height: 100dvh;
    flex-direction: column;
  }

  .reader-app.has-selected-book .reader-sidebar {
    min-height: 220px;
    padding: 24px;
  }

  .reader-app.has-selected-book .reader-mark {
    top: 24px;
    left: 24px;
  }

  .reader-app.has-selected-book .reader-chat-nav {
    margin-left: 62px;
    margin-top: 15px;
  }

  .reader-app.has-selected-book .reader-book-nav {
    margin-left: 62px;
    margin-top: 70px;
  }

  .reader-app.has-selected-book .reader-chat-panel {
    min-height: 58vh;
    padding-bottom: 24px;
  }

  .reader-app.has-selected-book .reader-empty-state h2 {
    font-size: 2.45rem;
  }

  .reader-app.has-selected-book .reader-overview {
    grid-template-columns: 80px 1fr;
    padding: 22px 24px;
  }
}

/* AI Reader dropdown controls */
.reader-nav-block summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
}

.reader-nav-block summary::-webkit-details-marker {
  display: none;
}

.reader-nav-block summary::before {
  content: "›";
  display: inline-block;
  color: var(--reader-muted);
  font-size: 1.05rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.14s ease;
}

.reader-nav-block[open] summary::before {
  transform: rotate(90deg);
}

.reader-book-nav[open] summary::before {
  transform: rotate(-90deg);
}

.reader-search {
  width: 200px;
  height: 31px;
  margin-top: 20px;
  margin-bottom: 7px;
  font-size: 0.84rem;
}

.reader-folder-button,
.reader-chat-item,
.reader-book-child,
.reader-empty-list,
.reader-folder-action,
.reader-list-actions button {
  font-size: 0.9rem;
}

.reader-folder-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  gap: 7px;
  border: 0;
  padding: 0;
  color: var(--reader-muted);
  background: transparent;
  cursor: pointer;
  line-height: 1.45;
  text-align: left;
}

.reader-folder-button .reader-chevron {
  display: inline-block;
  color: var(--reader-muted);
  font-size: 1.02rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.14s ease;
}

.reader-folder-button.is-open .reader-chevron {
  transform: rotate(90deg);
}

.reader-chat-item,
.reader-book-child {
  width: 100%;
  border: 0;
  padding: 2px 0 6px 39px;
  color: var(--reader-muted);
  background: transparent;
  cursor: pointer;
  line-height: 1.35;
  text-align: left;
}

.reader-chat-item {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AI Reader selected-state proportions */
.reader-app.has-selected-book {
  grid-template-columns: 300px minmax(460px, 1fr) clamp(300px, 23vw, 440px);
  background: #ffffff;
}

.reader-app.has-selected-book .reader-sidebar {
  background: #ffffff;
}

.reader-app.has-selected-book .reader-chat-panel {
  padding-bottom: 48px;
}

.reader-app.has-selected-book .reader-messages {
  width: 100%;
  max-width: 940px;
  justify-self: center;
  padding-top: 86px;
  padding-left: clamp(34px, 5vw, 74px);
  padding-right: clamp(34px, 5vw, 74px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, rgba(0, 0, 0, 0.25) 26px, #000 88px);
  mask-image: linear-gradient(to bottom, transparent 0, rgba(0, 0, 0, 0.25) 26px, #000 88px);
}

.reader-bubble {
  max-width: min(620px, 76%);
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.42;
}

.reader-message.is-user .reader-bubble {
  max-width: min(520px, 70%);
}

.reader-app.has-selected-book .reader-overview {
  background: var(--reader-soft);
  padding: 48px clamp(44px, 4.4vw, 78px) 54px;
}

.reader-app.has-selected-book .reader-overview-label {
  margin-bottom: 30px;
}

.reader-app.has-selected-book .reader-cover {
  width: clamp(132px, 8.8vw, 176px);
  margin-bottom: 36px;
}

.reader-app.has-selected-book .reader-facts {
  gap: clamp(42px, 5vw, 88px);
}

.reader-app.has-selected-book .reader-overview-section {
  margin-top: 54px;
}

.reader-app.has-selected-book .reader-question-form {
  position: relative;
  display: block;
  width: min(560px, calc(100% - 72px));
  margin: 0 auto;
}

.reader-app.has-selected-book .reader-question-form input {
  width: 100%;
  height: 46px;
  border: 1px solid rgba(217, 154, 90, 0.34);
  border-radius: 999px;
  padding: 0 58px 0 22px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 38px rgba(42, 30, 18, 0.045);
  font-size: 0.86rem;
  line-height: 1;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.reader-app.has-selected-book .reader-question-form input::placeholder {
  color: rgba(133, 136, 149, 0.82);
  opacity: 1;
  transition: opacity 0.12s ease;
}

.reader-app.has-selected-book .reader-question-form input:focus {
  border-color: rgba(217, 154, 90, 0.78);
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(42, 30, 18, 0.07), 0 0 0 3px rgba(217, 154, 90, 0.08);
}

.reader-app.has-selected-book .reader-question-form input:focus::placeholder {
  opacity: 0;
}

.reader-app.has-selected-book .reader-question-form button {
  position: absolute;
  top: 50%;
  right: 6px;
  display: inline-flex;
  width: 34px;
  height: 34px;
  min-width: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--reader-brand);
  box-shadow: 0 10px 22px rgba(217, 154, 90, 0.24);
  font-size: 0;
  transform: translateY(-50%);
}

.reader-app.has-selected-book .reader-question-form button::before {
  content: "›";
  font-size: 1.35rem;
  line-height: 1;
  transform: translateX(1px);
}

.reader-app.has-selected-book .reader-question-form button:hover,
.reader-app.has-selected-book .reader-question-form button:focus-visible {
  background: var(--reader-brand-dark);
  outline: none;
}

@media (max-width: 980px) {
  .reader-app.has-selected-book {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .reader-app.has-selected-book .reader-messages {
    max-width: none;
    padding-top: 64px;
  }
}

/* Aligned multiline AI Reader composer */
.reader-app.has-selected-book .reader-messages {
  width: min(760px, calc(100% - 92px));
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.reader-app.has-selected-book .reader-question-form {
  width: min(760px, calc(100% - 92px));
  max-width: none;
}

.reader-bubble {
  max-width: min(600px, 82%);
}

.reader-message.is-user .reader-bubble {
  max-width: min(460px, 68%);
}

.reader-app.has-selected-book .reader-question-form textarea {
  width: 100%;
  min-height: 46px;
  max-height: calc(1.42em * 5 + 24px);
  resize: none;
  border: 1px solid rgba(217, 154, 90, 0.34);
  border-radius: 23px;
  padding: 13px 58px 11px 22px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 38px rgba(42, 30, 18, 0.045);
  font-size: 0.86rem;
  line-height: 1.42;
  text-align: left;
  outline: none;
  overflow-y: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.reader-app.has-selected-book .reader-question-form textarea::placeholder {
  color: rgba(133, 136, 149, 0.82);
  opacity: 1;
  transition: opacity 0.12s ease;
}

.reader-app.has-selected-book .reader-question-form textarea:focus {
  border-color: rgba(217, 154, 90, 0.78);
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(42, 30, 18, 0.07), 0 0 0 3px rgba(217, 154, 90, 0.08);
}

.reader-app.has-selected-book .reader-question-form textarea:focus::placeholder {
  opacity: 0;
}

.reader-app.has-selected-book .reader-question-form button {
  top: auto;
  right: 6px;
  bottom: 6px;
  transform: none;
}

.reader-app.has-selected-book .reader-question-form textarea::-webkit-scrollbar {
  width: 6px;
}

.reader-app.has-selected-book .reader-question-form textarea::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(217, 154, 90, 0.28);
}

@media (max-width: 720px) {
  .reader-app.has-selected-book .reader-messages,
  .reader-app.has-selected-book .reader-question-form {
    width: calc(100% - 38px);
  }
}

/* Final AI Reader message spacing and overview fill */
.reader-app.has-selected-book .reader-messages,
.reader-app.has-selected-book .reader-question-form {
  width: min(760px, calc(100% - 140px));
  max-width: none;
}

.reader-app.has-selected-book .reader-message {
  padding-left: 46px;
  padding-right: 46px;
}

.reader-app.has-selected-book .reader-bubble {
  max-width: min(620px, 100%);
  font-family: inherit;
}

.reader-app.has-selected-book .reader-message.is-user .reader-bubble {
  max-width: min(520px, 100%);
}

.reader-app.has-selected-book .reader-book-nav {
  margin-bottom: 38px;
}

.reader-app.has-selected-book .reader-overview h2,
.reader-app.has-selected-book #reader-book-author,
.reader-app.has-selected-book .reader-facts strong,
.reader-app.has-selected-book .reader-overview-section p {
  display: block;
}

.reader-app.has-selected-book .reader-overview h2 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 1rem;
  line-height: 1.15;
}

.reader-app.has-selected-book #reader-book-author {
  margin: 0 0 22px;
  color: var(--reader-muted);
  font-size: 0.8rem;
}

.reader-app.has-selected-book .reader-facts strong {
  margin-top: 7px;
  font-size: 0.86rem;
  line-height: 1.25;
}

.reader-app.has-selected-book .reader-overview-section p {
  max-width: 230px;
  margin: 12px auto 0;
  color: var(--reader-muted);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
}

.reader-app.has-selected-book .reader-overview-sections .reader-overview-section + .reader-overview-section {
  margin-top: 58px;
}

.reader-app.has-selected-book .reader-empty-state img {
  width: 42px;
}

.reader-app.has-selected-book .reader-empty-state p {
  max-width: 460px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.reader-app.has-selected-book .reader-starter-questions {
  gap: 8px;
  margin-top: 20px;
}

.reader-app.has-selected-book .reader-starter-questions button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

@media (max-width: 720px) {
  .reader-app.has-selected-book .reader-messages,
  .reader-app.has-selected-book .reader-question-form {
    width: calc(100% - 38px);
  }

  .reader-app.has-selected-book .reader-message {
    padding-left: 0;
    padding-right: 0;
  }
}

/* Restore message size, only move rows inward */
.reader-app.has-selected-book .reader-messages,
.reader-app.has-selected-book .reader-question-form {
  width: min(860px, calc(100% - 96px));
  max-width: none;
}

.reader-app.has-selected-book .reader-message {
  padding-left: 0;
  padding-right: 0;
}

.reader-app.has-selected-book .reader-message.is-bot {
  padding-left: 42px;
}

.reader-app.has-selected-book .reader-message.is-user {
  padding-right: 42px;
}

.reader-app.has-selected-book .reader-bubble {
  max-width: min(680px, 82%);
}

.reader-app.has-selected-book .reader-message.is-user .reader-bubble {
  max-width: min(520px, 70%);
}

@media (max-width: 720px) {
  .reader-app.has-selected-book .reader-messages,
  .reader-app.has-selected-book .reader-question-form {
    width: calc(100% - 38px);
  }

  .reader-app.has-selected-book .reader-message.is-bot,
  .reader-app.has-selected-book .reader-message.is-user {
    padding-left: 0;
    padding-right: 0;
  }
}

/* Absolute final sizing override: keep old bubble size, only offset inward */
.reader-app.has-selected-book .reader-messages {
  width: min(640px, calc(100% - 96px)) !important;
  max-width: none !important;
}

.reader-app.has-selected-book .reader-question-form {
  width: min(640px, calc(100% - 96px)) !important;
  max-width: none !important;
}

.reader-app.has-selected-book .reader-message.is-bot {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.reader-app.has-selected-book .reader-message.is-user {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.reader-app.has-selected-book .reader-message.is-bot .reader-bubble {
  width: 100% !important;
  max-width: none !important;
}

.reader-app.has-selected-book .reader-message.is-user .reader-bubble {
  max-width: min(520px, 72%) !important;
}

@media (max-width: 720px) {
  .reader-app.has-selected-book .reader-messages {
    width: calc(100% - 38px) !important;
  }

  .reader-app.has-selected-book .reader-message.is-bot,
  .reader-app.has-selected-book .reader-message.is-user {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .reader-app.has-selected-book .reader-message.is-bot .reader-bubble,
  .reader-app.has-selected-book .reader-message.is-user .reader-bubble {
    width: auto !important;
    max-width: 94% !important;
  }
}

/* Final AI Reader chat lane alignment */
.reader-app.has-selected-book .reader-messages,
.reader-app.has-selected-book .reader-question-form {
  width: min(640px, calc(100% - 150px));
  max-width: none;
}

.reader-app.has-selected-book .reader-bubble {
  max-width: min(540px, 82%);
  font-family: inherit;
}

.reader-app.has-selected-book .reader-message.is-user .reader-bubble {
  max-width: min(390px, 64%);
}

.reader-app.has-selected-book .reader-question-form textarea,
.reader-app.has-selected-book .reader-question-form textarea::placeholder {
  font-family: inherit;
  font-size: 0.86rem;
  letter-spacing: 0;
}

@media (max-width: 720px) {
  .reader-app.has-selected-book .reader-messages,
  .reader-app.has-selected-book .reader-question-form {
    width: calc(100% - 38px);
  }
}

.reader-book-child span,
.reader-book-child small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-book-child small {
  margin-top: 1px;
  color: rgba(133, 136, 149, 0.72);
  font-size: 0.74rem;
}

.reader-book-nav[open] {
  max-height: min(70vh, 560px);
}

.reader-book-nav[open] summary {
  margin-top: 13px;
}

.reader-book-nav[open] .reader-search {
  margin-bottom: 10px;
}

.reader-book-nav[open] .reader-book-list {
  max-height: min(52vh, 390px);
  overflow-y: auto;
  padding-bottom: 2px;
}

.reader-book-list .reader-folder-button {
  margin-bottom: 1px;
}

.reader-book-list .reader-book-child {
  padding-top: 0;
  padding-bottom: 4px;
}

.reader-book-list .reader-book-child small {
  margin-top: 0;
}

.reader-empty-list {
  margin: 0;
  padding: 1px 0 4px 28px;
}

.reader-folder-action {
  width: max-content;
  border: 0;
  padding: 0 0 14px 39px;
  color: var(--reader-muted);
  background: transparent;
  cursor: pointer;
  line-height: 1.35;
  text-align: left;
}

.reader-chat-item.is-last-in-folder {
  margin-bottom: 12px;
}

.reader-list-actions {
  display: flex;
  justify-content: flex-start;
  width: 200px;
  gap: 43px;
  margin: 0 0 22px;
  padding-left: 4px;
}

.reader-list-actions button {
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--reader-muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 400;
}

.reader-list-actions button:hover,
.reader-list-actions button:focus-visible,
.reader-folder-button:hover,
.reader-folder-button:focus-visible,
.reader-chat-item:hover,
.reader-chat-item:focus-visible,
.reader-book-child:hover,
.reader-book-child:focus-visible,
.reader-folder-action:hover,
.reader-folder-action:focus-visible,
.reader-chat-item.is-active,
.reader-book-child.is-active {
  color: var(--reader-ink);
  outline: none;
}

.reader-chat-list {
  gap: 0;
}

.reader-folder-button {
  width: calc(100% - 20px);
  margin: 0 0 7px 18px;
}

.reader-chat-item,
.reader-folder-action {
  padding-left: 48px;
}

.reader-chat-nav,
.reader-book-nav {
  width: 210px;
}

.reader-add-code-form {
  width: 210px;
  margin: 0 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 166px) 34px;
  align-items: center;
  column-gap: 10px;
}

.reader-add-code-form input {
  min-width: 0;
  height: 30px;
  border: 1px solid var(--reader-accent);
  border-radius: 3px;
  padding: 0 8px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.78);
  font: 400 0.84rem/1.2 Inter, sans-serif;
  outline: none;
}

.reader-add-code-form input::placeholder {
  color: rgba(133, 136, 149, 0.74);
}

.reader-add-code-form input:focus {
  box-shadow: 0 0 0 2px rgba(218, 147, 82, 0.14);
}

.reader-add-code-form button {
  border: 0;
  min-width: 30px;
  padding: 0 2px;
  color: var(--reader-accent);
  background: transparent;
  font: 500 0.84rem/1 Inter, sans-serif;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.reader-add-code-form p {
  grid-column: 1 / -1;
  min-height: 18px;
  margin: 5px 0 0;
  color: var(--reader-muted);
  font: 400 0.72rem/1.35 Inter, sans-serif;
}

.reader-add-code-form p.is-success {
  color: var(--reader-accent);
}

.reader-add-code-form p.is-error {
  color: #9f3f2f;
}

.reader-inline-auth {
  width: 210px;
  display: flex;
  gap: 34px;
  margin: 0 0 26px 4px;
}

.reader-inline-auth a {
  color: var(--reader-muted);
  text-decoration: none;
  font: 400 0.84rem/1.2 Inter, sans-serif;
}

.reader-inline-auth a:hover,
.reader-inline-auth a:focus-visible {
  color: var(--reader-accent);
  outline: none;
}

.reader-app.has-selected-book .reader-add-code-form,
.reader-app.has-selected-book .reader-inline-auth {
  margin-left: 62px;
}

.reader-app.has-selected-book .reader-book-nav {
  margin-bottom: -18px !important;
}

.reader-app.has-selected-book .reader-add-code-form {
  width: 178px;
  grid-template-columns: minmax(0, 154px) 22px;
  column-gap: 2px;
  margin-top: 0;
  margin-bottom: -4px;
}

.reader-app.has-selected-book .reader-add-code-form input {
  padding-left: 4px;
  padding-right: 4px;
  font-size: 0.78rem;
}

.reader-app.has-selected-book .reader-add-code-form button {
  min-width: 22px;
  padding: 0;
  font-size: 0.8rem;
}

.reader-add-code-form p:empty {
  display: none;
}

.reader-inline-auth {
  margin-top: 0;
  margin-bottom: 0;
}

body.reader-unlocked {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.reader-unlocked .reader-app.has-selected-book {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.reader-unlocked .reader-app.has-selected-book .reader-sidebar,
body.reader-unlocked .reader-app.has-selected-book .reader-overview {
  min-height: 0;
  overflow-y: auto;
}

body.reader-unlocked .reader-app.has-selected-book .reader-chat-panel {
  min-height: 0;
  overflow: hidden;
}

body.reader-unlocked .reader-app.has-selected-book .reader-messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Keep the scrollbar outside the visible chat lane so it never crosses bubbles. */
.reader-app.has-selected-book {
  --reader-scroll-rail: 22px;
}

body.reader-unlocked .reader-app.has-selected-book .reader-messages {
  width: min(662px, calc(100% - 128px)) !important;
  padding-right: var(--reader-scroll-rail) !important;
  margin-right: calc(var(--reader-scroll-rail) * -1);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 23, 23, 0.18) transparent;
}

body.reader-unlocked .reader-app.has-selected-book .reader-messages::-webkit-scrollbar {
  width: 8px;
}

body.reader-unlocked .reader-app.has-selected-book .reader-messages::-webkit-scrollbar-track {
  background: transparent;
}

body.reader-unlocked .reader-app.has-selected-book .reader-messages::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.2);
  background-clip: content-box;
}

body.reader-unlocked .reader-app.has-selected-book .reader-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(23, 23, 23, 0.28);
  background-clip: content-box;
}

.reader-chat-row {
  position: relative;
  display: block;
  width: 100%;
}

.reader-folder-row {
  position: relative;
  display: block;
  width: 100%;
}

.reader-chat-row.is-last-in-folder {
  margin-bottom: 12px;
}

.reader-chat-row .reader-chat-item {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: padding-right 140ms ease;
}

.reader-folder-row .reader-folder-button {
  overflow: hidden;
  transition: padding-right 140ms ease;
}

.reader-folder-row .reader-folder-button span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-chat-row:hover .reader-chat-item,
.reader-chat-row:focus-within .reader-chat-item,
.reader-chat-row.is-active .reader-chat-item {
  padding-right: 88px;
}

.reader-folder-row:hover .reader-folder-button,
.reader-folder-row:focus-within .reader-folder-button {
  padding-right: 88px;
}

.reader-chat-actions {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  gap: 7px;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.reader-folder-actions {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  gap: 7px;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.reader-chat-row:hover .reader-chat-actions,
.reader-chat-row:focus-within .reader-chat-actions,
.reader-chat-row.is-active .reader-chat-actions {
  opacity: 1;
  pointer-events: auto;
}

.reader-folder-row:hover .reader-folder-actions,
.reader-folder-row:focus-within .reader-folder-actions {
  opacity: 1;
  pointer-events: auto;
}

.reader-chat-action {
  border: 0;
  padding: 0;
  color: rgba(133, 136, 149, 0.76);
  background: transparent;
  cursor: pointer;
  font-size: 0.66rem;
  line-height: 1;
}

.reader-folder-action-link {
  border: 0;
  padding: 0;
  color: rgba(133, 136, 149, 0.76);
  background: transparent;
  cursor: pointer;
  font-size: 0.66rem;
  line-height: 1;
}

.reader-chat-action:hover,
.reader-chat-action:focus-visible {
  color: var(--reader-ink);
  outline: none;
}

.reader-folder-action-link:hover,
.reader-folder-action-link:focus-visible {
  color: var(--reader-ink);
  outline: none;
}

.reader-chat-action.is-danger:hover,
.reader-chat-action.is-danger:focus-visible {
  color: #a94f3d;
}

.reader-folder-action-link.is-danger:hover,
.reader-folder-action-link.is-danger:focus-visible {
  color: #a94f3d;
}

.reader-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(30, 27, 24, 0.24);
  backdrop-filter: blur(5px);
}

.reader-modal {
  width: min(370px, calc(100vw - 42px));
  border: 1px solid rgba(217, 154, 90, 0.28);
  border-radius: 14px;
  padding: 22px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 26px 70px rgba(38, 29, 21, 0.16);
}

.reader-modal h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.reader-modal p {
  margin: 10px 0 16px;
  color: var(--reader-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.reader-modal input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--reader-brand);
  border-radius: 7px;
  padding: 0 11px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.94);
  outline: none;
  font-size: 0.86rem;
}

.reader-modal input:focus {
  box-shadow: 0 0 0 4px rgba(217, 154, 90, 0.12);
}

.reader-modal input.is-invalid {
  border-color: #a94f3d;
}

.reader-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.reader-modal-actions button {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 15px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.reader-modal-cancel {
  border: 1px solid rgba(217, 154, 90, 0.22);
  color: rgba(23, 23, 23, 0.72);
  background: #ffffff;
}

.reader-modal-confirm {
  border: 1px solid var(--reader-brand);
  color: #ffffff;
  background: var(--reader-brand);
}

.reader-modal-confirm.is-danger {
  border-color: #a94f3d;
  background: #a94f3d;
}

.reader-modal-cancel:focus-visible,
.reader-modal-confirm:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(217, 154, 90, 0.13);
}

@media (max-width: 720px) {
  .reader-app.has-selected-book {
    --reader-scroll-rail: 16px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-messages {
    width: calc(100% - 22px) !important;
  }
}


.reader-app.has-selected-book .reader-overview-carousel .reader-overview-section {
  margin-top: 0;
}

.reader-app.has-selected-book .reader-overview-card {
  height: 220px;
  min-height: 220px;
  background: transparent;
}

.reader-app.has-selected-book .reader-overview-card p {
  display: block;
  max-width: 260px;
  margin: 12px auto 0;
  text-align: center;
}


@media (max-width: 720px) {
  .reader-overview-card,
  .reader-app.has-selected-book .reader-overview-card {
    height: 240px;
    min-height: 240px;
    padding: 18px 18px 16px;
  }

  .reader-overview-nav-prev {
    left: -28px;
  }

  .reader-overview-nav-next {
    right: -28px;
  }
}

.reader-game-panel {
  position: relative;
  width: 100%;
  margin-top: 30px;
  text-align: left;
}

.reader-game-launcher {
  width: 100%;
  display: grid;
  gap: 11px;
  border: 1px solid rgba(23, 23, 23, 0.08);
  border-radius: 8px;
  padding: 14px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 12px 28px rgba(41, 29, 16, 0.06);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.reader-game-launcher:hover,
.reader-game-launcher:focus-visible,
.reader-game-panel.is-open .reader-game-launcher {
  border-color: rgba(36, 107, 90, 0.28);
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  box-shadow: 0 16px 34px rgba(41, 29, 16, 0.08);
}

.reader-game-launcher:hover,
.reader-game-launcher:focus-visible {
  transform: translateY(-1px);
}

.reader-game-launcher-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.reader-game-launcher-top strong,
.reader-game-popover-header h3,
.reader-game-heading h3 {
  margin: 0;
  color: rgba(23, 23, 23, 0.76);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.1;
  text-transform: uppercase;
}

.reader-game-launcher-top small {
  display: block;
  margin-top: 4px;
  color: var(--reader-muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
}

.reader-game-launcher-top em,
.reader-game-heading strong {
  flex: 0 0 auto;
  color: #246b5a;
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.reader-progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.08);
}

.reader-progress-track span {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #246b5a, #d99a5a);
}

.reader-game-launcher-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  color: var(--reader-muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.reader-game-launcher-stats span {
  min-width: 0;
  white-space: nowrap;
}

.reader-game-launcher-stats strong {
  color: var(--reader-ink);
  font-size: 0.76rem;
  font-weight: 900;
}

.reader-game-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 12px);
  z-index: 30;
  display: grid;
  gap: 15px;
  max-height: min(640px, calc(100vh - 96px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(23, 23, 23, 0.1);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 250, 244, 0.98);
  box-shadow: 0 22px 52px rgba(41, 29, 16, 0.16);
}

.reader-game-popover[hidden] {
  display: none;
}

.reader-game-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reader-game-popover-header button {
  width: 30px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(23, 23, 23, 0.08);
  border-radius: 50%;
  color: var(--reader-muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.reader-game-popover-header button:hover,
.reader-game-popover-header button:focus-visible {
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.96);
  outline: none;
}

.reader-game-section {
  width: 100%;
  border-top: 1px solid rgba(23, 23, 23, 0.08);
  padding-top: 14px;
}

.reader-game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.reader-quest-list,
.reader-mode-list,
.reader-companion-list {
  display: grid;
  gap: 8px;
}

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

.reader-quest-card,
.reader-mode-card,
.reader-companion-card {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(217, 154, 90, 0.22);
  border-radius: 8px;
  padding: 10px;
  color: rgba(23, 23, 23, 0.72);
  background: rgba(255, 255, 255, 0.66);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.reader-quest-card:hover,
.reader-mode-card:hover,
.reader-companion-card:hover,
.reader-quest-card:focus-visible,
.reader-mode-card:focus-visible,
.reader-companion-card:focus-visible {
  border-color: rgba(36, 107, 90, 0.32);
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
  transform: translateY(-1px);
}

.reader-quest-card.is-active,
.reader-mode-card.is-active,
.reader-companion-card.is-active {
  border-color: rgba(36, 107, 90, 0.38);
  color: var(--reader-ink);
  background: rgba(36, 107, 90, 0.09);
}

.reader-quest-card.is-complete {
  border-color: rgba(36, 107, 90, 0.24);
}

.reader-quest-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.reader-quest-card span,
.reader-mode-card strong,
.reader-companion-card strong,
.reader-mode-card small,
.reader-companion-card small {
  min-width: 0;
}

.reader-quest-card strong,
.reader-mode-card strong,
.reader-companion-card strong {
  display: block;
  overflow: hidden;
  color: inherit;
  font-size: 0.78rem;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-quest-card small,
.reader-mode-card small,
.reader-companion-card small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--reader-muted);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.reader-quest-card em {
  color: #246b5a;
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.reader-mode-card,
.reader-companion-card {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 720px) {
  .reader-game-popover {
    position: fixed;
    left: 18px;
    right: 18px;
    bottom: 18px;
    max-height: min(72vh, 620px);
  }

  .reader-mode-list,
  .reader-companion-list {
    grid-template-columns: 1fr;
  }
}
.reader-auth-body {
  min-height: 100vh;
  margin: 0;
  color: var(--reader-ink);
  background: #ffffff;
  font-family: Inter, sans-serif;
}

.reader-auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 38px 20px;
}

.reader-auth-card {
  width: min(360px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.reader-auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.reader-auth-logo img {
  width: 44px;
  height: auto;
}

.reader-auth-kicker {
  margin: 0 0 8px;
  color: var(--reader-accent);
  font: 700 0.78rem/1.2 Inter, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.reader-auth-card h1 {
  margin: 0;
  color: var(--reader-ink);
  font: 700 2rem/1.1 Inter, sans-serif;
}

.reader-auth-form {
  width: 100%;
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.reader-auth-form label {
  display: grid;
  gap: 6px;
  color: var(--reader-muted);
  font: 500 0.82rem/1.25 Inter, sans-serif;
  text-align: left;
}

.reader-auth-form input {
  width: 100%;
  box-sizing: border-box;
  height: 40px;
  border: 1px solid rgba(218, 147, 82, 0.68);
  border-radius: 3px;
  padding: 0 12px;
  color: var(--reader-ink);
  background: rgba(255, 255, 255, 0.86);
  font: 400 0.95rem/1.2 Inter, sans-serif;
  outline: none;
}

.reader-auth-form input:focus {
  border-color: var(--reader-accent);
  box-shadow: 0 0 0 3px rgba(218, 147, 82, 0.13);
}

.reader-auth-submit {
  height: 42px;
  margin-top: 4px;
  border: 1px solid var(--reader-accent);
  border-radius: 999px;
  color: #ffffff;
  background: var(--reader-accent);
  font: 700 0.95rem/1 Inter, sans-serif;
  cursor: pointer;
}

.reader-auth-submit:hover,
.reader-auth-submit:focus-visible {
  filter: brightness(0.96);
  outline: none;
}

.reader-auth-error {
  width: 100%;
  box-sizing: border-box;
  margin: 20px 0 0;
  border: 1px solid rgba(159, 63, 47, 0.2);
  border-radius: 6px;
  padding: 10px 12px;
  color: #9f3f2f;
  background: rgba(159, 63, 47, 0.05);
  font: 500 0.82rem/1.35 Inter, sans-serif;
  text-align: left;
}

.reader-auth-switch {
  margin: 18px 0 0;
  color: var(--reader-muted);
  font: 400 0.88rem/1.4 Inter, sans-serif;
}

.reader-auth-switch a,
.reader-auth-back {
  color: var(--reader-accent);
  text-decoration: none;
}

.reader-auth-switch a:hover,
.reader-auth-switch a:focus-visible,
.reader-auth-back:hover,
.reader-auth-back:focus-visible {
  color: var(--reader-ink);
  outline: none;
}

.reader-auth-back {
  margin-top: 22px;
  font: 500 0.84rem/1.3 Inter, sans-serif;
}

/* Balanced AI Overview tightening: preserve the airy version and only remove the last bit of excess height. */
@media (min-width: 981px) {
  .reader-app.has-selected-book .reader-overview {
    padding-top: clamp(40px, 5.4vh, 48px);
    padding-bottom: clamp(14px, 2.2vh, 24px);
  }

  .reader-app.has-selected-book .reader-overview-label {
    margin-bottom: clamp(22px, 3vh, 30px);
  }

  .reader-app.has-selected-book .reader-cover {
    width: clamp(130px, 8.8vw, 168px);
    margin-bottom: clamp(24px, 3.3vh, 34px);
  }

  .reader-app.has-selected-book .reader-overview h2 {
    margin-bottom: 6px;
    font-size: 1rem;
  }

  .reader-app.has-selected-book #reader-book-author {
    margin-bottom: clamp(18px, 2.6vh, 22px);
  }

  .reader-app.has-selected-book .reader-facts strong {
    margin-top: 7px;
  }

  .reader-app.has-selected-book .reader-overview-sections {
    gap: 10px;
    margin-top: clamp(24px, 3.2vh, 32px);
  }

  .reader-app.has-selected-book .reader-overview-card {
    height: clamp(202px, 27vh, 220px);
    min-height: clamp(202px, 27vh, 220px);
    grid-template-rows: 24px minmax(0, 1fr);
    padding: clamp(16px, 2.1vh, 20px) 20px clamp(14px, 1.9vh, 18px);
  }

  .reader-app.has-selected-book .reader-overview-card h3 {
    min-height: 24px;
  }

  .reader-app.has-selected-book .reader-overview-card p {
    margin-top: 10px;
    font-size: 0.82rem;
    line-height: 1.44;
  }

  .reader-game-panel {
    margin-top: clamp(20px, 2.8vh, 28px);
  }

  .reader-game-launcher {
    gap: 10px;
    padding: 13px;
  }

  .reader-game-launcher-top small {
    margin-top: 4px;
  }

  .reader-progress-track {
    height: 8px;
  }
}

@media (min-width: 981px) and (max-height: 780px) {
  .reader-app.has-selected-book .reader-overview {
    padding-top: 34px;
    padding-bottom: 14px;
  }

  .reader-app.has-selected-book .reader-cover {
    width: 124px;
    margin-bottom: 22px;
  }

  .reader-app.has-selected-book .reader-overview-sections {
    margin-top: 20px;
  }

  .reader-app.has-selected-book .reader-overview-card {
    height: 196px;
    min-height: 196px;
  }

  .reader-game-panel {
    margin-top: 18px;
  }
}
/* Full-rail interactive reading overlay: the AI Overview content stays underneath while this swoops over it. */
.reader-app.has-selected-book .reader-overview {
  position: relative;
}

@media (min-width: 981px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-overview {
    overflow: hidden;
  }
}

.reader-game-panel {
  position: static;
}

.reader-game-popover {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  height: 100%;
  max-height: none;
  padding: clamp(38px, 5vh, 48px) clamp(44px, 4.4vw, 78px) 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  background: var(--reader-soft);
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(104%);
  transition: transform 440ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 220ms ease, visibility 0s linear 440ms;
}

.reader-game-panel.is-open .reader-game-popover {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0);
  transition: transform 440ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 220ms ease, visibility 0s linear 0s;
}

.reader-game-popover[hidden] {
  display: flex;
}

.reader-game-popover-header {
  flex: 0 0 auto;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(23, 23, 23, 0.08);
}

.reader-game-popover-header button {
  background: rgba(255, 255, 255, 0.62);
}

.reader-game-section {
  flex: 0 0 auto;
  padding-top: 0;
  border-top: 0;
}

.reader-game-section + .reader-game-section {
  padding-top: 16px;
  border-top: 1px solid rgba(23, 23, 23, 0.08);
}

.reader-game-popover .reader-quest-card,
.reader-game-popover .reader-mode-card,
.reader-game-popover .reader-companion-card {
  background: rgba(255, 255, 255, 0.42);
}

@media (max-width: 980px) {
  .reader-game-popover {
    position: fixed;
    inset: 0;
    height: 100dvh;
    padding: 28px clamp(22px, 6vw, 44px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader-game-popover,
  .reader-game-panel.is-open .reader-game-popover {
    transition: opacity 120ms ease, visibility 0s linear 0s;
    transform: none;
  }
}
/* Keep interactive-reading card labels readable instead of truncating them. */
.reader-game-popover .reader-quest-card strong,
.reader-game-popover .reader-mode-card strong,
.reader-game-popover .reader-companion-card strong,
.reader-game-popover .reader-quest-card small,
.reader-game-popover .reader-mode-card small,
.reader-game-popover .reader-companion-card small {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.reader-game-popover .reader-mode-card,
.reader-game-popover .reader-companion-card {
  min-height: 78px;
  padding-left: 10px;
  padding-right: 10px;
}

.reader-game-popover .reader-mode-card strong,
.reader-game-popover .reader-companion-card strong {
  line-height: 1.16;
}
/* Interactive reading cards: clear helper text without shouty tags. */
.reader-game-popover .reader-quest-card small,
.reader-game-popover .reader-mode-card small,
.reader-game-popover .reader-companion-card small {
  margin-top: 5px;
  color: rgba(23, 23, 23, 0.54);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.22;
  text-transform: none;
}

.reader-game-popover .reader-quest-card {
  min-height: 64px;
}
/* Minimal interactive-reading launcher: title plus progress only. */
.reader-game-launcher {
  gap: 10px;
  padding: 16px 18px;
}

.reader-game-launcher-top {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.reader-game-launcher-top strong {
  width: 100%;
}
/* Rebalance the simplified AI Overview rail so the launcher does not leave a dead bottom zone. */
@media (min-width: 981px) and (min-height: 781px) {
  .reader-app.has-selected-book #reader-book-author {
    margin-bottom: clamp(24px, 3.4vh, 32px);
  }

  .reader-app.has-selected-book .reader-overview-sections {
    margin-top: clamp(32px, 4.4vh, 42px);
  }

  .reader-app.has-selected-book .reader-overview-card {
    height: clamp(218px, 28.8vh, 244px);
    min-height: clamp(218px, 28.8vh, 244px);
  }

  .reader-game-panel {
    margin-top: clamp(30px, 4.2vh, 46px);
  }
}
/* Small animated cue that the interactive reading menu opens upward. */
.reader-game-launcher {
  position: relative;
  padding: 28px 18px 16px;
}

.reader-game-launcher::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--reader-brand);
  border-left: 2px solid var(--reader-brand);
  transform: translate(-50%, 2px) rotate(45deg);
  animation: reader-launcher-chevron-hop 1.15s ease-in-out infinite;
}

@keyframes reader-launcher-chevron-hop {
  0%, 100% {
    opacity: 0.45;
    transform: translate(-50%, 3px) rotate(45deg);
  }

  50% {
    opacity: 0.9;
    transform: translate(-50%, -2px) rotate(45deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader-game-launcher::before {
    animation: none;
    opacity: 0.65;
    transform: translate(-50%, 0) rotate(45deg);
  }
}
/* Final overview rhythm: tighter top, roomier interactive launcher. */
@media (min-width: 981px) and (min-height: 781px) {
  .reader-app.has-selected-book .reader-overview-label {
    margin-bottom: clamp(18px, 2.4vh, 24px);
  }

  .reader-app.has-selected-book .reader-cover {
    margin-bottom: clamp(20px, 2.7vh, 28px);
  }

  .reader-app.has-selected-book #reader-book-author {
    margin-bottom: clamp(18px, 2.6vh, 24px);
  }

  .reader-app.has-selected-book .reader-overview-sections {
    margin-top: clamp(28px, 3.8vh, 36px);
  }

  .reader-game-panel {
    width: min(360px, calc(100% + 36px));
    max-width: calc(100% + 36px);
  }

  .reader-game-launcher {
    min-height: 86px;
    gap: 13px;
    padding: 34px 22px 20px;
  }

  .reader-game-launcher::before {
    top: 11px;
  }

  .reader-progress-track {
    height: 9px;
  }
}
/* Compact study prompts: the label explains the action, no progress fraction needed. */
.reader-game-popover .reader-quest-list {
  gap: 6px;
}

.reader-game-popover .reader-quest-card {
  min-height: 52px;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 0;
  padding: 8px 12px;
  text-align: center;
}

.reader-game-popover .reader-quest-card strong {
  font-size: 0.76rem;
  line-height: 1.14;
}

.reader-game-popover .reader-quest-card small {
  margin-top: 3px;
  font-size: 0.62rem;
  line-height: 1.15;
}

.reader-game-popover .reader-quest-card em {
  display: none;
}
/* Mobile accessibility pass: access gate, auth forms, and the unlocked reader. */
body.reader-body,
.reader-auth-body {
  overflow-x: hidden;
}

.reader-auth-form input,
.reader-auth-submit,
.reader-access-form input,
.reader-code-submit,
.reader-question-form textarea,
.reader-question-form button,
.reader-nav-block summary,
.reader-chat-item,
.reader-book-child,
.reader-folder-button,
.reader-game-launcher,
.reader-quest-card,
.reader-mode-card,
.reader-companion-card {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 760px) {
  .reader-product-switch {
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    left: 12px;
    right: 12px;
    max-width: none;
    justify-content: center;
  }

  .reader-language-switcher {
    top: calc(env(safe-area-inset-top, 0px) + 58px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .reader-product-current,
  .reader-product-link,
  .reader-language-option {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .reader-access-shell {
    min-height: 100svh;
    place-items: start center;
    padding: calc(env(safe-area-inset-top, 0px) + 122px) 18px calc(env(safe-area-inset-bottom, 0px) + 96px);
  }

  .reader-access-panel {
    width: min(100%, 360px);
    max-width: 100%;
    min-height: auto;
    align-content: start;
    padding-top: clamp(14px, 5vh, 34px);
  }

  .reader-access-panel h1 {
    max-width: 18rem;
    white-space: normal;
    font-size: clamp(1.05rem, 5.2vw, 1.28rem);
    line-height: 1.28;
  }

  .reader-access-mark {
    width: 44px;
    margin: clamp(34px, 8vh, 52px) 0 8px;
  }

  .reader-access-form {
    width: 100%;
    gap: 10px;
  }

  .reader-access-form label {
    max-width: 20rem;
    line-height: 1.35;
  }

  .reader-access-form input {
    max-width: min(100%, 18rem);
    min-height: 38px;
    font-size: 16px;
  }

  .reader-code-submit {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 1.45rem;
  }

  .reader-auth-links {
    width: min(100%, 18rem);
    margin-top: clamp(46px, 10vh, 68px);
  }

  .reader-auth-links a {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    font-size: 0.86rem;
  }

  .reader-signoff {
    left: 16px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  }

  .reader-auth-shell {
    min-height: 100svh;
    align-items: start;
    padding: calc(env(safe-area-inset-top, 0px) + 44px) 18px calc(env(safe-area-inset-bottom, 0px) + 34px);
  }

  .reader-auth-card {
    width: min(100%, 380px);
  }

  .reader-auth-logo {
    margin-bottom: 16px;
  }

  .reader-auth-card h1 {
    font-size: clamp(1.7rem, 8vw, 2rem);
  }

  .reader-auth-form {
    gap: 13px;
    margin-top: 24px;
  }

  .reader-auth-form input {
    min-height: 46px;
    font-size: 16px;
  }

  .reader-auth-submit {
    min-height: 46px;
  }
}

@media (max-width: 900px) {
  .reader-app,
  .reader-app.has-selected-book,
  body.reader-unlocked .reader-app.has-selected-book {
    display: flex;
    min-height: 100svh;
    flex-direction: column;
    overflow-x: hidden;
  }

  .reader-app:not(.has-selected-book) {
    display: block;
  }

  .reader-app:not(.has-selected-book) .reader-sidebar,
  .reader-app.has-selected-book .reader-sidebar {
    position: relative;
    min-height: auto;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px 14px;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 16px;
    border-bottom: 1px solid rgba(23, 23, 23, 0.08);
    background: #ffffff;
  }

  .reader-app:not(.has-selected-book) .reader-mark,
  .reader-app.has-selected-book .reader-mark {
    position: static;
    grid-row: 1 / span 2;
    width: 42px;
    margin: 0;
  }

  .reader-app:not(.has-selected-book) .reader-chat-nav,
  .reader-app:not(.has-selected-book) .reader-book-nav,
  .reader-app.has-selected-book .reader-chat-nav,
  .reader-app.has-selected-book .reader-book-nav {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    display: block;
  }

  .reader-app.has-selected-book .reader-book-nav {
    margin-bottom: 0;
  }

  .reader-nav-block summary {
    min-height: 34px;
    width: 100%;
    align-items: center;
    font-size: 0.9rem;
  }

  .reader-search {
    width: 100%;
    height: 40px;
    margin: 8px 0 10px;
    font-size: 16px;
  }

  .reader-chat-list,
  .reader-book-list {
    max-height: 30svh;
    overflow-y: auto;
    padding-right: 4px;
    overscroll-behavior: contain;
  }

  .reader-folder-button,
  .reader-chat-item,
  .reader-book-child,
  .reader-folder-action,
  .reader-list-actions button {
    min-height: 34px;
    font-size: 0.9rem;
  }

  .reader-chat-item,
  .reader-book-child {
    max-width: none;
    padding: 6px 0 6px 24px;
    white-space: normal;
  }

  .reader-add-code-form,
  .reader-inline-auth {
    grid-column: 1 / -1;
    width: 100%;
  }

  .reader-app.has-selected-book .reader-chat-panel {
    min-height: 72svh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 18px);
  }

  .reader-app.has-selected-book .reader-chat-header {
    display: flex;
    align-items: center;
    padding: 16px 16px 10px;
  }

  .reader-app.has-selected-book .reader-chat-header h1 {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.12rem;
    letter-spacing: 0;
    line-height: 1.1;
  }

  .reader-app.has-selected-book .reader-chat-header button {
    min-height: 38px;
    flex: 0 0 auto;
    padding: 0 13px;
    font-size: 0.84rem;
  }

  .reader-app.has-selected-book .reader-messages,
  body.reader-unlocked .reader-app.has-selected-book .reader-messages {
    width: calc(100% - 28px) !important;
    max-width: none !important;
    padding: 16px 0 14px !important;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .reader-app.has-selected-book .reader-question-form {
    width: calc(100% - 28px) !important;
    max-width: none !important;
  }

  .reader-app.has-selected-book .reader-question-form textarea {
    min-height: 46px;
    font-size: 16px;
  }

  .reader-app.has-selected-book .reader-question-form button {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .reader-app.has-selected-book .reader-message {
    margin-bottom: 14px;
  }

  .reader-app.has-selected-book .reader-message.is-bot,
  .reader-app.has-selected-book .reader-message.is-user {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .reader-app.has-selected-book .reader-message.is-bot .reader-bubble,
  .reader-app.has-selected-book .reader-message.is-user .reader-bubble {
    width: auto !important;
    max-width: 100% !important;
  }

  .reader-app.has-selected-book .reader-message.is-user .reader-bubble {
    max-width: 86% !important;
  }

  .reader-bubble.has-rich-text ul,
  .reader-bubble.has-rich-text ol {
    padding-left: 1.3rem;
  }

  .reader-message-actions {
    flex-wrap: wrap;
  }

  .reader-message-actions button,
  .reader-message-actions .reader-icon-button {
    min-height: 34px;
  }

  .reader-app.has-selected-book .reader-overview,
  body.reader-unlocked .reader-app.has-selected-book .reader-overview {
    position: relative;
    width: 100%;
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible;
    padding: 28px 18px calc(env(safe-area-inset-bottom, 0px) + 34px) !important;
    text-align: center;
  }

  .reader-app.has-selected-book .reader-overview-label {
    display: block;
    margin: 0 0 18px;
  }

  .reader-app.has-selected-book .reader-cover {
    width: clamp(112px, 34vw, 150px);
    margin: 0 0 22px;
  }

  .reader-app.has-selected-book .reader-overview h2,
  .reader-app.has-selected-book #reader-book-author,
  .reader-app.has-selected-book .reader-facts strong,
  .reader-app.has-selected-book .reader-overview-section p {
    display: block;
  }

  .reader-app.has-selected-book #reader-book-author {
    margin-bottom: 20px;
  }

  .reader-app.has-selected-book .reader-facts {
    width: min(100%, 320px);
    gap: 18px;
    margin: 0 0 22px;
  }

  .reader-app.has-selected-book .reader-overview-sections {
    width: 100%;
    margin-top: 14px;
  }

  .reader-overview-carousel {
    max-width: min(300px, calc(100vw - 86px));
  }

  .reader-overview-card,
  .reader-app.has-selected-book .reader-overview-card {
    height: 236px;
    min-height: 236px;
    padding: 18px 16px 16px;
  }

  .reader-app.has-selected-book .reader-overview-card p {
    max-width: 100%;
    font-size: 0.82rem;
  }

  .reader-overview-nav-prev {
    left: -32px;
  }

  .reader-overview-nav-next {
    right: -32px;
  }

  .reader-game-panel {
    width: min(360px, 100%) !important;
    max-width: 100% !important;
    margin: 22px auto 0;
  }

  .reader-game-launcher {
    min-height: 82px;
    padding: 32px 18px 18px;
  }

  .reader-game-popover {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100svh;
    padding: calc(env(safe-area-inset-top, 0px) + 22px) 18px calc(env(safe-area-inset-bottom, 0px) + 24px);
  }

  .reader-game-popover-header button {
    width: 42px;
    min-width: 42px;
  }
}

@media (max-width: 420px) {
  .reader-product-current,
  .reader-product-link,
  .reader-language-option {
    padding: 0 8px;
    font-size: 0.68rem;
  }

  .reader-access-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .reader-signoff-logo {
    width: 76px;
  }

  .reader-signoff-mail {
    font-size: 0.68rem;
  }

  .reader-app:not(.has-selected-book) .reader-sidebar,
  .reader-app.has-selected-book .reader-sidebar {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px 12px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .reader-app:not(.has-selected-book) .reader-mark,
  .reader-app.has-selected-book .reader-mark,
  .reader-mark img {
    width: 36px;
    height: 36px;
  }

  .reader-app.has-selected-book .reader-chat-header h1 {
    max-width: 48vw;
  }

  .reader-app.has-selected-book .reader-facts {
    width: 100%;
  }

  .reader-overview-carousel {
    max-width: min(278px, calc(100vw - 78px));
  }

  .reader-overview-card,
  .reader-app.has-selected-book .reader-overview-card {
    height: 244px;
    min-height: 244px;
  }

  .reader-mode-list,
  .reader-companion-list {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 640px) and (max-width: 760px) {
  .reader-signoff {
    display: none;
  }

  .reader-access-shell {
    padding-bottom: 32px;
  }

  .reader-access-mark {
    margin-top: 26px;
  }

  .reader-auth-links {
    margin-top: 36px;
  }
}
/* Mobile selected-reader flow fix: keep AI Overview from covering the nav or chat. */
@media (max-width: 900px) {
  body.reader-unlocked .reader-app.has-selected-book {
    height: auto;
    min-height: 100svh;
    overflow: visible;
    overflow-x: hidden;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-sidebar {
    order: 1;
    flex: 0 0 auto;
    overflow: visible;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview {
    order: 2;
    flex: 0 0 auto;
    position: relative;
    z-index: 0;
    clear: both;
    margin: 0;
    transform: none;
    overflow: visible;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-panel {
    order: 3;
    flex: 0 0 auto;
    min-height: 72svh;
    overflow: visible;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-messages {
    min-height: 44svh;
    overflow-y: auto;
  }
}
/* Mobile reader drawer: chat first, AI Overview tucked behind a right-edge flap. */
.reader-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.reader-overview-flap {
  display: none;
}

@media (max-width: 900px) {
  body.reader-unlocked.reader-overview-open {
    overflow: hidden;
  }

  body.reader-unlocked .reader-app.has-selected-book {
    --reader-overview-drawer-width: min(360px, calc(100vw - 46px));
    height: 100svh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-sidebar {
    order: 1;
    flex: 0 0 auto;
    max-height: min(30svh, 154px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-panel {
    order: 2;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-header {
    flex: 0 0 auto;
    padding: 12px 16px 8px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-messages {
    min-height: 0;
    height: auto;
    overflow-y: auto;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form {
    flex: 0 0 auto;
    margin-bottom: 0;
  }

  .reader-overview-flap {
    position: fixed;
    top: 50%;
    right: 0;
    z-index: 110;
    width: 34px;
    height: 72px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(217, 154, 90, 0.28);
    border-right: 0;
    border-radius: 16px 0 0 16px;
    color: var(--reader-brand-dark);
    background: rgba(255, 252, 248, 0.96);
    box-shadow: 0 16px 34px rgba(41, 29, 16, 0.16);
    cursor: pointer;
    transform: translateY(-50%);
    transition: right 260ms ease, background 160ms ease, box-shadow 160ms ease;
  }

  .reader-overview-flap:hover,
  .reader-overview-flap:focus-visible {
    background: #fff;
    box-shadow: 0 18px 38px rgba(41, 29, 16, 0.2);
    outline: none;
  }

  .reader-overview-flap-icon {
    width: 10px;
    height: 10px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 220ms ease;
  }

  body.reader-unlocked .reader-app.has-selected-book.is-overview-open .reader-overview-flap {
    right: var(--reader-overview-drawer-width);
  }

  body.reader-unlocked .reader-app.has-selected-book.is-overview-open .reader-overview-flap-icon {
    transform: rotate(225deg);
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview {
    order: initial;
    position: fixed !important;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 100;
    width: var(--reader-overview-drawer-width);
    height: 100svh;
    max-height: 100svh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden !important;
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px calc(env(safe-area-inset-bottom, 0px) + 16px) !important;
    text-align: center;
    background: var(--reader-soft);
    box-shadow: -24px 0 48px rgba(41, 29, 16, 0.16);
    pointer-events: none;
    transform: translateX(calc(100% + 14px));
    transition: transform 280ms cubic-bezier(0.2, 0.9, 0.2, 1);
  }

  body.reader-unlocked .reader-app.has-selected-book.is-overview-open .reader-overview {
    pointer-events: auto;
    transform: none;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-label {
    display: block;
    flex: 0 0 auto;
    margin: 0 0 10px;
    font-size: 0.8rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-cover {
    flex: 0 0 auto;
    width: clamp(88px, 18svh, 126px);
    margin: 0 0 12px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview h2,
  body.reader-unlocked .reader-app.has-selected-book #reader-book-author,
  body.reader-unlocked .reader-app.has-selected-book .reader-facts strong,
  body.reader-unlocked .reader-app.has-selected-book .reader-overview-section p {
    display: block;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview h2 {
    flex: 0 0 auto;
    max-width: 100%;
    font-size: 1.08rem;
  }

  body.reader-unlocked .reader-app.has-selected-book #reader-book-author {
    flex: 0 0 auto;
    margin: 5px 0 12px;
    font-size: 0.82rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-facts {
    flex: 0 0 auto;
    width: min(100%, 292px);
    gap: 10px;
    margin: 0 0 10px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-facts span {
    font-size: 0.72rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-facts strong {
    margin-top: 4px;
    font-size: 0.84rem;
    line-height: 1.12;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-sections {
    flex: 0 0 auto;
    width: 100%;
    margin-top: 2px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-carousel {
    max-width: min(276px, calc(100vw - 94px));
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-card {
    height: clamp(132px, 23svh, 178px);
    min-height: clamp(132px, 23svh, 178px);
    padding: 12px 12px 10px;
    grid-template-rows: 20px minmax(0, 1fr);
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-card h3 {
    min-height: 20px;
    font-size: 0.74rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-card p {
    margin-top: 6px;
    font-size: 0.76rem;
    line-height: 1.32;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-dots {
    gap: 6px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-nav-prev {
    left: -30px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-nav-next {
    right: -30px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-panel {
    flex: 0 0 auto;
    width: min(310px, 100%) !important;
    margin: 10px auto 0;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-launcher {
    min-height: 70px;
    gap: 9px;
    padding: 28px 18px 14px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-launcher-top strong {
    font-size: 0.82rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-launcher::before {
    top: 9px;
  }

  body.reader-unlocked .reader-game-popover {
    position: fixed !important;
    inset: 0 !important;
    z-index: 130;
    width: 100vw !important;
    height: 100svh !important;
    max-height: 100svh !important;
    gap: 8px;
    overflow: hidden !important;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
  }

  body.reader-unlocked .reader-game-popover-header {
    min-height: 36px;
    padding-bottom: 7px;
  }

  body.reader-unlocked .reader-game-popover-header h3 {
    font-size: 0.9rem;
  }

  body.reader-unlocked .reader-game-popover-header button {
    width: 36px;
    min-width: 36px;
    height: 36px;
  }

  body.reader-unlocked .reader-game-section + .reader-game-section {
    padding-top: 8px;
  }

  body.reader-unlocked .reader-game-heading {
    margin-bottom: 6px;
  }

  body.reader-unlocked .reader-game-heading h3 {
    font-size: 0.76rem;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-list,
  body.reader-unlocked .reader-game-popover .reader-mode-list,
  body.reader-unlocked .reader-game-popover .reader-companion-list {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-card,
  body.reader-unlocked .reader-game-popover .reader-mode-card,
  body.reader-unlocked .reader-game-popover .reader-companion-card {
    min-height: 48px;
    padding: 7px 8px;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-card strong,
  body.reader-unlocked .reader-game-popover .reader-mode-card strong,
  body.reader-unlocked .reader-game-popover .reader-companion-card strong {
    font-size: 0.7rem;
    line-height: 1.12;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-card small,
  body.reader-unlocked .reader-game-popover .reader-mode-card small,
  body.reader-unlocked .reader-game-popover .reader-companion-card small {
    margin-top: 2px;
    font-size: 0.58rem;
    line-height: 1.08;
  }
}

@media (max-width: 900px) and (max-height: 680px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-sidebar {
    max-height: min(27svh, 128px);
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview {
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-cover {
    width: clamp(78px, 16svh, 106px);
    margin-bottom: 8px;
  }

  body.reader-unlocked .reader-app.has-selected-book #reader-book-author {
    margin-bottom: 8px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-facts {
    margin-bottom: 6px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-card {
    height: clamp(118px, 21svh, 148px);
    min-height: clamp(118px, 21svh, 148px);
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-panel {
    margin-top: 7px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-launcher {
    min-height: 62px;
    padding-top: 24px;
    padding-bottom: 12px;
  }

  body.reader-unlocked .reader-game-popover {
    gap: 6px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px) !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px) !important;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-card,
  body.reader-unlocked .reader-game-popover .reader-mode-card,
  body.reader-unlocked .reader-game-popover .reader-companion-card {
    min-height: 42px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  body.reader-unlocked .reader-game-popover .reader-mode-card small,
  body.reader-unlocked .reader-game-popover .reader-companion-card small {
    display: none;
  }
}
/* Mobile reader top menu: keep the chat view primary and tuck navigation into a hamburger panel. */
.reader-mobile-menu-toggle {
  display: none;
}

.reader-mobile-menu {
  display: contents;
}

@media (max-width: 900px) {
  body.reader-unlocked.reader-menu-open {
    overflow: hidden;
  }

  body.reader-unlocked .reader-app .reader-sidebar,
  body.reader-unlocked .reader-app.has-selected-book .reader-sidebar,
  body.reader-unlocked .reader-app:not(.has-selected-book) .reader-sidebar {
    position: relative;
    z-index: 150;
    order: 1;
    height: calc(env(safe-area-inset-top, 0px) + 68px);
    min-height: auto;
    max-height: none;
    display: grid;
    grid-template-columns: 42px 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    overflow: visible;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px !important;
    border-bottom: 1px solid rgba(23, 23, 23, 0.08);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 26px rgba(41, 29, 16, 0.05);
  }

  body.reader-unlocked .reader-app .reader-mark,
  body.reader-unlocked .reader-app.has-selected-book .reader-mark,
  body.reader-unlocked .reader-app:not(.has-selected-book) .reader-mark {
    position: static;
    grid-column: 1;
    grid-row: 1;
    width: 42px;
    height: 42px;
    margin: 0;
  }

  .reader-mobile-menu-toggle {
    grid-column: 2;
    grid-row: 1;
    width: 40px;
    height: 40px;
    display: grid;
    place-content: center;
    gap: 4px;
    border: 1px solid rgba(217, 154, 90, 0.26);
    border-radius: 12px;
    background: rgba(255, 252, 248, 0.92);
    box-shadow: 0 10px 22px rgba(41, 29, 16, 0.06);
    cursor: pointer;
  }

  .reader-mobile-menu-toggle span {
    width: 17px;
    height: 2px;
    border-radius: 999px;
    background: var(--reader-brand-dark);
    transition: transform 180ms ease, opacity 160ms ease;
  }

  .reader-app.is-reader-menu-open .reader-mobile-menu-toggle span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .reader-app.is-reader-menu-open .reader-mobile-menu-toggle span:nth-child(2) {
    opacity: 0;
  }

  .reader-app.is-reader-menu-open .reader-mobile-menu-toggle span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .reader-mobile-menu {
    position: absolute;
    top: calc(100% - 1px);
    left: 12px;
    right: 12px;
    z-index: 160;
    display: grid;
    gap: 10px;
    max-height: min(72svh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
    border: 1px solid rgba(217, 154, 90, 0.2);
    border-radius: 0 0 20px 20px;
    background: rgba(255, 252, 248, 0.98);
    box-shadow: 0 24px 48px rgba(41, 29, 16, 0.16);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    visibility: hidden;
    transition: opacity 180ms ease, transform 220ms ease, visibility 0s linear 220ms;
  }

  .reader-app.is-reader-menu-open .reader-mobile-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    visibility: visible;
    transition: opacity 180ms ease, transform 220ms ease, visibility 0s linear 0s;
  }

  .reader-mobile-menu .reader-chat-nav,
  .reader-mobile-menu .reader-book-nav,
  .reader-app.has-selected-book .reader-mobile-menu .reader-chat-nav,
  .reader-app.has-selected-book .reader-mobile-menu .reader-book-nav {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    display: block;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid rgba(217, 154, 90, 0.16);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.66);
  }

  .reader-mobile-menu .reader-nav-block summary {
    min-height: 28px;
    width: 100%;
    color: var(--reader-muted);
    font-size: 0.84rem;
    font-weight: 750;
  }

  .reader-mobile-menu .reader-search {
    height: 38px;
    margin: 8px 0 10px;
    font-size: 16px;
  }

  .reader-mobile-menu .reader-chat-list,
  .reader-mobile-menu .reader-book-list {
    max-height: min(34svh, 230px);
    overflow-y: auto;
    padding-right: 4px;
  }

  .reader-mobile-menu .reader-add-code-form {
    grid-column: auto;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid rgba(217, 154, 90, 0.16);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.66);
  }

  .reader-mobile-menu .reader-add-code-form input {
    min-width: 0;
    height: 38px;
    font-size: 16px;
  }

  .reader-mobile-menu .reader-add-code-form button {
    height: 38px;
    min-width: 52px;
  }

  .reader-mobile-menu .reader-add-code-form p {
    grid-column: 1 / -1;
    margin: 0;
  }

  .reader-mobile-menu .reader-inline-auth {
    grid-column: auto;
    width: 100%;
    justify-content: flex-start;
    gap: 18px;
    margin: 0;
    padding: 0 4px;
  }

  .reader-mobile-menu .reader-logout-form {
    margin: 0;
  }

  .reader-mobile-menu .reader-logout-form button {
    min-height: 38px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-panel {
    order: 2;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-header {
    padding: 12px 16px 7px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-header h1 {
    max-width: calc(100vw - 164px);
    font-size: 1.04rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-header button {
    min-height: 38px;
    padding: 0 14px;
    font-size: 0.82rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-messages {
    padding-top: 8px !important;
    padding-bottom: 10px !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state {
    align-content: center;
    padding: 4px 36px 8px 18px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state img {
    width: 40px;
    margin-bottom: 12px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state h2 {
    max-width: min(292px, calc(100vw - 86px));
    margin: 0 auto 10px;
    font-size: clamp(1.88rem, 8.4vw, 2.34rem);
    line-height: 1.02;
    letter-spacing: -0.055em;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state p {
    max-width: min(280px, calc(100vw - 78px));
    margin: 0 auto;
    font-size: 0.86rem;
    line-height: 1.36;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-starter-questions {
    max-width: min(304px, calc(100vw - 58px));
    gap: 8px;
    margin-top: 20px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-starter-questions button {
    min-height: 34px;
    padding: 7px 14px;
    font-size: 0.82rem;
    white-space: normal;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form {
    width: calc(100% - 48px) !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-flap {
    top: 58%;
    width: 30px;
    height: 62px;
    border-radius: 14px 0 0 14px;
  }
}

@media (max-width: 420px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state h2 {
    max-width: min(276px, calc(100vw - 84px));
    font-size: clamp(1.72rem, 8vw, 2.12rem);
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state p {
    max-width: min(260px, calc(100vw - 78px));
    font-size: 0.82rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-starter-questions {
    max-width: min(286px, calc(100vw - 58px));
  }
}
/* Final mobile proportion pass: smaller chat type and real phone-sized menu controls. */
@media (max-width: 900px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-chat-header {
    padding: 10px 16px 6px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-header h1 {
    font-size: 0.98rem;
    line-height: 1.1;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-chat-header button {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.76rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state {
    padding: 0 42px 4px 18px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state img {
    width: 34px;
    margin-bottom: 10px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state h2 {
    max-width: min(250px, calc(100vw - 100px));
    margin-bottom: 8px;
    font-size: clamp(1.42rem, 6.5vw, 1.78rem);
    line-height: 1.04;
    letter-spacing: -0.045em;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state p {
    max-width: min(248px, calc(100vw - 92px));
    font-size: 0.78rem;
    line-height: 1.34;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-starter-questions {
    max-width: min(278px, calc(100vw - 78px));
    gap: 7px;
    margin-top: 18px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-starter-questions button {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 0.74rem;
    line-height: 1.15;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form {
    width: calc(100% - 58px) !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form textarea {
    min-height: 42px;
    border-radius: 21px;
    padding: 11px 52px 9px 18px;
    font-size: 0.82rem;
    line-height: 1.28;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form textarea::placeholder {
    font-size: 0.82rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form button {
    right: 5px;
    bottom: 5px;
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .reader-mobile-menu {
    gap: 8px;
    padding: 10px;
    max-height: min(76svh, 540px);
  }

  .reader-mobile-menu .reader-chat-nav,
  .reader-mobile-menu .reader-book-nav,
  .reader-app.has-selected-book .reader-mobile-menu .reader-chat-nav,
  .reader-app.has-selected-book .reader-mobile-menu .reader-book-nav,
  .reader-mobile-menu .reader-add-code-form,
  .reader-mobile-menu .reader-inline-auth {
    padding: 9px 10px;
    border-radius: 12px;
  }

  .reader-mobile-menu .reader-nav-block summary {
    min-height: 26px;
    font-size: 0.76rem;
    line-height: 1.15;
  }

  .reader-mobile-menu .reader-search {
    height: 34px;
    margin: 7px 0 8px;
    padding: 0 9px;
    font-size: 0.86rem;
  }

  .reader-mobile-menu .reader-chat-list,
  .reader-mobile-menu .reader-book-list {
    max-height: min(34svh, 220px);
    display: grid;
    gap: 2px;
    overflow-x: hidden;
    padding-right: 0;
  }

  .reader-mobile-menu .reader-list-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 8px;
    padding: 0;
  }

  .reader-mobile-menu .reader-list-actions button,
  .reader-mobile-menu .reader-folder-action {
    min-height: 30px;
    border: 1px solid rgba(217, 154, 90, 0.18);
    border-radius: 999px;
    padding: 0 10px;
    color: rgba(23, 23, 23, 0.62);
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .reader-mobile-menu .reader-folder-row,
  .reader-mobile-menu .reader-chat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 32px;
  }

  .reader-mobile-menu .reader-folder-button,
  .reader-mobile-menu .reader-chat-item,
  .reader-mobile-menu .reader-book-child {
    min-width: 0;
    min-height: 30px;
    padding: 4px 0;
    overflow: visible;
    color: rgba(90, 94, 113, 0.86);
    font-size: 0.78rem;
    line-height: 1.2;
  }

  .reader-mobile-menu .reader-folder-button {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 5px;
    align-items: center;
  }

  .reader-mobile-menu .reader-folder-button .reader-chevron {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    overflow: visible;
    font-size: 0.88rem;
    line-height: 1;
    transform-origin: 50% 50%;
  }

  .reader-mobile-menu .reader-folder-button.is-open .reader-chevron {
    transform: rotate(90deg);
  }

  .reader-mobile-menu .reader-chat-row .reader-chat-item,
  .reader-mobile-menu .reader-chat-row:hover .reader-chat-item,
  .reader-mobile-menu .reader-chat-row:focus-within .reader-chat-item,
  .reader-mobile-menu .reader-chat-row.is-active .reader-chat-item,
  .reader-mobile-menu .reader-folder-row .reader-folder-button,
  .reader-mobile-menu .reader-folder-row:hover .reader-folder-button,
  .reader-mobile-menu .reader-folder-row:focus-within .reader-folder-button {
    padding-right: 0;
  }

  .reader-mobile-menu .reader-chat-actions,
  .reader-mobile-menu .reader-folder-actions {
    position: static;
    display: inline-flex;
    gap: 5px;
    align-items: center;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .reader-mobile-menu .reader-chat-action,
  .reader-mobile-menu .reader-folder-action-link {
    min-height: 26px;
    border: 1px solid rgba(217, 154, 90, 0.16);
    border-radius: 999px;
    padding: 0 8px;
    color: rgba(90, 94, 113, 0.84);
    background: rgba(255, 255, 255, 0.68);
    font-size: 0.62rem;
    font-weight: 750;
    line-height: 1;
  }

  .reader-mobile-menu .reader-chat-action.is-danger,
  .reader-mobile-menu .reader-folder-action-link.is-danger {
    color: #a94f3d;
  }

  .reader-mobile-menu .reader-book-child {
    display: block;
    padding-left: 23px;
  }

  .reader-mobile-menu .reader-book-child span {
    font-size: 0.78rem;
  }

  .reader-mobile-menu .reader-book-child small {
    margin-top: 1px;
    font-size: 0.64rem;
  }

  .reader-mobile-menu .reader-add-code-form {
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 7px;
  }

  .reader-mobile-menu .reader-add-code-form::before {
    content: "Access code";
    grid-column: 1 / -1;
    color: rgba(90, 94, 113, 0.86);
    font-size: 0.72rem;
    font-weight: 800;
  }

  .reader-mobile-menu .reader-add-code-form input {
    height: 34px;
    padding: 0 9px;
    font-size: 0.82rem;
  }

  .reader-mobile-menu .reader-add-code-form input::placeholder {
    font-size: 0.78rem;
  }

  .reader-mobile-menu .reader-add-code-form button {
    height: 34px;
    min-width: 48px;
    padding: 0;
    font-size: 0.72rem;
  }

  .reader-mobile-menu .reader-inline-auth {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: rgba(255, 255, 255, 0.66);
    border: 1px solid rgba(217, 154, 90, 0.16);
  }

  .reader-mobile-menu .reader-inline-auth::before {
    content: "Account";
    grid-column: 1 / -1;
    color: rgba(90, 94, 113, 0.86);
    font-size: 0.72rem;
    font-weight: 800;
  }

  .reader-mobile-menu .reader-inline-auth a {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(217, 154, 90, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.74rem;
    font-weight: 750;
    text-decoration: none;
  }
}

@media (max-width: 420px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state h2 {
    max-width: min(238px, calc(100vw - 104px));
    font-size: clamp(1.34rem, 6.2vw, 1.62rem);
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-empty-state p {
    max-width: min(240px, calc(100vw - 96px));
    font-size: 0.76rem;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-starter-questions button {
    font-size: 0.72rem;
  }

  .reader-mobile-menu .reader-chat-action,
  .reader-mobile-menu .reader-folder-action-link {
    padding: 0 6px;
    font-size: 0.58rem;
  }
}
/* Mobile overlay stack fix: carousel arrows stay inside the drawer, game menu wins over header/flap. */
@media (max-width: 900px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-overview-carousel {
    box-sizing: border-box;
    width: min(100%, 304px);
    max-width: min(304px, calc(100vw - 74px));
    padding: 0 34px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-nav {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 20px rgba(41, 29, 16, 0.08);
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-nav-prev {
    left: 0;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-nav-next {
    right: 0;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-card {
    width: 100%;
  }

  body.reader-game-menu-open .reader-app.has-selected-book .reader-sidebar {
    opacity: 0;
    pointer-events: none;
  }

  body.reader-game-menu-open .reader-app.has-selected-book .reader-overview,
  body.reader-game-menu-open .reader-app.has-selected-book.is-overview-open .reader-overview {
    z-index: 240;
  }

  body.reader-game-menu-open .reader-overview-flap {
    opacity: 0;
    pointer-events: none;
  }

  body.reader-game-menu-open .reader-game-popover,
  body.reader-unlocked.reader-game-menu-open .reader-game-popover {
    z-index: 260;
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px) !important;
  }

  body.reader-game-menu-open .reader-game-popover-header {
    position: relative;
    z-index: 2;
    min-height: 38px;
    align-items: center;
    background: var(--reader-soft);
  }

  body.reader-game-menu-open .reader-game-popover-header button {
    opacity: 1;
    color: rgba(23, 23, 23, 0.68);
    background: rgba(255, 255, 255, 0.84);
  }
}

@media (max-width: 420px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-overview-carousel {
    max-width: min(292px, calc(100vw - 70px));
    padding: 0 32px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-nav {
    width: 27px;
    height: 27px;
  }
}
/* Final mobile menu fit pass: ellipsized titles, fixed actions, full-width utility cards. */
@media (max-width: 900px) {
  .reader-mobile-menu {
    box-sizing: border-box;
    left: 8px;
    right: 8px;
    width: auto;
    min-width: 0;
  }

  .reader-mobile-menu .reader-nav-block,
  .reader-mobile-menu .reader-chat-list,
  .reader-mobile-menu .reader-book-list,
  .reader-mobile-menu .reader-folder-children,
  .reader-mobile-menu .reader-book-children {
    min-width: 0;
  }

  .reader-mobile-menu .reader-folder-row,
  .reader-mobile-menu .reader-chat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px;
    gap: 6px;
    width: 100%;
    min-width: 0;
    align-items: center;
  }

  .reader-mobile-menu .reader-folder-button,
  .reader-mobile-menu .reader-chat-item,
  .reader-mobile-menu .reader-book-child,
  .reader-mobile-menu .reader-book-item {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .reader-mobile-menu .reader-folder-button {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 4px;
  }

  .reader-mobile-menu .reader-folder-button span:last-child,
  .reader-mobile-menu .reader-book-child span:last-child,
  .reader-mobile-menu .reader-book-item span:last-child {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .reader-mobile-menu .reader-chat-actions,
  .reader-mobile-menu .reader-folder-actions {
    position: static;
    display: inline-flex;
    width: 96px;
    min-width: 96px;
    justify-content: flex-end;
    gap: 4px;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .reader-mobile-menu .reader-chat-action,
  .reader-mobile-menu .reader-folder-action-link {
    min-width: 44px;
    min-height: 24px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.55rem;
    line-height: 1;
    text-align: center;
  }

  .reader-mobile-menu .reader-add-code-form,
  .reader-mobile-menu .reader-inline-auth {
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    justify-self: stretch;
    align-self: stretch;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .reader-mobile-menu .reader-add-code-form {
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 7px;
    padding: 10px;
  }

  .reader-mobile-menu .reader-add-code-form::before {
    grid-column: 1 / -1;
    min-width: 0;
    margin-bottom: -2px;
  }

  .reader-mobile-menu .reader-add-code-form input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0 9px;
    font-size: 0.8rem;
  }

  .reader-mobile-menu .reader-add-code-form input::placeholder {
    font-size: 0.76rem;
  }

  .reader-mobile-menu .reader-add-code-form button {
    width: 52px;
    min-width: 0;
    height: 34px;
    padding: 0;
    font-size: 0.7rem;
  }

  .reader-mobile-menu .reader-inline-auth {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }

  .reader-mobile-menu .reader-inline-auth::before {
    grid-column: 1 / -1;
    min-width: 0;
    margin-bottom: -2px;
  }

  .reader-mobile-menu .reader-inline-auth a {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 0 10px;
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  .reader-mobile-menu .reader-folder-row,
  .reader-mobile-menu .reader-chat-row {
    grid-template-columns: minmax(0, 1fr) 90px;
    gap: 5px;
  }

  .reader-mobile-menu .reader-chat-actions,
  .reader-mobile-menu .reader-folder-actions {
    width: 90px;
    min-width: 90px;
  }

  .reader-mobile-menu .reader-chat-action,
  .reader-mobile-menu .reader-folder-action-link {
    min-width: 41px;
    padding: 0 4px;
    font-size: 0.52rem;
  }

  .reader-mobile-menu .reader-add-code-form {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .reader-mobile-menu .reader-add-code-form button {
    width: 48px;
  }
}
/* Mobile menu spacing pass: keep utility cards from crowding each other. */
@media (max-width: 900px) {
  .reader-mobile-menu {
    gap: 11px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .reader-mobile-menu .reader-chat-nav,
  .reader-mobile-menu .reader-book-nav,
  .reader-app.has-selected-book .reader-mobile-menu .reader-chat-nav,
  .reader-app.has-selected-book .reader-mobile-menu .reader-book-nav,
  .reader-mobile-menu .reader-add-code-form,
  .reader-mobile-menu .reader-inline-auth {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

  .reader-mobile-menu .reader-add-code-form,
  .reader-mobile-menu .reader-inline-auth {
    padding-top: 11px;
    padding-bottom: 11px;
  }
}

@media (max-width: 420px) {
  .reader-mobile-menu {
    gap: 10px;
  }
}
/* Mobile modal layer pass: reader dialogs should sit above the collapsed header/menu chrome. */
@media (max-width: 900px) {
  .reader-modal-backdrop {
    z-index: 320;
  }
}
/* Mobile folder hierarchy pass: outdent folders, indent their chats. */
@media (max-width: 900px) {
  .reader-mobile-menu .reader-folder-row {
    width: 100%;
    margin-left: 0;
    grid-template-columns: minmax(0, 1fr) 96px;
  }

  .reader-mobile-menu .reader-folder-button {
    grid-template-columns: 13px minmax(0, 1fr);
    gap: 2px;
    min-height: 32px;
    padding-left: 0;
  }

  .reader-mobile-menu .reader-folder-button .reader-chevron {
    width: 13px;
    height: 18px;
  }

  .reader-mobile-menu .reader-chat-row {
    width: calc(100% - 20px);
    margin-left: 20px;
    grid-template-columns: minmax(0, 1fr) 96px;
    min-height: 32px;
  }

  .reader-mobile-menu .reader-chat-item {
    min-height: 32px;
    display: flex;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
  }

  .reader-mobile-menu .reader-folder-action {
    width: calc(100% - 20px);
    min-height: 32px;
    margin-left: 20px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    justify-content: flex-start;
    text-align: left;
    color: rgba(90, 94, 113, 0.9);
    font-size: 0.78rem;
    line-height: 1.2;
  }

  .reader-mobile-menu .reader-folder-action:hover,
  .reader-mobile-menu .reader-folder-action:focus-visible {
    border-color: rgba(217, 154, 90, 0.18);
    background: rgba(255, 255, 255, 0.58);
  }
}

@media (max-width: 420px) {
  .reader-mobile-menu .reader-folder-row {
    grid-template-columns: minmax(0, 1fr) 90px;
  }

  .reader-mobile-menu .reader-chat-row {
    width: calc(100% - 18px);
    margin-left: 18px;
    grid-template-columns: minmax(0, 1fr) 90px;
  }

  .reader-mobile-menu .reader-folder-action {
    width: calc(100% - 18px);
    margin-left: 18px;
  }
}
/* Mobile chat title truncation pass: keep long titles out of the action buttons. */
@media (max-width: 900px) {
  .reader-mobile-menu .reader-chat-row {
    overflow: hidden;
  }

  .reader-mobile-menu .reader-chat-row .reader-chat-item,
  .reader-mobile-menu .reader-chat-row:hover .reader-chat-item,
  .reader-mobile-menu .reader-chat-row:focus-within .reader-chat-item,
  .reader-mobile-menu .reader-chat-row.is-active .reader-chat-item {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 32px;
    min-height: 32px;
    padding: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 32px;
  }

  .reader-mobile-menu .reader-chat-actions,
  .reader-mobile-menu .reader-folder-actions {
    flex: 0 0 96px;
    width: 96px;
    min-width: 96px;
    max-width: 96px;
  }

  .reader-mobile-menu .reader-chat-action,
  .reader-mobile-menu .reader-folder-action-link {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 420px) {
  .reader-mobile-menu .reader-chat-actions,
  .reader-mobile-menu .reader-folder-actions {
    flex-basis: 90px;
    width: 90px;
    min-width: 90px;
    max-width: 90px;
  }

  .reader-mobile-menu .reader-chat-action,
  .reader-mobile-menu .reader-folder-action-link {
    flex-basis: 42px;
    width: 42px;
    min-width: 42px;
    max-width: 42px;
  }
}
/* Mobile menu search typography pass: match placeholders to folder and chat labels. */
@media (max-width: 900px) {
  .reader-mobile-menu .reader-search,
  .reader-mobile-menu .reader-search::placeholder {
    font-size: 0.78rem;
    line-height: 1.2;
  }

  .reader-mobile-menu .reader-search {
    height: 34px;
    padding: 0 9px;
  }
}
/* AI Reader access gate: match the lockpage mobile dropdown controls. */
.reader-access-dropdown-trigger {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(217, 154, 90, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--reader-ink);
  box-shadow: 0 14px 32px rgba(69, 47, 34, 0.08);
  padding: 0 14px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.1;
  text-align: left;
  cursor: pointer;
}

.reader-access-dropdown-chevron {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-right: 2px solid var(--reader-brand);
  border-bottom: 2px solid var(--reader-brand);
  transform: translateY(-2px) rotate(45deg);
}

.reader-access-dropdown-menu {
  display: inline-flex;
  align-items: center;
  gap: inherit;
}

@media (max-width: 760px) {
  body.reader-locked .reader-product-switch,
  body.reader-locked .reader-language-switcher {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    z-index: 70;
    display: block;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: none;
  }

  body.reader-locked .reader-product-switch {
    left: 12px;
    right: auto;
    width: min(220px, calc(100vw - 144px));
    max-width: none;
  }

  body.reader-locked .reader-language-switcher {
    right: 12px;
    left: auto;
    width: 112px;
    margin: 0;
    align-self: auto;
  }

  body.reader-locked .reader-access-dropdown-trigger {
    display: flex;
  }

  body.reader-locked .reader-access-dropdown-menu {
    position: absolute;
    top: calc(100% + 7px);
    left: 0;
    right: 0;
    display: grid;
    gap: 6px;
    padding: 6px;
    border: 1px solid rgba(217, 154, 90, 0.24);
    border-radius: 16px;
    background: rgba(255, 252, 248, 0.97);
    box-shadow: 0 18px 38px rgba(69, 47, 34, 0.13);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
    visibility: hidden;
  }

  body.reader-locked .reader-access-dropdown.is-open .reader-access-dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    visibility: visible;
  }

  body.reader-locked .reader-product-current,
  body.reader-locked .reader-product-link,
  body.reader-locked .reader-language-option {
    justify-content: flex-start;
    width: 100%;
    min-height: 36px;
    border-radius: 12px;
    padding: 0 12px;
    font-size: 0.72rem;
    text-align: left;
  }

  body.reader-locked .reader-language-option.is-active,
  body.reader-locked .reader-product-current {
    color: #ffffff;
    background: var(--reader-brand);
  }

  body.reader-locked .reader-access-shell {
    padding-top: calc(env(safe-area-inset-top, 0px) + 94px);
  }
}

@media (max-width: 380px) {
  body.reader-locked .reader-product-switch {
    left: 8px;
    width: min(210px, calc(100vw - 128px));
  }

  body.reader-locked .reader-language-switcher {
    right: 8px;
    width: 104px;
  }

  body.reader-locked .reader-access-dropdown-trigger {
    min-height: 38px;
    padding: 0 12px;
    font-size: 0.68rem;
  }
}
/* Mobile Safari polish: stable overview dots, composer button, and visible launcher. */
@media (max-width: 900px) {
  body.reader-unlocked .reader-app.has-selected-book,
  body.reader-unlocked .reader-app.has-selected-book.is-overview-open {
    height: 100dvh;
    min-height: 100dvh;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-dots {
    min-height: 10px;
    align-items: center;
    justify-content: center;
    gap: 7px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-dot {
    box-sizing: border-box;
    flex: 0 0 7px !important;
    width: 7px !important;
    min-width: 7px !important;
    max-width: 7px !important;
    height: 7px !important;
    min-height: 7px !important;
    max-height: 7px !important;
    aspect-ratio: 1 / 1;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    appearance: none;
    -webkit-appearance: none;
    line-height: 0;
    transform: none !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form {
    position: relative;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form textarea {
    min-height: 46px;
    padding: 12px 54px 10px 18px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form button {
    top: 50% !important;
    right: 6px !important;
    bottom: auto !important;
    width: 34px;
    height: 34px;
    min-width: 34px;
    transform: translateY(-50%) !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-panel {
    margin-top: 6px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-launcher {
    min-height: 64px;
    gap: 7px;
    padding: 24px 18px 11px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-launcher::before {
    top: 8px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-game-launcher-top strong {
    font-size: 0.78rem;
    line-height: 1.08;
  }
}

@media (max-width: 900px) and (max-height: 740px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-cover {
    width: clamp(80px, 16svh, 112px);
    margin-bottom: 9px;
  }

  body.reader-unlocked .reader-app.has-selected-book #reader-book-author {
    margin-bottom: 8px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-facts {
    margin-bottom: 7px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-card {
    height: clamp(116px, 20svh, 148px);
    min-height: clamp(116px, 20svh, 148px);
    padding-top: 10px;
    padding-bottom: 8px;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-overview-card p {
    line-height: 1.26;
  }
}
/* Mobile game menu parity: keep helper descriptions visible in every browser. */
@media (max-width: 900px) {
  body.reader-unlocked .reader-game-popover {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-card,
  body.reader-unlocked .reader-game-popover .reader-mode-card,
  body.reader-unlocked .reader-game-popover .reader-companion-card {
    align-content: center;
    min-height: 56px;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-card small,
  body.reader-unlocked .reader-game-popover .reader-mode-card small,
  body.reader-unlocked .reader-game-popover .reader-companion-card small {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-top: 2px;
    color: rgba(23, 23, 23, 0.54);
    font-size: 0.58rem;
    font-weight: 650;
    line-height: 1.08;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
  }
}

@media (max-width: 900px) and (max-height: 680px) {
  body.reader-unlocked .reader-game-popover .reader-quest-card,
  body.reader-unlocked .reader-game-popover .reader-mode-card,
  body.reader-unlocked .reader-game-popover .reader-companion-card {
    min-height: 52px;
  }

  body.reader-unlocked .reader-game-popover .reader-quest-card small,
  body.reader-unlocked .reader-game-popover .reader-mode-card small,
  body.reader-unlocked .reader-game-popover .reader-companion-card small {
    display: block !important;
    font-size: 0.56rem;
    line-height: 1.05;
  }
}
/* Mobile composer zoom guard: iOS zooms focused fields below 16px. */
@media (max-width: 900px) {
  body.reader-unlocked .reader-app.has-selected-book .reader-question-form textarea,
  body.reader-unlocked .reader-app.has-selected-book .reader-question-form textarea::placeholder {
    font-size: 16px !important;
  }

  body.reader-unlocked .reader-app.has-selected-book .reader-question-form textarea {
    line-height: 1.25;
  }
}
/* Cross-browser mobile focus zoom guard for the chat composer. */
@media (max-width: 900px) {
  body.reader-unlocked #reader-question-input,
  body.reader-unlocked .reader-question-form textarea,
  body.reader-unlocked .reader-question-form textarea::placeholder {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body.reader-unlocked .reader-question-form {
    touch-action: manipulation;
  }
}
