:root {
  --ink: #152827;
  --muted: #6c7b78;
  --paper: #f6f2e9;
  --paper-deep: #ece6d9;
  --mint: #dcebe3;
  --teal: #12645f;
  --teal-dark: #0e4845;
  --coral: #e99372;
  --line: rgba(21, 40, 39, 0.13);
  --shadow: 0 24px 70px rgba(31, 63, 54, 0.17);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "IBM Plex Sans Thai", system-ui, sans-serif;
}
button, label { font: inherit; }
button { border: 0; cursor: pointer; }
.app-shell { min-height: 100vh; overflow: hidden; }
body.reading-mode { overflow: hidden; }
body.reading-mode .topbar, body.reading-mode .footer { display: none; }
body.reading-mode .workspace { width: min(1680px, calc(100% - 20px)); }
body.reading-mode .reader-stage { margin: 12px 0 18px; }
.reader-stage { --sidebar-width: 190px; --sidebar-scale: 1; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(24px, 5vw, 76px);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 242, 233, 0.9);
}
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--paper);
  background: var(--teal);
  border-radius: 14px 14px 14px 5px;
  font-family: "Noto Serif Thai", serif;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 6px 6px 0 #b9d5c9;
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .19em;
}
.eyebrow.warm { color: #ae6348; }
.topbar h1 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.topbar-status { color: var(--muted); font-size: 12px; }
.auth-user-bar { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.text-button { padding: 5px 0; color: var(--teal); background: transparent; font-size: 12px; font-weight: 700; }
.text-button:hover { color: var(--teal-dark); text-decoration: underline; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #54a66f; box-shadow: 0 0 0 4px rgba(84, 166, 111, .14); }
.workspace { width: min(1520px, calc(100% - 40px)); margin: 0 auto; }
.intro-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, .9fr); gap: clamp(40px, 7vw, 100px); align-items: center; padding: 72px 0 66px; }
.intro-copy { max-width: 570px; }
.intro-copy h2, .bottom-panel h2 { margin: 17px 0 22px; font-family: "Noto Serif Thai", serif; font-size: clamp(34px, 5vw, 62px); font-weight: 600; line-height: 1.13; letter-spacing: -.055em; }
.intro-copy h2 em { color: var(--teal); font-style: normal; }
.intro-text { max-width: 510px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.8; }
.action-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.primary-button, .secondary-button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 0 22px; border-radius: 999px; font-size: 14px; font-weight: 700; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.primary-button { color: #fff; background: var(--teal); box-shadow: 0 8px 18px rgba(18, 100, 95, .2); }
.secondary-button { color: var(--teal); background: transparent; border: 1px solid rgba(18,100,95,.35); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.hint { margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.hero-card { position: relative; min-height: 440px; isolation: isolate; }
.hero-card::before { position: absolute; inset: 8% 2% 3% 5%; z-index: -2; content: ""; border-radius: 42px; background: linear-gradient(145deg, #c6e0d0, #e9cab8 75%); transform: rotate(4deg); }
.hero-card::after { position: absolute; inset: 0 8% 9% 0; z-index: -1; content: ""; border: 1px solid rgba(255,255,255,.8); border-radius: 42px; background: linear-gradient(135deg, rgba(255,255,255,.48), rgba(255,255,255,.03)); box-shadow: var(--shadow); }
.hero-glow { position: absolute; right: 15%; top: 10%; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.36); filter: blur(6px); }
.mock-book { position: absolute; top: 52px; left: 50%; width: 260px; height: 340px; transform: translateX(-46%) rotate(-7deg); perspective: 1000px; }
.mock-page { position: absolute; width: 100%; height: 100%; border-radius: 6px 15px 15px 6px; box-shadow: 18px 22px 28px rgba(23,52,43,.2); }
.back-page { left: 25px; top: 12px; background: #a8c4b4; transform: rotate(8deg); }
.front-page { overflow: hidden; padding: 34px 29px; color: #f9f4e8; background: linear-gradient(155deg, #0f5552, #1b776b); }
.front-page::before { position: absolute; inset: 0; content: ""; background: radial-gradient(circle at 70% 26%, rgba(236,198,130,.7) 0 2px, transparent 3px), radial-gradient(circle at 45% 62%, rgba(255,255,255,.19) 0 1px, transparent 2px); background-size: 90px 90px, 45px 45px; opacity: .75; }
.page-rule { position: absolute; top: 19px; left: 28px; right: 28px; height: 1px; background: rgba(255,255,255,.5); }
.cover-kicker { position: relative; margin: 0 0 42px; font-size: 8px; letter-spacing: .2em; opacity: .8; }
.front-page h3 { position: relative; margin: 0; font-family: "Noto Serif Thai", serif; font-size: 41px; line-height: 1.08; letter-spacing: -.08em; }
.front-page h3 span { color: #f0c687; }
.cover-caption { position: absolute; bottom: 25px; margin: 0; color: #d3e3d9; font-size: 10px; letter-spacing: .08em; }
.cover-orbit { position: absolute; right: -40px; bottom: 40px; width: 170px; height: 170px; border: 1px solid rgba(240,198,135,.55); border-radius: 50%; box-shadow: 0 0 0 14px rgba(240,198,135,.1), 0 0 0 31px rgba(240,198,135,.07); }
.floating-note { position: absolute; display: grid; gap: 1px; padding: 11px 15px; border: 1px solid rgba(255,255,255,.8); border-radius: 13px; background: rgba(255,255,255,.64); box-shadow: 0 15px 30px rgba(31,63,54,.1); backdrop-filter: blur(12px); }
.floating-note span { color: var(--coral); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.floating-note b { font-size: 12px; }
.floating-note small { color: var(--muted); font-size: 10px; }
.note-one { top: 54px; right: 7%; }
.note-two { right: 2%; bottom: 32px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding-bottom: 68px; }
.quick-card { display: flex; gap: 15px; min-height: 150px; padding: 23px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.38); }
.active-card { border-color: rgba(18,100,95,.3); background: var(--mint); }
.card-icon { display: grid; flex: 0 0 auto; width: 37px; height: 37px; place-items: center; color: #fff; border-radius: 50%; background: var(--teal); font-size: 11px; font-weight: 700; }
.outline-icon { color: var(--teal); background: transparent; border: 1px solid rgba(18,100,95,.32); }
.card-label { margin: 0 0 3px; color: var(--coral); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.quick-card h3 { margin: 0 0 7px; font-size: 16px; }
.quick-card p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.bottom-panel { display: grid; grid-template-columns: .8fr 1.2fr; gap: 50px; padding: 52px 0 60px; border-top: 1px solid var(--line); }
.bottom-panel h2 { margin: 12px 0 0; font-size: clamp(27px, 3vw, 41px); }
.workflow-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; align-self: center; margin: 0; padding: 0; list-style: none; }
.workflow-list li { position: relative; display: grid; gap: 9px; padding: 0 14px; border-left: 1px solid var(--line); }
.workflow-list li:first-child { border-left: 0; }
.workflow-list li::after { position: absolute; top: 15px; right: -4px; width: 7px; height: 7px; content: ""; border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: rotate(45deg); }
.workflow-list li:last-child::after { display: none; }
.workflow-list span { color: var(--coral); font-size: 11px; font-weight: 700; }
.workflow-list b { display: block; font-size: 14px; }
.workflow-list small { color: var(--muted); font-size: 10px; }
.workflow-list .current b { color: var(--teal); }
.footer { display: flex; justify-content: space-between; padding: 20px clamp(24px, 5vw, 76px); color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.auth-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(246,242,233,.96); }
.auth-card { width: min(100%, 480px); padding: clamp(28px, 6vw, 52px); border: 1px solid rgba(18,100,95,.16); border-radius: 28px; background: rgba(255,255,255,.78); box-shadow: var(--shadow); }
.auth-card-mark { display: grid; width: 52px; height: 52px; place-items: center; margin-bottom: 22px; color: var(--paper); background: var(--teal); border-radius: 16px 16px 16px 6px; box-shadow: 6px 6px 0 #b9d5c9; font-family: "Noto Serif Thai", serif; font-size: 27px; font-weight: 700; }
.auth-card h2 { margin: 10px 0 8px; font-family: "Noto Serif Thai", serif; font-size: clamp(28px, 5vw, 42px); line-height: 1.15; letter-spacing: -.04em; }
.auth-hint { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.auth-status { min-height: 22px; margin: 0 0 12px; color: #ae6348; font-size: 13px; line-height: 1.5; }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.auth-form input { width: 100%; min-height: 46px; padding: 0 13px; color: var(--ink); border: 1px solid rgba(18,100,95,.22); border-radius: 10px; background: #fff; outline: none; font-size: 14px; }
.auth-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(18,100,95,.12); }
.auth-submit { width: 100%; margin-top: 5px; }
.auth-security-note { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.auth-recovery-link { justify-self: center; margin-top: 4px; color: var(--teal); font-size: 12px; }
.auth-recovery-notice { display: grid; gap: 12px; margin: 14px 0; padding: 15px; border: 1px solid rgba(174,99,72,.35); border-radius: 14px; background: rgba(247,235,220,.78); }
.auth-recovery-notice p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.auth-recovery-notice code { display: block; padding: 12px; color: var(--ink); border: 1px dashed rgba(18,100,95,.35); border-radius: 9px; background: #fff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; user-select: all; }
.family-recovery-box { display: grid; gap: 10px; margin: 14px 0; padding: 13px; border: 1px solid rgba(174,99,72,.25); border-radius: 12px; background: rgba(247,235,220,.5); }
.family-recovery-box > div:first-child { display: grid; gap: 4px; }
.family-recovery-box strong { font-size: 12px; }
.family-recovery-box small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.family-recovery-box .auth-recovery-notice { margin: 0; }
.family-user-form { display: grid; gap: 10px; margin: 16px 0 14px; padding: 14px; border: 1px solid rgba(18,100,95,.15); border-radius: 14px; background: rgba(220,235,227,.34); }
.family-user-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.family-user-form .checkbox-row { display: flex; grid-template-columns: none; align-items: flex-start; gap: 8px; color: var(--ink); font-size: 11px; line-height: 1.5; }
.family-user-form .checkbox-row input { width: 16px; min-height: 16px; margin-top: 1px; accent-color: var(--teal); }
.family-user-form input { min-height: 38px; padding: 0 10px; color: var(--ink); border: 1px solid rgba(18,100,95,.2); border-radius: 8px; background: #fff; font-size: 13px; }
.family-user-form .primary-button { min-height: 38px; }
.family-users-list { display: grid; gap: 8px; max-height: 240px; overflow-y: auto; }
.family-user-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.62); }
.family-user-row strong { display: block; font-size: 13px; }
.family-user-row small { color: var(--muted); font-size: 10px; }
.family-user-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; flex: 0 0 auto; }
.family-user-actions button { min-height: 28px; padding: 0 8px; color: var(--teal); background: transparent; border: 1px solid rgba(18,100,95,.22); border-radius: 7px; font-size: 10px; font-weight: 700; }
.family-user-actions button.danger { color: #a5553e; border-color: rgba(165,85,62,.3); }
.book-permissions-card { width: min(640px, 100%); max-height: calc(100dvh - 32px); overscroll-behavior: contain; scrollbar-gutter: stable; }
.book-permissions-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 8px; margin-top: 12px; }
.book-permissions-filter { min-height: 44px; padding: 0 10px; color: var(--ink); border: 1px solid rgba(18,100,95,.24); border-radius: 8px; background: #fff; font-size: 12px; }
.book-permissions-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.book-permissions-actions .compact-button { flex: 1 1 120px; }
.book-permissions-summary { min-height: 18px; margin: 9px 0 4px; color: var(--teal); font-size: 11px; font-weight: 700; }
.book-permissions-list { display: grid; gap: 8px; max-height: min(40dvh, 360px); overflow-y: auto; padding: 2px; }
.book-permission-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.68); }
.book-permission-row.is-locked { background: rgba(220,235,227,.45); }
.book-permission-info { display: grid; gap: 3px; min-width: 0; }
.book-permission-info strong { overflow: hidden; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.book-permission-info small { overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.book-permission-toggle { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; color: var(--teal); font-size: 11px; font-weight: 700; cursor: pointer; }
.book-permission-toggle input { width: 17px; height: 17px; accent-color: var(--teal); }
.book-permission-toggle input:disabled { cursor: not-allowed; opacity: .7; }
.book-permission-locked { color: var(--muted); font-size: 10px; font-weight: 700; text-align: right; }
.hidden { display: none !important; }
.reader-stage { margin: 24px 0 48px; border: 1px solid var(--line); border-radius: 28px; background: rgba(255,255,255,.38); box-shadow: var(--shadow); overflow: hidden; }
.reader-sidebar-brand { display: flex; align-items: center; gap: calc(9px * var(--sidebar-scale)); margin: 0 calc(3px * var(--sidebar-scale)) calc(22px * var(--sidebar-scale)); padding-bottom: calc(16px * var(--sidebar-scale)); border-bottom: 1px solid var(--line); }
.reader-sidebar-brand .eyebrow { margin: 0 0 3px; font-size: calc(9px * var(--sidebar-scale)); letter-spacing: .12em; }
.reader-sidebar-brand strong { display: block; color: var(--teal); font-size: calc(15px * var(--sidebar-scale)); }
.small-brand-mark { width: calc(30px * var(--sidebar-scale)); height: calc(30px * var(--sidebar-scale)); border-radius: 10px 10px 10px 4px; font-size: calc(16px * var(--sidebar-scale)); box-shadow: 4px 4px 0 #b9d5c9; }
.reader-single-page .right-paper { display: none; }
.reader-single-page .page-spread { justify-content: center; }
.reader-stage:fullscreen { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--reader-background, #f0eadf); }
.reader-stage:fullscreen .overlay-editor { position: fixed; }
.reader-stage:fullscreen .interaction-drawer { position: fixed; top: 74px; right: 16px; bottom: 54px; }
.reader-stage:fullscreen { display: flex; flex-direction: column; }
.reader-stage:fullscreen .reader-body { min-height: 0; height: 0; flex: 1 1 auto; }
.reader-stage:fullscreen .book-reader { min-height: 0; height: 100%; }
.reader-stage:fullscreen .thumbnail-list { max-height: none; }
.reader-stage:fullscreen .reader-note { flex: 0 0 auto; }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 19px 22px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.58); }
.reader-title-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.reader-title-wrap h2 { margin: 0; max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Noto Serif Thai", serif; font-size: clamp(20px, 1.45vw, 25px); }
.icon-button, .toolbar-button, .round-control { display: inline-grid; place-items: center; color: var(--teal); background: transparent; border: 1px solid rgba(18,100,95,.25); border-radius: 999px; }
.icon-button { width: 44px; height: 44px; font-size: 24px; }
.reader-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-button { min-width: 44px; height: 40px; padding: 0 14px; font-size: 14px; font-weight: 700; }
.zoom-label { min-width: 54px; color: var(--muted); font-size: 14px; text-align: center; }
.reader-body { position: relative; display: grid; grid-template-columns: var(--sidebar-width) 10px minmax(0, 1fr); height: calc(100dvh - 164px); min-height: 560px; }
.reader-body.reader-no-sidebar { grid-template-columns: minmax(0, 1fr); }
.reader-body.reader-no-sidebar .book-reader { grid-column: 1 / -1; }
.reader-body.reader-no-sidebar .reader-sidebar, .reader-body.reader-no-sidebar .sidebar-resizer { display: none; }
.reader-stage:fullscreen .reader-body { display: grid; }
.reader-sidebar { display: flex; flex-direction: column; min-height: 0; padding: calc(18px * var(--sidebar-scale)) calc(14px * var(--sidebar-scale)); border-right: 1px solid var(--line); background: rgba(220,235,227,.45); overflow: hidden; }
.sidebar-heading { display: flex; justify-content: space-between; gap: calc(8px * var(--sidebar-scale)); margin: 0 calc(4px * var(--sidebar-scale)) calc(12px * var(--sidebar-scale)); }
.sidebar-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: calc(5px * var(--sidebar-scale)); margin: 0 0 calc(10px * var(--sidebar-scale)); }
.sidebar-tab { min-height: calc(30px * var(--sidebar-scale)); padding: 0 calc(5px * var(--sidebar-scale)); color: var(--muted); background: rgba(255,255,255,.48); border: 1px solid rgba(18,100,95,.16); border-radius: 7px; font-size: calc(11px * var(--sidebar-scale)); font-weight: 700; }
.sidebar-tab.active { color: #fff; background: var(--teal); border-color: var(--teal); }
.sidebar-resizer { position: relative; z-index: 12; width: 10px; cursor: col-resize; background: transparent; }
.sidebar-resizer::after { position: absolute; inset: 0 4px; content: ""; border-left: 1px solid rgba(18,100,95,.18); border-right: 1px solid rgba(18,100,95,.08); }
.sidebar-resizer:hover::after, body.sidebar-resizing .sidebar-resizer::after { border-color: var(--teal); background: rgba(18,100,95,.08); }
body.sidebar-resizing, body.sidebar-resizing * { cursor: col-resize !important; user-select: none !important; }
.sidebar-panel { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.sidebar-panel .thumbnail-list { height: auto; flex: 1 1 auto; }
.toc-list { display: grid; gap: 5px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.toc-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; width: 100%; padding: 8px 7px; color: var(--ink); background: rgba(255,255,255,.5); border: 1px solid transparent; border-radius: 7px; text-align: left; cursor: pointer; }
.toc-item:hover, .toc-item:focus-visible { border-color: rgba(18,100,95,.35); background: #fff; }
.toc-item.active { color: var(--teal); border-color: var(--teal); background: #fff; }
.toc-title { min-width: 0; overflow: hidden; font-size: 11px; line-height: 1.35; text-overflow: ellipsis; }
.toc-page { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.toc-level-1 { padding-left: 13px; }
.toc-level-2 { padding-left: 21px; }
.toc-level-3 { padding-left: 29px; }
.toc-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-bottom: 8px; color: var(--teal); font-size: 11px; font-weight: 700; }
.toc-add-button { padding: 5px 7px; color: #fff; background: var(--teal); border-radius: 6px; font-size: 10px; font-weight: 700; }
.toc-form { display: grid; gap: 7px; margin-bottom: 9px; padding: 9px; border: 1px solid rgba(18,100,95,.2); border-radius: 8px; background: rgba(255,255,255,.7); }
.toc-form label { display: grid; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 700; }
.toc-form input, .toc-form select { width: 100%; min-height: 27px; padding: 3px 5px; color: var(--ink); border: 1px solid rgba(18,100,95,.25); border-radius: 5px; background: #fff; font-size: 11px; }
.toc-form-row { display: grid; grid-template-columns: 1fr 1.2fr; gap: 6px; }
.toc-form-actions { display: flex; justify-content: flex-end; gap: 5px; }
.toc-cancel-button, .toc-save-button { min-height: 27px; padding: 0 7px; border-radius: 5px; font-size: 10px; font-weight: 700; }
.toc-cancel-button { color: var(--muted); background: var(--paper-deep); }
.toc-save-button { color: #fff; background: var(--teal); }
.toc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px; align-items: stretch; }
.toc-actions { display: grid; grid-template-columns: repeat(2, 20px); grid-template-rows: repeat(2, 20px); gap: 2px; }
.toc-action { display: grid; place-items: center; padding: 0; color: var(--teal); background: rgba(255,255,255,.7); border: 1px solid rgba(18,100,95,.18); border-radius: 4px; font-size: 11px; }
.toc-action:hover { background: #fff; }
.toc-empty { margin: 16px 4px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.sidebar-heading span { color: var(--teal); font-size: calc(12px * var(--sidebar-scale)); font-weight: 700; letter-spacing: .12em; }
.sidebar-heading b { color: var(--muted); font-size: calc(12px * var(--sidebar-scale)); }
.thumbnail-list { display: grid; gap: 12px; height: auto; max-height: none; overflow-y: auto; padding-right: 2px; }
.thumbnail-item { display: grid; gap: calc(5px * var(--sidebar-scale)); padding: calc(6px * var(--sidebar-scale)); color: var(--muted); background: rgba(255,255,255,.5); border: 1px solid transparent; border-radius: 9px; cursor: pointer; }
.thumbnail-item.active { color: var(--teal); border-color: var(--teal); background: #fff; }
.thumbnail-item canvas { display: block; width: 100%; height: auto; border-radius: 4px; background: #fff; }
.thumbnail-number { font-size: calc(12px * var(--sidebar-scale)); text-align: center; }
.book-reader { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 22px 24px 28px; background: var(--reader-background, radial-gradient(circle at 50% 30%, rgba(220,235,227,.52), transparent 48%), #f0eadf); overflow: hidden; }
.reader-scroll { position: relative; min-width: 0; min-height: 0; flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable both-edges; }
.page-spread { display: flex; align-items: flex-start; justify-content: center; width: max-content; height: max-content; min-width: 1px; min-height: 1px; flex: 0 0 auto; margin: 14px auto 92px; transform-origin: top center; transition: transform .18s ease; filter: drop-shadow(0 20px 18px rgba(21,40,39,.17)); }
.paper-page { position: relative; display: grid; place-items: center; flex: 0 0 auto; width: max-content; height: max-content; min-width: 0; min-height: 0; padding: 10px; background: #fffdf8; overflow: visible; }
.paper-page canvas { position: relative; z-index: 1; display: block; width: auto; max-width: none; height: auto; max-height: none; }
.overlay-layer { position: absolute; z-index: 2; top: 10px; left: 10px; pointer-events: none; touch-action: none; }
.reader-overlay-editing .overlay-layer { pointer-events: auto; }
.overlay-link { position: absolute; display: block; border: 1px solid transparent; border-radius: 5px; background: transparent; cursor: pointer; pointer-events: auto; }
.overlay-link:hover, .overlay-link:focus-visible { outline: 2px solid rgba(18,100,95,.65); background: rgba(18,100,95,.08); }
.reader-overlay-editing .overlay-link { border: 2px dashed var(--coral); background: rgba(233,147,114,.13); cursor: move; }
.reader-overlay-editing .overlay-link::after { position: absolute; right: 3px; bottom: 3px; width: 7px; height: 7px; content: ""; border-right: 2px solid var(--coral); border-bottom: 2px solid var(--coral); }
.overlay-resize-handle { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; cursor: nwse-resize; }
.overlay-editor { position: absolute; z-index: 30; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(21,40,39,.18); }
.overlay-editor-card { width: min(420px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); }
.overlay-editor-card h3 { margin: 5px 0 8px; font-family: "Noto Serif Thai", serif; font-size: 24px; }
.overlay-editor-hint { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.overlay-editor-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.overlay-editor-card input { min-height: 42px; padding: 0 11px; color: var(--ink); border: 1px solid rgba(18,100,95,.25); border-radius: 8px; background: #fff; font-size: 14px; }
.overlay-editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.paper-page canvas { display: block !important; flex: 0 0 auto; }
.right-paper { border-left: 1px solid rgba(21,40,39,.15); }
.reader-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); background: rgba(246,242,233,.75); z-index: 5; }
.reader-loading p { margin: 0; font-size: 13px; }
.loading-ring { width: 29px; height: 29px; border: 3px solid rgba(18,100,95,.2); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reader-controls { display: flex; position: absolute; z-index: 10; left: 50%; bottom: 16px; align-items: center; gap: 16px; transform: translateX(-50%); padding: 7px 11px; border: 1px solid rgba(21,40,39,.11); border-radius: 999px; background: rgba(255,255,255,.8); box-shadow: 0 8px 20px rgba(21,40,39,.1); backdrop-filter: blur(10px); }
.round-control { width: 42px; height: 42px; font-size: 30px; line-height: 1; }
.page-position { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.page-position input { width: 50px; height: 34px; padding: 0 4px; color: var(--teal); font-size: 15px; text-align: center; border: 1px solid rgba(18,100,95,.3); border-radius: 7px; background: #fff; }
.editor-category { border-bottom: 1px solid var(--line); }
.editor-category > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 2px; color: var(--teal); cursor: pointer; list-style: none; font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.editor-category > summary::-webkit-details-marker { display: none; }
.editor-category > summary::before { width: 18px; color: var(--coral); content: "▸"; font-size: 14px; letter-spacing: 0; }
.editor-category[open] > summary::before { content: "▾"; }
.editor-category > summary span { flex: 1; }
.editor-category > summary small { color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: 0; }
.editor-category-body { display: grid; gap: 7px; padding: 0 0 14px; }
.editor-subtool { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 38px; padding: 8px 10px; color: var(--ink); background: rgba(255,255,255,.55); border: 1px solid rgba(18,100,95,.13); border-radius: 8px; text-align: left; }
.editor-subtool span { font-size: 12px; font-weight: 600; }
.editor-subtool small { color: var(--muted); font-size: 10px; }
.editor-subtool:hover, .editor-subtool:focus-visible { color: var(--teal); background: rgba(220,235,227,.55); border-color: rgba(18,100,95,.35); }
.editor-subtool.muted-tool { opacity: .62; }
.style-audio-section { margin-top: 3px; padding: 12px 0 0; border-top: 1px dashed rgba(18,100,95,.18); }
.editor-submodal { position: absolute; z-index: 45; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(21,40,39,.2); backdrop-filter: blur(2px); }
.editor-submodal-card { width: min(560px, 100%); max-height: min(680px, 90%); overflow-y: auto; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 24px 70px rgba(21,40,39,.28); }
.editor-submodal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.editor-submodal-head h3 { margin: 3px 0 0; font-family: "Noto Serif Thai", serif; font-size: 22px; }
.editor-submodal-hint { margin: 14px 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.editor-submodal-body { display: grid; gap: 9px; }
.editor-setting-note { padding: 12px; color: var(--muted); background: rgba(220,235,227,.42); border: 1px solid rgba(18,100,95,.16); border-radius: 9px; font-size: 12px; line-height: 1.6; }
.editor-setting-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.editor-setting-card { display: grid; gap: 5px; padding: 11px; background: rgba(255,255,255,.56); border: 1px solid rgba(18,100,95,.14); border-radius: 9px; }
.editor-setting-card label { color: var(--muted); font-size: 11px; font-weight: 700; }
.editor-setting-card select, .editor-setting-card input { min-height: 34px; padding: 0 8px; color: var(--ink); border: 1px solid rgba(18,100,95,.22); border-radius: 6px; background: #fff; font-size: 12px; }
.editor-toggle-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px; color: var(--ink); background: rgba(255,255,255,.56); border: 1px solid rgba(18,100,95,.14); border-radius: 9px; cursor: pointer; }
.editor-toggle-card > span:first-child { display: grid; gap: 3px; }
.editor-toggle-card strong { font-size: 13px; }
.editor-toggle-card small { color: var(--muted); font-size: 11px; }
.editor-toggle-card input { position: absolute; opacity: 0; pointer-events: none; }
.editor-toggle-track { position: relative; flex: 0 0 auto; width: 42px; height: 24px; border-radius: 999px; background: #c8d2cd; transition: background .18s ease; }
.editor-toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(21,40,39,.22); transition: transform .18s ease; }
.editor-toggle-card:has(input:checked) .editor-toggle-track { background: var(--teal); }
.editor-toggle-card:has(input:checked) .editor-toggle-track::after { transform: translateX(18px); }
.editor-submodal-done { width: 100%; margin-top: 16px; min-height: 36px; }
.audio-conflict-modal { z-index: 60; }
.audio-conflict-card { width: min(540px, 100%); }
.audio-conflict-list { display: grid; gap: 7px; margin: 12px 0 16px; }
.audio-conflict-item { padding: 10px 12px; color: var(--ink); background: rgba(233,147,114,.1); border: 1px solid rgba(233,147,114,.35); border-radius: 8px; font-size: 12px; line-height: 1.5; }
.audio-conflict-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.audio-conflict-actions button { min-height: 34px; }
.interaction-drawer { position: absolute; z-index: 25; top: 74px; right: 16px; bottom: 54px; display: flex; flex-direction: column; width: min(340px, calc(100% - 32px)); overflow-y: auto; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,253,248,.97); box-shadow: 0 18px 45px rgba(21,40,39,.22); }
.interaction-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.interaction-drawer-head h3 { margin: 2px 0 0; font-family: "Noto Serif Thai", serif; font-size: 20px; }
.drawer-close { width: 30px; height: 30px; color: var(--teal); background: var(--paper-deep); border-radius: 50%; font-size: 20px; }
.interaction-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.interaction-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.interaction-status { color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: 0; }
.interaction-tool { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; color: var(--ink); background: rgba(220,235,227,.35); border: 1px solid rgba(18,100,95,.18); border-radius: 9px; text-align: left; }
.interaction-tool.active, .interaction-tool:hover { color: var(--teal); background: rgba(220,235,227,.7); border-color: var(--teal); }
.interaction-tool-icon { display: grid; place-items: center; width: 28px; height: 28px; color: #fff; background: var(--teal); border-radius: 7px; font-size: 18px; }
.interaction-tool b, .interaction-tool small { display: block; }
.interaction-tool b { font-size: 13px; }
.interaction-tool small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.selected-overlay-panel { margin-top: 10px; padding: 10px; border: 1px solid rgba(233,147,114,.4); border-radius: 9px; background: rgba(233,147,114,.1); }
.selected-overlay-title { margin: 0 0 4px; color: var(--coral); font-size: 11px; font-weight: 700; }
.selected-overlay-url { margin: 0 0 9px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.selected-overlay-actions, .audio-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.selected-overlay-actions button, .audio-actions button { min-height: 28px; padding: 0 8px; color: var(--teal); background: #fff; border: 1px solid rgba(18,100,95,.2); border-radius: 6px; font-size: 10px; font-weight: 700; }
.selected-overlay-actions .danger-button { color: #a33e2e; border-color: rgba(163,62,46,.3); }
.confirm-editor-button { width: 100%; min-height: 36px; margin-top: 12px; padding: 0 12px; color: #fff; background: var(--teal); border: 1px solid var(--teal); border-radius: 8px; font-size: 12px; font-weight: 700; }
.confirm-editor-button:hover { background: var(--teal-dark); }
.confirm-editor-button:focus-visible { outline: 3px solid rgba(233,147,114,.55); outline-offset: 2px; }
.audio-file-button { display: grid; place-items: center; min-height: 38px; color: var(--teal); background: rgba(220,235,227,.35); border: 1px dashed rgba(18,100,95,.35); border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; }
.audio-range-form { margin-top: 9px; padding: 9px; border: 1px solid rgba(18,100,95,.18); border-radius: 8px; background: rgba(220,235,227,.3); }
.audio-range-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 5px; align-items: end; }
.audio-range-row label { display: grid; gap: 3px; color: var(--muted); font-size: 10px; }
.audio-range-row input { width: 100%; min-height: 28px; padding: 0 5px; border: 1px solid rgba(18,100,95,.22); border-radius: 5px; font-size: 11px; }
.audio-range-row > button { min-height: 28px; padding: 0 8px; color: #fff; background: var(--teal); border-radius: 5px; font-size: 10px; font-weight: 700; }
.audio-range-help { margin: -3px 0 7px; color: var(--muted); font-size: 10px; }
.audio-range-form-actions { display: flex; gap: 5px; align-items: end; }
.audio-range-form-actions > button { white-space: nowrap; }
.nas-audio-range-form { border-color: rgba(18,100,95,.32); background: rgba(220,235,227,.48); }
.audio-list { display: grid; gap: 6px; max-height: 270px; overflow-y: auto; margin-top: 9px; }
.audio-row { position: relative; display: grid; grid-template-columns: 26px minmax(80px,1fr) 58px 58px 26px; gap: 4px; align-items: center; padding: 6px; border: 1px solid rgba(18,100,95,.15); border-radius: 7px; background: rgba(255,255,255,.68); }
.audio-delete { width: 25px; height: 28px; color: #fff; background: #dc6c6c; border-radius: 5px; font-size: 13px; }
.audio-name { min-width: 0; overflow: hidden; color: var(--ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.audio-row select, .audio-page-field input { min-height: 28px; padding: 0 3px; color: var(--muted); border: 1px solid rgba(18,100,95,.18); border-radius: 5px; background: #fff; font-size: 9px; }
.audio-page-field { display: grid; gap: 2px; color: var(--muted); font-size: 8px; font-weight: 700; }
.audio-page-field input { width: 100%; min-width: 0; }
.background-audio-modal-card { width: min(940px, 100%); max-height: min(820px, 92%); }
.audio-modal-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.audio-modal-tab { min-height: 34px; padding: 0 18px; color: var(--muted); background: transparent; border-bottom: 3px solid transparent; font-size: 12px; font-weight: 700; }
.audio-modal-tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.audio-modal-tab.muted { opacity: .55; }
.audio-modal-add { display: grid; gap: 8px; }
.audio-modal-toolbar { display: grid; grid-template-columns: auto minmax(180px, 1fr) 210px; gap: 8px; align-items: center; margin-top: 14px; padding: 9px; border: 1px solid rgba(18,100,95,.14); border-radius: 9px; background: rgba(220,235,227,.3); }
.audio-modal-toolbar strong { color: var(--teal); font-size: 12px; white-space: nowrap; }
.audio-modal-toolbar input, .audio-modal-toolbar select { min-height: 34px; padding: 0 9px; color: var(--ink); border: 1px solid rgba(18,100,95,.22); border-radius: 6px; background: #fff; font-size: 11px; }
.audio-modal-list { max-height: min(48vh, 440px); margin-top: 10px; padding-right: 4px; }
.background-audio-modal .audio-row { grid-template-columns: 30px minmax(180px,1fr) 92px 92px minmax(150px,auto) 30px; gap: 8px; padding: 8px; }
.audio-playback-summary { min-width: 0; overflow: hidden; color: var(--teal); font-size: 10px; font-weight: 700; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.audio-row-nas .audio-playback-summary { color: var(--teal-dark); }
.background-audio-modal .audio-name { font-size: 12px; }
.background-audio-modal .audio-delete, .background-audio-modal .audio-options-button { width: 30px; height: 32px; }
.audio-empty { margin: 18px 0; padding: 20px; color: var(--muted); text-align: center; border: 1px dashed rgba(18,100,95,.2); border-radius: 9px; }
.audio-current-label { margin: 14px 0 6px; color: var(--teal); font-size: 11px; font-weight: 700; }
.audio-options-button { width: 25px; height: 28px; color: var(--teal); background: rgba(220,235,227,.45); border-radius: 5px; font-size: 15px; }
.audio-options-menu { position: absolute; z-index: 40; top: 38px; right: 5px; display: grid; min-width: 172px; padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: #fffdf8; box-shadow: 0 10px 25px rgba(21,40,39,.2); }
.audio-options-menu button { padding: 7px; color: var(--ink); background: transparent; border-radius: 4px; text-align: left; font-size: 11px; }
.audio-options-menu button:hover { color: var(--teal); background: rgba(220,235,227,.45); }
.audio-settings { margin-top: 9px; }
.audio-file-name { margin: 0 0 8px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.audio-actions button.active { color: #fff; background: var(--teal); }
.interaction-drawer-note { margin: auto 0 0; padding-top: 16px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.library-panel { display: grid; gap: 14px; margin: 26px 0 8px; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,253,248,.82); box-shadow: 0 12px 30px rgba(21,40,39,.06); }
.dashboard-hero { padding-bottom: 48px; }
.dashboard-hero .intro-copy { max-width: 700px; }
.dashboard-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 28px; }
.dashboard-stat-card { display: grid; gap: 4px; min-height: 92px; padding: 13px 14px; border: 1px solid rgba(18,100,95,.16); border-radius: 13px; background: rgba(255,255,255,.52); }
.dashboard-stat-card span { color: var(--muted); font-size: 10px; font-weight: 700; }
.dashboard-stat-card strong { overflow: hidden; color: var(--teal); font-family: "Noto Serif Thai", serif; font-size: 24px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-stat-card small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.library-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.library-panel-head h2 { margin: 3px 0 5px; font-family: "Noto Serif Thai", serif; font-size: 25px; }
.library-panel-head p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 12px; }
.library-panel-actions, .library-book-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.compact-button { min-height: 34px; padding: 0 12px; font-size: 11px; }
.library-toolbar { display: grid; grid-template-columns: minmax(170px, .65fr) minmax(0, 1.35fr); gap: 9px; align-items: center; }
.library-status { padding: 10px 12px; color: var(--muted); border: 1px solid rgba(18,100,95,.14); border-radius: 8px; background: rgba(220,235,227,.3); font-size: 11px; }
.library-toolbar-controls { display: grid; grid-template-columns: minmax(160px, 1fr) 160px auto; gap: 7px; }
.library-toolbar-controls input, .library-toolbar-controls select { min-height: 36px; padding: 0 10px; color: var(--ink); border: 1px solid rgba(18,100,95,.22); border-radius: 7px; background: #fff; font-size: 11px; }
.library-toolbar-controls input:focus, .library-toolbar-controls select:focus { outline: 2px solid rgba(18,100,95,.22); outline-offset: 1px; }
.library-list { display: grid; gap: 14px; }
.library-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.library-book-card { display: grid; min-width: 0; overflow: hidden; border: 1px solid rgba(18,100,95,.16); border-radius: 14px; background: rgba(255,255,255,.78); box-shadow: 0 8px 22px rgba(21,40,39,.05); transition: transform .18s ease, box-shadow .18s ease; }
.library-book-card:hover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(21,40,39,.11); }
.library-book-cover { position: relative; display: block; width: 100%; aspect-ratio: 0.73; padding: 0; overflow: hidden; background: linear-gradient(145deg, #dcebe3, #f0d7c8); cursor: pointer; }
.library-book-cover::after { position: absolute; inset: 0; content: ""; border: 1px solid rgba(255,255,255,.38); pointer-events: none; }
.library-book-cover img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; transition: transform .3s ease; }
.library-book-cover:hover img { transform: scale(1.025); }
.library-book-cover img.cover-missing { opacity: 0; }
.library-book-card-body { display: grid; gap: 6px; min-width: 0; padding: 14px; }
.library-book-date { margin: 0; color: var(--coral); font-size: 10px; font-weight: 700; }
.library-book-card h3 { margin: 0; overflow: hidden; color: var(--ink); font-family: "Noto Serif Thai", serif; font-size: 17px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.library-book-meta { margin: 0; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.library-book-actions { padding-top: 5px; }
.library-book-actions .compact-button { flex: 1 1 auto; min-height: 31px; padding: 0 8px; font-size: 10px; }
.library-table-view { grid-template-columns: 1fr; }
.library-table-view .library-book-card { grid-template-columns: 110px minmax(0, 1fr); }
.library-table-view .library-book-cover { aspect-ratio: .78; }
.library-table-view .library-book-card-body { align-content: center; }
.library-empty { margin: 0; padding: 18px; color: var(--muted); text-align: center; border: 1px dashed rgba(18,100,95,.2); border-radius: 9px; }
.danger-outline { color: #a33e2e; border-color: rgba(163,62,46,.32); }
.share-link-modal { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(17,42,42,.42); }
.share-link-card { width: min(560px, 100%); max-height: calc(100dvh - 44px); overflow-y: auto; padding: 24px; border: 1px solid rgba(18,100,95,.2); border-radius: 18px; background: #fffdf8; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.family-users-card { max-height: calc(100dvh - 32px); overscroll-behavior: contain; scrollbar-gutter: stable; }
.share-link-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.share-link-head h3 { margin: 2px 0 0; font-family: "Noto Serif Thai", serif; font-size: 24px; }
.share-link-hint { margin: 14px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.share-link-input { width: 100%; min-height: 44px; padding: 0 12px; color: var(--ink); border: 1px solid rgba(18,100,95,.24); border-radius: 8px; background: #f5f1e8; font: 12px "IBM Plex Sans Thai", sans-serif; }
.share-link-input:focus { outline: 2px solid rgba(18,100,95,.24); outline-offset: 2px; }
.book-rename-label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.book-rename-label .share-link-input { margin-top: 0; }
.book-rename-card .share-link-actions { justify-content: flex-start; }
.book-rename-card button:disabled, .book-delete-card button:disabled { cursor: wait; opacity: .6; }
.book-delete-card .share-link-head h3 { color: #9d4132; }
.danger-fill { min-height: 34px; padding: 0 12px; color: #fff; background: #a94c3b; border-radius: 999px; font-size: 11px; font-weight: 700; }
.danger-fill:hover { background: #8f3c2f; }
.share-link-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.share-link-status { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: 11px; }
.reader-note { margin: 0; padding: 13px 20px; color: var(--muted); background: rgba(255,255,255,.54); border-top: 1px solid var(--line); font-size: 13px; text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 320px; padding: 13px 17px; color: #fff; border-radius: 12px; background: var(--teal-dark); box-shadow: 0 15px 30px rgba(0,0,0,.18); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 850px) {
  .share-link-card { padding: 18px; }
  .book-permissions-toolbar { grid-template-columns: 1fr; }
  .book-permissions-actions .compact-button { flex: 1 1 135px; }
  .book-permission-row { align-items: flex-start; }
  .book-permission-toggle { padding-top: 2px; }
  .share-link-actions > * { flex: 1 1 130px; }
  .library-panel-head { align-items: stretch; flex-direction: column; }
  .library-panel-actions { width: 100%; }
  .library-panel-actions > * { flex: 1 1 0; }
  .library-toolbar { grid-template-columns: 1fr; }
  .library-toolbar-controls { grid-template-columns: minmax(0, 1fr) 150px auto; }
  .audio-modal-toolbar { grid-template-columns: 1fr 1fr; }
  .audio-modal-toolbar strong { grid-column: 1 / -1; }
  .background-audio-modal .audio-row { grid-template-columns: 28px minmax(120px, 1fr) 72px 72px 28px; gap: 5px; }
  .interaction-drawer { top: 64px; right: 10px; bottom: 48px; width: min(320px, calc(100% - 20px)); }

  .intro-panel { grid-template-columns: 1fr; padding-top: 52px; }
  .intro-copy { max-width: none; }
  .hero-card { max-width: 580px; width: 100%; margin: 0 auto; }
  .bottom-panel { grid-template-columns: 1fr; gap: 28px; }
}
@media (max-width: 620px) {
  .workspace { width: calc(100% - 24px); }
  .dashboard-stats { grid-template-columns: 1fr 1fr; }
  .dashboard-stat-card:last-child { grid-column: 1 / -1; }
  .library-toolbar-controls { grid-template-columns: 1fr 1fr; }
  .library-toolbar-controls input { grid-column: 1 / -1; }
  .library-toolbar-controls .compact-button { grid-column: 1 / -1; }
  .library-table-view .library-book-card { grid-template-columns: 86px minmax(0, 1fr); }
  .topbar { align-items: flex-start; gap: 18px; }
  .topbar-status { max-width: 120px; text-align: right; line-height: 1.4; }
  .workspace { width: min(100% - 32px, 540px); }
  .intro-copy h2 { font-size: 39px; }
  .hero-card { min-height: 370px; }
  .mock-book { top: 38px; width: 220px; height: 290px; }
  .front-page { padding: 28px 24px; }
  .front-page h3 { font-size: 34px; }
  .note-one { right: 0; }
  .note-two { right: -4px; bottom: 17px; }
  .quick-grid { grid-template-columns: 1fr; padding-bottom: 50px; }
  .workflow-list { grid-template-columns: repeat(2, 1fr); gap: 24px 0; }
  .workflow-list li:nth-child(3) { border-left: 0; }
  .workflow-list li::after { display: none; }
  .footer { gap: 10px; flex-direction: column; }
  .reader-stage { margin-top: 28px; border-radius: 20px; }
  .reader-toolbar { align-items: flex-start; flex-direction: column; padding: 16px; }
  .reader-actions { width: 100%; justify-content: flex-end; }
  .reader-body { grid-template-columns: 1fr; height: calc(100dvh - 210px); min-height: 420px; }
  .reader-sidebar { display: none; }
  .book-reader { display: flex; min-height: 0; height: 100%; padding: 18px 10px 90px; overflow: hidden; }
  .reader-scroll { width: 100%; min-height: 0; }
  .reader-stage:fullscreen .reader-body { height: 0; flex: 1 1 auto; }
  .reader-stage:fullscreen .book-reader { min-height: 0; }
  .page-spread { min-height: 0; }
  .paper-page { width: auto; min-height: 0; padding: 5px; }
  .right-paper { display: none; }
  .reader-controls { bottom: 12px; }
}


/* v43 · NAS Audio Manager modal */
.audio-library-modal .editor-submodal-card { width: min(820px, 100%); max-height: min(760px, 92%); }
.audio-library-actions { display: flex; gap: 8px; align-items: stretch; }
.audio-library-actions > * { flex: 1 1 0; }
.audio-library-status { margin: 12px 0 0; padding: 9px 11px; color: var(--muted); background: rgba(220,235,227,.32); border: 1px solid rgba(18,100,95,.14); border-radius: 8px; font-size: 11px; line-height: 1.5; }
.audio-library-status.error { color: #9a3d2f; background: rgba(220,108,108,.1); border-color: rgba(154,61,47,.25); }
.audio-library-toolbar { display: grid; grid-template-columns: auto minmax(180px, 1fr) 170px; gap: 8px; align-items: center; margin-top: 12px; padding: 9px; border: 1px solid rgba(18,100,95,.14); border-radius: 9px; background: rgba(220,235,227,.3); }
.audio-library-toolbar strong { color: var(--teal); font-size: 12px; white-space: nowrap; }
.audio-library-toolbar input, .audio-library-toolbar select { min-height: 34px; padding: 0 9px; color: var(--ink); border: 1px solid rgba(18,100,95,.22); border-radius: 6px; background: #fff; font-size: 11px; }
.audio-library-list { display: grid; gap: 8px; max-height: min(48vh, 430px); overflow-y: auto; margin-top: 12px; padding: 2px 4px 2px 0; }
.audio-library-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 11px 12px; border: 1px solid rgba(18,100,95,.15); border-radius: 10px; background: rgba(255,255,255,.72); }
.audio-library-info { min-width: 0; display: grid; gap: 4px; }
.audio-library-name { overflow: hidden; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.audio-library-info small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.audio-library-row-actions { display: flex; flex: 0 0 auto; gap: 5px; align-items: center; }
.audio-library-row-actions .compact-button { min-height: 30px; padding: 0 9px; font-size: 10px; white-space: nowrap; }
.audio-library-row-actions button:disabled { cursor: not-allowed; opacity: .46; }
.audio-preview-button { color: var(--teal); }
@media (max-width: 980px) {
  .share-link-modal { padding: 12px; align-items: start; }
  .share-link-card { max-height: calc(100dvh - 24px); padding: 18px; }
  .auth-user-bar { gap: 8px; }

  .audio-library-actions { flex-direction: column; }
  .audio-library-toolbar { grid-template-columns: 1fr 1fr; }
  .audio-library-toolbar strong { grid-column: 1 / -1; }
  .audio-library-row { align-items: flex-start; flex-direction: column; gap: 9px; }
  .audio-library-row-actions { width: 100%; }
  .audio-library-row-actions > button { flex: 1 1 0; }
}

/* v43 Audio Manager: one modal with two switchable panels */
.audio-manager-panel {
  min-height: 180px;
}

.audio-manager-panel.hidden {
  display: none;
}

.audio-panel-note {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
}

.audio-use-button:disabled {
  opacity: .58;
  cursor: not-allowed;
}

.audio-row-nas {
  border-color: rgba(18, 100, 95, .34);
  background: rgba(220, 235, 227, .42);
}

.audio-row-nas .audio-name::after {
  content: " NAS";
  display: inline-block;
  margin-left: 7px;
  color: var(--teal);
  font-size: .72em;
  letter-spacing: .08em;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .background-audio-modal .audio-row { grid-template-columns: 30px minmax(120px,1fr) 72px 72px; }
  .background-audio-modal .audio-row .audio-playback-summary { grid-column: 2 / -1; }
  .background-audio-modal .audio-row .audio-options-button { grid-column: 1; grid-row: 2; }
  .audio-library-row-actions {
    flex-wrap: wrap;
  }

  .audio-library-row-actions button {
    flex: 1 1 42%;
  }
}


/* v52 Guest Viewer / Guest Share Manager */
.guest-user-bar { display: flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 600; font-size: 12px; }
.guest-reader-badge { display: inline-flex; margin-top: 6px; padding: 4px 10px; border: 1px solid rgba(18,108,101,.25); border-radius: 999px; color: var(--teal); background: rgba(224,241,232,.78); font-size: 12px; font-weight: 600; }
.guest-error-panel { min-height: 56vh; display: grid; place-items: center; padding: 64px 24px; }
.guest-error-card { width: min(620px, 100%); padding: 42px; border: 1px solid rgba(18,52,50,.14); border-radius: 28px; background: rgba(255,253,247,.92); box-shadow: var(--shadow); text-align: center; }
.guest-error-card h2 { margin: 8px 0 12px; font-family: "Noto Serif Thai", serif; color: var(--ink); }
.guest-error-card p:last-child { margin: 0; color: var(--muted); }
.guest-share-card { max-height: min(760px, calc(100vh - 40px)); overflow-y: auto; }
.guest-share-label { display: grid; gap: 7px; margin-top: 14px; color: #38504c; font-weight: 600; }
.guest-share-list { display: grid; gap: 10px; margin-top: 18px; max-height: 260px; overflow-y: auto; padding-right: 4px; }
.guest-share-item { padding: 14px 16px; border: 1px solid rgba(18,52,50,.14); border-radius: 16px; background: rgba(250,252,246,.84); }
.guest-share-item-head, .guest-share-item-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.guest-share-item-head strong { color: #173c38; }
.guest-share-item p { margin: 7px 0 10px; color: #65736f; font-size: .86rem; }
.guest-share-status { padding: 3px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.guest-share-status.active { color: #126c65; background: #dff2e7; }
.guest-share-status.inactive { color: #8b4c3e; background: #f5e2da; }
.guest-share-item-actions { justify-content: flex-start; flex-wrap: wrap; }
.guest-share-empty { margin: 8px 0; color: #697773; text-align: center; }
@media (max-width: 720px) { .guest-user-bar { font-size: .82rem; } .guest-error-card { padding: 28px 22px; } .guest-share-card { max-height: calc(100vh - 20px); } .guest-share-item-head { align-items: flex-start; flex-direction: column; } }

.guest-share-url-field { width: 100%; margin: 2px 0 10px; font-size: 12px; }
