:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Noto Sans KR", sans-serif;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #dbeafe;
  --paper: #fff;
  --surface: #f8fafc;
  --toolbar: #edf3fa;
  --workspace: #e6edf6;
  --text: #18243a;
  --muted: #506079;
  --line: #cbd8e8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--surface); color: var(--text); display: flex; flex-direction: column; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button { cursor: pointer; }
button:disabled { opacity: .42; cursor: default; }
.topbar { padding: 10px max(16px, calc((100% - 1290px) / 2)); min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); flex: none; }
.brand, .document-title { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.brand strong { font-size: 1.16rem; }
.brand-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.brand-icon::before { content: ""; width: 15px; height: 20px; border-radius: 3px; background: var(--accent); grid-area: 1 / 1; }
.brand-icon::after { content: ""; width: 8px; height: 2px; background: white; box-shadow: 0 4px 0 white; margin-top: -4px; grid-area: 1 / 1; }
.document-title > div { min-width: 0; }
.document-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-title small { display: block; color: var(--muted); margin-top: 1px; font-size: .73rem; }
.header-actions { display: flex; gap: 5px; flex: none; }
#home { margin: clamp(44px, 11vh, 110px) auto 32px; width: min(100% - 32px, 520px); text-align: center; }
h1 { font-size: clamp(1.55rem, 4vw, 2rem); margin: 0; letter-spacing: -.045em; }
.intro { margin: 14px 0 28px; color: var(--muted); }
.dropzone { border: 1px dashed #7891b4; background: #f1f6fc; border-radius: 18px; padding: 26px 20px 20px; }
.dropzone p { margin: 10px 0 6px; font-weight: 650; }
.dropzone small { display: block; color: var(--muted); font-size: .8rem; }
.drop-icon { display: grid; place-items: center; margin: 0 auto; width: 42px; height: 42px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); font-size: 1.55rem; }
.primary { display: block; width: 100%; border: 0; border-radius: 12px; background: var(--accent); color: white; font-weight: 700; padding: 13px 16px; margin-top: 22px; }
.primary:hover { background: var(--accent-hover); }
#reader { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.workspace { display: flex; flex: 1; min-height: 0; background: var(--workspace); position: relative; }
#viewport { flex: 1; min-width: 0; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; }
#pages { position: relative; padding: 18px 12px var(--bottom, 18px); display: flex; flex-direction: column; align-items: center; gap: 15px; min-width: max-content; }
#viewport.horizontal { scroll-snap-type: x proximity; }
.horizontal #pages { padding: 18px var(--edge, 12px); flex-direction: row; align-items: flex-start; width: max-content; min-height: 100%; }
.sheet { flex: none; margin: 0; width: calc(var(--page-width, 700px) * var(--zoom, 1)); aspect-ratio: var(--ratio, .707); background: var(--paper); box-shadow: 0 1px 5px #162d5030; scroll-snap-align: center; }
.sheet canvas { display: block; width: 100%; height: auto; }
.sheet-error { color: var(--muted); padding: 18px; }
.button { border: 0; border-radius: 8px; color: var(--accent); background: transparent; min-height: 40px; padding: 4px 11px; font-weight: 600; }
.button:hover:not(:disabled) { background: var(--accent-soft); }
.icon { min-width: 38px; color: var(--text); font-size: 1.3rem; line-height: 1; }
.tab { position: absolute; left: 0; top: 14px; padding: 6px 10px; z-index: 1; background: var(--surface); box-shadow: 0 2px 10px #162d5028; border-radius: 0 10px 10px 0; font-size: .78rem; }
.tab span { display: block; font-size: 1rem; }
#thumbnails { display: flex; flex-direction: column; width: 180px; flex: none; background: var(--surface); border-right: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 4px; justify-content: space-between; padding: 3px 6px 3px 12px; font-size: .8rem; }
#thumbnail-list { padding: 6px 14px 14px; overflow: auto; display: grid; gap: 9px; align-content: start; }
.thumb { position: relative; padding: 6px; background: var(--toolbar); border: 1px solid transparent; border-radius: 9px; color: var(--text); min-height: 86px; width: 100%; aspect-ratio: var(--ratio, .707); }
.thumb[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); }
.thumb span { position: absolute; top: 6px; left: 6px; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; color: var(--text); background: var(--surface); }
.thumb canvas { width: 100%; display: block; margin: 0 auto; }
.toolbar { display: flex; justify-content: center; align-items: center; gap: 7px; flex-wrap: wrap; flex: none; background: var(--surface); border-top: 1px solid var(--line); padding: 7px 10px max(7px, env(safe-area-inset-bottom)); }
.control-group, .direction { background: var(--toolbar); border: 1px solid var(--line); border-radius: 10px; }
.control-group { display: flex; align-items: center; }
.readout, .page-form, .direction { font-size: .84rem; white-space: nowrap; }
.readout { min-width: 55px; }
.page-form { color: var(--accent); display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.page-form input { width: 3ch; text-align: right; color: var(--accent); border: 0; border-radius: 4px; padding: 6px 0; background: transparent; }
.page-form span:last-child { min-width: 2ch; }
.notice { display: flex; position: fixed; bottom: 68px; left: 50%; transform: translateX(-50%); align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 24px); z-index: 4; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 3px 18px #162d5030; }
.notice .button { flex: none; }
.drag-overlay { position: fixed; inset: 10px; z-index: 6; pointer-events: none; border: 2px dashed var(--accent); border-radius: 18px; background: #f1f6fcea; display: grid; place-items: center; color: var(--accent); font-size: 1.2rem; font-weight: 750; }
@media (max-width: 620px) {
  #thumbnails { width: min(168px, 50vw); position: absolute; z-index: 2; inset: 8px auto 8px 0; border-radius: 0 12px 12px 0; box-shadow: 2px 3px 14px #162d5028; }
  .topbar { padding-inline: 12px; }
  .toolbar .button { min-width: 34px; }
}
