:root {
  color-scheme: light;
  --bg: #f6f2e8;
  --bg-deep: #dfd4bf;
  --panel: rgba(255, 251, 243, 0.84);
  --panel-strong: #fffdf8;
  --panel-muted: rgba(246, 239, 226, 0.92);
  --panel-dark: rgba(20, 23, 27, 0.92);
  --ink: #1f1912;
  --ink-soft: #66594b;
  --ink-inverse: #f9f1e2;
  --accent: #b85d2c;
  --accent-strong: #9c4418;
  --accent-soft: rgba(184, 93, 44, 0.14);
  --support: #254f55;
  --line: rgba(49, 35, 21, 0.12);
  --line-strong: rgba(49, 35, 21, 0.2);
  --success-bg: rgba(44, 144, 98, 0.14);
  --success-ink: #216a48;
  --warning-bg: rgba(181, 36, 36, 0.12);
  --warning-ink: #8a1f1f;
  --working-bg: rgba(200, 132, 29, 0.14);
  --working-ink: #8a5d16;
  --shadow-lg: 0 30px 90px rgba(43, 31, 18, 0.14);
  --shadow-md: 0 16px 40px rgba(43, 31, 18, 0.12);
  --radius-2xl: 34px;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Manrope", "Segoe UI", sans-serif;
  --reader-topbar-height: 74px;
  --reader-bottom-bar-height: 128px;
  --reader-stage-width: 0px;
  --reader-stage-height: 0px;
  --drawer-width: min(420px, 100vw);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.82), transparent 30%),
    radial-gradient(circle at bottom right, rgba(176, 120, 65, 0.16), transparent 28%),
    linear-gradient(140deg, #f8f4ed 0%, #ede4d5 48%, #e5d6c2 100%);
  color: var(--ink);
  font-family: var(--font-ui);
}

body {
  min-height: 100vh;
}

body.reader-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

img {
  max-width: 100%;
}

.app-shell {
  min-height: 100vh;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.subtle-text {
  margin: 0;
  color: var(--ink-soft);
}

.field {
  display: grid;
  gap: 0.5rem;
}

.field span {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.field input,
.settings-field input,
.settings-field select,
.search-panel-form input,
.selection-note-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: none;
}

.field input:focus,
.settings-field input:focus,
.settings-field select:focus,
.search-panel-form input:focus,
.selection-note-field input:focus {
  border-color: rgba(184, 93, 44, 0.45);
  box-shadow: 0 0 0 4px rgba(184, 93, 44, 0.1);
}

.compact-field input {
  padding: 0.8rem 0.9rem;
}

.primary-button,
.ghost-button,
.round-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  padding: 0.82rem 1.18rem;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, #cb6f36, #a9471e);
  box-shadow: 0 18px 36px rgba(169, 71, 30, 0.28);
}

.ghost-button,
.round-button {
  color: var(--ink);
  border: 1px solid rgba(49, 35, 21, 0.1);
  background: rgba(255, 255, 255, 0.78);
}

.round-button {
  min-width: 2.8rem;
  padding-inline: 1rem;
}

.primary-button:hover,
.ghost-button:hover,
.round-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled,
.round-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.chip {
  background: rgba(42, 30, 18, 0.07);
  color: var(--ink-soft);
}

.count-chip {
  min-width: 7rem;
}

.status-pill {
  background: var(--success-bg);
  color: var(--success-ink);
}

.status-pill.status-error {
  background: var(--warning-bg);
  color: var(--warning-ink);
}

.status-pill.status-working {
  background: var(--working-bg);
  color: var(--working-ink);
}

.status-pill.status-neutral {
  background: rgba(42, 30, 18, 0.08);
  color: var(--ink-soft);
}

.inline-error {
  margin: 0;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(181, 36, 36, 0.09);
  color: #8a1f1f;
}

.segmented-control {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.34rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(49, 35, 21, 0.07);
}

.segmented-control-full {
  width: 100%;
}

.segmented-control button {
  min-width: 7.2rem;
  padding: 0.76rem 1rem;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button.is-active {
  background: white;
  color: var(--ink);
  box-shadow: 0 12px 24px rgba(49, 35, 21, 0.08);
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 430px);
  gap: 1.5rem;
  width: min(1140px, 100%);
  padding: 1.6rem;
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: linear-gradient(145deg, rgba(255, 253, 248, 0.96), rgba(244, 236, 222, 0.9));
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}

.auth-copy {
  padding: 1.6rem;
}

.auth-copy h1 {
  margin: 0.65rem 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 4.1rem);
  line-height: 1;
}

.auth-copy p {
  margin: 0;
  max-width: 38rem;
  color: var(--ink-soft);
  line-height: 1.7;
}

.auth-feature-list {
  display: grid;
  gap: 0.82rem;
  margin: 1.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}

.auth-form {
  display: grid;
  gap: 1rem;
  padding: 1.3rem;
  border-radius: var(--radius-xl);
  background: rgba(255, 251, 243, 0.96);
  border: 1px solid rgba(49, 35, 21, 0.08);
}

.auth-mode-switch {
  display: inline-flex;
  padding: 0.32rem;
  border-radius: 999px;
  background: rgba(49, 35, 21, 0.06);
}

.auth-mode-switch button {
  padding: 0.72rem 1rem;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.auth-mode-switch button.is-active {
  background: white;
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(49, 35, 21, 0.09);
}

.workspace {
  min-height: 100vh;
}

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.72rem 1rem;
  background: rgba(250, 247, 241, 0.84);
  border-bottom: 1px solid rgba(49, 35, 21, 0.08);
  backdrop-filter: blur(18px);
}

.workspace-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 35, 21, 0.1);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  cursor: pointer;
}

.hamburger-icon {
  display: inline-grid;
  gap: 0.26rem;
}

.hamburger-line {
  width: 1.15rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 140ms ease, opacity 140ms ease;
}

.workspace-menu-toggle.is-active .hamburger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.workspace-menu-toggle.is-active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.workspace-menu-toggle.is-active .hamburger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.brand-block,
.workspace-header-actions,
.reader-leading,
.reader-actions,
.section-heading {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-block {
  min-width: 0;
}

.user-chip {
  background: rgba(42, 30, 18, 0.08);
  color: var(--ink);
}

.brand-block h2,
.section-heading h2,
.drawer-header h4,
.reader-meta h3 {
  margin: 0.08rem 0 0;
}

.brand-block h2,
.section-heading h2,
.reader-meta h3 {
  font-family: var(--font-display);
}

.workspace-header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.library-browser {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 0.85rem 1rem 1rem;
  display: grid;
  align-content: start;
  gap: 0.95rem;
}

.library-hero,
.shelf-section,
.reader-topbar,
.drawer,
.selection-toolbar {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(49, 35, 21, 0.08);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
}

.reader-topbar {
  border-radius: 0;
}

.library-hero {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 32%),
    linear-gradient(135deg, rgba(255, 251, 243, 0.96), rgba(239, 229, 211, 0.86));
}

.library-hero-toggle {
  justify-self: end;
}

.hero-copy h1,
.hero-copy h2,
.hero-copy p {
  margin: 0;
}

.hero-copy h1,
.hero-copy h2 {
  margin-top: 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1.02;
}

.hero-copy p {
  margin-top: 0.9rem;
  max-width: 52rem;
  color: var(--ink-soft);
  line-height: 1.7;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.hero-stat-card {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(49, 35, 21, 0.06);
}

.hero-stat-card strong {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
}

.hero-stat-card span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.shelf-section {
  padding: 1rem;
}

.library-section-tools {
  margin-bottom: 0.75rem;
}

.library-search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
}

.search-field {
  min-width: 0;
}

.search-field input {
  padding-right: 1rem;
}

.search-clear-button {
  min-width: 3rem;
  padding-inline: 1rem;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-empty {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
}

.continue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.continue-card,
.library-card,
.drawer-item-card,
.result-card,
.annotation-card {
  display: grid;
  gap: 0.72rem;
  min-width: 0;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(49, 35, 21, 0.08);
  background: rgba(255, 255, 255, 0.84);
}

.continue-card,
.library-card,
.drawer-item-card {
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.continue-card {
  position: relative;
}

.continue-card:hover,
.library-card:hover,
.drawer-item-card:hover {
  transform: translateY(-1px);
  border-color: rgba(184, 93, 44, 0.24);
  box-shadow: 0 18px 34px rgba(49, 35, 21, 0.08);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 1rem;
}

.library-card {
  padding: 0.92rem;
  align-content: start;
}

.continue-card {
  padding: 0.95rem;
  align-content: start;
}

.continue-dismiss-wrap {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 1;
}

.continue-dismiss-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 35, 21, 0.1);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(43, 31, 18, 0.08);
}

.continue-dismiss-button:hover {
  color: var(--ink);
  border-color: rgba(184, 93, 44, 0.28);
  background: rgba(255, 248, 240, 0.98);
}

.library-card.is-active,
.drawer-item-card.is-active {
  border-color: rgba(184, 93, 44, 0.34);
  box-shadow: inset 0 0 0 1px rgba(184, 93, 44, 0.18);
  background: rgba(255, 248, 240, 0.96);
}

.card-topline {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
}

.drawer-item-card .card-topline {
  grid-template-columns: 52px minmax(0, 1fr);
}

.cover-chip {
  display: grid;
  place-items: center;
  width: 72px;
  height: 102px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(230, 199, 166, 0.62), rgba(183, 122, 69, 0.24)),
    linear-gradient(120deg, rgba(255, 255, 255, 0.4), transparent);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.cover-thumb {
  width: 72px;
  height: 102px;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(244, 232, 215, 0.94), rgba(214, 187, 152, 0.72));
  border: 1px solid rgba(49, 35, 21, 0.08);
  box-shadow: 0 16px 30px rgba(43, 31, 18, 0.1);
}

.cover-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-thumb-compact {
  width: 52px;
  height: 74px;
  border-radius: 14px;
}

.drawer-item-card .cover-chip {
  width: 52px;
  height: 74px;
  border-radius: 14px;
}

.card-copy {
  min-width: 0;
}

.card-copy h3,
.card-copy h4 {
  margin: 0;
  font-size: 1rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-copy p {
  margin: 0.28rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.card-copy-meta {
  margin-top: 0.18rem;
  font-size: 0.82rem;
  color: rgba(102, 89, 75, 0.9);
}

.library-explorer {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding: 0.9rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(49, 35, 21, 0.07);
}

.folder-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.folder-crumb {
  padding: 0.45rem 0.72rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(49, 35, 21, 0.08);
  color: var(--ink-soft);
  cursor: pointer;
}

.folder-crumb.is-active {
  background: rgba(184, 93, 44, 0.12);
  border-color: rgba(184, 93, 44, 0.22);
  color: var(--ink);
  font-weight: 800;
}

.folder-crumb-separator {
  color: var(--ink-soft);
  font-weight: 700;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.folder-card {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.82rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(49, 35, 21, 0.08);
  background: rgba(255, 255, 255, 0.84);
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.folder-card:hover {
  transform: translateY(-1px);
  border-color: rgba(184, 93, 44, 0.24);
  box-shadow: 0 16px 28px rgba(49, 35, 21, 0.08);
}

.folder-card strong,
.folder-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-card span {
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
  min-width: 0;
}

.meta-chips {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  overflow: hidden;
}

.library-card-footer,
.continue-card-footer {
  display: block;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.library-card-footer span,
.continue-card-footer span {
  display: block;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-progress-meta {
  min-width: 0;
  text-align: right;
  color: var(--ink-soft);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-shell {
  position: fixed;
  inset: 0;
  z-index: 90;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #13171b, #1f242a 35%, #171b1f 100%);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.reader-topbar {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'meta actions';
  gap: 1rem;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.9rem;
  background: rgba(247, 243, 236, 0.9);
  border-radius: 0;
  border-inline: 0;
  border-top: 0;
  box-shadow: 0 14px 32px rgba(43, 31, 18, 0.08);
}

.reader-meta {
  grid-area: meta;
  min-width: 0;
}

.reader-meta-track {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.reader-meta h3 {
  margin: 0;
  font-size: clamp(1.02rem, 1.45vw, 1.32rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-back-button {
  flex: 0 0 auto;
  min-width: 2.7rem;
  padding-inline: 0.8rem;
}

.reader-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-content: flex-end;
  position: relative;
}

.reader-icon-button {
  min-width: 0;
}

.reader-action-menu-shell {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.reader-action-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 9;
  width: min(280px, calc(100vw - 1.1rem));
  padding: 0.42rem;
  display: grid;
  gap: 0.22rem;
  border-radius: 22px;
  border: 1px solid rgba(49, 35, 21, 0.08);
  background: rgba(255, 251, 243, 0.98);
  box-shadow: 0 22px 44px rgba(43, 31, 18, 0.16);
  backdrop-filter: blur(16px);
}

.reader-action-item {
  width: 100%;
  padding: 0.78rem 0.9rem;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, opacity 140ms ease;
}

.reader-action-item:hover:not(:disabled),
.reader-action-item.is-active {
  background: rgba(184, 93, 44, 0.12);
}

.reader-action-item.is-accent {
  color: var(--accent-strong);
}

.reader-action-item:disabled {
  opacity: 0.45;
  cursor: default;
}

.reader-action-divider {
  height: 1px;
  margin: 0.18rem 0;
  background: rgba(49, 35, 21, 0.08);
}

.reader-topbar .ghost-button,
.reader-topbar .primary-button,
.reader-topbar .round-button {
  padding: 0.68rem 1rem;
}

.reader-icon {
  position: relative;
  display: inline-block;
  width: 0.96rem;
  height: 0.96rem;
  color: currentColor;
}

.reader-icon::before,
.reader-icon::after {
  content: '';
  position: absolute;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-radius: 0.18rem;
}

.reader-icon-maximize::before {
  inset: 0.02rem;
}

.reader-icon-maximize::after {
  top: -0.16rem;
  right: -0.16rem;
  bottom: 0.18rem;
  left: 0.18rem;
  opacity: 0.6;
}

.reader-icon-minimize::before {
  inset: 0.18rem;
}

.reader-icon-minimize::after {
  top: -0.04rem;
  right: -0.04rem;
  bottom: 0.34rem;
  left: 0.34rem;
  opacity: 0.72;
}

.reader-icon-back::before,
.reader-icon-back::after {
  border-radius: 0;
}

.reader-icon-back::before {
  top: 50%;
  left: 0.14rem;
  width: 0.68rem;
  height: 0;
  border: 0;
  border-top: 2px solid currentColor;
  transform: translateY(-50%);
}

.reader-icon-back::after {
  top: 50%;
  left: 0.14rem;
  width: 0.42rem;
  height: 0.42rem;
  border: 0;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}

.reader-stage-wrap {
  position: relative;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
}

.reader-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 0 var(--reader-bottom-bar-height);
  overscroll-behavior: contain;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(251, 245, 234, 0.98), rgba(242, 229, 204, 0.92)),
    repeating-linear-gradient(
      180deg,
      rgba(182, 154, 120, 0.06) 0,
      rgba(182, 154, 120, 0.06) 32px,
      rgba(255, 255, 255, 0.04) 32px,
      rgba(255, 255, 255, 0.04) 64px
    );
}

.reader-stage.reader-stage-paginated {
  overflow: hidden;
}

.reader-stage.reader-stage-scroll {
  overflow-x: hidden;
  overflow-y: auto;
}

.reader-stage.reader-stage-comic {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #101418, #1b2025 100%);
}

.reader-stage.theme-paper {
  background:
    linear-gradient(180deg, rgba(251, 245, 234, 0.98), rgba(242, 229, 204, 0.92)),
    repeating-linear-gradient(
      180deg,
      rgba(182, 154, 120, 0.06) 0,
      rgba(182, 154, 120, 0.06) 32px,
      rgba(255, 255, 255, 0.04) 32px,
      rgba(255, 255, 255, 0.04) 64px
    );
}

.reader-stage.theme-sepia {
  background: linear-gradient(180deg, #ead9b8, #d5bb93);
}

.reader-stage.theme-night {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.05), transparent 28%),
    linear-gradient(180deg, #171b1f, #101317);
  color: var(--ink-inverse);
}

.reader-stage.theme-night .empty-state,
.reader-stage.theme-night .pdf-page,
.reader-stage.theme-night .comic-scroll-page,
.reader-stage.theme-night .comic-frame {
  background: rgba(26, 29, 34, 0.98);
  color: var(--ink-inverse);
}

.empty-stage {
  display: grid;
  place-items: center;
}

.empty-state {
  width: min(520px, 100%);
  padding: 2.2rem;
  text-align: center;
  border-radius: var(--radius-xl);
  background: rgba(255, 251, 243, 0.92);
  border: 1px solid rgba(49, 35, 21, 0.08);
}

.empty-state h4 {
  margin: 0.55rem 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.8rem;
}

.empty-state p {
  margin: 0;
  line-height: 1.68;
  color: var(--ink-soft);
}

.loading-state {
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  width: min(420px, 100%);
  padding: 2rem 1.6rem;
  text-align: center;
  border-radius: var(--radius-xl);
  background: rgba(255, 251, 243, 0.94);
  border: 1px solid rgba(49, 35, 21, 0.08);
  box-shadow: 0 20px 44px rgba(43, 31, 18, 0.12);
}

.loading-state strong {
  font-size: 1.04rem;
}

.loading-state p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.loading-state.is-error {
  background: rgba(255, 247, 244, 0.96);
}

.reader-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  padding: 1.4rem;
  background: rgba(20, 24, 28, 0.4);
  backdrop-filter: blur(7px);
}

.reader-loading-card {
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  width: min(420px, calc(100vw - 2.8rem));
  padding: 2rem 1.6rem;
  text-align: center;
  border-radius: var(--radius-xl);
  background: rgba(255, 251, 243, 0.95);
  border: 1px solid rgba(49, 35, 21, 0.08);
  box-shadow: 0 24px 54px rgba(43, 31, 18, 0.2);
}

.reader-loading-card strong {
  font-size: 1.05rem;
}

.reader-loading-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.spinner-ring {
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  border: 4px solid rgba(184, 93, 44, 0.16);
  border-top-color: var(--accent);
  animation: spinner-rotate 900ms linear infinite;
}

.reader-bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  transform: none;
  width: 100%;
  display: grid;
  gap: 0.45rem;
  padding: 0.62rem 1.2rem 0.9rem;
  border-radius: 24px 24px 0 0;
  background: rgba(255, 251, 243, 0.9);
  border: 1px solid rgba(49, 35, 21, 0.08);
  border-bottom: 0;
  box-shadow: 0 16px 34px rgba(43, 31, 18, 0.12);
  backdrop-filter: blur(16px);
}

.reader-restore-button {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 8;
  width: 2.85rem;
  height: 2.85rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 251, 243, 0.18);
  border-radius: 999px;
  background: rgba(20, 24, 28, 0.28);
  color: rgba(255, 251, 243, 0.96);
  box-shadow: 0 16px 30px rgba(8, 10, 12, 0.24);
  backdrop-filter: blur(14px);
}

.reader-shell.reader-shell-immersive .reader-topbar {
  display: none;
}

.reader-shell.reader-shell-immersive {
  grid-template-rows: minmax(0, 1fr);
}

.reader-shell.reader-shell-immersive .reader-stage {
  padding-top: 0;
  padding-bottom: 0;
}

.reader-shell.reader-shell-immersive .edge-zone {
  top: 0;
  bottom: 0;
}

.reader-bottom-copy {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.reader-bottom-copy .subtle-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-inline-chip {
  display: none;
}

.reader-scrubber {
  display: grid;
  gap: 0.4rem;
}

.reader-scrubber input[type='range'] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.reader-scrubber-labels {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.reader-scrubber-labels strong {
  min-width: 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: rgba(10, 12, 15, 0.48);
  backdrop-filter: blur(6px);
}

.drawer {
  position: absolute;
  top: calc(var(--reader-topbar-height) + 0.45rem);
  bottom: 1rem;
  z-index: 5;
  width: var(--drawer-width);
  padding: 1rem;
  display: grid;
  align-content: start;
  gap: 0.95rem;
  overflow: auto;
  background: rgba(255, 251, 243, 0.94);
}

.drawer-left {
  left: 1rem;
}

.drawer-right {
  right: 1rem;
}

.drawer-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
}

.drawer-library-list,
.utility-content,
.result-list,
.annotation-list {
  display: grid;
  gap: 0.8rem;
}

.drawer-item-card {
  padding: 0.82rem;
}

.contents-entry {
  display: grid;
  gap: 0.35rem;
  padding: 0.88rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(49, 35, 21, 0.08);
  background: rgba(255, 255, 255, 0.82);
  text-align: left;
  cursor: pointer;
}

.contents-entry small {
  color: var(--ink-soft);
}

.utility-panel-copy p,
.annotation-card p,
.result-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.search-panel-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
}

.settings-group {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(49, 35, 21, 0.06);
}

.settings-group h5 {
  margin: 0;
  font-size: 1rem;
}

.settings-field {
  display: grid;
  gap: 0.45rem;
}

.settings-field span {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.settings-grid {
  display: grid;
  gap: 0.9rem;
}

.settings-range-value {
  justify-self: end;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 800;
}

.settings-help {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.55;
}

.result-card,
.annotation-card {
  padding: 0.95rem;
}

.annotation-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.annotation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.swatch {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 35, 21, 0.08);
}

.selection-toolbar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--reader-bottom-bar-height) + 0.28rem);
  z-index: 7;
  transform: translateX(-50%);
  width: min(700px, calc(100% - 0.9rem));
  padding: 0.34rem 0.45rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  background: rgba(255, 251, 243, 0.97);
}

.selection-colors {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.selection-color {
  width: 1.18rem;
  height: 1.18rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(49, 35, 21, 0.1);
}

.selection-color.is-active {
  border-color: rgba(49, 35, 21, 0.75);
}

.selection-note-field {
  min-width: 0;
}

.selection-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

.selection-toolbar .selection-note-field input {
  padding: 0.58rem 0.82rem;
  min-height: 0;
}

.selection-toolbar .ghost-button,
.selection-toolbar .primary-button {
  padding: 0.52rem 0.82rem;
}

.edge-nav {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.edge-zone {
  position: absolute;
  top: calc(var(--reader-topbar-height) + 0.35rem);
  bottom: calc(var(--reader-bottom-bar-height) + 0.2rem);
  width: clamp(112px, 18vw, 220px);
  border: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent);
  opacity: 0.75;
  pointer-events: auto;
  transition: opacity 140ms ease, background 140ms ease, width 140ms ease;
}

.edge-zone:hover {
  opacity: 1;
}

.edge-zone::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 2.45rem;
  height: 2.45rem;
  border-radius: 999px;
  background: rgba(255, 251, 243, 0.82);
  border: 1px solid rgba(49, 35, 21, 0.1);
  box-shadow: 0 12px 28px rgba(43, 31, 18, 0.14);
  transform: translateY(-50%);
}

.edge-zone::before {
  position: absolute;
  top: 50%;
  z-index: 1;
  font-size: 1.35rem;
  font-weight: 800;
  color: rgba(49, 35, 21, 0.72);
  transform: translateY(-50%);
}

.edge-zone-left {
  left: 0;
}

.edge-zone-left::after {
  left: 0.8rem;
}

.edge-zone-left::before {
  content: '‹';
  left: 1.68rem;
}

.edge-zone-right {
  right: 0;
  background: linear-gradient(270deg, rgba(255, 255, 255, 0.08), transparent);
}

.edge-zone-right::after {
  right: 0.8rem;
}

.edge-zone-right::before {
  content: '›';
  right: 1.62rem;
}

.epub-host,
.pdf-host,
.comic-host {
  min-height: 100%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.epub-host {
  min-height: 0;
  height: 100%;
  display: grid;
  justify-content: center;
  align-content: start;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  contain: layout paint;
}

.epub-frame {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
  position: relative;
  isolation: isolate;
  contain: layout paint;
  clip-path: inset(0);
}

.epub-frame > div,
.epub-frame iframe {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  clip-path: inset(0);
}

.epub-frame iframe {
  display: block;
  border: 0;
  background: transparent;
}

.reader-stage.reader-stage-scroll .epub-host {
  overflow: visible;
  contain: none;
}

.epub-frame.epub-frame-scroll {
  height: 100%;
  clip-path: none;
  contain: none;
}

.epub-frame.epub-frame-scroll > div,
.epub-frame.epub-frame-scroll iframe {
  overflow: visible;
  clip-path: none;
}

.pdf-host {
  display: grid;
  height: 100%;
  gap: 1.4rem;
  min-height: 100%;
  padding-bottom: 0;
}

.pdf-host.pdf-flow-paged {
  min-height: 100%;
  height: 100%;
  align-content: stretch;
  justify-items: center;
  overflow: hidden;
  overflow-x: hidden;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.pdf-host.pdf-flow-scroll {
  width: min(1480px, 100%);
  margin: 0 auto;
  align-content: start;
  justify-items: center;
  padding-inline: 0.45rem;
}

.pdf-host.pdf-flow-scroll.pdf-spread-double {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.pdf-host.pdf-flow-scroll.pdf-spread-single {
  grid-template-columns: minmax(0, 1fr);
}

.pdf-host.pdf-flow-paged::-webkit-scrollbar {
  display: none;
}

.pdf-paged-host {
  display: grid;
  align-items: stretch;
  justify-items: center;
  width: 100%;
  min-height: 100%;
  height: 100%;
}

.pdf-spread {
  display: grid;
  width: min(1480px, 100%);
  max-width: 100%;
  gap: 1.15rem;
  height: 100%;
  align-items: stretch;
  align-content: stretch;
  justify-content: center;
}

.pdf-spread[data-pages="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pdf-page-shell {
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 24px;
}

.pdf-page-shell.pdf-page-shell-paged {
  display: grid;
  align-items: start;
  justify-items: center;
}

.pdf-page {
  position: relative;
  width: fit-content;
  margin: 0 auto;
  border-radius: 24px;
  background: white;
  box-shadow: 0 24px 46px rgba(27, 21, 15, 0.16);
  scroll-snap-align: center;
}

.pdf-canvas {
  display: block;
  border-radius: 24px;
}

.pdf-text-layer,
.pdf-annotation-layer {
  position: absolute;
  inset: 0;
}

.pdf-annotation-layer {
  pointer-events: none;
}

.pdf-highlight {
  position: absolute;
  border-radius: 4px;
  mix-blend-mode: multiply;
  opacity: 0.38;
}

.pdf-highlight.is-focus-hit {
  opacity: 0.72;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.78), 0 0 0 6px rgba(244, 162, 97, 0.56);
}

.comic-host {
  display: grid;
  width: 100%;
  height: auto;
  min-height: var(--reader-stage-height);
  align-content: start;
}

.comic-frame,
.comic-scroll-page {
  border-radius: 24px;
  background: rgba(19, 23, 27, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.comic-paged-host {
  display: grid;
  align-items: center;
  align-content: center;
  justify-items: center;
  width: 100%;
  min-height: var(--reader-stage-height);
  height: var(--reader-stage-height);
}

.comic-frame {
  display: grid;
  align-items: center;
  align-content: center;
  justify-items: center;
  width: min(1380px, 100%);
  max-width: 100%;
  height: var(--reader-stage-height);
  min-height: 0;
  padding: 0 1rem;
  box-shadow: 0 24px 52px rgba(0, 0, 0, 0.28);
}

.comic-spread {
  display: grid;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  gap: 0.9rem;
  align-items: center;
  align-content: center;
  justify-content: center;
  justify-items: center;
}

.comic-spread[data-pages="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.comic-spread.is-rtl[data-pages="2"] .comic-panel:first-child {
  order: 2;
}

.comic-panel {
  display: grid;
  align-items: center;
  align-content: center;
  justify-items: center;
  min-height: 0;
  height: 100%;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.comic-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  border-radius: 18px;
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.25);
  align-self: center;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.comic-scroll-host {
  display: grid;
  gap: 1.2rem;
  width: min(1460px, 100%);
  margin: 0 auto;
  padding-bottom: 2rem;
}

.comic-scroll-host[data-columns="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.comic-scroll-page {
  display: grid;
  place-items: center;
  padding: 1rem;
  min-height: 280px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.22);
}

.comic-scroll-page .comic-image {
  width: 100%;
  height: auto;
  max-height: none;
  border-radius: 18px;
}

.comic-magnifier {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 9;
  width: var(--comic-magnifier-size, 258px);
  height: var(--comic-magnifier-size, 258px);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(13, 16, 20, 0.94);
  box-shadow:
    0 24px 46px rgba(8, 10, 12, 0.34),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 120ms ease, transform 120ms ease;
  backdrop-filter: blur(10px);
}

.comic-magnifier.is-visible {
  opacity: 1;
  transform: scale(1);
}

.comic-magnifier__viewport {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-color: rgba(8, 10, 12, 0.88);
}

.reader-stage-wrap.comic-zoom-active .edge-zone {
  opacity: 0;
  pointer-events: none;
}

.loading-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink-soft);
  font-weight: 700;
}

@keyframes spinner-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.textLayer {
  opacity: 1;
  line-height: 1;
}

.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  transform-origin: 0 0;
  cursor: text;
}

.textLayer ::selection {
  background: rgba(65, 131, 245, 0.25);
}

@media (max-width: 1280px) {
  .hero-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .reader-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'meta actions';
    gap: 0.75rem 0.85rem;
  }

  .reader-actions {
    justify-content: flex-end;
    align-self: start;
  }
}

@media (max-width: 1024px) {
  .workspace-header {
    align-items: start;
    flex-direction: column;
  }

  .workspace-header-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .selection-toolbar {
    grid-template-columns: 1fr;
  }

  .selection-actions {
    justify-content: stretch;
  }

  .selection-actions .ghost-button,
  .selection-actions .primary-button {
    flex: 1;
  }
}

@media (max-width: 860px) {
  .auth-card {
    grid-template-columns: 1fr;
  }

  .workspace-header,
  .library-browser {
    padding-inline: 0.95rem;
  }

  .workspace-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.85rem;
    padding-bottom: 0.45rem;
  }

  .workspace-menu-toggle {
    display: inline-flex;
  }

  .workspace-header.is-mobile-expanded {
    padding-inline: 0;
  }

  .workspace-header.is-mobile-expanded .brand-block {
    padding-left: 0.95rem;
  }

  .workspace-header.is-mobile-expanded .workspace-menu-toggle {
    margin-right: 0.95rem;
  }

  .workspace-header-actions {
    grid-column: 1 / -1;
    width: calc(100% + 1.9rem);
    margin-inline: -0.95rem;
    padding: 0.2rem 0.95rem 0;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    align-self: stretch;
  }

  .workspace-header-actions > * {
    width: 100%;
    max-width: none;
  }

  .workspace-header-actions .segmented-control,
  .workspace-header-actions .status-pill,
  .workspace-header-actions .ghost-button,
  .workspace-header-actions .user-chip {
    display: flex;
    width: 100%;
  }

  .workspace-header-actions .ghost-button,
  .workspace-header-actions .user-chip {
    justify-content: center;
  }

  .workspace-header-actions .segmented-control button {
    flex: 1 1 0;
    min-width: 0;
  }

  .workspace-header.is-mobile-expanded .workspace-header-actions {
    width: 100%;
    margin-inline: 0;
    padding-inline: 0;
  }

  .workspace.is-mobile-menu-open .workspace-header,
  .workspace.is-mobile-menu-open .library-browser {
    padding-inline: 0;
  }

  .workspace.is-mobile-menu-open .brand-block {
    padding-left: 0.95rem;
  }

  .workspace.is-mobile-menu-open .workspace-menu-toggle {
    margin-right: 0.95rem;
  }

  .workspace.is-mobile-menu-open .workspace-header-actions {
    width: 100%;
    margin-inline: 0;
    padding-inline: 0;
  }

  .workspace.is-mobile-menu-open .library-browser {
    width: 100%;
  }

  .workspace.is-mobile-menu-open .library-hero,
  .workspace.is-mobile-menu-open .shelf-section {
    margin-inline: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding-inline: 0.95rem;
  }

  .library-grid,
  .continue-grid {
    grid-template-columns: 1fr;
  }

  .library-search-bar {
    grid-template-columns: 1fr;
  }

  .search-clear-button {
    width: 100%;
  }

  .library-browser {
    padding-top: 0.35rem;
    gap: 0.8rem;
  }

  .library-hero,
  .shelf-section {
    padding: 0.9rem;
  }

  .library-hero.is-collapsed {
    padding-block: 0.8rem;
  }

  .library-hero-toggle {
    width: 100%;
    justify-self: stretch;
    justify-content: center;
  }

  .section-heading {
    margin-bottom: 0.7rem;
  }

  .drawer {
    top: auto;
    left: 0.8rem;
    right: 0.8rem;
    bottom: 0.8rem;
    width: auto;
    max-height: 78vh;
  }

  .drawer-left,
  .drawer-right {
    left: 0.8rem;
    right: 0.8rem;
  }

  .reader-stage {
    padding-inline: 0;
  }

  .reader-bottom-bar {
    padding-inline: 0.95rem;
  }

  .epub-frame {
    height: calc(100vh - 200px);
    min-height: 520px;
  }

  .comic-frame {
    height: var(--reader-stage-height);
    min-height: 0;
  }

}

@media (max-width: 640px) {
  .workspace-header-actions,
  .section-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .reader-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'meta actions';
    align-items: start;
  }

  .reader-actions {
    flex-direction: row;
    align-items: center;
  }

  .reader-action-menu {
    width: min(260px, calc(100vw - 1rem));
  }

  .search-panel-form {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .epub-frame {
    height: calc(100vh - 260px);
    min-height: 440px;
  }

  .reader-bottom-bar {
    gap: 0.28rem;
    padding: 0.5rem 0.78rem 0.58rem;
    border-radius: 18px 18px 0 0;
  }

  .reader-bottom-copy {
    gap: 0.28rem;
  }

  .reader-bottom-copy .subtle-text {
    font-size: 0.92rem;
    line-height: 1.15;
  }

  .reader-scrubber {
    gap: 0.18rem;
  }

  .reader-scrubber-labels {
    grid-template-columns: 1fr;
    gap: 0.14rem;
    text-align: center;
  }

  .reader-scrubber-labels span {
    display: none;
  }

  .reader-scrubber-labels strong {
    font-size: 0.94rem;
    line-height: 1.15;
  }
}
