:root {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1b1f24;
  --surface-light: #252b32;
  --paper: #f7f3ea;
  --ink: #26313c;
  --text: #ecf0f2;
  --muted: #9aa4ae;
  --accent: #d7a85b;
  --accent-strong: #f0bf6e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% -10%, #303944 0, var(--bg) 43rem);
}
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 3.25rem 0 2.5rem; }
.intro { text-align: center; margin-bottom: 2rem; }
.eyebrow { margin: 0 0 .55rem; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 500; }
.subtitle { margin: .65rem 0 0; color: var(--muted); }
.source-panel { max-width: 760px; margin: 0 auto 1.5rem; padding: 1.15rem; border: 1px solid #343c45; border-radius: 15px; background: rgba(27, 31, 36, .88); box-shadow: 0 15px 40px #0004; }
form > label { display: block; margin-bottom: .55rem; color: #cbd2d7; font-size: .88rem; }
.url-row { display: flex; gap: .65rem; }
input[type="url"] { flex: 1; min-width: 0; padding: .8rem .9rem; border: 1px solid #47515c; border-radius: 9px; color: var(--text); background: #12161a; outline: none; }
input[type="url"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #d7a85b22; }
.primary-button { border: 0; border-radius: 9px; padding: .8rem 1rem; background: var(--accent); color: #21180c; font-weight: 750; white-space: nowrap; }
.primary-button:hover { background: var(--accent-strong); }
.source-help { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .75rem; color: var(--muted); font-size: .79rem; align-items: center; }
.file-button { color: var(--accent-strong); text-decoration: underline; cursor: pointer; }
#pdf-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.message { min-height: 1.25rem; margin: .75rem 0 0; color: #ffbf8b; font-size: .85rem; }
.reader { max-width: 1120px; margin: 0 auto; }
.book-toolbar { display: flex; align-items: baseline; justify-content: space-between; margin: 0 .4rem .7rem; gap: 1rem; }
.document-title { margin: 0; overflow: hidden; font-family: Georgia, serif; font-size: 1.12rem; text-overflow: ellipsis; white-space: nowrap; }
.page-indicator { flex: none; margin: 0; color: var(--muted); font-size: .83rem; }
.book-frame { position: relative; display: grid; min-height: 430px; place-items: center; overflow: hidden; border: 1px solid #303740; border-radius: 16px; background: #090b0d; box-shadow: 0 25px 55px #0007; }
.book { width: 100%; height: min(76vh, 790px); }
.book .page { display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--paper); }
.book .page canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.book .stf__item { background-color: var(--paper); }
.loader { position: absolute; inset: 0; z-index: 10; display: grid; place-content: center; gap: .8rem; text-align: center; color: #d8dde0; background: #090b0dcc; backdrop-filter: blur(3px); }
.loader[hidden] { display: none !important; }
.loader span { width: 34px; height: 34px; margin: auto; border: 3px solid #ffffff2c; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.loader p { margin: 0; }
@keyframes spin { to { transform: rotate(1turn); } }
.controls { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1.1rem auto 0; }
.icon-button { border: 1px solid #424b54; border-radius: 8px; padding: .62rem .8rem; color: var(--text); background: var(--surface); }
.icon-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.icon-button:disabled { cursor: not-allowed; opacity: .4; }
.progress-wrap { width: min(330px, 36vw); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.empty-state { padding: 5rem 1rem; color: var(--muted); text-align: center; }
.book-mark { display: block; margin-bottom: .65rem; color: var(--accent); font-family: Georgia, serif; font-size: 3rem; transform: rotate(90deg); }
.empty-state p { margin: 0; }
@media (max-width: 620px) {
  .app-shell { width: min(100% - 1rem, 1180px); padding-top: 2rem; }
  .url-row { flex-direction: column; }
  .primary-button { width: 100%; }
  .book-frame { min-height: 390px; border-radius: 10px; }
  .book { height: min(72vh, 690px); }
  .icon-button span { display: none; }
  .controls { gap: .6rem; }
  .progress-wrap { width: min(220px, 58vw); }
}
