:root {
  color-scheme: light;
  --reader-bg: #f4f6fb;
  --reader-grad-a: rgba(55, 91, 218, 0.12);
  --reader-grad-b: rgba(0, 207, 153, 0.08);
  --page-bg: #ffffff;
  --surface: rgba(255, 255, 255, 0.94);
  --ink: #111111;
  --muted: #737780;
  --line: rgba(17, 17, 17, 0.1);
  --accent: #3f5bd8;
  --accent-strong: #2545cf;
  --accent-soft: #eef2ff;
  --delegate: #e05243;
  --labor: #146fc7;
  --management: #c34b37;
  --moderator: #057a6f;
  --page-margin: 26px;
  --font-size: 13px;
  --line-height: 1.72;
  --shadow: 0 28px 80px rgba(23, 31, 42, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 14% 0%, var(--reader-grad-a), transparent 25%),
    radial-gradient(circle at 92% 4%, var(--reader-grad-b), transparent 24%),
    var(--reader-bg);
  color: var(--ink);
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body.theme-white {
  --reader-bg: #f7f8fb;
  --reader-grad-a: rgba(63, 91, 216, 0.08);
  --reader-grad-b: rgba(0, 207, 153, 0.05);
  --page-bg: #ffffff;
  --surface: rgba(255, 255, 255, 0.9);
}

body.theme-sepia {
  --reader-bg: #e9decf;
  --reader-grad-a: rgba(0, 103, 127, 0.07);
  --reader-grad-b: rgba(147, 98, 40, 0.15);
  --page-bg: #fbf0de;
  --ink: #30281f;
  --muted: #746a5f;
  --accent: #3f5bd8;
  --accent-strong: #2545cf;
  --accent-soft: #eef2ff;
}

body.theme-night {
  color-scheme: dark;
  --reader-bg: #0d1117;
  --reader-grad-a: rgba(0, 103, 127, 0.2);
  --reader-grad-b: rgba(255, 255, 255, 0.04);
  --page-bg: #15191f;
  --surface: rgba(22, 27, 34, 0.88);
  --ink: #eef2f5;
  --muted: #aab2bd;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #7f96ff;
  --accent-strong: #b8c4ff;
  --accent-soft: #222a4d;
  --delegate: #e2a298;
  --labor: #89b8ff;
  --management: #ff9a83;
  --moderator: #73d2c2;
}

#brightnessMask {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: #000;
  opacity: 0;
}

.reader-app {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
}

.desktop-rail {
  display: none;
}

.library-home {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  overflow: auto;
  background:
    radial-gradient(circle at 12% 0%, rgba(63, 91, 216, 0.12), transparent 24%),
    #f7f8fb;
  color: var(--ink);
  padding: max(22px, env(safe-area-inset-top)) clamp(18px, 4vw, 54px) max(88px, env(safe-area-inset-bottom));
}

.mode-library .library-home {
  display: block;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1040px;
  margin: 0 auto 18px;
}

.home-header p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
}

.home-header h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: -.02em;
}

.round-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px rgba(63, 91, 216, .24);
  cursor: pointer;
}

.round-icon svg {
  width: 20px;
  height: 20px;
}

.home-search {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1040px;
  min-height: 48px;
  margin: 0 auto 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: #8a9099;
  padding: 0 15px;
  font-size: 14px;
  font-weight: 700;
}

.home-search svg {
  width: 19px;
  height: 19px;
}

.home-tabs {
  display: flex;
  gap: 8px;
  max-width: 1040px;
  margin: 0 auto 18px;
  overflow-x: auto;
}

.home-tabs button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 15px;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.home-tabs button.active {
  border-color: #dce3ff;
  background: #edf1ff;
  color: var(--accent-strong);
}

.featured-book {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 22px;
  max-width: 1040px;
  margin: 0 auto 24px;
  border: 1px solid rgba(17, 17, 17, .08);
  border-radius: 28px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 22px 54px rgba(17, 24, 39, .1);
}

.featured-cover {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 230px;
  border-radius: 22px;
  background:
    linear-gradient(150deg, rgba(63, 91, 216, .92), rgba(20, 31, 65, .95)),
    var(--accent);
  color: #fff;
  padding: 20px;
  box-shadow: 0 18px 36px rgba(63, 91, 216, .22);
}

.featured-cover span {
  align-self: flex-start;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 900;
}

.featured-cover strong {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.featured-info {
  align-self: center;
  min-width: 0;
}

.featured-info p,
.section-title button {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.featured-info h2 {
  max-width: 620px;
  margin: 0 0 10px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.25;
  letter-spacing: -.02em;
}

.featured-info > span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.home-progress {
  width: min(420px, 100%);
  height: 7px;
  margin: 22px 0;
  border-radius: 999px;
  background: #e6eaf0;
  overflow: hidden;
}

.home-progress div {
  width: 2%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.home-read-button {
  min-width: 140px;
}

.book-grid-section {
  max-width: 1040px;
  margin: 0 auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
}

.section-title button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.book-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.book-cover-mini {
  display: grid;
  place-items: center;
  width: 58px;
  height: 78px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--accent), #172043);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
}

.book-card strong {
  display: block;
  margin-bottom: 5px;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.home-bottom-nav {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 75;
  display: none;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.96);
  padding: 8px;
  box-shadow: 0 16px 36px rgba(17, 24, 39, .12);
}

.home-bottom-nav button {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 48px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.home-bottom-nav button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.home-bottom-nav svg {
  width: 19px;
  height: 19px;
}

.reader-topbar,
.reader-bottombar {
  position: relative;
  z-index: 20;
  background: var(--surface);
  border-color: var(--line);
  backdrop-filter: blur(22px);
  transition: transform 180ms ease, opacity 180ms ease;
}

.reader-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: max(9px, env(safe-area-inset-top)) clamp(14px, 3vw, 28px) 9px;
  border-bottom: 1px solid var(--line);
}

.reader-bottombar {
  display: grid;
  gap: 10px;
  min-height: 88px;
  padding: 8px clamp(16px, 3vw, 30px) max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

body:not(.controls-on) .reader-topbar {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}

body:not(.controls-on) .reader-bottombar {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
}

.book-heading {
  min-width: 0;
}

.book-heading p,
.dialog-head p,
.sheet-head p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-heading h1 {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.primary-button,
.theme-grid button,
.stepper button,
.nav-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 40px;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 900;
}

.icon-button svg,
.nav-icon svg,
.rail-menu svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.brand-button {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(63, 91, 216, 0.22);
}

.brand-symbol {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
}

.bookmark-action {
  gap: 7px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.34);
}

.icon-button.active,
.icon-button:hover,
.nav-button:hover,
.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.reader-surface {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: clamp(10px, 2.2vw, 24px);
}

.book-page {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 760px);
  height: 100%;
  max-height: 980px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 16px;
  background: var(--page-bg);
  box-shadow: 0 18px 52px rgba(17, 24, 39, 0.12);
  overflow: hidden;
}

.page-brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
  padding: 0 var(--page-margin);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-content {
  min-height: 0;
  padding: calc(var(--page-margin) * 0.9) var(--page-margin) var(--page-margin);
  overflow: hidden;
  color: var(--ink);
  font-size: var(--font-size);
  line-height: var(--line-height);
  word-break: keep-all;
  user-select: text;
  -webkit-user-select: text;
}

.page-content p {
  margin: 0 0 0.92em;
  user-select: text;
  -webkit-user-select: text;
}

.page-content .speaker,
.admin-preview-body .speaker {
  margin-right: 0.22em;
  color: var(--accent-strong);
  font-weight: 900;
}

.page-content .speaker.delegate,
.admin-preview-body .speaker.delegate {
  color: var(--delegate);
}

.page-content .speaker.labor,
.admin-preview-body .speaker.labor {
  color: var(--labor);
}

.page-content .speaker.management,
.admin-preview-body .speaker.management {
  color: var(--management);
}

.page-content .speaker.moderator,
.admin-preview-body .speaker.moderator {
  color: var(--moderator);
}

.page-content .break,
.admin-preview-body .break {
  position: relative;
  margin: 1.65em 0;
  border-top: 1px solid rgba(47, 103, 232, 0.18);
  border-bottom: 1px solid rgba(47, 103, 232, 0.18);
  background: linear-gradient(90deg, transparent, rgba(47, 103, 232, 0.06), transparent);
  padding: 0.78em 0;
  color: var(--accent-strong);
  font-weight: 900;
  text-align: center;
}

.page-content .section-start {
  padding-top: 0.2em;
}

.page-content .article-marker,
.admin-preview-body .article-marker {
  margin: 1em 0 0.75em;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: rgba(47, 103, 232, 0.04);
  color: var(--ink);
  padding: 0.58em 0.72em;
  font-weight: 900;
  line-height: 1.42;
}

.page-content .milestone-marker,
.admin-preview-body .milestone-marker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.45em 0 1.05em;
  color: var(--ink);
  font-size: 0.95em;
  font-weight: 950;
  text-align: center;
}

.page-content .milestone-marker::before,
.page-content .milestone-marker::after,
.admin-preview-body .milestone-marker::before,
.admin-preview-body .milestone-marker::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(17, 17, 17, 0.22);
}

.page-content .milestone-marker {
  justify-content: center;
}

.page-content .strong-marker,
.admin-preview-body .strong-marker {
  color: var(--ink);
  font-weight: 950;
}

.turn-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 10;
  border: 0;
  background: transparent;
  pointer-events: none;
  cursor: pointer;
}

.turn-left {
  left: 0;
  width: 30%;
}

.turn-center {
  left: 30%;
  width: 40%;
}

.turn-right {
  right: 0;
  width: 30%;
}

.progress-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

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

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 13px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.nav-icon {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
}

.nav-button:hover .nav-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.reader-dialog {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--page-bg);
  color: var(--ink);
  padding: 20px;
  box-shadow: var(--shadow);
}

.reader-dialog::backdrop {
  background: rgba(7, 11, 16, 0.46);
  backdrop-filter: blur(3px);
}

.dialog-head,
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.dialog-head h2,
.sheet-head h2 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.library-card {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  padding: 14px;
}

.bookshelf-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: -2px 0 14px;
  border-bottom: 1px solid var(--line);
}

.bookshelf-tabs span {
  position: relative;
  padding: 0 0 11px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  font-weight: 900;
}

.bookshelf-tabs span.active {
  color: var(--ink);
}

.bookshelf-tabs span.active::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -1px;
  height: 2px;
  border-radius: 99px;
  background: var(--ink);
}

.library-card img {
  width: 116px;
  height: 154px;
  border-radius: 14px;
  object-fit: cover;
  background: #d8dde5;
  box-shadow: 0 12px 28px rgba(22, 27, 34, 0.16);
}

.library-card h3 {
  margin: 5px 0 9px;
  font-size: 18px;
  line-height: 1.36;
}

.library-card p {
  color: var(--muted);
}

.primary-button {
  min-height: 42px;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 900;
}

.file-picker {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 900;
}

.file-picker input {
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.36);
  padding: 14px;
  color: var(--ink);
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.sheet {
  position: fixed;
  right: 16px;
  top: 110vh;
  bottom: auto;
  z-index: 40;
  width: min(460px, calc(100vw - 32px));
  max-height: min(74vh, 700px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--page-bg);
  color: var(--ink);
  padding: 18px;
  box-shadow: var(--shadow);
  overflow: auto;
  opacity: 0;
  pointer-events: none;
  transition: none;
}

.sheet.open {
  top: 16vh;
  opacity: 1;
  pointer-events: auto;
}

.sheet-list {
  display: grid;
  gap: 8px;
}

.sheet-list button,
.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.3);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  font: inherit;
}

.sheet-list button {
  cursor: pointer;
}

.sheet-list button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sheet-list small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.search-input {
  min-height: 46px;
  margin-bottom: 12px;
}

mark {
  border-radius: 4px;
  background: #ffe08a;
  color: inherit;
  padding: 0 2px;
}

.setting-block {
  border-top: 1px solid var(--line);
  padding: 15px 0;
}

.setting-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.stepper,
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: center;
}

.stepper span {
  text-align: center;
  font-weight: 900;
}

.stepper button,
.theme-grid button {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 900;
}

.theme-grid {
  grid-template-columns: repeat(4, 1fr);
}

.theme-grid button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(116px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: calc(100vw - 32px);
  border-radius: 999px;
  background: rgba(22, 27, 34, 0.9);
  color: #fff;
  padding: 10px 15px;
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.measuring {
  position: fixed;
  left: -200vw;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (min-width: 900px) {
  :root {
    --page-margin: 34px;
    --font-size: 18px;
  }

  .reader-app {
    grid-template-columns: 312px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    column-gap: 0;
  }

  .desktop-rail {
    display: flex;
    grid-row: 1 / 4;
    flex-direction: column;
    gap: 20px;
    min-height: 100dvh;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
    padding: 28px 22px;
    backdrop-filter: blur(22px);
  }

  .rail-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 22px;
  }

  .rail-logo {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font-size: 18px;
    font-weight: 900;
    box-shadow: 0 14px 28px rgba(0, 103, 127, 0.2);
  }

  .rail-brand p,
  .rail-document p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .rail-brand h2 {
    margin: 3px 0 0;
    font-size: 20px;
    line-height: 1.2;
  }

  .rail-document {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.38));
    padding: 16px;
  }

  .rail-document h3 {
    margin: 8px 0 10px;
    font-size: 16px;
    line-height: 1.45;
  }

  .rail-document span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .rail-menu {
    display: grid;
    gap: 8px;
  }

  .rail-menu button {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 3px;
    align-items: center;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    color: var(--ink);
    padding: 13px 14px;
    text-align: left;
    font: inherit;
    cursor: pointer;
  }

  .rail-menu button:hover,
  .rail-menu button.active {
    border-color: var(--line);
    background: var(--accent-soft);
  }

  .rail-menu span {
    grid-column: 2;
    font-size: 14px;
    font-weight: 900;
  }

  .rail-menu small {
    grid-column: 2;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }

  .rail-menu svg {
    grid-row: 1 / 3;
    color: var(--accent);
  }

  .reader-topbar {
    grid-column: 2;
    min-height: 76px;
    border-bottom: 0;
    background: transparent;
    padding: 22px 44px 10px;
  }

  .reader-topbar .brand-button {
    display: none;
  }

  .book-heading {
    max-width: min(900px, 72vw);
    margin: 0 auto;
    text-align: center;
  }

  .book-heading h1 {
    font-size: 19px;
  }

  .bookmark-action {
    min-width: 88px;
    background: var(--surface);
  }

  .reader-surface {
    grid-column: 2;
    padding: 22px 54px;
  }

  .book-page {
    width: min(88%, 880px);
    max-height: 1040px;
    border-radius: 28px;
  }

  .page-brandbar {
    min-height: 48px;
  }

  .reader-bottombar {
    grid-column: 2;
    min-height: 76px;
    border-top: 0;
    background: transparent;
    padding: 8px 54px 24px;
  }

  .reader-bottombar .progress-line {
    width: min(88%, 880px);
    min-height: 48px;
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    padding: 0 16px;
  }

  .bottom-nav {
    display: none;
  }

  .sheet {
    right: 32px;
    width: min(460px, calc(100vw - 360px));
  }

  .reader-dialog {
    margin-left: 312px;
  }
}

@media (max-width: 720px) {
  .library-home {
    padding: max(18px, env(safe-area-inset-top)) 16px 92px;
  }

  .home-header {
    margin-bottom: 14px;
  }

  .home-header h1 {
    font-size: 31px;
  }

  .home-search {
    min-height: 46px;
    margin-bottom: 14px;
    border-radius: 15px;
  }

  .home-tabs {
    margin-bottom: 16px;
  }

  .featured-book {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 15px;
    border-radius: 22px;
    padding: 14px;
  }

  .featured-cover {
    min-height: 158px;
    border-radius: 18px;
    padding: 14px;
  }

  .featured-cover strong {
    font-size: 17px;
  }

  .featured-info h2 {
    display: -webkit-box;
    overflow: hidden;
    font-size: 18px;
    line-height: 1.34;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .home-progress {
    margin: 14px 0;
  }

  .home-read-button {
    width: 100%;
    min-width: 0;
  }

  .book-card {
    grid-template-columns: 50px minmax(0, 1fr) auto;
    border-radius: 16px;
  }

  .book-cover-mini {
    width: 50px;
    height: 66px;
    font-size: 21px;
  }

  .home-bottom-nav {
    display: grid;
  }

  .reader-topbar {
    min-height: 58px;
    padding-inline: 12px;
  }

  .bookmark-action {
    min-width: 40px;
    padding-inline: 10px;
  }

  .bookmark-action span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .bookmark-action::before {
    content: "";
  }

  .reader-surface {
    padding: 8px;
  }

  .book-page {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    box-shadow: none;
  }

  .page-brandbar {
    min-height: 34px;
  }

  .reader-bottombar {
    min-height: 92px;
    padding-inline: 12px;
  }

  .nav-button {
    flex-direction: column;
    gap: 3px;
    min-height: 46px;
    border-color: transparent;
    background: transparent;
    font-size: 12px;
  }

  .nav-icon {
    min-width: 24px;
    height: 22px;
  }

  .reader-dialog {
    padding: 16px;
  }

  .library-card {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .library-card img {
    width: 92px;
    height: 122px;
  }

  .sheet {
    right: 8px;
    top: 110vh;
    bottom: auto;
    width: calc(100vw - 16px);
    max-height: 76vh;
    border-radius: 24px;
  }

  .sheet.open {
    top: 20vh;
  }
}

/* Kyobo-style reader pass */
:root {
  --reader-bg: #f2f3f5;
  --reader-grad-a: transparent;
  --reader-grad-b: transparent;
  --surface: rgba(255, 255, 255, 0.96);
  --page-bg: #ffffff;
  --ink: #17191f;
  --muted: #7d838c;
  --line: rgba(24, 29, 37, 0.1);
  --accent: #2f67e8;
  --accent-strong: #2559d4;
  --accent-soft: #edf4ff;
  --delegate: #d64d3f;
  --labor: #146fc7;
  --management: #c34b37;
  --moderator: #057a6f;
  --shadow: 0 18px 52px rgba(28, 36, 48, 0.13);
}

body {
  background: var(--reader-bg);
}

body.theme-white {
  --reader-bg: #f4f5f7;
  --surface: rgba(255, 255, 255, 0.98);
}

body.theme-sepia {
  --reader-bg: #eee7db;
  --surface: rgba(255, 250, 241, 0.96);
  --page-bg: #fff8ec;
  --ink: #29231d;
  --muted: #7c7166;
}

body.theme-night {
  --reader-bg: #111419;
  --surface: rgba(22, 25, 31, 0.96);
  --page-bg: #171b22;
  --ink: #eef1f5;
  --muted: #a4acb7;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #8aa2ff;
  --accent-strong: #b9c7ff;
  --accent-soft: rgba(138, 162, 255, 0.15);
  --labor: #89b8ff;
  --management: #ff9a83;
  --moderator: #73d2c2;
}

.reader-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100dvh;
  background: var(--reader-bg);
}

.desktop-rail {
  display: none;
}

.reader-topbar {
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr) 42px 42px 42px;
  gap: 2px;
  align-items: center;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: max(8px, env(safe-area-inset-top)) 8px 8px;
  backdrop-filter: blur(18px);
}

.reader-topbar .icon-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  padding: 0;
}

.reader-topbar .icon-button:hover,
.reader-topbar .icon-button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.reader-topbar .icon-button svg {
  width: 21px;
  height: 21px;
}

.book-heading {
  min-width: 0;
  text-align: center;
}

.book-heading p {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
}

.book-heading h1 {
  margin: 2px auto 0;
  max-width: min(72vw, 680px);
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-heading span {
  display: none;
}

.bookmark-action span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.reader-surface {
  display: grid;
  place-items: center;
  min-height: 0;
  background: var(--reader-bg);
  padding: 14px 14px 10px;
}

.book-page {
  width: min(100%, 740px);
  height: 100%;
  max-height: 980px;
  border: 1px solid rgba(23, 25, 31, 0.08);
  border-radius: 12px;
  background: var(--page-bg);
  box-shadow: 0 10px 32px rgba(30, 36, 46, 0.08);
}

.page-brandbar {
  min-height: 44px;
  border-bottom: 0;
  padding: 0 var(--page-margin);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.page-brandbar::after {
  content: "";
  position: absolute;
  left: var(--page-margin);
  right: var(--page-margin);
  top: 44px;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), rgba(47, 103, 232, 0.12));
}

.page-content {
  padding: calc(var(--page-margin) * 0.85) var(--page-margin) var(--page-margin);
  font-size: var(--font-size);
  line-height: var(--line-height);
  letter-spacing: 0;
}

.turn-slide .page-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.turn-slide .turn-zone {
  pointer-events: none;
}

.turn-flip .page-content {
  overflow: hidden;
}

.page-content p {
  margin: 0 0 0.86em;
}

.page-content .speaker,
.admin-preview-body .speaker {
  color: var(--accent-strong);
  font-weight: 900;
}

.page-content .break,
.admin-preview-body .break {
  border-top: 1px solid rgba(47, 103, 232, 0.18);
  border-bottom: 1px solid rgba(47, 103, 232, 0.18);
}

.reader-bottombar {
  display: grid;
  gap: 8px;
  min-height: 116px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  backdrop-filter: blur(18px);
}

.bottom-menu-hidden .reader-app {
  grid-template-rows: auto minmax(0, 1fr) 0;
}

.bottom-menu-hidden .reader-bottombar {
  min-height: 0;
  height: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
}

body:not(.controls-on):not(.mode-library) .reader-app {
  grid-template-rows: 0 minmax(0, 1fr) 0;
}

body:not(.controls-on):not(.mode-library) .reader-topbar,
body:not(.controls-on):not(.mode-library) .reader-bottombar {
  min-height: 0;
  height: 0;
  border: 0;
  padding: 0;
  overflow: hidden;
}

.show-bottom-menu {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 32;
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 10px 28px rgba(27, 34, 45, 0.14);
  transform: translateX(-50%);
  cursor: pointer;
}

.show-bottom-menu svg {
  width: 16px;
  height: 16px;
}

.bottom-menu-hidden:not(.mode-library) .show-bottom-menu {
  display: inline-flex;
}

.reader-pagebar {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto 36px 36px;
  gap: 8px;
  align-items: center;
  min-height: 42px;
}

.reader-pagebar input[type="range"] {
  min-width: 0;
}

#pageLabel {
  min-width: 58px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.page-round-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.page-round-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.page-round-button svg {
  width: 18px;
  height: 18px;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2px;
}

.nav-button {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1.1;
  text-align: center;
  word-break: keep-all;
}

.nav-button:hover,
.nav-button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-icon {
  min-width: 0;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: currentColor;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.wide-setting-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--page-bg);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.wide-setting-button.active,
.wide-setting-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.wide-setting-button svg {
  width: 18px;
  height: 18px;
}

.mode-toggle-button span:last-child {
  max-width: 100%;
  line-height: 1.15;
}

.library-list {
  display: grid;
  gap: 8px;
}

.library-list-item {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--page-bg);
  color: var(--ink);
  padding: 10px 14px;
  text-align: left;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.3;
  cursor: pointer;
}

.library-list-item small,
.library-page-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.library-list-item:hover,
.library-list-item[aria-current="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.library-page {
  z-index: 90;
  background: var(--reader-bg);
  padding: max(22px, env(safe-area-inset-top)) clamp(18px, 5vw, 48px) max(26px, env(safe-area-inset-bottom));
}

.mode-library .reader-app {
  pointer-events: none;
}

.library-page-shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

.library-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 70px;
  margin-bottom: 28px;
}

.library-page-header p,
.library-page main > h2 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.library-page-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(27px, 5vw, 40px);
  font-weight: 950;
  line-height: 1.05;
}

.library-page main > h2 {
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 18px;
}

.library-page-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 18px 14px;
}

.library-page-item {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--page-bg);
  color: var(--ink);
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
  box-shadow: none;
  cursor: pointer;
}

.library-page-item:hover,
.library-page-item[aria-current="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.library-category-item {
  grid-column: auto;
  display: grid;
  justify-items: center;
  gap: 7px;
  min-height: 132px;
  border-color: transparent;
  background: transparent;
  padding: 8px;
  text-align: center;
}

.library-category-item:hover {
  border-color: rgba(47, 103, 232, 0.18);
  background: rgba(47, 103, 232, 0.06);
}

.folder-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 58px;
}

.folder-icon::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 5px;
  height: 39px;
  border: 1px solid #e2aa34;
  border-radius: 6px;
  background: linear-gradient(#ffd86a, #f6bd46);
}

.folder-icon::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 9px;
  width: 31px;
  height: 16px;
  border: 1px solid #e2aa34;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: #ffd86a;
}

.folder-icon img {
  position: relative;
  z-index: 1;
  width: 54px;
  height: 42px;
  border-radius: 4px;
  object-fit: cover;
}

.folder-icon.custom {
  width: 76px;
  height: 76px;
}

.folder-icon.custom::before,
.folder-icon.custom::after {
  display: none;
}

.folder-icon.custom img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: contain;
}

.folder-name {
  display: -webkit-box;
  max-width: 108px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.library-back-item {
  grid-column: 1 / -1;
  background: transparent;
  color: var(--muted);
}

.summary-dialog {
  width: min(720px, calc(100vw - 28px));
}

.summary-content {
  max-height: min(68vh, 720px);
  overflow: auto;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
}

.summary-content h1,
.summary-content h2,
.summary-content h3,
.summary-content h4,
.summary-content h5,
.summary-content h6 {
  margin: 1.05em 0 0.5em;
  color: var(--ink);
  line-height: 1.35;
  font-weight: 950;
}

.summary-content h1 {
  font-size: 26px;
}

.summary-content h2 {
  font-size: 23px;
}

.summary-content h3 {
  font-size: 20px;
}

.summary-content h4 {
  font-size: 17px;
}

.summary-content p {
  margin: 0 0 0.85em;
}

.summary-content strong {
  color: var(--ink);
  font-weight: 950;
}

.summary-content em {
  color: var(--muted);
}

.summary-content del {
  color: var(--muted);
  text-decoration-thickness: 2px;
}

.summary-content a {
  color: var(--accent-strong);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.summary-content ul,
.summary-content ol {
  margin: 0 0 1em;
  padding-left: 1.35em;
}

.summary-content li {
  margin: 0.22em 0;
  padding-left: 0.15em;
}

.summary-content .task-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin-left: -1.2em;
}

.summary-content .task-list-item input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.summary-content blockquote {
  margin: 0 0 1em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.7em 0.9em;
}

.summary-content code {
  border-radius: 4px;
  background: rgba(24, 29, 37, 0.08);
  padding: 0.1em 0.35em;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
}

.summary-content pre {
  overflow: auto;
  margin: 0 0 1em;
  border-radius: 8px;
  background: #101418;
  color: #f4f7fb;
  padding: 12px;
}

.summary-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.summary-content table {
  width: 100%;
  margin: 0 0 1em;
  border-collapse: collapse;
  font-size: 14px;
}

.summary-content th,
.summary-content td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.summary-content th {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 950;
}

.summary-content hr {
  height: 1px;
  margin: 1.45em 0;
  border: 0;
  background: var(--line);
}

.summary-content .summary-subhead {
  margin: 0.75em 0 0.25em;
  font-weight: 950;
}

.admin-page {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  overflow: auto;
  background: var(--reader-bg);
  padding: max(22px, env(safe-area-inset-top)) clamp(18px, 5vw, 48px) max(28px, env(safe-area-inset-bottom));
}

.mode-admin .admin-page {
  display: block;
}

.mode-admin .library-home {
  display: none;
}

.mode-admin .reader-app {
  pointer-events: none;
}

.admin-shell {
  width: min(820px, 100%);
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  margin-bottom: 22px;
}

.admin-header p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.admin-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(27px, 5vw, 40px);
  font-weight: 950;
  line-height: 1.05;
}

.admin-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--page-bg);
  padding: 18px;
  box-shadow: 0 12px 34px rgba(27, 34, 45, 0.08);
}

.admin-panel + .admin-panel,
.admin-workspace {
  margin-top: 14px;
}

.admin-workspace[hidden],
.admin-login[hidden] {
  display: none;
}

.admin-panel h2 {
  margin: 0;
  font-size: 18px;
}

.admin-panel label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.admin-panel input,
.admin-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.admin-panel textarea {
  min-height: 280px;
  resize: vertical;
}

.admin-preview {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(47, 103, 232, 0.04);
  padding: 12px;
}

.admin-preview > strong {
  font-size: 13px;
}

.admin-preview-body {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.admin-preview-body p {
  margin: 0;
}

.admin-preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid rgba(24, 29, 37, 0.06);
  padding-bottom: 7px;
}

.admin-preview-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.admin-preview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.admin-preview-controls button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--page-bg);
  color: var(--muted);
  padding: 0 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.admin-preview-controls button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.admin-password-row,
.admin-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

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

.admin-book-list {
  display: grid;
  gap: 8px;
}

.admin-book-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.admin-book-main strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-book-main span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-book-item label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.admin-book-item input {
  min-height: 42px;
}

.admin-book-actions,
.admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-book-actions {
  justify-content: flex-end;
}

.admin-folder-list {
  display: grid;
  gap: 8px;
}

.admin-folder-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) minmax(180px, 260px) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.admin-folder-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-folder-item input {
  min-width: 0;
}

.book-page.slide-next {
  animation: slideNext 280ms ease both;
}

.book-page.slide-prev {
  animation: slidePrev 280ms ease both;
}

.book-page.flip-next {
  animation: flipNext 330ms ease both;
  transform-origin: left center;
}

.book-page.flip-prev {
  animation: flipPrev 330ms ease both;
  transform-origin: right center;
}

@keyframes slideNext {
  0% {
    opacity: 0.72;
    transform: translateY(28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slidePrev {
  0% {
    opacity: 0.72;
    transform: translateY(-28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flipNext {
  0% {
    opacity: 0.78;
    transform: perspective(900px) rotateY(-12deg);
  }
  100% {
    opacity: 1;
    transform: perspective(900px) rotateY(0);
  }
}

@keyframes flipPrev {
  0% {
    opacity: 0.78;
    transform: perspective(900px) rotateY(12deg);
  }
  100% {
    opacity: 1;
    transform: perspective(900px) rotateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-page.slide-next,
  .book-page.slide-prev,
  .book-page.flip-next,
  .book-page.flip-prev {
    animation: none;
  }
}

.sheet {
  border-radius: 22px 22px 0 0;
}

@media (min-width: 900px) {
  .reader-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .desktop-rail {
    display: none;
  }

  .reader-topbar {
    grid-column: 1;
    min-height: 78px;
    padding: 12px max(28px, calc((100vw - 980px) / 2)) 10px;
    background: var(--surface);
  }

  .reader-topbar .brand-button {
    display: inline-flex;
  }

  .book-heading h1 {
    max-width: 760px;
    font-size: 13px;
  }

  .reader-surface {
    grid-column: 1;
    padding: 24px 54px 18px;
  }

  .book-page {
    width: min(760px, 72vw);
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(25, 32, 44, 0.13);
  }

  .reader-bottombar {
    grid-column: 1;
    width: min(760px, 72vw);
    min-height: 104px;
    margin: 0 auto 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 34px rgba(27, 34, 45, 0.1);
    padding: 10px 14px 12px;
  }

  .bottom-nav {
    display: grid;
  }

  .sheet {
    right: max(24px, calc((100vw - 980px) / 2));
    width: min(440px, calc(100vw - 48px));
  }

  .reader-dialog {
    margin-left: auto;
  }
}

@media (max-width: 720px) {
  .reader-topbar {
    min-height: 72px;
    padding-inline: 6px;
  }

  .reader-topbar .icon-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .reader-surface {
    padding: 10px 10px 8px;
  }

  .book-page {
    width: 100%;
    border-radius: 10px;
    box-shadow: none;
  }

  .page-brandbar {
    min-height: 38px;
  }

  .page-brandbar::after {
    top: 38px;
  }

  .reader-bottombar {
    min-height: 116px;
    padding-inline: 10px;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-password-row,
  .admin-form-grid,
  .admin-book-item {
    grid-template-columns: 1fr;
  }

  .admin-preview-row {
    grid-template-columns: 1fr;
  }

  .admin-preview-controls {
    justify-content: flex-start;
  }

  .admin-folder-item {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .admin-folder-item input,
  .admin-folder-item button {
    grid-column: 1 / -1;
  }
}
