:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface2: #eceae4; --line: #e2dfd7;
  --text: #17171a; --sub: #6d6b66; --faint: #a3a09a;
  --accent: #2d5bff; --accent-ink: #fff;
  --pdf: #e5483f; --ppt: #e8762c;
  --view: #1b1c20; --view2: #26272d; --view-text: #f2f2f4;
  --font: 'Pretendard Variable', Pretendard, -apple-system, system-ui, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111214; --surface: #1b1c20; --surface2: #26272d; --line: #2e3036; --text: #f2f2f4; --sub: #a2a3aa; --faint: #6e7078; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- 홈 ---------- */
.home { max-width: 560px; margin: 0 auto; padding: env(safe-area-inset-top) 16px calc(28px + env(safe-area-inset-bottom)); min-height: 100%; }
.h-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 6px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; letter-spacing: -0.03em; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.brand .mark svg { width: 18px; height: 18px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 700; }
.hero { margin-top: 18px; background: var(--surface); border-radius: 24px; padding: 26px 22px 22px; border: 1px solid var(--line); }
.hero h1 { margin: 0; font-size: 30px; line-height: 1.2; letter-spacing: -0.045em; font-weight: 800; }
.hero p { margin: 10px 0 22px; color: var(--sub); font-size: 14px; }
.open-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 58px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 17px; cursor: pointer; box-shadow: 0 8px 22px -10px var(--accent); transition: transform .12s; }
.open-btn:active { transform: scale(.98); }
.open-btn svg { width: 22px; height: 22px; }
.kinds { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }
.k { font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px; color: #fff; }
.k.pdf { background: var(--pdf); } .k.ppt { background: var(--ppt); }

.recent { margin-top: 26px; }
.r-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 10px; }
.r-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.03em; }
.r-head small { color: var(--faint); font-size: 12px; }
.r-empty { text-align: center; color: var(--faint); font-size: 14px; padding: 34px 0; border: 1.5px dashed var(--line); border-radius: var(--r); }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; width: 100%; text-align: left; }
.doc .th { width: 54px; height: 54px; flex: none; border-radius: 10px; background: var(--surface2); overflow: hidden; display: grid; place-items: center; position: relative; }
.doc .th img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.doc .th .k { position: absolute; left: 4px; bottom: 4px; font-size: 9px; padding: 1px 5px; }
.doc .meta { flex: 1; min-width: 0; }
.doc .meta b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc .meta small { color: var(--sub); font-size: 12px; }
.doc .bar { display: block; height: 3px; border-radius: 2px; background: var(--surface2); margin-top: 6px; overflow: hidden; }
.doc .bar i { display: block; height: 100%; background: var(--accent); }
.doc .del { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: var(--faint); font-size: 20px; line-height: 1; }
.doc .del:active { background: var(--surface2); }
.drop { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--accent) 18%, transparent); display: grid; place-items: center; }
.drop div { background: var(--surface); padding: 18px 26px; border-radius: 16px; font-weight: 800; border: 2px dashed var(--accent); }

/* ---------- 보기 화면 ---------- */
.viewer { position: fixed; inset: 0; background: var(--view); color: var(--view-text); display: flex; flex-direction: column; z-index: 10; }
.v-top { flex: none; display: flex; align-items: center; gap: 6px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: var(--view); border-bottom: 1px solid #2c2d33; }
.v-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.v-title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-title small { font-size: 11.5px; color: #9a9ba3; }
.ib { width: 42px; height: 42px; flex: none; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; color: inherit; }
.ib:active { background: rgba(255,255,255,.08); }
.ib svg { width: 22px; height: 22px; }
.ib.sm { width: 36px; height: 36px; font-size: 20px; font-weight: 600; }
.scroller { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.pages { padding: 12px 0 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; transform-origin: 0 0; min-width: 100%; width: max-content; margin: 0 auto; }
.page { position: relative; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.35); flex: none; }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .pn { position: absolute; right: 6px; bottom: 6px; font-size: 10.5px; color: #fff; background: rgba(0,0,0,.45); padding: 1px 6px; border-radius: 6px; pointer-events: none; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--view); font-size: 14px; color: #c9cad0; z-index: 3; }
.loading i { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #3a3b42; border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.v-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--view); border-top: 1px solid #2c2d33; }
.pg { border: 0; background: var(--view2); border-radius: 10px; padding: 7px 10px; display: flex; gap: 3px; font-size: 13px; color: #c9cad0; font-variant-numeric: tabular-nums; flex: none; }
.pg b { color: #fff; }
#pg-range { flex: 1; min-width: 40px; accent-color: #fff; }
.zoom { display: flex; align-items: center; background: var(--view2); border-radius: 12px; flex: none; }
.z-val { border: 0; background: none; font-size: 12.5px; font-weight: 700; min-width: 44px; color: #fff; padding: 0; }

/* PPTX 슬라이드: 원래 크기로 그린 뒤 폭에 맞게 줄인다 */
.slide { position: relative; background: #fff; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,.35); flex: none; }
.slide > .inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.slide .pn { position: absolute; right: 6px; bottom: 6px; font-size: 10.5px; color: #fff; background: rgba(0,0,0,.45); padding: 1px 6px; border-radius: 6px; z-index: 5; }
.pptx-host { position: absolute; left: -99999px; top: 0; }
.pptx-preview-slide-wrapper { margin: 0 !important; box-shadow: none !important; }

/* 발표 모드 */
.stage { position: fixed; inset: 0; z-index: 30; background: #000; display: grid; place-items: center; touch-action: none; user-select: none; }
.st-slide { position: relative; overflow: hidden; background: #fff; }
.st-slide > .inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.st-ui { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(6px + env(safe-area-inset-top)) 10px 0 6px; color: #fff; opacity: .75; transition: opacity .3s; font-size: 13px; font-variant-numeric: tabular-nums; }
.stage.idle .st-ui { opacity: 0; }

/* 공통 */
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 13px; font-weight: 700; width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); margin-bottom: 8px; }
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); color: var(--text); border-radius: 22px 22px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 10px; font-size: 18px; }
.sheet ol { margin: 0 0 18px; padding-left: 20px; font-size: 14px; line-height: 1.7; color: var(--sub); }
.sheet ol b { color: var(--text); }

/* 예전 PPT: 글상자·그림을 제자리에 */
.ppt-old { background: #fff; color: #1d1d1f; font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', var(--font); }
.ppt-old > div { position: absolute; }
.po-img img { width: 100%; height: 100%; object-fit: fill; display: block; }
.po-meta { background: repeating-linear-gradient(45deg, #eef0f3 0 6px, #e4e7ec 6px 12px); }
.po-txt { overflow: hidden; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; line-height: 1.25; padding: 2px 4px; }
.po-txt.t { font-weight: 700; }
.po-txt.dk { color: #fff; }
.po-loose { left: 4%; right: 4%; bottom: 3%; font-size: 13px; white-space: pre-wrap; color: #555; }
