:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #73808d;
  --faint: #a4adb7;
  --paper: #ffffff;
  --canvas: #f5f6f8;
  --line: #e4e8ec;
  --line-strong: #d6dce2;
  --accent: #326d75;
  --accent-dark: #285a61;
  --accent-pale: #e8f2f2;
  --error: #a83636;
  --shadow: 0 18px 50px rgba(28, 43, 54, .08);
  font-family: Inter, "Segoe UI", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.topbar {
  height: 68px; padding: 0 clamp(18px, 4.2vw, 64px); display: flex; align-items: center;
  justify-content: space-between; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-size: 15px; font-weight: 750; text-decoration: none; letter-spacing: -.035em; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--accent); font-size: 17px; font-weight: 800; }
.brand-light { color: #687681; font-weight: 500; }
.topbar-note, .app-footer > span:first-child { display: inline-flex; gap: 9px; align-items: center; color: var(--muted); font-size: 12px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #51a682; box-shadow: 0 0 0 3px #e4f3eb; }

.app-shell { width: min(100% - 40px, 1100px); margin: 0 auto; min-height: calc(100vh - 120px); }
.welcome { max-width: 860px; margin: 0 auto; padding: clamp(50px, 8vh, 86px) 0 60px; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .16em; }
.eyebrow-line { width: 22px; height: 1px; background: var(--accent); }
h1 { margin: 20px 0 14px; font-size: clamp(32px, 5vw, 48px); line-height: 1.24; letter-spacing: -.065em; font-weight: 730; }
h1 span { color: var(--accent); }
.intro { color: #677480; font-size: 15px; line-height: 1.8; margin: 0 0 30px; }
.drop-zone {
  position: relative; width: 100%; min-height: 223px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 25px; border: 1px dashed #9eb0b3; border-radius: 14px; background: #fbfdfd; cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}
.drop-zone:hover, .drop-zone.drag-over { background: #f2f8f8; border-color: var(--accent); transform: translateY(-1px); }
.drop-zone:focus-visible { outline: 3px solid #a8d4d7; outline-offset: 3px; }
.upload-icon { width: 43px; height: 43px; display: grid; place-items: center; margin-bottom: 11px; border-radius: 12px; background: var(--accent-pale); color: var(--accent); }
.upload-icon svg { width: 25px; height: 25px; }
.drop-zone strong { color: #283841; font-size: 14px; font-weight: 650; }
.drop-hint { margin-top: 7px; color: var(--muted); font-size: 12px; }
.choose-button { display: inline-flex; gap: 9px; align-items: center; margin-top: 16px; padding: 9px 15px; border: 1px solid #d7e0e1; border-radius: 8px; color: var(--accent-dark); background: white; font-size: 12px; font-weight: 650; }
.format-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 10px; margin-top: 19px; }
.format-card { display: flex; align-items: center; gap: 9px; min-height: 61px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.78); }
.format-card b, .format-card small { display: block; white-space: nowrap; }
.format-card b { margin-bottom: 4px; font-size: 11px; font-weight: 680; }
.format-card small { color: var(--muted); font-size: 9px; }
.format-icon { flex: 0 0 28px; width: 28px; height: 31px; display: grid; place-items: center; border-radius: 5px; color: white; font-size: 11px; font-weight: 800; }
.icon-hwp { background: #4389b5; }
.icon-word { background: #3c71c5; }
.icon-excel { background: #39866d; }
.icon-ppt { background: #d8794f; }
.icon-pdf { background: #c75a55; font-size: 8px; }
.icon-text { background: #87919b; font-size: 8px; }
.limits-note { margin: 17px 0 0; color: #8a959f; font-size: 11px; line-height: 1.7; }
.limits-note code { padding: 1px 4px; border-radius: 3px; background: #eaedf0; color: #55616c; font-family: ui-monospace, monospace; font-size: 10px; }

.viewer { padding: 32px 0 48px; }
.viewer-toolbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 12px 12px 0 0; background: var(--paper); }
.document-meta { min-width: 0; display: flex; align-items: center; gap: 12px; }
.file-badge { min-width: 47px; padding: 7px 8px; border-radius: 6px; background: var(--accent-pale); color: var(--accent-dark); text-align: center; font-size: 10px; font-weight: 750; }
.file-titles { min-width: 0; }
.file-titles strong { display: block; max-width: min(55vw, 610px); overflow: hidden; color: #29353e; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.file-titles span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.secondary-button, .icon-button, .nav-button { border: 1px solid var(--line-strong); border-radius: 7px; background: white; cursor: pointer; }
.secondary-button { padding: 9px 12px; color: #42515b; font-size: 11px; font-weight: 600; }
.secondary-button:hover, .icon-button:hover, .nav-button:hover:not(:disabled) { border-color: #9eafb1; background: #f8fbfb; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; color: #596670; font-size: 20px; }
.icon-button svg { width: 17px; height: 17px; }
.close-button { font-size: 25px; line-height: 1; font-weight: 300; }
.page-nav { height: 48px; display: flex; align-items: center; justify-content: center; gap: 17px; border: 1px solid var(--line); border-top: 0; background: #fcfcfd; }
.nav-button { padding: 6px 10px; color: #4c5b65; font-size: 11px; }
.nav-button:disabled { opacity: .4; cursor: default; }
.page-info { min-width: 90px; color: #697680; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.sheet-tabs { display: flex; gap: 3px; overflow: auto; padding: 8px 12px 0; border: 1px solid var(--line); border-top: 0; background: white; }
.sheet-tab { flex: 0 0 auto; padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #697680; cursor: pointer; font-size: 11px; }
.sheet-tab.active { border-bottom-color: var(--accent); color: var(--accent-dark); font-weight: 700; }
.viewer-content { position: relative; min-height: min(72vh, 850px); max-height: 78vh; overflow: auto; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; background: #e9edf0; outline: none; }
.sheet-tabs:not(.hidden) ~ .viewer-content { border-top: 1px solid var(--line); }
.loading { position: absolute; z-index: 5; inset: 0; min-height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; color: var(--muted); background: rgba(233,237,240,.92); font-size: 12px; }
.spinner { width: 27px; height: 27px; border: 2px solid #d8e2e3; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-message { padding: 9px 12px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; background: white; color: var(--muted); font-size: 11px; }
.status-message.warning { color: #855c23; background: #fff9eb; }

.pdf-page, .hwp-page { width: fit-content; max-width: calc(100% - 30px); margin: 20px auto; background: white; box-shadow: 0 3px 15px rgba(35,49,59,.14); }
.pdf-page canvas { display: block; max-width: 100%; height: auto; }
.hwp-page { min-width: min(700px, 100%); padding: 0; }
.hwp-page svg { display: block; width: 100%; height: auto; }
.docx-host { min-height: 100%; padding: 20px 12px; background: #e9edf0; }
.docx-host .docx-wrapper { background: transparent !important; padding: 0 !important; }
.docx-host .docx { margin: 0 auto 18px !important; box-shadow: 0 3px 15px rgba(35,49,59,.14); }
.docx-style { display: none; }
.pptx-host { min-height: 100%; padding: 18px 12px; }
.pptx-host > * { max-width: 100%; }
.text-page { width: min(800px, calc(100% - 36px)); min-height: calc(100% - 36px); margin: 18px auto; padding: clamp(20px, 4vw, 42px); border: 1px solid #e6e9eb; border-radius: 3px; background: white; color: #27333b; box-shadow: 0 3px 15px rgba(35,49,59,.10); font: 14px/1.8 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet-grid-wrap { min-height: 100%; overflow: auto; padding: 17px; background: #fff; }
.sheet-grid { border-collapse: separate; border-spacing: 0; min-width: 100%; color: #303a42; background: white; font-size: 11px; }
.sheet-grid th, .sheet-grid td { min-width: 90px; max-width: 280px; height: 29px; padding: 5px 8px; border-right: 1px solid #e7eaed; border-bottom: 1px solid #e7eaed; text-align: left; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet-grid thead th { position: sticky; z-index: 2; top: 0; background: #f4f6f7; color: #6d7a84; text-align: center; font-weight: 650; }
.sheet-grid .row-number { position: sticky; z-index: 1; left: 0; min-width: 48px; width: 48px; background: #f7f8f9; color: #84909a; text-align: right; font-variant-numeric: tabular-nums; }
.sheet-grid thead .row-number { z-index: 3; }
.sheet-notice { padding: 8px 3px; color: #8a959e; font-size: 10px; }
.error-panel { display: flex; align-items: center; gap: 14px; margin: 35px auto; max-width: 700px; padding: 18px; border: 1px solid #ecd5d5; border-radius: 10px; background: #fffafa; }
.error-mark { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #f8e8e8; color: var(--error); font-weight: 750; }
.error-panel strong { color: #6b3030; font-size: 13px; }
.error-panel p { margin: 5px 0 0; color: #865b5b; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.error-panel .secondary-button { margin-left: auto; flex: 0 0 auto; }
.app-footer { width: min(100% - 40px, 1100px); min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 auto; border-top: 1px solid var(--line); color: #77838c; }
.footer-detail { font-size: 10px; }

@media (max-width: 850px) {
  .format-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .welcome { padding-top: 54px; }
}
@media (max-width: 560px) {
  .topbar { height: 58px; }
  .topbar-note { font-size: 10px; }
  .app-shell { width: min(100% - 28px, 1100px); }
  .welcome { padding: 42px 0 38px; }
  h1 { font-size: 32px; }
  .intro { font-size: 13px; }
  .drop-zone { min-height: 205px; padding: 20px 12px; }
  .drop-zone strong { font-size: 12px; }
  .drop-hint { font-size: 10px; }
  .format-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
  .viewer { padding-top: 18px; }
  .viewer-toolbar { align-items: flex-start; padding: 10px; gap: 8px; }
  .document-meta { gap: 8px; }
  .file-titles strong { max-width: 42vw; font-size: 11px; }
  .file-titles span { font-size: 9px; }
  .toolbar-actions { gap: 5px; }
  .secondary-button { padding: 8px 9px; font-size: 10px; }
  .icon-button { width: 31px; height: 31px; }
  .close-button { display: none; }
  .viewer-content { min-height: 68vh; max-height: 78vh; }
  .app-footer { width: min(100% - 28px, 1100px); align-items: flex-start; flex-direction: column; justify-content: center; gap: 6px; padding: 12px 0; }
  .error-panel { align-items: flex-start; flex-wrap: wrap; }
  .error-panel .secondary-button { margin-left: 42px; }
}

/* Optional server-upload controls never replace local file selection. */
.mobile-panel { margin: 18px 0; padding: 16px; border: 1px solid var(--line); background: white; border-radius: 12px; overflow-wrap: anywhere; }
.mobile-panel h2 { font-size: 17px; margin: 0 0 10px; }
.mobile-panel p { font-size: 12px; line-height: 1.6; }
.mobile-panel .warning { color: #855c23; background: #fff9eb; padding: 10px; }
.pair-form, .mobile-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pair-form input { flex: 1 1 180px; min-width: 0; min-height: 44px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 6px; }
.mobile-panel button { min-height: 44px; }
.mobile-panel progress { width: 100%; height: 20px; }
/* Shared mobile shell: retain the desktop document engines. */
html { -webkit-text-size-adjust: 100%; }
/* Insets are additional space, not part of the header's content height. */
.topbar { padding: calc(12px + env(safe-area-inset-top, 0px)) calc(18px + env(safe-area-inset-right, 0px)) 12px calc(18px + env(safe-area-inset-left, 0px)); height: auto; min-height: calc(68px + env(safe-area-inset-top, 0px)); gap: 12px; }
body { padding-bottom: env(safe-area-inset-bottom, 0px); }
.app-shell, .app-footer { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.connection-state { border-left: 3px solid var(--accent); padding-left: 10px; font-weight: 650; }
.connection-state[data-state="auth-failed"], .connection-state[data-state="unreachable"], .connection-state[data-state="server-error"] { color: var(--error); border-color: var(--error); }
.document-source { margin: 0; padding: 8px 12px; background: var(--accent-pale); color: var(--accent-dark); font-size: 12px; line-height: 1.5; }
.local-mode-note { margin: 0 0 12px; font-size: 13px; color: var(--accent-dark); }
@media (max-width: 560px) { .topbar { min-height: calc(58px + env(safe-area-inset-top, 0px)); } }
.app-shell { min-height: calc(100dvh - 120px); }
.render-host { zoom: var(--document-zoom, 1); }
.zoom-controls { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 6px; background: white; border-inline: 1px solid var(--line); }
.zoom-controls button { min-width: 44px; min-height: 44px; }
.viewer-content { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
input { max-width: 100%; }
@media (max-width: 850px), (pointer: coarse) {
  .nav-button, .icon-button, .secondary-button, .sheet-tab { min-width: 44px; min-height: 44px; }
  .close-button { display: grid; }
  .page-nav { height: auto; min-height: 56px; gap: 8px; }
  .viewer-toolbar { flex-wrap: wrap; gap: 10px; }
  .document-meta { flex: 1 1 100%; }
  .file-titles { flex: 1; }
  .file-titles strong { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .toolbar-actions { width: 100%; justify-content: flex-end; }
  .viewer-content { min-height: 45vh; min-height: 45dvh; max-height: 65vh; max-height: 65dvh; }
  .app-shell { width: calc(100% - 24px); }
  .sheet-tabs { max-width: 100%; }
  .intro, .limits-note { overflow-wrap: anywhere; }
  .app-footer { overflow-wrap: anywhere; }
  input, select { font-size: 16px; }
  .topbar-note { max-width: 45%; font-size: 10px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .viewer { padding-top: 8px; }
  .viewer-content { min-height: 40dvh; max-height: 70dvh; }
}
/* Independent mobile shell: no PC connection panel. */
.offline-panel { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 12px; color: var(--muted); }
.offline-panel p { margin: 4px 0; line-height: 1.6; }
.offline-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.offline-panel summary { cursor: pointer; min-height: 28px; }
.welcome { padding-top: clamp(20px, 4vh, 40px); padding-bottom: 24px; }
h1 { font-size: clamp(28px, 5vw, 40px); }
.drop-zone:disabled { opacity: .55; cursor: wait; }
.pdf-text { border-top: 1px solid #ddd; padding: 12px; color: #1e293b; font-size: 12px; background: white; }
.pdf-text summary { min-height: 32px; cursor: pointer; }
.pdf-text pre { white-space: pre-wrap; overflow-wrap: anywhere; }
body:has(#viewer:not(.hidden)) .offline-panel { display: none; }
body:has(#viewer:not(.hidden)) .app-footer { display: none; }
body:has(#viewer:not(.hidden)) .viewer { padding-top: 4px; }
body:has(#viewer:not(.hidden)) .viewer-content { max-height: calc(100dvh - 265px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); min-height: 35dvh; }
@media (max-height: 500px) and (orientation: landscape) {
  body:has(#viewer:not(.hidden)) .topbar { display: none; }
  body:has(#viewer:not(.hidden)) .viewer-content { max-height: 60dvh; }
}
@media (prefers-color-scheme: dark) {
  :root { --ink:#e2e8f0; --muted:#b0becb; --line:#344451; --accent-pale:#193f43; }
  body { background:#101820; color:var(--ink); }
  .topbar,.offline-panel,.viewer-toolbar,.zoom-controls,.sheet-tabs,.page-nav,.status-message { background:#18252e; color:var(--ink); }
  .brand,.brand-light,.file-titles strong,.page-info { color:var(--ink); }
  .drop-zone,.format-card,.choose-button,.secondary-button,.icon-button,.nav-button { background:#1b2d38; color:var(--ink); }
  .drop-zone strong { color:var(--ink); }
  .viewer-content { background:#26343f; }
  /* Document pages remain their source colors; do not invert charts/images. */
}
