/* StPageFlip v2.0.7 (MIT) required base styles */
.stf__parent { position: relative; display: block; box-sizing: border-box; transform: translateZ(0); -ms-touch-action: pan-y; touch-action: pan-y; }
.sft__wrapper { position: relative; width: 100%; box-sizing: border-box; }
.stf__parent canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
.stf__block { position: absolute; width: 100%; height: 100%; box-sizing: border-box; perspective: 2000px; }
.stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.stf__outerShadow, .stf__innerShadow, .stf__hardShadow, .stf__hardInnerShadow { position: absolute; left: 0; top: 0; }

:root {
  --bg: #2f2a26;
  --desk: #d9d4ca;
  --paper: #f6f3ec;
  --topbar: #2d72b7;
  --topbar2: #2d2f93;
  --ink: #f5f5f4;
  --ink-dim: #b3aca3;
  --accent: #e8a33d;
  --accent-ink: #211703;
  --line: #e2dcd1;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .22);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
html { -webkit-touch-callout: none; }
body {
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 90% at 50% 0%, #453e37 0%, var(--desk) 60%, #c4bdb0 100%);
  color: #241f1a;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
#searchPanel, input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
svg { display: block; }

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: linear-gradient(180deg, var(--topbar2), var(--topbar));
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: 4px; }
.brand-logo { color: var(--accent); display: flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 14px; letter-spacing: .2px; white-space: nowrap; }
.brand-text span { font-size: 10.5px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1.6px; }

.transport { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.tbtn {
  width: 34px; height: 34px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--ink-dim);
  transition: background .15s, color .15s;
}
.tbtn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.tbtn:disabled { opacity: .3; cursor: default; }
.tbtn:disabled:hover { background: none; color: var(--ink-dim); }
.pagelabel {
  min-width: 84px; text-align: center; font-variant-numeric: tabular-nums;
  font-size: 13.5px; color: var(--ink); padding: 0 4px;
}
.pagelabel .sep { color: var(--ink-dim); margin: 0 5px; }
.pagelabel #pageTotal { color: var(--ink-dim); }

.actions { display: flex; align-items: center; gap: 2px; }
.abtn {
  width: 34px; height: 34px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--ink-dim);
  transition: background .15s, color .15s;
}
.abtn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.abtn.on { background: var(--accent); color: var(--accent-ink); }
.lang {
  margin-left: 6px; width: 40px; height: 30px; border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, .25); color: var(--ink);
  font-size: 12px; font-weight: 700; letter-spacing: .4px;
}
.lang:hover { border-color: var(--accent); color: var(--accent); }

#stage {
  flex: 1 1 auto; min-width: 0; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 8px;
}
#stage::before {
  content: ""; position: absolute; inset: auto 4% 4px; height: 26px;
  background: radial-gradient(50% 100% at 50% 0%, rgba(0, 0, 0, .3), transparent 75%);
  pointer-events: none;
}
#book { position: relative; }
/* page "paper" while its image loads */
.stf__item { background: var(--paper); }
.stf__item.--hard { background: #181512; }
.fpage { position: relative; width: 100%; height: 100%; overflow: hidden; }
.fpage .pimg {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  background-repeat: no-repeat; background-position: center;
  background-size: 100% 100%;
}
.fpage .fwm {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  background-repeat: repeat;
  pointer-events: none;
}

.content { flex: 1 1 auto; min-height: 0; display: flex; position: relative; }

.search {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 94vw);
  z-index: 45; display: flex; flex-direction: column;
  background: #fbfaf7; border-left: 1px solid var(--line);
  box-shadow: var(--shadow); transform: translateX(105%);
  transition: transform .22s ease;
}
.search[hidden] { display: none; }
.search.open { transform: translateX(0); }
.search-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.search-head h2 { margin: 0; font-size: 15px; }
.iconbtn {
  width: 30px; height: 30px; border-radius: 7px; display: inline-flex;
  align-items: center; justify-content: center; color: #57534e;
}
.iconbtn:hover { background: #ece7dd; }
.search-box { position: relative; padding: 10px 14px 4px; }
.search-box input {
  width: 100%; height: 40px; padding: 0 12px; font-size: 14px; color: #1c1917;
  background: #fff; border: 1px solid #d6cfc2; border-radius: 8px;
}
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 163, 61, .22); }
.search-box .iconbtn { position: absolute; right: 20px; top: 16px; }
.search-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 6px 14px 10px;
}
.search-actions button {
  font-size: 12px; color: #fff; background: #3a332b; border-radius: 7px;
  padding: 6px 12px; opacity: .85;
}
.search-actions button:hover { background: var(--accent); color: var(--accent-ink); }
.search-actions button:disabled { opacity: .3; cursor: default; }
.search-meta { font-size: 12px; color: #78716c; font-variant-numeric: tabular-nums; white-space: nowrap; }
.search-results { flex: 1 1 auto; overflow-y: auto; padding: 2px 8px 16px; }
.srow {
  display: flex; gap: 10px; width: 100%; text-align: left;
  padding: 8px 8px; border-radius: 8px; border-bottom: 1px dashed var(--line);
}
.srow:hover { background: #f3eee4; }
.srow .pnum {
  flex: 0 0 auto; width: 44px; height: 32px; border-radius: 7px;
  background: #efe9dd; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: #44403c;
}
.srow .snip { font-size: 12.5px; line-height: 1.45; color: #57534e; overflow: hidden; }
.srow .snip mark { background: #fde6b8; color: inherit; border-radius: 2px; }
.search .empty { padding: 26px 16px; text-align: center; color: #a8a29e; font-size: 13px; }

#lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: rgba(18, 16, 14, .96);
}
#lightbox[hidden] { display: none; }
.lb-toolbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  color: #e7e2da; padding: 8px 12px;
}
.lb-toolbar .spacer { flex: 1; }
.lb-toolbar .iconbtn { color: #cfc8be; }
.lb-toolbar .iconbtn:hover { background: rgba(255,255,255,.12); color: #fff; }
.lb-toolbar #lbTitle { font-size: 13px; margin-right: 8px; }
.lb-zoom { font-size: 12px; min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; color: #cfc8be; }
.lb-body {
  flex: 1 1 auto; overflow: auto; display: flex; justify-content: center; align-items: flex-start;
  padding: 8px 16px 20px;
}
#lbCanvas { display: block; background: #fff; box-shadow: var(--shadow); touch-action: pan-x pan-y; }

#tocPanel {
  flex: 0 0 auto; width: 320px; min-width: 320px;
  display: flex; flex-direction: column;
  background: #f6f3ec; border-left: 1px solid var(--line);
  overflow: hidden; transition: width .18s ease, min-width .18s ease;
}
body.toc-hide #tocPanel { width: 0; min-width: 0; border-left: 0; }
.toc-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px; border-bottom: 1px solid var(--line);
}
.toc-head h2 { margin: 0; font-size: 14.5px; color: #1c1917; }
.toc-scroll { flex: 1 1 auto; overflow-y: auto; padding: 8px; scrollbar-width: thin; }
.toc-scroll ul { list-style: none; margin: 0; padding: 0; }

.tbrand { padding: 2px 0; }
.tbrand-btn {
  width: 100%; display: flex; align-items: baseline; gap: 8px;
  padding: 11px 12px; border-radius: 9px; text-align: left;
  color: #292419; background: #eee8dc; border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.tbrand-btn:hover { background: #2d72b7;color:#fff;}
.tbrand-btn.active {
  background: #2d2f93; color: #fff;
  border-color: var(--accent);
}
.tbrand-btn .tnm { font-size: 14px; font-weight: 700; letter-spacing: .3px; }
.tbrand-btn .tsub { font-size: 10.5px; opacity: .7; letter-spacing: .4px; margin-left: auto; }

@media (max-width: 980px) {
  #tocPanel {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 34;
    width: min(320px, 88vw); min-width: min(320px, 88vw);
    box-shadow: var(--shadow); transform: translateX(104%);
    transition: transform .22s ease;
  }
  #tocPanel.toc-open { transform: translateX(0); }
  body.toc-hide #tocPanel { width: min(320px, 88vw); min-width: min(320px, 88vw); border-left: 1px solid var(--line); }
  .toc-close { display: flex; }
}
@media (min-width: 981px) {
  .toc-close { display: none; }
}

@media (max-width: 640px) {
  .brand-text strong { font-size: 12.5px; }
  .brand-text span { display: none; }
  .pagelabel { min-width: 60px; font-size: 12.5px; }
}
