:root {
  color-scheme: light;
  --ink: #183029; --deep: #152e27; --deep-2: #21453a; --leaf: #bce6bd; --leaf-soft: #eef6ec; --paper: #f6f5ef;
  --line: #e3e8e1; --muted: #5d6d64; --danger: #8a2a1a;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tap: 44px; /* 애플 최소 터치 영역 44pt */
  font-family: -apple-system, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  color: var(--ink); background: var(--paper);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, label.open { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; touch-action: manipulation; cursor: pointer; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.hero:has(#file:focus-visible) .open { outline: 3px solid #4f9a68; outline-offset: 3px; }
body { word-break: keep-all; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #4f9a68; outline-offset: 2px; border-radius: 10px; }
svg { flex: none; }

/* 위 막대 */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; min-height: calc(56px + var(--safe-top));
  padding: calc(6px + var(--safe-top)) 10px 6px 14px; background: var(--deep); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-height: var(--tap); border: 0; background: none; font-weight: 800; letter-spacing: -.03em; font-size: 17px; padding: 0; }
.brand img { border-radius: 9px; box-shadow: 0 2px 8px #0005; }
.back { display: grid; place-items: center; width: var(--tap); height: var(--tap); margin-left: -8px; border: 0; border-radius: 12px; background: none; }
.back:active { background: #ffffff1f; }
.doc-title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.doc-title strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-title span { font-size: 12px; color: #c4d8ca; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-actions { display: flex; gap: 6px; margin-left: auto; }
.bar-actions button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 52px; min-height: var(--tap); padding: 3px 8px; border: 0; border-radius: 12px; background: #ffffff14; font-size: 11px; font-weight: 700;
}
.bar-actions button:active { background: #ffffff30; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; overflow: hidden; background: #ffffff20; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 40%; background: var(--leaf); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* 첫 화면 */
.start { max-width: 600px; margin: 0 auto; padding: 0 18px calc(28px + var(--safe-bottom)); }
.hero { padding: 22px 0 6px; }
.guide { position: relative; display: flex; align-items: flex-end; justify-content: flex-end; height: 150px; margin: 0 -4px 4px; }
.guide-pic { position: absolute; right: 2px; bottom: 0; height: 150px; width: auto; }
.bubble {
  position: absolute; left: 0; top: 14px; max-width: 64%; margin: 0; padding: 13px 15px; border-radius: 18px 18px 18px 4px;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 22px #1d392112; font-size: 14.5px; font-weight: 700; line-height: 1.5;
}
.bubble small { display: block; color: #3f7d57; font-size: 11.5px; font-weight: 800; letter-spacing: .02em; margin-bottom: 2px; }
h1 { text-wrap: balance; margin: 18px 0 8px; font-size: clamp(31px, 8.6vw, 44px); line-height: 1.17; letter-spacing: -.06em; }
h1 span { color: #2f6b47; }
.lead { margin: 0; color: #46574e; font-size: 16px; line-height: 1.7; }
.open {
  display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 64px; margin-top: 22px; border-radius: 18px;
  background: var(--deep); color: #fff; cursor: pointer; box-shadow: 0 12px 26px #12302533; transition: transform .12s, background .12s;
}
.open span { display: flex; flex-direction: column; font-size: 19px; font-weight: 900; line-height: 1.15; }
.open small { font-size: 12px; font-weight: 600; color: #bfd6c6; margin-top: 2px; }
.open:active { transform: scale(.985); background: var(--deep-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0 0; padding: 0; list-style: none; }
.chips li { padding: 5px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 800; color: #fff; }
.c-hwp { background: #2563c9; } .c-doc { background: #2b4f9e; } .c-xls { background: #187a3c; }
.c-ppt { background: #c4541d; } .c-pdf { background: #c62828; } .c-etc { background: #e7ebe5; color: var(--ink) !important; }
.safe { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 12px 0 0; color: var(--muted); font-size: 12.5px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; }
.tiles div { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px 13px; border-radius: 16px; background: #fff; border: 1px solid var(--line); text-align: center; align-items: center; }
.tiles svg { color: #2f6b47; }
.tiles strong { font-size: 14.5px; }
.tiles small { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.card { margin-top: 12px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 18px; line-height: 1.6; font-size: 14px; }
.install { display: flex; gap: 12px; align-items: flex-start; background: var(--leaf-soft); border-color: #cfe5cd; }
.install .mini { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; background: #fff; border: 2px solid #fff; box-shadow: 0 3px 10px #1d392120; }
.install strong { display: block; font-size: 15.5px; margin-bottom: 4px; }
.install ol { margin: 0; padding-left: 18px; }
.install li { margin: 3px 0; }
.note { margin: 16px 4px 0; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.foot { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-top: 22px; color: var(--muted); font-size: 12.5px; }
.foot a { color: inherit; padding: 8px 2px; }

/* 문서 화면 */
.viewer { min-height: calc(100dvh - 56px - var(--safe-top)); }
.doc-body { background: #e6eae7; min-height: inherit; padding-bottom: calc(80px + var(--safe-bottom)); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.loading { display: grid; place-items: center; gap: 10px; padding: 70px 24px; color: var(--muted); text-align: center; font-size: 14px; }
.loading .ring { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #cfdcd2; border-top-color: #2f6b47; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.problem { max-width: 460px; margin: 40px auto; padding: 22px 20px; background: #fff; border-radius: 18px; border: 1px solid var(--line); text-align: center; line-height: 1.6; }
.problem img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; }
.problem strong { display: block; margin: 8px 0 4px; font-size: 17px; }
.problem p { margin: 0 0 14px; color: #4b5a52; font-size: 14px; white-space: pre-line; }
.problem label { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 20px; border-radius: 14px; background: var(--deep); color: #fff; font-weight: 800; cursor: pointer; }

.pager {
  position: fixed; left: 50%; bottom: calc(14px + var(--safe-bottom)); transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 5px; border-radius: 99px; background: #152e27ee; color: #fff; box-shadow: 0 10px 26px #0d221a50;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.pager button { width: 46px; height: 46px; border: 0; border-radius: 50%; background: #ffffff1a; font-size: 26px; line-height: 1; }
.pager button:active { background: #ffffff33; }
.pager button:disabled { opacity: .3; }
.pager span { min-width: 68px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }

/* 문서 형식별 */
.page { display: block; margin: 12px auto; background: #fff; box-shadow: 0 2px 4px #143b2b10, 0 8px 22px #143b2b1a; max-width: calc(100% - 16px); border-radius: 2px; }
.page > svg, .page > canvas, .page > img { display: block; width: 100%; height: auto; }
.hwp-page { width: 100%; }
.docx-frame { display: block; width: 100%; height: 100%; min-height: 70vh; border: 0; background: #e6eae7; }
.photo { display: block; max-width: 100%; height: auto; margin: 12px auto; background: #fff; }
.plain { margin: 12px; padding: 16px; background: #fff; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.6 ui-monospace, Menlo, monospace; }
.sheet-tabs { position: sticky; top: 0; z-index: 2; display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line); }
.sheet-tabs button { flex: none; min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: #f5f6f2; font-size: 13.5px; font-weight: 700; }
.sheet-tabs button[aria-pressed="true"] { background: var(--deep); color: #fff; border-color: var(--deep); }
.sheet-wrap { overflow: auto; padding: 10px; }
.sheet-wrap table { border-collapse: collapse; background: #fff; font-size: 13px; }
.sheet-wrap td, .sheet-wrap th { border: 1px solid #d5dbd5; padding: 5px 8px; white-space: nowrap; vertical-align: top; }
.slide { margin: 12px; padding: 16px 18px; background: #fff; border-radius: 14px; box-shadow: 0 4px 14px #143b2b18; line-height: 1.6; }
.slide h2 { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); letter-spacing: .04em; }
.slide p { margin: 4px 0; overflow-wrap: anywhere; }
.slide p.title { font-size: 18px; font-weight: 800; }
.slide table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.slide td { border: 1px solid #d5dbd5; padding: 4px 6px; }
.banner { margin: 10px 12px 0; padding: 10px 12px; border-radius: 12px; background: #fff7e6; border: 1px solid #ecd7a8; font-size: 13px; line-height: 1.5; }

@media (hover: hover) {
  .open:hover { background: var(--deep-2); }
  .bar-actions button:hover, .back:hover { background: #ffffff26; }
  .pager button:hover:not(:disabled) { background: #ffffff2e; }
  .sheet-tabs button:hover { border-color: #9fb7a6; }
  .problem label:hover { background: var(--deep-2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

#print-area { display: none; }
@media print {
  @page { margin: 0; }
  html, body { background: #fff !important; }
  #app { display: none !important; }
  #print-area { display: block; }
  #print-area > * { break-after: page; page-break-after: always; margin: 0 auto; box-shadow: none; }
  #print-area > *:last-child { break-after: auto; page-break-after: auto; }
  #print-area img, #print-area svg { display: block; width: 100%; height: auto; }
  #print-area .docx-wrapper { zoom: 1 !important; padding: 0 !important; background: none !important; }
  #print-area .docx-wrapper > section.docx { margin: 0 !important; box-shadow: none !important; break-after: page; page-break-after: always; display: flex !important; }
  #print-area .sheet-wrap { overflow: visible; }
}
