/* 모두뷰어 — 디자인 기준은 여기 :root 한 곳 (글자 20·15·13·12px, 간격 24·16·12·8·4, 단추 34) */
:root {
  --bg: #f3f5f9; --panel: #ffffff; --line: #dfe3ea; --text: #161a22; --sub: #5b6474; --hover: #eef1f6;
  --accent: #2f6bff; --accent-ink: #fff; --stage: #e9ecf2; --danger: #e5484d;
  --f-xl: 20px; --f-l: 15px; --f-m: 13px; --f-s: 12px;
  --g5: 24px; --g4: 16px; --g3: 12px; --g2: 8px; --g1: 4px; --btn: 34px; --r: 8px;
  color-scheme: light;
}
:root.dark {
  --bg: #17191e; --panel: #1f2228; --line: #2e333c; --text: #e8ebf1; --sub: #9aa3b2; --hover: #2a2e36;
  --accent: #4c82ff; --stage: #121418;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: var(--f-m)/1.5 "Pretendard", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; }
/* 단추·막대 아이콘(24칸 선 그림)에만 — 보기 안의 큰 그림 SVG(도면·차트·비지오…)는 줄이거나 선을 덧그리지 않음 */
:where(svg[viewBox="0 0 24 24"]) { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:where(svg[viewBox="0 0 24 24"]) circle.dot { fill: currentColor; stroke: none; }

#bar { position: fixed; inset: 0 0 auto 0; height: 48px; display: flex; align-items: center; gap: var(--g3); padding: 0 var(--g2) 0 var(--g4); background: var(--panel); border-bottom: 1px solid var(--line); z-index: 10; }
.brand { display: flex; align-items: center; gap: var(--g2); font-weight: 700; font-size: var(--f-l); white-space: nowrap; }
.brand img { width: 24px; height: 24px; }
.fileinfo { flex: 1; min-width: 160px; display: flex; align-items: baseline; gap: var(--g2); overflow: hidden; }
#vtools { min-width: 0; overflow: hidden; flex-shrink: 1; }
#vtools select { max-width: 132px; }
@media (max-width: 1000px) { .brand span { display: none; } .fileinfo small { display: none; } }
@media (max-width: 860px) { #vtools button:has(svg) span { display: none; } .tools button[data-act=open] span { display: none; } }
.fileinfo b { font-size: var(--f-m); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; max-width: 70%; }
.fileinfo small { color: var(--sub); font-size: var(--f-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tools { display: flex; align-items: center; gap: 2px; }
.tools button { flex-shrink: 0; white-space: nowrap; height: 40px; min-width: 40px; } /* PC 도 터치 노트북을 생각해 40 (휴대폰은 아래에서 44) */ /* 좁은 화면에서 단추 글자가 세로로 쪼개지지 않게 (넘치면 옆으로 밀어 봄) */
#vtools select { flex-shrink: 0; }
.tools button, #vtools select { height: var(--btn); min-width: var(--btn); padding: 0 var(--g2); border: 0; border-radius: var(--r); background: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.tools button:hover { background: var(--hover); }
.tools button.on { background: var(--hover); color: var(--accent); }
.tools button:disabled { opacity: .35; cursor: default; background: transparent; }
#vtools select { background: var(--hover); color: var(--text); font-size: var(--f-s); }
#vtools .zoomv { min-width: 46px; text-align: center; font-size: var(--f-s); color: var(--sub); font-variant-numeric: tabular-nums; }
#pos { font-size: var(--f-s); color: var(--sub); min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 var(--g1); }
body:not(.hasfile) .needfile { display: none !important; }
#pos:empty { display: none !important; } /* 파일이 하나면 빈 자리를 차지하지 않음 */
.tools > button[data-act=prev]:disabled, .tools > button[data-act=next]:disabled { display: none; } /* 넘길 파일이 없으면 ‹ › 도 숨김 */

#menu { position: fixed; top: 52px; right: var(--g2); z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: var(--g1); min-width: 220px; display: flex; flex-direction: column; }
#menu[hidden] { display: none; }
#menu button { text-align: left; border: 0; background: none; padding: var(--g2) var(--g3); border-radius: 6px; cursor: pointer; }
#menu button:hover { background: var(--hover); }
#menu hr { border: 0; border-top: 1px solid var(--line); margin: var(--g1) 0; width: 100%; }

#stage { position: fixed; inset: 48px 0 0 0; background: var(--stage); overflow: hidden; }
body:not(.hasfile) #stage { display: none; }
body.hasfile #home { display: none; }

#home { position: fixed; inset: 48px 0 0 0; display: flex; align-items: center; justify-content: center; overflow: auto; padding: var(--g5); }
.card { width: min(560px, 100%); text-align: center; }
.card .big { width: 88px; height: 88px; }
.card h1 { font-size: 26px; margin: var(--g3) 0 var(--g2); }
.lead { font-size: var(--f-l); color: var(--sub); margin: 0 0 var(--g5); }
.lead b { color: var(--text); }
.primary { height: 44px; padding: 0 32px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: var(--f-l); font-weight: 700; cursor: pointer; }
.primary:hover { filter: brightness(1.08); }
.hint { color: var(--sub); font-size: var(--f-s); margin: var(--g2) 0 var(--g5); }
.assocbox { display: flex; flex-direction: column; gap: var(--g1); align-items: center; padding: var(--g4); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin-bottom: var(--g5); }
.assocbox span { color: var(--sub); font-size: var(--f-s); }
.assocbox button { margin-top: var(--g2); height: var(--btn); padding: 0 var(--g4); border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: var(--r); cursor: pointer; font-weight: 600; }
.assocbox.done button { border-color: var(--line); color: var(--sub); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips span { font-size: var(--f-s); padding: 2px 10px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--sub); }
.chips .chipmore { font-size: var(--f-s); padding: 2px 10px; border-radius: 99px; background: none; border: 1px solid transparent; color: var(--accent); cursor: pointer; min-height: 24px; }
.fmtall { margin-top: var(--g3); text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: var(--g2) var(--g4); }
.fmtall[hidden] { display: none; }
.fmtall p { margin: 0; padding: var(--g2) 0; border-bottom: 1px solid var(--line); display: flex; gap: var(--g3); font-size: var(--f-s); }
.fmtall p:last-child { border-bottom: 0; }
.fmtall b { flex: 0 0 76px; color: var(--text); }
.fmtall span { color: var(--sub); word-break: keep-all; overflow-wrap: break-word; }
/* 11-30 형식별 로고: 이름 왼편에 18px 판 */
.chips span { display: inline-flex; align-items: center; gap: 5px; }
.chips .fis { display: inline-flex; gap: 2px; }
.fi, .fis { font-style: normal; } /* <i> 기본 기울임이 로고 글자에 묻지 않게 */
.fi { display: inline-flex; flex: none; width: 18px; height: 18px; border-radius: 4.6px; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.fi svg { display: block; width: 18px; height: 18px; }
.chips .fi { width: 16px; height: 16px; border-radius: 4px; }
.chips .fi svg { width: 16px; height: 16px; }
.fmtall .fl { display: flex; flex-wrap: wrap; gap: 6px 12px; min-width: 0; }
.fmtall .fl .f { display: inline-flex; align-items: center; gap: 5px; color: var(--sub); white-space: nowrap; line-height: 20px; }
.dark .fi { box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.card > .primary { margin-bottom: var(--g1); }

#drop { position: fixed; inset: 0; z-index: 50; background: rgba(47,107,255,.14); display: flex; align-items: center; justify-content: center; pointer-events: none; }
#drop[hidden] { display: none; }
#drop div { border: 3px dashed var(--accent); border-radius: 16px; padding: 40px 60px; font-size: var(--f-xl); font-weight: 700; color: var(--accent); background: var(--panel); }
#toast { position: fixed; bottom: var(--g5); left: 50%; transform: translateX(-50%); background: #111; color: #fff; padding: var(--g2) var(--g4); border-radius: 99px; z-index: 60; font-size: var(--f-m); max-width: 80%; }
#toast[hidden] { display: none; }

/* 공통 보기 틀 */
.fill { position: absolute; inset: 0; }
.frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.scroll { position: absolute; inset: 0; overflow: auto; }
.msg { position: absolute; inset: 0; display: flex; flex-direction: column; gap: var(--g3); align-items: center; justify-content: center; color: var(--sub); text-align: center; padding: var(--g5); }
.msg b { color: var(--text); font-size: var(--f-l); }
.msg button { height: var(--btn); padding: 0 var(--g4); border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* 그림 */
.imgview { position: absolute; inset: 0; overflow: hidden; cursor: grab; background-image: linear-gradient(45deg, rgba(128,128,128,.12) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.12) 75%), linear-gradient(45deg, rgba(128,128,128,.12) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.12) 75%); background-size: 20px 20px; background-position: 0 0, 10px 10px; }
.imgview.drag { cursor: grabbing; }
.imgview > .pic { position: absolute; left: 0; top: 0; transform-origin: 0 0; image-rendering: auto; user-select: none; -webkit-user-drag: none; }
.imgview.pixel > .pic { image-rendering: pixelated; }
.pages { position: absolute; left: 0; right: 0; bottom: var(--g3); display: flex; justify-content: center; gap: var(--g2); pointer-events: none; }
.pages span { pointer-events: auto; background: rgba(0,0,0,.6); color: #fff; padding: 4px 12px; border-radius: 99px; font-size: var(--f-s); }

/* 영상·음악 */
.media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; }
.media video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; }
.media.audio { background: var(--stage); flex-direction: column; gap: var(--g4); }
.media.audio .disc { width: 160px; height: 160px; border-radius: 24px; background: linear-gradient(135deg, var(--accent), #8a5cff); display: flex; align-items: center; justify-content: center; color: #fff; }
.media.audio .disc svg { width: 64px; height: 64px; }
.media.audio audio { width: min(560px, 90%); }
.media.audio b { font-size: var(--f-l); }

/* 목록(압축) */
.list { max-width: 1100px; margin: 0 auto; padding: var(--g4) var(--g5) 60px; }
.list .head { display: flex; align-items: center; gap: var(--g3); margin-bottom: var(--g3); color: var(--sub); }
.list .head b { color: var(--text); font-size: var(--f-l); }
.list .crumb button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0 2px; }
.list table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list td, .list th { padding: 9px var(--g3); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.list th { font-weight: 600; color: var(--sub); font-size: var(--f-s); background: var(--hover); }
.list tr.row { cursor: pointer; }
.list tr.row:hover td { background: var(--hover); }
.list td.nm { width: 100%; white-space: normal; word-break: normal; overflow-wrap: anywhere; }
.list .head { flex-wrap: wrap; }
.list .crumb { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .list { padding: var(--g3) var(--g2) 60px; } .list .dt { display: none; } .list td, .list th { padding: 10px 8px; } }
.list td.nm i { font-style: normal; margin-right: 8px; }
.list td.num { text-align: right; color: var(--sub); font-variant-numeric: tabular-nums; }
.backbar { position: absolute; top: 6px; left: var(--g2); max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; z-index: 5; height: var(--btn); padding: 0 var(--g3); border-radius: 99px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* 텍스트 */
.textview { position: absolute; inset: 0; overflow: auto; background: var(--panel); }
.textview pre { margin: 0; padding: var(--g4) var(--g5); font: 13px/1.6 "D2Coding", Consolas, "Malgun Gothic", monospace; white-space: pre-wrap; word-break: break-all; tab-size: 4; }
.textview pre.nowrap { white-space: pre; word-break: normal; }
.textview pre code.hljs { background: none; padding: 0; }
.textview .ln { display: inline-block; width: 4.5em; color: var(--sub); opacity: .55; user-select: none; text-align: right; margin-right: 1.2em; }
.textbar { position: absolute; right: var(--g4); top: var(--g2); z-index: 3; display: flex; gap: var(--g1); }
.textbar select, .textbar button { height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font-size: var(--f-s); padding: 0 var(--g2); cursor: pointer; }
.grid { border-collapse: collapse; font-size: var(--f-s); background: var(--panel); }
.grid td, .grid th { border: 1px solid var(--line); padding: 4px 8px; white-space: pre; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.grid th { position: sticky; top: 0; background: var(--hover); font-weight: 600; z-index: 1; }
.grid.xl { table-layout: fixed; }
.grid.xl td { white-space: pre; overflow: hidden; text-overflow: clip; }
.grid.xl td.n { text-align: right; font-variant-numeric: tabular-nums; }
.grid.xl td.c { text-align: center; }
.grid.xl td.e { color: var(--danger); }
.grid.xl thead th { position: sticky; top: 0; }
.grid td.rn, .grid th.rn { position: sticky; left: 0; background: var(--hover); color: var(--sub); text-align: right; z-index: 2; }

/* 글꼴 */
.fontview { padding: var(--g5); max-width: 1100px; margin: 0 auto; }
.fontview h2 { margin: 0 0 var(--g1); font-size: var(--f-xl); }
.fontview .s { margin: var(--g4) 0; border-top: 1px solid var(--line); padding-top: var(--g3); word-break: break-all; }
.fontview .s small { color: var(--sub); font-family: "Malgun Gothic", sans-serif; display: block; }

/* 16진 */
.hexview { position: absolute; inset: 0; overflow: auto; background: var(--panel); }
.hexview .info { padding: var(--g4) var(--g5); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: max-content 1fr; gap: 4px var(--g4); }
.hexview .info span { color: var(--sub); }
.hexview pre { margin: 0; padding: var(--g3) var(--g5); font: 12.5px/1.6 Consolas, monospace; }
.hexview pre .o { color: var(--sub); }
.hexview pre .a { color: var(--accent); }

/* 문서(한글·오피스) 공통 */
.docview { position: absolute; inset: 0; overflow: auto; background: var(--stage); }
/* 1.7: 확대해서 쪽이 화면보다 넓어지면 가운데 맞춤 때문에 왼쪽이 화면 밖(스크롤로도 못 감)으로 밀리던 것 → 내용 폭만큼 넓혀 왼쪽부터 스크롤 */
.docview > div { min-width: max-content; }
.sheet-tabs { position: absolute; left: 0; right: 0; bottom: 0; height: 34px; display: flex; gap: 2px; padding: 0 var(--g2); background: var(--panel); border-top: 1px solid var(--line); overflow-x: auto; }
.sheet-tabs button { border: 0; background: none; padding: 0 var(--g4); cursor: pointer; white-space: nowrap; border-top: 2px solid transparent; flex-shrink: 0; color: var(--text); } /* 시트가 많아도 이름이 겹치지 않고 옆으로 밀어 봄 */
.sheet-tabs button.on { border-top-color: var(--accent); font-weight: 700; background: var(--hover); }

/* ── 쪽 문서 도우미(pagedoc.js): 글자 층·찾기 표시·메모·쪽 이동 창 */
.pd-text { position: absolute; inset: 0; z-index: 2; color: transparent; overflow: hidden; line-height: 1; user-select: text; -webkit-user-select: text; }
.pd-text span { position: absolute; white-space: pre; transform-origin: 0 0; font-family: sans-serif; cursor: text; }
.pd-text span::selection { background: rgba(47,107,255,.35); color: transparent; }
.pd-hl { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.pd-hl i { position: absolute; background: rgba(255,214,0,.45); border-radius: 2px; }
.pd-hl i.cur { background: rgba(255,120,0,.55); outline: 2px solid #ff7a00; }
.pd-ann { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
.pd-ann.on { pointer-events: auto; touch-action: none; cursor: crosshair; }
.pd-drawing .pd-text { pointer-events: none; }
.pd-annbar { position: absolute; left: 8px; right: 8px; margin: 0 auto; width: fit-content; bottom: 12px; z-index: 8; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: calc(100% - 16px); }
.pd-annbar[hidden] { display: none; }
.pd-annbar button { height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.pd-annbar button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pd-annbar button.dot { width: 26px; min-width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); }
.pd-annbar .primary-s { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.pagebtn { border: 0; background: none; cursor: pointer; color: var(--sub); border-radius: 6px; }
.pagebtn:hover { background: var(--hover); color: var(--accent); }
.pd-nav { position: absolute; inset: 0 auto 0 0; width: min(340px, 92vw); z-index: 9; background: var(--panel); border-right: 1px solid var(--line); box-shadow: 6px 0 24px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.pd-nav-head { display: flex; gap: 6px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.pd-nav-head b { white-space: nowrap; }
.pd-nav-head input { flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: var(--bg); color: var(--text); font-size: 16px; }
.pd-nav-head button { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); cursor: pointer; }
.pd-nav-head button.x { border: 0; }
.pd-toc { display: flex; flex-direction: column; max-height: 40%; overflow: auto; border-bottom: 1px solid var(--line); padding: 6px 0; }
.pd-toc > b { padding: 4px 12px; color: var(--sub); font-size: var(--f-s); }
.pd-toc button { text-align: left; border: 0; background: none; color: var(--text); padding: 6px 12px; cursor: pointer; }
.pd-toc button:hover { background: var(--hover); }
.pd-toc small { color: var(--sub); }
.pd-thumbs { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px; align-content: start; }
.pd-th { position: relative; display: block; width: 100%; align-self: start; height: auto; border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 0; cursor: pointer; overflow: hidden; }
.pd-th canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pd-th span { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 99px; }

#menu .mobileonly { display: none; }
@media (max-width: 600px) { #menu .mobileonly { display: block; } }

/* ── 찾기 막대 */
#findbar { position: fixed; top: 52px; right: 8px; max-width: calc(100vw - 16px); box-sizing: border-box; z-index: 25; display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
#findbar[hidden] { display: none; }
#findbar input { width: min(260px, 50vw); min-width: 0; flex: 1 1 auto; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--bg); color: var(--text); font-size: 16px; }
#findbar span { min-width: 54px; text-align: center; color: var(--sub); font-size: var(--f-s); font-variant-numeric: tabular-nums; }
#findbar button { height: 34px; min-width: 34px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--text); }
#findbar button:hover { background: var(--hover); }
::highlight(mvfind) { background: rgba(255,214,0,.55); }
::highlight(mvfindcur) { background: rgba(255,120,0,.7); }

/* ── 문서 어둡게 보기 (그림·영상 제외) */
#stage.docdark .docview > div > div, #stage.docdark .frame, #stage.docdark .textview { filter: invert(.9) hue-rotate(180deg); }

/* ── 첫 화면 최근 파일 */
.recent { margin: 0 0 var(--g5); text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.recent[hidden] { display: none; }
.recent .rh { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.recent .rh button { border: 0; background: none; color: var(--sub); cursor: pointer; font-size: var(--f-s); }
.recent .ri { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); padding: 10px 14px; text-align: left; cursor: pointer; }
.recent .ri:last-child { border-bottom: 0; }
.recent .ri:hover { background: var(--hover); }
.recent .ri b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.recent .ri small { color: var(--sub); white-space: nowrap; }

/* ── 웹판(휴대폰·브라우저): 윈도우 전용 메뉴 숨김 */
.web [data-act=reveal], .web [data-act=openWith], .web #assocBtn { display: none; }
.web #home { align-items: flex-start; }
.assocbox small:empty { display: none; }
.iosarrow { position: fixed; bottom: 6px; left: 50%; transform: translateX(-50%); font-size: 34px; color: var(--accent); animation: mvbob 1.2s infinite; }
@keyframes mvbob { 50% { transform: translate(-50%, 6px); } }
/* ── 휴대폰 화면 (좁은 폭) */
@media (max-width: 600px) {
  #bar { padding: 0 4px 0 10px; gap: 4px; height: calc(48px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  #home { inset: calc(48px + env(safe-area-inset-top)) 0 0 0; padding: 20px 16px; }
  #stage { top: calc(48px + env(safe-area-inset-top)) !important; }
  .fileinfo { min-width: 0; flex: 1 1 34%; }
  .fileinfo b { max-width: 100%; flex-shrink: 1; }
  body.hasfile .brand { display: none; }
  .tools button.needfile:disabled { display: none; }
  .tools > button[data-act=print] { display: none; } /* 휴대폰: 인쇄는 「더 보기」 메뉴로 → 보기 도구 자리 넓힘 */
  body.hasfile .tools > button[data-act=open] { display: none; } /* 파일을 보는 중: 「열기」는 「더 보기」 메뉴로 */
  #vtools { overflow-x: auto; max-width: 62vw; scrollbar-width: none; }
  #vtools.ovf { padding-right: 16px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); } /* 넘칠 때만: 옆으로 밀어 봄, 끝은 흐리게 */
  #vtools::-webkit-scrollbar { display: none; }
  #vtools .zoomv { display: none; }
  .tools button { min-width: 36px; padding: 0 6px; }
  #pos, .sep.needfile { display: none; }
  .web .card .hint { display: none; }
  .card h1 { font-size: 22px; }
  .card .big { width: 72px; height: 72px; }
  .primary { width: 100%; height: 52px; font-size: 17px; }
  .card > .primary { margin-bottom: var(--g4); }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom)); } /* 영상 조작 막대·시트 띠·쪽 단추를 가리지 않게 */
  #menu { right: 6px; left: 6px; min-width: 0; }
  #menu button { min-height: 44px; }
  #vtools select { max-width: 112px; }
}
/* 손가락 화면: 끌어다 놓기 안내는 필요 없음 · 위 막대 단추는 손가락 크기(높이 44) */
@media (pointer: coarse) {
  .card .hint { display: none; }
  .tools button { height: 44px; min-width: 44px; }
  #findbar button { min-width: 40px; height: 40px; }
  .sheet-tabs { height: 42px; } .sheet-tabs button { min-width: 44px; }
  .scroll.xlarea { bottom: 42px !important; }
}
/* 가로로 눕힌 휴대폰(높이가 낮은 화면): 큰 로고를 줄여 「파일 열기」가 첫 화면에 보이게 */
@media (max-height: 520px) {
  #home { padding-top: 12px; }
  .card .big { width: 44px; height: 44px; }
  .card h1 { font-size: 20px; margin: 4px 0; }
  .lead { margin-bottom: var(--g3); font-size: var(--f-m); }
  .primary { height: 46px; }
}
/* 크롬에 넘어와 설치: 화면 전체가 설치 단추 */
.installgate { position: fixed; inset: 0; z-index: 100; background: var(--bg, #f3f5f9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; cursor: pointer; }
.installgate img { width: 112px; height: 112px; border-radius: 26px; box-shadow: 0 8px 28px rgba(30, 90, 230, .25); }
.installgate b { font-size: 24px; }
.installgate span { color: var(--sub); }
.installgate .big { margin-top: 10px; width: min(360px, 100%); height: 58px; border-radius: 14px; background: #2f6cf6; color: #fff; font-size: 19px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.installgate small { color: var(--sub); min-height: 1.2em; }

/* 아주 좁은 화면(폴더블 바깥 화면 등 360px 미만): 찾기 막대·메모 막대가 잘리지 않게 */
@media (max-width: 359px) {
  #findbar { left: 8px; }
  #findbar span { min-width: 40px; }
  #findbar button { min-width: 30px; padding: 0 2px; }
  .pd-annbar button { padding: 0 8px; height: 32px; }
}
/* ── 1.7 아이폰: 글자 자동 확대 끄기, 노치·홈 막대 비켜 가기(가로 화면 포함) — 다른 기기는 env() = 0 이라 그대로 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (padding: max(0px)) {
  #bar { padding-left: max(var(--g4), env(safe-area-inset-left)); padding-right: max(var(--g2), env(safe-area-inset-right)); }
  #stage { left: env(safe-area-inset-left); right: env(safe-area-inset-right); bottom: env(safe-area-inset-bottom); }
  @media (max-width: 600px) { #bar { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); } }
}
/* 1.7: 안내 화면(.msg) 단추 규칙이 바탕을 흰색으로 덮어 강조 단추(.primary) 글자가 안 보이던 것 */
.msg button.primary { background: var(--accent); color: #fff; border: 0; }

/* ══ 1.8 사용자 1,000회 실제 사용 시험 반영 (10 기기 × 10 파일 × 10 과제) ══════════════ */
#vtools [hidden] { display: none !important; }
/* 닫기: PC = 파일 이름 옆 ✕, 휴대폰 = 맨 왼쪽 ← (전에는 PC 에서 보던 파일을 닫을 방법이 없었음) */
.closebtn { display: none; flex-shrink: 0; height: var(--btn); min-width: var(--btn); padding: 0; border: 0; border-radius: var(--r); background: transparent; color: var(--sub); align-items: center; justify-content: center; cursor: pointer; }
body.hasfile .closebtn { display: inline-flex; }
.closebtn:hover { background: var(--hover); color: var(--text); }
.closebtn .ic-back { display: none; }
body.hasfile .brand[data-act=home] { cursor: pointer; }
@media (min-width: 601px) {
  .brand { order: 0; } .fileinfo { order: 1; flex: 0 1 auto; min-width: 120px; } .closebtn { order: 2; }
  #vtools { order: 3; margin-left: auto; } #bar > .tools:last-child { order: 4; }
}
/* 넓은 PC: 찾기·인쇄에 글자도 (아이콘만으로는 무슨 단추인지 몰라 마우스를 올려 봐야 했음) */
@media (max-width: 1399px) { .tools button span.wide { display: none; } }
/* 이 파일에 맞지 않는 단추 숨김 (app.js setCaps) */
body.c-notext [data-act=find], body.c-notext .cap-text { display: none !important; }
body.c-noprint [data-act=print], body.c-noprint .cap-print, body.c-noprint .cap-pdf { display: none !important; }
/* 「⋯」 메뉴: 묶음 제목 · 화면보다 길면 안에서 밀림(가로 휴대폰에서 아래 항목을 못 누르던 것) */
#menu { max-height: calc(100vh - 64px); overflow-y: auto; overscroll-behavior: contain; }
#menu .mh { font-size: 11px; font-weight: 700; color: var(--sub); padding: 8px 12px 2px; letter-spacing: .02em; }
#menu .mrow { display: flex; gap: 2px; }
#menu .mrow button { flex: 1; white-space: nowrap; }
#menu .mgrip { display: none; }
/* 압축 목록: 경로·「저장」 단추가 손가락에 너무 작았음 (38×22) */
@media (pointer: coarse) {
  .list .crumb button { min-height: 40px; padding: 0 8px; }
  .list .rowsave { min-height: 40px; min-width: 52px; border-radius: 8px !important; }
}
.pd-plist { max-height: none; flex: 1; }
.pd-plist button.on { color: var(--accent); font-weight: 700; background: var(--hover); }

/* ── 아래 도구 막대: 휴대폰·손가락 태블릿 (app.js DOCK 조건일 때 body.hasdock) */
/* 보기 도구 = 엄지가 닿는 아래 막대, 아이콘 + 이름표 (전에는 위 막대 62% 안에 끼워 넣어 메모·회전·글자 크게가 밖으로 밀려 숨었음) */
body.hasdock #vtools { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-width: none; height: calc(60px + env(safe-area-inset-bottom)); padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left)); background: var(--panel); border-top: 1px solid var(--line); display: flex; align-items: stretch; justify-content: space-around; gap: 0; overflow-x: auto; }
body.hasdock #stage { bottom: calc(60px + env(safe-area-inset-bottom)) !important; }
body.hasdock #vtools button { flex: 1 1 0; min-width: 48px; max-width: 88px; height: 100%; flex-direction: column; gap: 3px; padding: 6px 2px 4px; border-radius: 10px; }
body.hasdock #vtools button > span { display: none; }
body.hasdock #vtools button::after { content: attr(data-cap); font-size: 11px; line-height: 1.1; color: var(--sub); white-space: nowrap; }
body.hasdock #vtools button.on::after { color: var(--accent); font-weight: 700; }
body.hasdock #vtools button svg { width: 22px; height: 22px; }
body.hasdock #vtools .sep, body.hasdock #vtools .zoomv:not(.pagebtn) { display: none; }
body.hasdock #vtools .pagebtn { display: inline-flex; flex-direction: row; min-width: 66px; font-size: 13px; font-weight: 700; color: var(--text); background: var(--hover); margin: 8px 2px; height: auto; }
body.hasdock #vtools .pagebtn::after { content: none; }
body.hasdock #vtools:has(.pagebtn:not([hidden])) button[data-cap="쪽 이동"] { display: none; } /* 쪽 번호를 누르면 같은 창 */
body.hasdock #vtools select { align-self: center; max-width: 100px; height: 38px; }
#vtools.ovf { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
body.hasdock #vtools { order: 0; margin: 0; }

/* ── 휴대폰(폭 600 이하) */
@media (max-width: 600px) {
  /* 위 막대 = ← · 파일 이름(두 줄: 이름 / 종류·크기) · ‹ › · 찾기 · ⋯ */
  .closebtn { order: -1; min-width: 44px; height: 44px; color: var(--text); }
  .closebtn .ic-back { display: block; } .closebtn .ic-x { display: none; }
  .fileinfo { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; line-height: 1.25; }
  .fileinfo small { display: block !important; font-size: 11px; max-width: 100%; }
  body.hasfile #bar { padding-left: max(2px, env(safe-area-inset-left)); }
  #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  /* 「⋯」 메뉴 = 아래에서 올라오는 판 (엄지로 닿게), 뒤는 어둡게 */
  #menu { top: auto; bottom: 0; left: 0; right: 0; max-height: 82vh; border-radius: 16px 16px 0 0; border-bottom: 0; padding: 0 8px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 0 0 100vmax rgba(0,0,0,.38); z-index: 30; }
  #menu .mgrip { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 2px; flex-shrink: 0; }
  #menu button { font-size: 15px; }
}
@media (max-width: 600px) {
  body.finding #findbar { top: calc(48px + env(safe-area-inset-top)); left: 0; right: 0; max-width: none; border-radius: 0; border-width: 0 0 1px; box-shadow: none; }
  body.finding #findbar input { width: auto; }
  body.finding #stage { top: calc(95px + env(safe-area-inset-top)) !important; }
}

/* 손가락 기기 위 막대: 닫기도 44 · 가로 폰은 배율 숫자와 겹치는 목차 단추를 빼 자리를 냄 */
@media (pointer: coarse) { .closebtn { min-width: 44px; height: 44px; } #vtools .zoomv:not(.pagebtn) { display: none; } #vtools:has(.pagebtn:not([hidden])) button[title^="쪽 이동"]:not(.pagebtn) { display: none; } }
body.hasdock #toast { bottom: calc(80px + env(safe-area-inset-bottom)); } /* 알림이 아래 막대를 덮지 않게 */
@media (min-width: 601px) { .fileinfo b { max-width: none; flex-shrink: 1; min-width: 0; } } /* 태블릿에서 파일 이름이 빈자리가 있는데도 잘리던 것 */
.list .crumb button { min-height: 28px; padding: 0 6px; border-radius: 6px; } .list .crumb button:hover { background: var(--hover); }
.list .rowsave { min-height: 28px; min-width: 44px; border-radius: 6px !important; } .list .rowsave:hover { background: var(--hover) !important; }
@media (pointer: coarse) { .list .crumb button, .list .rowsave { min-height: 40px; } .list .rowsave { min-width: 52px; } }
