* { box-sizing: border-box; }
:root { --paper: #ffffff; --ink: #25272a; --muted: #626872; --line: #dde1e4; --accent: #146b55; --selected: #e6f2ed; --reading-size: 17px; }
html { scroll-padding-top: 86px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "Noto Sans KR Variable", system-ui, -apple-system, sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.toolbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 60px; padding: 8px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 16px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand img { width: 22px; height: 22px; }
.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-button { flex-shrink: 0; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 5px; background: transparent; display: grid; place-items: center; }
.icon-button:hover { background: #f0f3f2; border-color: var(--line); }
.icon-button img, .document-nav img, .search-wrap img { width: 18px; height: 18px; }
#copy-status { font-size: 12px; color: var(--accent); }
#workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
#sidebar { position: sticky; top: 60px; height: calc(100dvh - 60px); display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #f7f8f8; min-width: 0; }
.project-picker { padding: 22px 18px 16px; }
.project-picker label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
#project-select { width: 100%; min-height: 42px; background: white; color: var(--ink); border: 1px solid #bcc5c3; border-radius: 5px; font-size: 16px; font-weight: 650; padding: 8px; }
#project-meta { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 9px 0 0; word-break: keep-all; overflow-wrap: anywhere; }
.tabs { display: flex; margin: 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 10px 3px; font-size: 13px; white-space: nowrap; background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tabs span { margin-left: 3px; font-size: 11px; font-variant-numeric: tabular-nums; }
.search-wrap { margin: 14px 18px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: white; padding: 8px 9px; border-radius: 5px; }
.search-wrap img { opacity: .5; flex-shrink: 0; }
#search { min-width: 0; width: 100%; border: 0; background: transparent; font-size: 13px; color: var(--ink); }
#toc { flex: 1; overflow-y: auto; padding: 0 10px 24px; scrollbar-width: thin; }
#toc details { margin-bottom: 8px; }
#toc summary { cursor: pointer; padding: 9px 8px; font-size: 12px; color: var(--muted); font-weight: 650; }
#toc summary .count { float: right; font-size: 11px; font-weight: 400; }
.doc-link { display: block; padding: 9px 12px; margin: 2px 0; border-left: 3px solid transparent; text-decoration: none; font-size: 13px; line-height: 1.55; color: #474e56; overflow-wrap: anywhere; border-radius: 0 4px 4px 0; }
.doc-link:hover { background: #edf0f0; }
.doc-link[aria-current="page"] { background: var(--selected); color: #10533f; border-left-color: var(--accent); font-weight: 650; }
.doc-link small { display: block; font-weight: 400; color: var(--muted); font-size: 10px; margin-top: 3px; }
#main { width: 100%; max-width: 1280px; min-width: 0; margin: 0 auto; padding: 32px 42px 64px; }
.document-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--accent); font-size: 12px; font-weight: 600; min-height: 25px; }
.badge { color: #8b3545; background: #fbeef0; padding: 3px 7px; border-radius: 3px; font-size: 11px; }
#document-path { font-size: 11px; color: var(--muted); margin: 7px 0 24px; overflow-wrap: anywhere; line-height: 1.7; }
#reader-body { min-width: 0; font-size: var(--reading-size); line-height: 1.85; overflow-wrap: anywhere; }
#reader-body > :first-child { margin-top: 0; }
#reader-body h1 { font-size: 28px; line-height: 1.45; margin: 0 0 30px; }
#reader-body h2 { font-size: 21px; line-height: 1.5; margin: 36px 0 14px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
#reader-body h3 { font-size: 18px; line-height: 1.5; margin: 26px 0 12px; }
#reader-body h4, #reader-body h5, #reader-body h6 { font-size: 16px; }
#reader-body p { margin: 14px 0; }
#reader-body li { margin: 7px 0; }
#reader-body ul, #reader-body ol { padding-left: 1.6em; }
#reader-body strong { font-weight: 700; }
#reader-body blockquote { margin: 20px 0; border-left: 3px solid #77a79a; padding: 1px 18px; color: #40564f; background: #f5f9f7; }
#reader-body hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0; }
#reader-body code { padding: 2px 4px; border-radius: 3px; background: #f0f2f3; font-size: .85em; }
#reader-body pre { overflow-x: auto; padding: 16px; border: 1px solid var(--line); background: #f7f8f9; font-size: 13px; line-height: 1.7; border-radius: 4px; }
#reader-body pre code { padding: 0; background: none; }
.table-scroll { max-width: 100%; overflow-x: auto; margin: 18px 0 24px; border: 1px solid var(--line); border-radius: 4px; }
#reader-body table { width: 100%; border-collapse: collapse; font-size: .82em; line-height: 1.65; }
#reader-body th, #reader-body td { min-width: 110px; max-width: 380px; padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
#reader-body th { background: #eef3f1; color: #364f46; font-weight: 650; }
#reader-body tr:last-child td { border-bottom: 0; }
#reader-body td:last-child, #reader-body th:last-child { border-right: 0; }
#reader-body tr:nth-child(even) td { background: #fbfcfc; }
#reader-body.manuscript { max-width: 760px; margin: auto; font-family: "Noto Serif KR", Georgia, "Noto Sans KR Variable", serif; line-height: 2.1; }
.empty { padding: 20px 12px; color: var(--muted); font-size: 14px; }
.error { color: #a33b40; }
.document-nav { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); margin-top: 38px; padding-top: 20px; font-size: 13px; }
.document-nav a { min-width: 0; max-width: 48%; display: flex; align-items: flex-start; gap: 8px; text-decoration: none; }
.document-nav a:last-child { margin-left: auto; text-align: right; }
.document-nav img { flex-shrink: 0; }
.document-nav span { overflow-wrap: anywhere; }
#backdrop { display: none; }
body.sidebar-closed #workspace { grid-template-columns: minmax(0, 1fr); }
body.sidebar-closed #sidebar { display: none; }
@media (max-width: 800px) {
  .toolbar { padding: 8px 10px; gap: 8px; }
  .brand { font-size: 14px; gap: 6px; }
  .brand img { display: none; }
  .toolbar-actions { gap: 2px; }
  #copy-status { position: absolute; right: 12px; top: 60px; background: white; }
  #workspace { display: block; }
  #sidebar { display: none; position: fixed; z-index: 30; top: 60px; left: 0; width: min(320px, calc(100% - 40px)); height: calc(100dvh - 60px); }
  body.menu-open #sidebar { display: flex; }
  body.menu-open #backdrop { display: block; position: fixed; inset: 60px 0 0; z-index: 25; border: 0; background: #0006; }
  body.menu-open { overflow: hidden; }
  #main { padding: 24px 18px 40px; }
  #reader-body h1 { font-size: 23px; }
  #reader-body h2 { font-size: 19px; }
  #reader-body h3 { font-size: 17px; }
  #reader-body th, #reader-body td { min-width: 125px; }
}
@media print {
  .toolbar, #sidebar, .document-nav, #backdrop { display: none !important; }
  #workspace { display: block; }
  #main { max-width: none; padding: 0; }
  .table-scroll { overflow: visible; }
}
