/**
 * Protected PDF flipbook viewer styles.
 */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #23252d;
  color: #e8e8ec;
}
.atc-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Toolbar ---------------------------------------------------------------- */
.atc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: #17181d;
  border-bottom: 1px solid #34363f;
  min-height: 48px;
  z-index: 30;
}
.tb-sec { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-left { flex: 1 1 0; }
.tb-center { flex: 0 0 auto; }
.tb-right {
  flex: 1 1 0;
  justify-content: flex-end;
  /* Too many tools for the width? Wrap to a second row instead of
     overflowing sideways across the page navigation. */
  flex-wrap: wrap;
  row-gap: 4px;
}
.tb-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border-left: 1px solid #34363f;
}
.tb-right .tb-group:first-child { border-left: none; padding-left: 0; }
.tb-ic { width: 17px; height: 17px; display: block; }
.atc-btn svg { pointer-events: none; margin: 0 auto; }
.atc-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Toolbar chrome, not selectable content: keep the arrow cursor; the
     full name shows on hover (title attribute) or tap (tooltip). */
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
.atc-btn {
  background: #2c2e37;
  color: #e8e8ec;
  border: 1px solid #41434e;
  border-radius: 4px;
  min-width: 34px;
  height: 34px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 8px;
}
.atc-btn:hover, .atc-btn:focus { background: #3a3d49; outline: none; }
.atc-btn:focus-visible { outline: 2px solid #7aa7ff; outline-offset: 1px; }
.atc-btn-text { font-size: 13px; }
.atc-nav, .atc-tools { display: flex; align-items: center; gap: 6px; }
#page-indicator {
  min-width: 74px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 6px;
}
#page-indicator:hover, #page-indicator:focus-visible { background: #2c2e37; outline: none; }
#page-input {
  width: 64px;
  background: #2c2e37;
  border: 1px solid #3498db;
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  padding: 3px 6px;
  text-align: center;
}
/* Company logo: centered in whatever space remains between the title (and
   expiry ribbon, when present) and the page navigation. */
.atc-logo {
  height: 24px;
  width: auto;
  flex: 0 0 auto;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 1300px) {
  .atc-logo { height: 20px; }
}
/* Only narrow phones lose the logo; on the sub-900px layout it rides the
   full-width title row, where there is room to spare. The 901-1060px band
   also drops it: everything shares one row there and the title would be
   squeezed to nothing. */
@media (min-width: 901px) and (max-width: 1060px) {
  .atc-logo { display: none; }
}
@media (max-width: 520px) {
  .atc-logo { display: none; }
}
/* Tap/click tooltip showing the full (possibly ellipsized) book title. */
#title-tip {
  position: fixed;
  z-index: 80;
  max-width: calc(100vw - 16px);
  background: #2c2e37;
  border: 1px solid #41434e;
  border-radius: 6px;
  color: #e8e8ec;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  padding: 8px 11px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.atc-ribbon {
  background: #3498db;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 3px;
  white-space: nowrap;
}
#zoom-level {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  color: #a5a7b4;
  font-variant-numeric: tabular-nums;
}

/* Layout ----------------------------------------------------------------- */
.atc-main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
#atc-sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: #1d1f26;
  border-right: 1px solid #34363f;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: margin-left 0.2s ease;
}
.atc-app.sidebar-closed #atc-sidebar { margin-left: -300px; visibility: hidden; }
.atc-tabs { display: flex; border-bottom: 1px solid #34363f; }
.atc-tab {
  flex: 1;
  background: none;
  border: none;
  color: #a5a7b4;
  padding: 10px 0;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.atc-tab.active { color: #fff; border-bottom-color: #3498db; }
.atc-pane { display: none; overflow-y: auto; padding: 10px; flex: 1 1 auto; min-height: 0; }
.sidebar-foot { border-top: 1px solid #34363f; padding: 10px; }
#btn-tour {
  width: 100%;
  background: linear-gradient(180deg, #ffdd5c, #ffc933);
  border: 1px solid #e0a800;
  color: #221a00;
  font-weight: 700;
  font-size: 14px;
  height: 38px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(255, 201, 51, 0.25);
}
#btn-tour:hover, #btn-tour:focus {
  background: linear-gradient(180deg, #ffe680, #ffd24d);
  box-shadow: 0 3px 10px rgba(255, 201, 51, 0.4);
  outline: none;
}
#btn-text-version {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  color: #a5b6ff;
  text-decoration: none;
}
#btn-text-version:hover, #btn-text-version:focus { color: #cfd8ff; text-decoration: underline; }
.atc-pane.active { display: block; }
.atc-muted { color: #8a8c99; font-size: 13px; }

/* TOC */
.atc-toc-list { list-style: none; margin: 0; padding: 0; }
.atc-toc-list .atc-toc-list { padding-left: 14px; }
.atc-toc-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #cfd1da;
  font-size: 13px;
  line-height: 1.35;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 3px;
}
.atc-toc-item:hover, .atc-toc-item:focus { background: #2c2e37; color: #fff; outline: none; }

/* Search */
#search-form { display: flex; gap: 6px; margin-bottom: 8px; }
#search-input {
  flex: 1;
  background: #2c2e37;
  border: 1px solid #41434e;
  border-radius: 4px;
  color: #fff;
  padding: 7px 9px;
  font-size: 13px;
}
#search-status { font-size: 12px; color: #8a8c99; margin: 4px 0 8px; }
#search-results { list-style: none; margin: 0; padding: 0; }
#search-results li { margin-bottom: 6px; }
.atc-search-hit {
  display: block;
  width: 100%;
  text-align: left;
  background: #2c2e37;
  border: 1px solid #41434e;
  border-radius: 4px;
  color: #cfd1da;
  padding: 7px 9px;
  cursor: pointer;
}
.atc-search-hit:hover, .atc-search-hit:focus { background: #3a3d49; outline: none; }
.hit-page { display: block; font-size: 11px; font-weight: 700; color: #7aa7ff; margin-bottom: 2px; }
.hit-snippet { display: block; font-size: 12px; line-height: 1.4; }
.hit-snippet mark { background: #f1c40f; color: #222; border-radius: 2px; padding: 0 1px; }

/* Stage ------------------------------------------------------------------ */
#atc-stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #2e313b 0%, #23252d 75%);
}
#flipbook-wrap {
  width: 100%;
  margin: 0 auto;
  padding: 12px;
  /* Native panning allowed; pinch reserved for the in-app pinch zoom. */
  touch-action: pan-x pan-y;
}

/* Edge arrows: always-visible page-turn targets beside the book. */
.atc-edge-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 24, 29, 0.55);
  color: #e8e8ec;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 28px;
  line-height: 1;
  padding: 0 0 4px;
  cursor: pointer;
}
#nav-left { left: 10px; }
#nav-right { right: 10px; }
.atc-edge-btn:hover, .atc-edge-btn:focus { background: rgba(52, 152, 219, 0.75); color: #fff; outline: none; }
.atc-edge-btn:focus-visible { outline: 2px solid #7aa7ff; outline-offset: 2px; }
.atc-edge-btn:disabled { opacity: 0.2; cursor: default; }
.atc-edge-btn:disabled:hover { background: rgba(23, 24, 29, 0.55); }
.atc-app[data-mode="read"] .atc-edge-btn { display: none; }
@media (max-width: 900px) {
  .atc-edge-btn { width: 38px; height: 38px; font-size: 24px; }
  #nav-left { left: 4px; }
  #nav-right { right: 4px; }
}

/* Zoomed flipbook: the book grows past the stage and the user pans. */
.atc-app.flip-zoomed #atc-stage {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
  cursor: grab;
}
.atc-app.flip-zoomed #atc-stage.panning { cursor: grabbing; }
.atc-app.flip-zoomed #flipbook-wrap { margin: 0 auto; flex: 0 0 auto; }
.atc-page {
  background: #fff;
  overflow: hidden;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
}
.atc-page-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9bbc4;
  font-size: 22px;
  background: #f4f4f6;
  z-index: -1;
}
.atc-page canvas { display: block; position: relative; z-index: 1; }
.atc-page, .atc-page canvas { user-select: none; -webkit-user-select: none; }

/* Selectable text overlay for flip mode — lives outside StPageFlip's DOM
   so selections survive the engine's constant re-styling. Only the text
   spans catch the pointer; everywhere else falls through to the book. */
#flip-textlayer {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
}
#flip-textlayer .textLayer { pointer-events: none; overflow: visible; }
#flip-textlayer .textLayer span {
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
}

/* Translate-this-page panel: sits beside the stage on desktop, mirrors the
   visible page(s) in the chosen language. */
#trans-panel {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  background: #1c1d23;
  border-left: 1px solid #34363f;
  min-width: 0;
}
#trans-panel[hidden] { display: none; }
.trans-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #34363f;
}
.trans-lang-label { font-size: 12px; color: #a5a7b4; display: flex; align-items: center; gap: 6px; }
#trans-lang {
  background: #26272e;
  color: #e8e9ee;
  border: 1px solid #41434e;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
}
#trans-status { padding: 4px 12px; font-size: 12px; color: #ffd54a; min-height: 4px; }
#trans-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px 14px;
  font-size: 14px;
  line-height: 1.55;
  color: #dfe1e8;
}
.trans-page-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8e93a3;
  border-bottom: 1px solid #34363f;
  padding-bottom: 3px;
  margin: 14px 0 8px;
}
.trans-heading { font-size: 15px; font-weight: 700; color: #fff; margin: 12px 0 4px; }
.trans-block { margin: 0 0 9px; }
.trans-note {
  padding: 8px 12px;
  margin: 0;
  font-size: 11px;
  color: #7c8090;
  border-top: 1px solid #34363f;
}
@media (max-width: 900px) {
  #trans-panel {
    position: fixed;
    inset: 0;
    z-index: 60;
    flex: none;
    border-left: none;
  }
}

/* Guided tour: a spotlight cut-out over the featured control plus a card
   explaining it. The giant box-shadow dims everything except the target. */
#tour-spotlight {
  display: none;
  position: fixed;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(10, 11, 14, 0.72);
  border: 2px solid #ffd54a;
  transition: all 0.25s ease;
}
#tour-card {
  display: none;
  position: fixed;
  z-index: 201;
  background: #1c1d23;
  border: 1px solid #41434e;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  transition: left 0.25s ease, top 0.25s ease;
}
#tour-card h3 { margin: 0 0 6px; font-size: 15px; color: #fff; }
#tour-card p { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: #cfd1da; }
.tour-row { display: flex; align-items: center; gap: 6px; }
.tour-count { flex: 1; font-size: 11px; color: #8a8c99; }
.tour-next { background: #3498db; border-color: #3498db; color: #fff; }
.tour-next:hover, .tour-next:focus { background: #2f89c5; }

/* Cover centering: a lone front/back cover is centered on screen by
   sliding the whole book sideways by half a page; opening the book slides
   everything back so the spine lands at center. */
#flipbook { transition: transform 0.45s ease; }
#flipbook.cover-shift-front { transform: translateX(-25%); }
#flipbook.cover-shift-back { transform: translateX(25%); }

/* Slide mode (small screens): slide-left page transition instead of curl. */
#slider {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: 100%;
  padding: 8px;
  flex: 0 0 auto;
}
#slider[hidden] { display: none; }
#slide-viewport {
  position: relative;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  touch-action: pan-y;
  /* Never let flex shrink the zoomed page back to the screen width —
     that made zoom appear to grow the book only vertically. */
  flex: 0 0 auto;
}
.slide-page {
  position: absolute;
  inset: 0;
  background: #fff;
  will-change: transform;
  transform: translateX(-200%);
  user-select: none;
  -webkit-user-select: none;
}
.slide-page.anim { transition: transform 0.3s ease-out; }
.slide-page canvas { display: block; width: 100%; height: 100%; }

/* Reader mode */
#reader {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 12px 0 40px;
  /* No smooth scrolling: programmatic jumps (mode switch, TOC, search)
     must land instantly instead of animating through hundreds of pages. */
}
.reader-page {
  position: relative;
  margin: 0 auto 16px;
  background: #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}
.reader-page canvas { display: block; width: 100%; height: 100%; }
.reader-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9bbc4;
  font-size: 18px;
  background: #f4f4f6;
}

/* PDF.js text layer (subset of the official stylesheet). */
.textLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  text-align: initial;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
  z-index: 2;
}
.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}
.textLayer ::selection { background: rgba(52, 152, 219, 0.4); }
#reader.no-select .textLayer {
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* Highlights and sticky notes --------------------------------------------- */
.anno-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.anno-hl {
  position: absolute;
  background: #ffd54a;
  opacity: 0.4;
  border-radius: 2px;
  mix-blend-mode: multiply;
  pointer-events: auto;
  cursor: pointer;
}
.anno-hl:hover { opacity: 0.55; outline: 1px solid #d4a017; }
.anno-flash { animation: anno-flash-pulse 0.4s ease-in-out 3; }
@keyframes anno-flash-pulse {
  50% { opacity: 0.9; box-shadow: 0 0 0 4px rgba(255, 213, 74, 0.7); }
}

#hl-pop {
  position: absolute;
  z-index: 31;
  width: 250px;
  background: #17181d;
  border: 1px solid #41434e;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.55);
}
#hl-pop[hidden] { display: none; }
#hl-quote {
  margin: 0 0 4px;
  font-size: 12px;
  font-style: italic;
  color: #cfd1da;
  line-height: 1.45;
  max-height: 90px;
  overflow: hidden;
}
#hl-pop #hl-delete { color: #ff9a9a; }

/* Toolbar jump group (desktop); the sidebar copy takes over on mobile. */
.atc-anno-jump .atc-btn { min-width: 24px; height: 30px; font-size: 15px; padding: 0 3px; }
/* Space between the highlight cluster and the note cluster. */
.atc-anno-jump .anno-jump + .anno-tool { margin-left: 8px; }
.anno-tool .tb-ic { width: 15px; height: 15px; }
.anno-tool[data-tool="highlight"] { color: #ffd54a; }
.anno-tool.tool-active,
.anno-tool[aria-pressed="true"] { background: rgba(255, 213, 74, 0.28); box-shadow: inset 0 0 0 1px #ffd54a; }
.anno-tool[data-tool="note"].tool-active { background: rgba(255, 201, 51, 0.28); box-shadow: inset 0 0 0 1px #ffc933; }

.anno-nav {
  display: none;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #34363f;
}
@media (max-width: 900px) {
  .atc-anno-jump { display: none; }
  .anno-nav { display: flex; }
}
.anno-nav .atc-btn { min-width: 26px; height: 26px; font-size: 14px; }
.anno-nav-label { font-size: 11px; color: #a5a7b4; white-space: nowrap; }
.anno-nav-label + .anno-nav-label,
.anno-nav .atc-btn + .anno-nav-label { margin-left: 8px; }
.anno-pin {
  position: absolute;
  transform: translate(-50%, -90%);
  pointer-events: auto;
  background: none;
  border: none;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.anno-pin:hover, .anno-pin:focus { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)) brightness(1.08); outline: none; }
.anno-pin .tb-ic { width: 20px; height: 20px; }
.anno-item .tb-ic { width: 14px; height: 14px; }
.anno-ic-note { color: #a5a7b4; }
.anno-pin:hover, .anno-pin:focus { background: #ffe97a; outline: none; }
.atc-app.note-mode #atc-stage,
.atc-app.note-mode #reader { cursor: crosshair; }
.atc-app.hl-mode #atc-stage,
.atc-app.hl-mode #reader { cursor: text; }

/* In-book PDF links (the book's own TOC, cross-references, web links). */
.link-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.link-layer .pdf-link {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 2px;
}
.link-layer .pdf-link:hover,
.link-layer .pdf-link:focus-visible {
  background: rgba(52, 152, 219, 0.16);
  box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.55);
  outline: none;
}

/* Search-result landing pulse on the found word. */
.search-flash {
  background: rgba(255, 213, 74, 0.9) !important;
  color: transparent;
  border-radius: 2px;
  animation: search-flash-pulse 0.7s ease 2;
}
@keyframes search-flash-pulse {
  50% { background-color: rgba(255, 170, 30, 0.95); }
}
#search-status.searching::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 2px solid #5b5e6b;
  border-top-color: #ffd54a;
  border-radius: 50%;
  animation: atc-spin 0.8s linear infinite;
}

#note-pop {
  position: absolute;
  z-index: 31;
  width: 250px;
  background: #17181d;
  border: 1px solid #41434e;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.55);
}
#note-pop[hidden] { display: none; }
#note-text {
  width: 100%;
  background: #2c2e37;
  border: 1px solid #41434e;
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  padding: 7px 9px;
  resize: vertical;
}
.note-pop-actions { display: flex; gap: 6px; margin-top: 8px; }
.note-pop-actions #note-delete { margin-left: auto; color: #ff9a9a; }

/* Notes sidebar list */
#anno-list { list-style: none; margin: 0; padding: 0; }
#anno-list li { display: flex; align-items: stretch; gap: 4px; margin-bottom: 6px; }
.anno-item {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  text-align: left;
  background: #2c2e37;
  border: 1px solid #41434e;
  border-radius: 4px;
  color: #cfd1da;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  min-width: 0;
}
.anno-item:hover, .anno-item:focus { background: #3a3d49; outline: none; }
.anno-ic-hl { color: #ffd54a; flex: 0 0 auto; }
.anno-ic-note { flex: 0 0 auto; }
.anno-item-body { overflow: hidden; }
.anno-del {
  flex: 0 0 auto;
  background: #2c2e37;
  border: 1px solid #41434e;
  border-radius: 4px;
  color: #ff9a9a;
  font-size: 15px;
  width: 28px;
  cursor: pointer;
}
.anno-del:hover, .anno-del:focus { background: #4a2e33; outline: none; }

/* On-screen diagnostics (?atcdebug=1) ------------------------------------- */
#atc-diag {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  margin: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.85);
  color: #7fe08a;
  font: 11px/1.5 monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 40%;
  overflow-y: auto;
}

/* Toast ------------------------------------------------------------------- */
#atc-toast {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 40;
  background: #b3382f;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90%;
}
#atc-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Read aloud -------------------------------------------------------------- */
#tts-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #17181d;
  border: 1px solid #41434e;
  border-radius: 24px;
  padding: 6px 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  max-width: calc(100% - 20px);
}
#tts-bar[hidden] { display: none; }
.tts-rate-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #a5a7b4;
  white-space: nowrap;
}
#tts-rate {
  background: #2c2e37;
  color: #e8e8ec;
  border: 1px solid #41434e;
  border-radius: 4px;
  font-size: 12px;
  padding: 3px 4px;
}
#tts-status {
  font-size: 12px;
  color: #a5a7b4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
#btn-tts[aria-pressed="true"] { background: rgba(52, 152, 219, 0.6); }

/* Loading ---------------------------------------------------------------- */
#atc-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  background: rgba(35, 37, 45, 0.92);
  font-size: 14px;
  z-index: 20;
  text-align: center;
  padding: 20px;
}
#atc-loading[hidden] { display: none; }
.atc-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #41434e;
  border-top-color: #3498db;
  border-radius: 50%;
  animation: atc-spin 0.9s linear infinite;
}
@keyframes atc-spin { to { transform: rotate(360deg); } }

/* Copyright agreement ---------------------------------------------------- */
#atc-agree-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
#atc-agree {
  background: #fff;
  color: #222;
  max-width: 720px;
  border-radius: 6px;
  padding: 22px 26px;
  font-size: 14px;
  line-height: 1.5;
}
#atc-agree h2 { margin-top: 0; font-size: 18px; }
.atc-agree-check { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.atc-agree-check input { margin-top: 3px; }

/* Mid-size screens (small monitors, iPads): trim the toolbar controls in
   steps so every tool stays on a single row instead of wrapping under the
   page navigation. */
@media (max-width: 1500px) {
  .atc-toolbar { gap: 8px; }
  .atc-btn { min-width: 30px; height: 30px; font-size: 15px; padding: 0 6px; }
  .tb-ic { width: 15px; height: 15px; }
  .tb-group { padding: 0 7px; }
  #page-indicator { min-width: 64px; }
}
@media (max-width: 1300px) {
  .atc-toolbar { gap: 6px; }
  .atc-btn { min-width: 28px; height: 28px; font-size: 14px; padding: 0 5px; }
  .atc-btn-text { font-size: 12px; }
  .atc-title { font-size: 14px; }
  .atc-nav, .atc-tools { gap: 4px; }
  .tb-group { gap: 3px; padding: 0 5px; }
  #page-indicator { min-width: 58px; font-size: 12px; }
  #zoom-level { min-width: 34px; }
  .atc-ribbon { font-size: 11px; padding: 3px 7px; }
}
/* Laptops and tablets: the title yields its remaining space (it already
   ellipsizes) so the tool cluster keeps to one row; the page nav sits
   beside the title instead of dead-center, which beats wrapping. Real
   books push the tools wider than the test sizes suggest (roman-numeral
   page labels widen the indicator, Chrome adds the translate button), so
   this applies through typical MacBook widths. */
@media (max-width: 1600px) {
  .tb-right { flex: 0 1 auto; }
}

/* Look Inside preview mode ------------------------------------------------
   The public excerpt viewer: personal features (annotations, notes, the
   tour) are hidden — nobody is logged in, so there is nothing to save. */
.atc-preview .atc-anno-jump,
.atc-preview #tab-notes,
.atc-preview #pane-notes,
.atc-preview .sidebar-foot {
  display: none;
}

/* Small screens ---------------------------------------------------------- */
@media (max-width: 900px) {
  #atc-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    box-shadow: 4px 0 14px rgba(0, 0, 0, 0.5);
  }
  .atc-app.sidebar-closed #atc-sidebar { margin-left: 0; transform: translateX(-100%); }
  .tb-left { flex-basis: 100%; order: -1; }
  .tb-center, .tb-right { flex: 1 1 auto; justify-content: center; }
  .tb-group { padding: 0 6px; }
}

/* Printing is not part of the license. */
@media print {
  body * { display: none !important; }
  body::after {
    content: "Printing of this eBook is not permitted.";
    display: block !important;
    font-size: 18px;
    padding: 40px;
  }
}
