*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f0ede8;
  --accent: #1e4d8c;
  --text: #2a2a2a;
  --sub: #777;
}
html, body {
  height: 100%; overflow: hidden;
  font-family: 'Pretendard', -apple-system, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(255,255,255,0.55) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(180,170,160,0.28) 0%, transparent 60%);
}
body { display: flex; flex-direction: column; }

/* ── Loading ── */
#loader {
  position: fixed; inset: 0; z-index: 9999;
  background: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  transition: opacity 0.6s ease;
}
#loader.hide { opacity: 0; pointer-events: none; }
#loader img { width: 320px; max-width: 80vw; }
.load-bar { width: 260px; height: 3px; background: rgba(30,77,140,0.12); border-radius: 2px; overflow: hidden; }
.load-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.25s ease; width: 0%; }
.load-txt { font-size: 13px; color: var(--sub); }

/* ── Header ── */
.hd {
  flex-shrink: 0; height: 58px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: rgba(240,237,232,0.93);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.07);
  z-index: 100;
}
.hd-logo { height: 30px; }
.hd-div { width: 1px; height: 18px; background: rgba(0,0,0,0.14); flex-shrink: 0; }
.hd-titles { flex: 1; min-width: 0; }
.hd-title { font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: 0.02em; white-space: nowrap; }
.hd-sub { font-size: 11px; color: var(--sub); }
.hd-pg { font-size: 13px; color: var(--sub); font-weight: 300; white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tbtn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(30,77,140,0.2);
  background: rgba(30,77,140,0.05);
  color: var(--accent); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.tbtn:hover { background: rgba(30,77,140,0.13); border-color: var(--accent); }
.tbtn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.zbr {
  display: flex; align-items: center; gap: 2px;
  padding: 5px 10px;
  border: 1px solid rgba(30,77,140,0.2);
  background: rgba(30,77,140,0.05);
  border-radius: 999px;
}
.zbtn {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 17px; font-weight: 700;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.zbtn:hover { color: #174080; }
#zLvl { font-size: 11px; color: var(--sub); min-width: 34px; text-align: center; }
.pdf-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid rgba(30,77,140,0.3);
  background: rgba(30,77,140,0.06); color: var(--accent);
  font-size: 12px; font-weight: 500; font-family: inherit;
  cursor: pointer; text-decoration: none; transition: all 0.18s;
}
.pdf-btn:hover { background: rgba(30,77,140,0.13); }

/* ── Stage ── */
.stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
#bwrap { transition: transform 0.25s ease; transform-origin: center center; }

/* ── Controls ── */
.ctrl {
  flex-shrink: 0; height: 62px;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  background: rgba(240,237,232,0.93);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0,0,0,0.07);
}
.nbtn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 24px; border-radius: 999px;
  font-family: inherit; font-size: 13px; cursor: pointer; border: none;
  transition: all 0.18s;
}
.nbtn-p { background: #fff; color: var(--text); border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.nbtn-p:hover:not(:disabled) { background: #f9f9f9; transform: translateX(-2px); }
.nbtn-n { background: var(--accent); color: #fff; box-shadow: 0 2px 12px rgba(30,77,140,0.28); }
.nbtn-n:hover:not(:disabled) { background: #174080; transform: translateX(2px); }
.nbtn:disabled { opacity: 0.32; cursor: not-allowed; transform: none !important; }
.dots { display: flex; gap: 6px; align-items: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(0,0,0,0.14); cursor: pointer; transition: all 0.28s; }
.dot.on { background: var(--accent); width: 20px; border-radius: 4px; }

/* ── Search panel ── */
#srchPanel {
  position: fixed; top: 66px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #fff; border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px; padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 22px rgba(0,0,0,0.12);
  z-index: 200; min-width: 340px;
  opacity: 0; visibility: hidden; transition: all 0.2s;
}
#srchPanel.on { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
#srchInp {
  border: none; outline: none; flex: 1;
  font-family: inherit; font-size: 14px; color: var(--text); background: none;
}
#srchCnt { font-size: 11px; color: var(--sub); white-space: nowrap; }
.snav { background: none; border: none; cursor: pointer; color: var(--accent); font-size: 14px; padding: 2px 5px; }
.sclose { background: none; border: none; cursor: pointer; color: var(--sub); font-size: 18px; line-height: 1; }

/* ── Thumbnail drawer ── */
#tOverlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.35);
  opacity: 0; visibility: hidden; transition: all 0.3s;
}
#tOverlay.on { opacity: 1; visibility: visible; }
#tDrawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 290px; background: #f5f4f1;
  transform: translateX(100%);
  transition: transform 0.34s cubic-bezier(.4,0,.2,1);
  z-index: 301; display: flex; flex-direction: column;
  box-shadow: -4px 0 28px rgba(0,0,0,0.14);
}
#tDrawer.on { transform: translateX(0); }
.thd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.08); flex-shrink: 0;
}
.thd-ttl { font-size: 14px; font-weight: 700; color: var(--accent); }
.thd-x { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--sub); line-height: 1; }
#tList { flex: 1; overflow-y: auto; padding: 14px 12px 24px; display: flex; flex-direction: column; gap: 12px; }
.titem {
  cursor: pointer; border-radius: 6px; overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  transition: transform 0.18s, box-shadow 0.18s;
  background: #fff;
}
.titem:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.titem.on { outline: 2px solid var(--accent); }
.titem canvas { width: 100%; display: block; }
.tlbl { text-align: center; font-size: 11px; color: var(--sub); padding: 5px 0 6px; }

/* ── Share modal ── */
#shrModal {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.38);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.22s;
}
#shrModal.on { opacity: 1; visibility: visible; }
.shbox {
  background: #fff; border-radius: 18px;
  padding: 28px 26px 22px; width: 310px;
  box-shadow: 0 12px 44px rgba(0,0,0,0.2); text-align: center;
  transform: scale(0.9); transition: transform 0.22s;
}
#shrModal.on .shbox { transform: scale(1); }
.shtitle { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 18px; }
#qrBox { width: 180px; height: 180px; margin: 0 auto 14px; border-radius: 10px; overflow: hidden; border: 1px solid rgba(0,0,0,0.07); display: flex; align-items: center; justify-content: center; background: #fff; }
#qrBox canvas, #qrBox img { width: 180px !important; height: 180px !important; display: block; }
.shurl {
  font-size: 10px; color: var(--sub); word-break: break-all;
  background: #f5f5f5; padding: 8px 10px; border-radius: 8px;
  margin-bottom: 16px; text-align: left;
}
.shacts { display: flex; gap: 8px; justify-content: center; }
.shcopy, .shclose {
  padding: 8px 18px; border-radius: 999px; border: none;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.18s;
}
.shcopy { background: var(--accent); color: #fff; }
.shcopy:hover { background: #174080; }
.shclose { background: #f0f0f0; color: var(--text); }
.shclose:hover { background: #e0e0e0; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .hd-sub, .hd-div, .hd-logo { display: none; }
  .tools { gap: 4px; }
  .zbr { padding: 4px 7px; }
  .pdf-btn span { display: none; }
}
