/* 글꼴: 미리보기에서는 배포처에서 바로 불러온다. */
@import url("https://cdn.jsdelivr.net/npm/pretendard@1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

@font-face {
  font-family: "MaruBuri";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/MaruBuri-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "MaruBuri";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/MaruBuri-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: "MaruBuri";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/MaruBuri-Bold.woff2") format("woff2");
}

:root {
  /* 색: 바탕과 면 */
  --color-bg: #f4f0e6;              /* 미색 모조지 */
  --color-surface: #fbf8f1;         /* 밝은 종이. 입력 칸과 떠 있는 면 */
  --color-surface-2: #e9e3d4;       /* 서식의 항목 칸 */
  --color-line: #cbc3b1;            /* 가는 괘선 */
  --color-line-strong: #24211d;     /* 굵은 괘선 */
  --color-line-accent: #b8281f;     /* 도장 테두리 */

  /* 색: 글자 */
  --color-text: #24211d;            /* 먹색 */
  --color-text-muted: #5f594e;

  /* 색: 실행 버튼 */
  --color-action: #24211d;
  --color-action-hover: #45403a;
  --color-on-action: #fbf8f1;

  /* 색: 강조 */
  --color-accent: #b8281f;          /* 인주색 */
  --color-accent-strong: #a3221a;   /* 종이 위에 글자로 쓸 때 */
  --color-accent-soft: #f1dcd3;
  --color-on-accent: #fbf8f1;
  --color-mark: #ecdfb4;            /* 옅은 밑칠 */

  /* 색: 상태 */
  --color-ok: #2c5a49;
  --color-ok-soft: #dae5dc;
  --color-warn: #7a5200;
  --color-warn-soft: #f0e2bd;
  --color-danger: #a3221a;
  --color-danger-soft: #f1dcd3;
  --color-info: #3c4756;
  --color-info-soft: #dfe2e4;

  /* 색: 모듈 */
  --color-module-admin: #24211d;
  --color-module-journal: #2c5a49;
  --color-module-conference: #7a5200;
  --color-module-link: #5f594e;
  --color-on-module: #fbf8f1;

  /* 색: 기타 */
  --color-focus: #24211d;
  --color-overlay: rgba(36, 33, 29, 0.45);

  /* 글꼴 */
  --font-display: "MaruBuri", "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
  --font-body: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-num: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-bold: 600;
  --weight-display: 700;

  /* 글자 크기 단계 */
  --text-2xs: 0.6875rem;            /* 11px */
  --text-xs: 0.75rem;               /* 12px */
  --text-sm: 0.875rem;              /* 14px */
  --text-base: 1rem;                /* 16px */
  --text-md: 1.125rem;              /* 18px */
  --text-lg: 1.3125rem;             /* 21px */
  --text-xl: 1.5rem;                /* 24px */
  --text-2xl: 2.25rem;              /* 36px */
  --text-3xl: 3rem;                 /* 48px */
  --text-hero: clamp(2rem, 1rem + 3.4vw, 4rem);
  --leading-tight: 1.3;
  --leading-snug: 1.45;
  --leading-normal: 1.65;
  --leading-loose: 1.85;
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.06em;

  /* 간격 단계 */
  --space-1: 0.25rem;               /* 4px */
  --space-2: 0.5rem;                /* 8px */
  --space-3: 0.75rem;               /* 12px */
  --space-4: 1rem;                  /* 16px */
  --space-5: 1.5rem;                /* 24px */
  --space-6: 2rem;                  /* 32px */
  --space-7: 3rem;                  /* 48px */
  --space-8: 4rem;                  /* 64px */
  --space-9: 6rem;                  /* 96px */
  --space-gutter: clamp(1rem, 4.5vw, 4.5rem);

  /* 모서리 */
  --radius-sm: 0.125rem;            /* 2px */
  --radius-md: 0.1875rem;           /* 3px */
  --radius-lg: 0.25rem;             /* 4px */
  --radius-full: 999px;

  /* 그림자 */
  --shadow-sm: 0 1px 0 rgba(36, 33, 29, 0.12);
  --shadow-md: 0 2px 0 rgba(36, 33, 29, 0.14), 0 8px 20px rgba(36, 33, 29, 0.08);
  --shadow-lg: 0 3px 0 rgba(36, 33, 29, 0.16), 0 20px 44px rgba(36, 33, 29, 0.14);

  /* 선 */
  --border-thin: 1px;
  --border-mid: 1.5px;
  --border-thick: 2px;
  --icon-stroke: 1.5;

  /* 크기 */
  --size-content: 76rem;            /* 본문 최대 폭 */
  --size-header: 4.75rem;           /* 포털 머리말 높이 */
  --size-sidebar: 14.5rem;          /* 사무국 왼쪽 메뉴 폭 */
  --size-topbar: 3.5rem;            /* 사무국 위쪽 막대 높이 */
  --size-aside: 20rem;              /* 보조 단 폭 */
  --size-label: 7rem;               /* 항목 칸 폭 */
  --size-control: 2.5rem;           /* 버튼과 입력 칸 높이 */
  --size-control-lg: 3rem;
  --size-control-sm: 2rem;
  --size-nav-item: 1.875rem;        /* 메뉴 한 줄 높이 */
  --size-icon: 1.125rem;
  --size-measure: 30em;             /* 읽기 좋은 한 줄 길이 */

  /* 움직임 */
  --duration-fast: 120ms;

  /* 2차에서 더한 변수: 서류함과 문서의 짜임 */
  --color-desk: #e4ddcc;            /* 종이를 올려 둔 책상 */
  --size-tray: 24.5rem;             /* 사무국 서류함 단의 폭 */
  --size-toc: 13rem;                /* 포털 차례 단의 폭 */
  --size-paper: 47rem;              /* 문서 한 장의 최대 폭 */
  --size-seal: 3.5rem;              /* 결재란 도장의 지름 */
  --size-tap: 2.75rem;              /* 좁은 화면에서 누르는 대상의 최소 높이 */
  --duration-stamp: 280ms;
}

/* 미리보기 틀: 방향의 디자인이 아니다. 값을 직접 적는다. */
.pv-bar { box-sizing: border-box; display: flex; align-items: center; gap: 14px; height: 36px; margin: 0; padding: 0 16px; border-bottom: 1px dashed #8d8d8d; background: #efefef; color: #2b2b2b; font: 12px/1.4 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; letter-spacing: 0; white-space: nowrap; overflow: hidden; }
.pv-bar__title { font-weight: 700; }
.pv-bar a { padding: 3px 8px; border: 1px solid transparent; border-radius: 3px; color: #2b2b2b; text-decoration: underline; text-underline-offset: 2px; }
.pv-bar a:focus-visible { outline: 2px solid #2b2b2b; outline-offset: 1px; }
.pv-bar a[aria-current="page"] { border-color: #2b2b2b; background: #ffffff; font-weight: 700; text-decoration: none; }
.pv-bar__note { color: #555555; }
.pv-bar__back { margin-left: auto; }
@media (max-width: 720px) { .pv-bar__note { display: none; } }

/* ---------- 바탕 ---------- */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

:where(.portal, .office) :where(h1, h2, h3, h4, p, ul, ol, dl, dd, figure) { margin: 0; padding: 0; }
:where(.portal, .office) :where(ul, ol) { list-style: none; }
:where(.portal, .office) :where(h1, h2, h3, h4) { font-size: inherit; font-weight: inherit; }
:where(.portal, .office) a { color: inherit; }
:where(.portal, .office) :focus-visible {
  outline: var(--border-thick) solid var(--color-focus);
  outline-offset: var(--border-thick);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.icon { flex: none; width: var(--size-icon); height: var(--size-icon); stroke-width: var(--icon-stroke); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ---------- 공통 부품: 버튼 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--size-control);
  padding: 0 var(--space-4);
  border: var(--border-thin) solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--color-surface-2); }
.btn--primary {
  background: var(--color-action);
  border-color: var(--color-action);
  color: var(--color-on-action);
}
.btn--primary:hover { background: var(--color-action-hover); }
.btn--lg { min-height: var(--size-control-lg); padding: 0 var(--space-5); font-size: var(--text-base); }
.btn:disabled { cursor: default; opacity: 0.55; }

/* ---------- 공통 부품: 도장 ---------- */

/* 인주색은 도장에만 쓴다. 겹줄 테두리와 기울기로 찍은 자국을 낸다. */
.seal {
  display: inline-grid;
  place-items: center;
  width: var(--size-seal);
  height: var(--size-seal);
  border: var(--border-thick) solid var(--color-line-accent);
  border-radius: var(--radius-full);
  box-shadow: inset 0 0 0 var(--border-mid) var(--color-surface), inset 0 0 0 calc(var(--border-mid) + var(--border-thin)) var(--color-line-accent);
  color: var(--color-accent-strong);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-display);
  line-height: 1;
  transform: rotate(-8deg);
}
.seal--alt { transform: rotate(5deg); }
.seal--empty {
  border: var(--border-thin) dashed var(--color-text-muted);
  box-shadow: none;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  transform: none;
}
/* 네모난 접수 도장: 보냄, 접수 */
.seal--box {
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
  text-align: center;
  transform: rotate(-4deg);
}
.seal--muted {
  border-color: var(--color-text-muted);
  box-shadow: inset 0 0 0 var(--border-mid) var(--color-surface), inset 0 0 0 calc(var(--border-mid) + var(--border-thin)) var(--color-text-muted);
  color: var(--color-text-muted);
}
.seal.is-new { animation: stamp-in var(--duration-stamp) cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes stamp-in {
  0% { opacity: 0; transform: scale(1.9) rotate(-14deg); }
  70% { opacity: 1; transform: scale(0.94) rotate(-7deg); }
  100% { opacity: 1; transform: scale(1) rotate(-8deg); }
}
@media (prefers-reduced-motion: reduce) {
  .seal.is-new { animation: none; }
  html { scroll-behavior: auto !important; }
}

/* 결재란: 칸마다 역할, 도장 자리, 날짜 */
.sign {
  display: flex;
  flex: none;
  align-self: start;
  border: var(--border-mid) solid var(--color-line-strong);
}
.sign__label {
  display: grid;
  place-items: center;
  width: var(--space-6);
  padding: var(--space-2) 0;
  border-right: var(--border-thin) solid var(--color-line-strong);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  writing-mode: vertical-rl;
  letter-spacing: var(--tracking-wide);
}
.sign__cell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 5.5rem;
  text-align: center;
}
.sign__cell + .sign__cell { border-left: var(--border-thin) solid var(--color-line-strong); }
.sign__role {
  padding: var(--space-1) 0;
  border-bottom: var(--border-thin) solid var(--color-line-strong);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.sign__mark { display: grid; place-items: center; min-height: 4.75rem; padding: var(--space-2) 0; }
.sign__date {
  padding: var(--space-1) 0;
  border-top: var(--border-thin) solid var(--color-line);
  color: var(--color-text-muted);
  font-family: var(--font-num);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}
.sign__cell[data-turn] .sign__role { background: var(--color-mark); }

/* 서식 표: 항목 칸과 값 */
.form-table { width: 100%; border-collapse: collapse; border-top: var(--border-thick) solid var(--color-line-strong); border-bottom: var(--border-thin) solid var(--color-line-strong); }
.form-table th, .form-table td { padding: var(--space-3) var(--space-4); border-bottom: var(--border-thin) solid var(--color-line); text-align: left; vertical-align: top; font-size: var(--text-sm); line-height: var(--leading-snug); }
.form-table th { width: var(--size-label); background: var(--color-surface-2); font-weight: var(--weight-bold); white-space: nowrap; }
.form-table td strong { font-weight: var(--weight-bold); }

.paper-letter {
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border-left: var(--border-thick) solid var(--color-line-strong);
  background: var(--color-bg);
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
}
.paper-letter p + p { margin-top: var(--space-2); }

.overdue {
  color: var(--color-danger);
  font-weight: var(--weight-bold);
}

/* ================================================================
   사무국: 서류함과 문서의 2단
   ================================================================ */

.office {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: calc(100vh - 36px);
  min-height: 34rem;
}

/* 격자의 칸이 내용 폭에 밀려 넓어지지 않게 한다. */
.office > *, .o-main > *, .desk > * { min-width: 0; }

/* 맨 위 한 줄 */
.o-top {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 2.75rem;
  padding: 0 var(--space-5);
  background: var(--color-bg);
}
.o-top__brand { font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--weight-display); white-space: nowrap; }
.o-top__society { padding-left: var(--space-4); border-left: var(--border-thin) solid var(--color-line); font-size: var(--text-sm); font-weight: var(--weight-bold); white-space: nowrap; }
.o-top__society span { color: var(--color-text-muted); font-weight: var(--weight-regular); }
.o-top__side { display: flex; align-items: center; gap: var(--space-4); margin-left: auto; font-size: var(--text-sm); }
.o-top__side a { display: inline-flex; align-items: center; gap: var(--space-1); text-underline-offset: 3px; }
.role { display: flex; align-items: center; gap: var(--space-2); }
.role label { color: var(--color-text-muted); }
.role select {
  min-height: var(--size-control-sm);
  padding: 0 var(--space-2);
  border: var(--border-thin) solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-weight: var(--weight-bold);
}

/* 견출지 탭과 메뉴 줄 */
.o-nav { position: relative; padding: 0 var(--space-5); background: var(--color-bg); }
.tabs { display: flex; align-items: flex-end; gap: var(--space-1); }
.tab {
  position: relative;
  bottom: calc(var(--border-thin) * -1);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.125rem;
  padding: 0 var(--space-5);
  border: var(--border-thin) solid var(--color-line-strong);
  border-bottom-color: var(--color-line-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  cursor: pointer;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 100%, 0 100%);
  padding-inline: calc(var(--space-5) + 4px);
}
.tab:hover { color: var(--color-text); }
.tab[aria-selected="true"] {
  z-index: 1;
  min-height: 2.375rem;
  border-bottom-color: var(--color-surface);
  background: var(--color-surface);
  color: var(--color-text);
}
.tab:focus-visible { outline-offset: calc(var(--border-thick) * -2); }
.tab__count {
  min-width: 1.25rem;
  padding: 0 var(--space-1);
  border-radius: var(--radius-full);
  background: var(--color-action);
  color: var(--color-on-action);
  font-family: var(--font-num);
  font-size: var(--text-2xs);
  line-height: 1.25rem;
  text-align: center;
}
.menu-strip {
  border: var(--border-thin) solid var(--color-line-strong);
  border-bottom-width: var(--border-thick);
  background: var(--color-surface);
}
.menu { display: flex; align-items: center; gap: var(--space-1); min-height: 2.5rem; padding: var(--space-1) var(--space-3); overflow-x: auto; }
.menu[hidden] { display: none; }
.menu a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--size-control-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--radius-sm);
}
.menu a:hover { background: var(--color-surface-2); }
.menu a[aria-current="page"] {
  font-weight: var(--weight-bold);
  box-shadow: inset 0 calc(var(--border-thick) * -1) 0 var(--color-line-strong);
  border-radius: 0;
}
.menu small { color: var(--color-text-muted); font-size: var(--text-2xs); }
.menu__sep { width: var(--border-thin); height: var(--space-4); margin: 0 var(--space-2); background: var(--color-line); }

/* 본문 2단 */
.o-main {
  display: grid;
  grid-template-columns: var(--size-tray) minmax(0, 1fr);
  min-height: 0;
  margin: 0 var(--space-5) var(--space-5);
  border: var(--border-thin) solid var(--color-line-strong);
  border-top: 0;
  background: var(--color-surface);
}

/* 서류함 */
.tray { display: flex; flex-direction: column; min-height: 0; border-right: var(--border-thin) solid var(--color-line-strong); }
.tray__head { padding: var(--space-4) var(--space-5) var(--space-3); border-bottom: var(--border-thick) solid var(--color-line-strong); }
.tray__title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.tray__title h1 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-display); line-height: var(--leading-tight); }
.tray__date { color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap; }
.tray__sum { margin-top: var(--space-1); font-size: var(--text-sm); }
.tray__sum b { font-family: var(--font-num); font-weight: var(--weight-bold); }
.tray__list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.doc-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-5);
  border: 0;
  border-bottom: var(--border-thin) solid var(--color-line);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.doc-row:hover { background: var(--color-bg); }
.doc-row[aria-current="true"] { background: var(--color-mark); }
.doc-row[aria-current="true"] { box-shadow: inset 0 var(--border-thin) 0 var(--color-line-strong), inset 0 calc(var(--border-thin) * -1) 0 var(--color-line-strong); }
.doc-row:focus-visible { outline-offset: calc(var(--border-thick) * -2); }
.doc-row__type { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.doc-row__title { grid-column: 1; font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: var(--leading-snug); }
.doc-row__meta { grid-column: 1; color: var(--color-text-muted); font-size: var(--text-xs); line-height: var(--leading-snug); }
.doc-row__due { grid-column: 2; grid-row: 1 / span 3; align-self: center; font-size: var(--text-xs); text-align: right; white-space: nowrap; }
.doc-row__due .overdue { display: block; }
.doc-row__done { display: none; }
.doc-row[data-state="done"] .doc-row__title { color: var(--color-text-muted); font-weight: var(--weight-regular); }
.doc-row[data-state="done"] .doc-row__due > :not(.doc-row__done) { display: none; }
.doc-row[data-state="done"] .doc-row__done { display: inline-grid; }
.doc-row__done.seal { width: auto; height: auto; padding: var(--border-thick) var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-xs); transform: rotate(-5deg); }

/* 주요 수치: 서식의 칸 */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: var(--border-thick) solid var(--color-line-strong); }
.figure { padding: var(--space-2) var(--space-3); text-align: left; }
.figure + .figure { border-left: var(--border-thin) solid var(--color-line); }
.figure dt { color: var(--color-text-muted); font-size: var(--text-2xs); line-height: var(--leading-snug); }
.figure dd { font-family: var(--font-num); font-size: var(--text-md); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; line-height: var(--leading-tight); }
.figure dd small { color: var(--color-text-muted); font-size: var(--text-2xs); font-weight: var(--weight-regular); }

/* 문서 단: 책상 위의 종이 한 장 */
.desk { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; background: var(--color-desk); }
.desk__back { display: none; }
.desk__scroll { min-height: 0; overflow-y: auto; padding: var(--space-5) var(--space-6) var(--space-6); }
.paper {
  max-width: var(--size-paper);
  margin: 0 auto;
  padding: var(--space-6) var(--space-7) var(--space-7);
  border: var(--border-thin) solid var(--color-line);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}
.paper[hidden] { display: none; }
.paper__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5); padding-bottom: var(--space-4); border-bottom: var(--border-thin) solid var(--color-line-strong); box-shadow: 0 var(--border-thick) 0 var(--color-surface), 0 calc(var(--border-thick) + var(--border-thin)) 0 var(--color-line-strong); }
.paper__kind { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: var(--tracking-wide); }
.paper__title { margin-top: var(--space-1); font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-display); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.paper__meta { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-4); margin-top: var(--space-4); font-size: var(--text-sm); }
.paper__meta dt { color: var(--color-text-muted); }
.paper__meta dd { font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 문서 영역이 좁으면 제목과 문서 정보를 문서 폭 전체에 두고 결재란을 그 아래 오른쪽으로 내린다. */
.paper { container-type: inline-size; }
@container (max-width: 38rem) {
  .paper__head { flex-direction: column; }
  .paper__head .sign { align-self: flex-end; }
}
.paper__body { margin-top: var(--space-5); }
.paper__foot { margin-top: var(--space-5); color: var(--color-text-muted); font-size: var(--text-xs); text-align: right; }

/* 처리 줄: 문서 단 아래에 붙는다 */
.actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 4rem;
  padding: var(--space-3) var(--space-6);
  border-top: var(--border-thick) solid var(--color-line-strong);
  background: var(--color-surface);
}
.actions[hidden] { display: none; }
.actions__note { margin-right: auto; color: var(--color-text-muted); font-size: var(--text-sm); }
.actions__note b { color: var(--color-text); }

/* ================================================================
   포털: 한 편의 안내 문서
   ================================================================ */

html:has(.portal) { scroll-behavior: smooth; scroll-padding-top: var(--space-5); }

.p-head { border-bottom: var(--border-thick) solid var(--color-line-strong); background: var(--color-bg); }
.p-head__inner { display: flex; align-items: center; gap: var(--space-6); max-width: 84rem; min-height: 4.25rem; margin: 0 auto; padding: 0 var(--space-gutter); }
.brand { display: flex; align-items: baseline; gap: var(--space-3); text-decoration: none; white-space: nowrap; }
.brand b { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-display); }
.brand span { color: var(--color-text-muted); font-size: var(--text-sm); }
.p-menu { display: flex; gap: var(--space-1); margin-left: auto; }
.p-menu a { display: inline-flex; align-items: center; min-height: var(--size-control); padding: 0 var(--space-3); font-size: var(--text-sm); text-decoration: none; }
.p-menu a:hover { text-decoration: underline; text-underline-offset: 4px; }

.p-body {
  display: grid;
  grid-template-columns: var(--size-toc) minmax(0, 1fr);
  gap: var(--space-7);
  max-width: 84rem;
  margin: 0 auto;
  padding: 0 var(--space-gutter) var(--space-9);
}

/* 차례 */
.toc { position: sticky; top: 0; align-self: start; padding-top: var(--space-6); }
.toc__title { padding-bottom: var(--space-2); border-bottom: var(--border-thick) solid var(--color-line-strong); font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--weight-display); }
.toc ol { counter-reset: none; }
.toc a {
  display: grid;
  grid-template-columns: 3rem 1fr;
  align-items: baseline;
  padding: var(--space-2) 0;
  border-bottom: var(--border-thin) dotted var(--color-line);
  font-size: var(--text-sm);
  text-decoration: none;
}
.toc a span { color: var(--color-text-muted); font-family: var(--font-display); font-size: var(--text-xs); }
.toc a:hover { text-decoration: underline; text-underline-offset: 3px; }
.toc a[aria-current="true"] { font-weight: var(--weight-bold); border-bottom: var(--border-thin) solid var(--color-line-strong); }
.toc a[aria-current="true"] span { color: var(--color-text); }
.toc-m { display: none; }

/* 장 */
.chapter { padding-top: var(--space-6); }
.chapter + .chapter { margin-top: var(--space-8); }
.chapter__no { color: var(--color-text-muted); font-family: var(--font-display); font-size: var(--text-sm); font-weight: var(--weight-bold); }
.chapter__title { margin-top: var(--space-1); padding-bottom: var(--space-3); border-bottom: var(--border-thin) solid var(--color-line-strong); font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-display); line-height: var(--leading-tight); }
.chapter__lead { margin-top: var(--space-3); color: var(--color-text-muted); font-size: var(--text-sm); }
.chapter__sub { margin-top: var(--space-6); font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--weight-display); }

/* 제1장: 표지와 견본 문서 */
.cover { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 31rem); gap: var(--space-7); align-items: center; min-height: calc(100vh - 36px - 4.25rem - var(--space-6)); padding-bottom: var(--space-6); }
.cover__text { max-width: 34rem; }
.cover__title { margin-top: var(--space-3); font-family: var(--font-display); font-size: clamp(2rem, 0.75rem + 2.2vw, 2.75rem); font-weight: var(--weight-display); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.cover__desc { max-width: var(--size-measure); margin-top: var(--space-5); color: var(--color-text-muted); font-size: var(--text-md); line-height: var(--leading-normal); }
.cover__cta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }
.cover__fine { margin-top: var(--space-4); color: var(--color-text-muted); font-size: var(--text-xs); }

.sample { position: relative; padding: var(--space-5) var(--space-5) var(--space-6); border: var(--border-thin) solid var(--color-line); background: var(--color-surface); box-shadow: var(--shadow-lg); transform: rotate(0.6deg); }
.sample::after { content: ""; position: absolute; inset: var(--space-2) calc(var(--space-2) * -1) calc(var(--space-2) * -1) var(--space-2); z-index: -1; border: var(--border-thin) solid var(--color-line); background: var(--color-surface-2); transform: rotate(-1.6deg); }
.sample .paper__title { font-size: var(--text-xl); }
.sample .paper__head { gap: var(--space-3); }
.sample .sign__cell { width: 4.75rem; }
.sample .sign__mark { min-height: 4rem; }
.sample .form-table th { width: 5.5rem; }
.sample .form-table th, .sample .form-table td { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.sample__flag { position: absolute; top: calc(var(--space-3) * -1); left: var(--space-5); padding: var(--border-thick) var(--space-2); border: var(--border-mid) solid var(--color-text-muted); background: var(--color-surface); color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-bold); transform: rotate(-3deg); }

/* 제2장: 신청서의 선택란 */
.choice-table { width: 100%; margin-top: var(--space-5); border-collapse: collapse; border-top: var(--border-thick) solid var(--color-line-strong); border-bottom: var(--border-thick) solid var(--color-line-strong); font-size: var(--text-sm); }
.choice-table th, .choice-table td { padding: var(--space-4); border-bottom: var(--border-thin) solid var(--color-line); text-align: left; vertical-align: top; line-height: var(--leading-snug); }
.choice-table thead th { padding-block: var(--space-2); background: var(--color-surface-2); font-size: var(--text-xs); }
.choice-table tbody th { width: 9rem; font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--weight-display); }
.choice-table tbody th small { display: block; margin-top: var(--space-1); color: var(--color-text-muted); font-family: var(--font-body); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.choice-table .menus { color: var(--color-text-muted); }
.choice-table td:last-child { width: 15rem; }
.opts { display: grid; gap: var(--space-1); border: 0; margin: 0; padding: 0; }
.opt { display: flex; align-items: center; gap: var(--space-2); min-height: var(--size-control-sm); cursor: pointer; }
.opt input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--color-action); }
.opt--fixed { color: var(--color-text-muted); cursor: default; }
.opt--fixed b { color: var(--color-text); }

/* 제3장: 결재 흐름과 진위확인 */
.flow { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-6); margin-top: var(--space-5); }
.flow__lines { flex: 1 1 18rem; font-size: var(--text-sm); }
.flow__lines li { display: grid; grid-template-columns: 7.5rem 1fr; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: var(--border-thin) solid var(--color-line); }
.flow__lines li b { font-weight: var(--weight-bold); }
.flow__lines li span { color: var(--color-text-muted); }

.verify { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-5); align-items: center; margin-top: var(--space-4); padding: var(--space-5); border: var(--border-thin) solid var(--color-line-strong); background: var(--color-surface); }
.verify__fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.field { display: grid; gap: var(--space-1); font-size: var(--text-sm); }
.field label { font-weight: var(--weight-bold); }
.field input {
  min-height: var(--size-control);
  padding: 0 var(--space-3);
  border: var(--border-thin) solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-family: var(--font-num);
}
.field input::placeholder { color: var(--color-text-muted); }
.field--wide input { width: 13rem; }
.field--short input { width: 7rem; }
.verify__result { display: flex; align-items: center; gap: var(--space-4); min-width: 16rem; min-height: var(--size-seal); font-size: var(--text-sm); }
.verify__result p { max-width: 15rem; }
.verify__help { grid-column: 1 / -1; color: var(--color-text-muted); font-size: var(--text-xs); }

/* 제4장: 명부 */
.roster-wrap { margin-top: var(--space-5); overflow-x: auto; }
.roster { width: 100%; border-collapse: collapse; border-top: var(--border-thick) solid var(--color-line-strong); font-size: var(--text-sm); }
.roster th, .roster td { padding: var(--space-2) var(--space-3); border-bottom: var(--border-thin) solid var(--color-line); text-align: left; white-space: nowrap; }
.roster thead th { background: var(--color-surface-2); font-size: var(--text-xs); }
.roster .r { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.roster td.off { color: var(--color-text-muted); }
.roster tfoot td, .roster tfoot th { border-top: var(--border-thick) double var(--color-line-strong); border-bottom: var(--border-thick) solid var(--color-line-strong); font-weight: var(--weight-bold); }
.notes { display: grid; gap: var(--space-2); margin-top: var(--space-3); font-size: var(--text-sm); }
.notes li { display: grid; grid-template-columns: 5rem 1fr; gap: var(--space-3); padding-bottom: var(--space-2); border-bottom: var(--border-thin) solid var(--color-line); }
.notes time { font-family: var(--font-num); font-weight: var(--weight-bold); }
.notes span { color: var(--color-text-muted); }

/* 제5장: 신청서 */
.apply { position: relative; max-width: var(--size-paper); margin-top: var(--space-5); padding: var(--space-6) var(--space-7); border: var(--border-thin) solid var(--color-line); background: var(--color-surface); box-shadow: var(--shadow-md); }
.apply__steps { display: flex; gap: var(--space-5); padding-bottom: var(--space-3); border-bottom: var(--border-thin) solid var(--color-line); color: var(--color-text-muted); font-size: var(--text-xs); }
.apply__steps b { color: var(--color-text); }
.apply__title { margin-top: var(--space-4); font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-display); text-align: center; letter-spacing: var(--tracking-wide); }
.apply .form-table { margin-top: var(--space-5); }
.apply .form-table input {
  width: 100%;
  min-height: var(--size-control);
  padding: 0 var(--space-3);
  border: var(--border-thin) solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
}
.apply .form-table th { vertical-align: middle; }
.apply__error { margin-top: var(--space-2); color: var(--color-danger); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.apply__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); margin-top: var(--space-6); }
.apply__date { font-size: var(--text-sm); }
.apply__receipt { display: flex; align-items: center; gap: var(--space-4); }
.apply__receipt[hidden] { display: none; }

/* ================================================================
   좁은 화면
   ================================================================ */

@media (max-width: 1100px) {
  .cover { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .sample { max-width: 31rem; }
  .p-body { grid-template-columns: 11rem minmax(0, 1fr); gap: var(--space-6); }
}

@media (max-width: 720px) {
  .btn { min-height: var(--size-tap); }

  /* 사무국: 서류함 먼저, 문서는 화면 전체로 */
  .office { height: auto; min-height: calc(100vh - 36px); grid-template-rows: auto auto 1fr; }
  .o-top { flex-wrap: wrap; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-4); }
  .o-top__society { padding-left: var(--space-3); }
  .o-top__side { width: 100%; justify-content: space-between; margin-left: 0; }
  .o-top__side a, .role select { min-height: var(--size-tap); }
  .o-nav { padding: 0 var(--space-3); }
  .tabs { overflow-x: auto; padding-top: var(--space-1); }
  .tab { min-height: var(--size-tap); padding-inline: var(--space-4); }
  .tab[aria-selected="true"] { min-height: var(--size-tap); }
  .menu a { min-height: var(--size-tap); }
  .o-main { grid-template-columns: minmax(0, 1fr); margin: 0 var(--space-3) var(--space-4); }
  .tray { border-right: 0; }
  .tray__list { overflow: visible; }
  .doc-row { min-height: var(--size-tap); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: var(--border-thin) solid var(--color-line); }

  .desk { display: none; }
  .office[data-view="doc"] .desk {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .desk__back {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--size-tap);
    padding: 0 var(--space-4);
    border: 0;
    border-bottom: var(--border-thin) solid var(--color-line-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    cursor: pointer;
  }
  .desk__scroll { padding: var(--space-3); }
  .paper { padding: var(--space-5) var(--space-4); }
  .paper__head { flex-direction: column; }
  .paper__title { font-size: var(--text-xl); }
  .sign { align-self: flex-end; }
  .sign__cell { width: 4.75rem; }
  .form-table th { width: 5.5rem; white-space: normal; }
  .actions { padding: var(--space-3) var(--space-4); }
  .actions__note { font-size: var(--text-xs); }

  /* 포털: 접히는 차례, 한 단 */
  .p-head__inner { flex-wrap: wrap; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-4); }
  .brand span { display: none; }
  .p-head .btn { margin-left: auto; }
  .p-menu { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .p-menu a { min-height: var(--size-tap); padding: 0 var(--space-2); }
  .p-body { display: block; padding: 0 var(--space-4) var(--space-8); }
  .toc { display: none; }
  .toc-m { position: sticky; top: 0; z-index: 5; display: block; margin: 0 calc(var(--space-4) * -1); border-bottom: var(--border-thin) solid var(--color-line-strong); background: var(--color-bg); }
  .toc-m summary { display: flex; align-items: center; justify-content: space-between; min-height: var(--size-tap); padding: 0 var(--space-4); font-size: var(--text-sm); font-weight: var(--weight-bold); cursor: pointer; }
  .toc-m ol { padding: 0 var(--space-4) var(--space-2); }
  .toc-m a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--size-tap); border-top: var(--border-thin) dotted var(--color-line); font-size: var(--text-sm); text-decoration: none; }
  .toc-m a[aria-current="true"] { font-weight: var(--weight-bold); }
  .cover { gap: var(--space-6); }
  .cover__title { font-size: var(--text-2xl); }
  .cover__desc { font-size: var(--text-base); }
  .sample { padding: var(--space-4); transform: none; }
  .sample .paper__head { flex-direction: column; }
  .choice-table thead { display: none; }
  .choice-table, .choice-table tbody, .choice-table tr, .choice-table th, .choice-table td { display: block; width: auto; }
  .choice-table tbody tr { padding: var(--space-3) 0; border-bottom: var(--border-thin) solid var(--color-line); }
  .choice-table th, .choice-table td { padding: var(--space-1) 0; border: 0; }
  .choice-table td:last-child { width: auto; padding-top: var(--space-2); }
  .opt { min-height: var(--size-tap); }
  .verify { grid-template-columns: minmax(0, 1fr); padding: var(--space-4); }
  .field--wide input, .field--short input { width: 100%; }
  .field { flex: 1 1 100%; }
  .verify__result { min-width: 0; }
  .flow .sign { align-self: flex-start; }
  .apply { padding: var(--space-5) var(--space-4); }
  .apply__foot { flex-direction: column; align-items: stretch; }
  .notes li { grid-template-columns: 4rem 1fr; }
}

.keep { display: inline-block; }
