/* =========================================================
   청소년미래전략연구소 그룹웨어 — 스타일
   메인 사이트(../styles.css)의 디자인 토큰·버튼·포커스 규칙을 따른다.
   ========================================================= */

/* ---------- 1. Design tokens (메인 사이트와 동일) ---------- */
:root {
  --navy: #182B4A;
  --teal: #35A0A6;
  --teal-light: #5FC8CE;
  --teal-text: #1F7277;
  --ink: #101A2B;
  --paper: #FBFBFA;
  --paper-2: #F1F1EE;

  --text-body: #2C3A52;
  --text-muted: #5D677D;
  --border: rgba(24, 43, 74, .10);
  --border-strong: rgba(24, 43, 74, .18);

  /* 상태색: 모두 흰 바탕 4.5:1 이상 */
  --danger: #B42318;
  --danger-bg: #FDF1EF;
  --warn: #8A4B08;
  --warn-bg: #FCF4E4;
  --ok: #1F7277;
  --ok-bg: #E8F4F4;

  --font-ko: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --font-serif: "Noto Serif KR", "AppleMyungjo", "Batang", serif;
  --tracking-mark: -0.045em;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  --header-h: 64px;
  --sidebar-w: 232px;
  --gutter: 32px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
@media (max-width: 640px) { :root { --gutter: 16px; --header-h: 56px; } }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }   /* 스크롤바가 생겨도 화면이 옆으로 밀리지 않게 */
body {
  margin: 0;
  background: var(--paper);
  color: var(--text-body);
  font-family: var(--font-ko);
  font-size: 15px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--teal-text); outline-offset: 3px; }
::selection { background: var(--teal-light); color: var(--ink); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--s-4); top: -100px; z-index: 100;
  padding: var(--s-3) var(--s-4);
  background: var(--navy); color: var(--paper);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--s-3); }
#main:focus { outline: none; }

/* ---------- 3. Buttons (메인 사이트: 각진 버튼) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  border: 1.5px solid transparent;
  border-radius: 0;
  background: transparent;
  font-family: var(--font-ko);
  font-size: 15px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em;
  color: var(--navy);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--sm { min-height: 40px; padding: 0 var(--s-4); font-size: 14px; }
.btn--primary { background: var(--navy); color: var(--paper); }
.btn--primary:hover { background: var(--ink); }
.btn--ghost { border-color: var(--border-strong); background: #fff; }
.btn--ghost:hover { border-color: var(--navy); }
.btn--text { padding-inline: var(--s-2); }
.btn--text:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn--danger { color: var(--danger); }
.btn--ghost.btn--danger:hover { border-color: var(--danger); background: var(--danger-bg); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.icon-btn {
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 0; background: #fff;
  font: 600 14px/1 var(--font-ko); color: var(--navy); cursor: pointer;
}
.icon-btn:hover { border-color: var(--navy); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.file-btn:focus-within { outline: 3px solid var(--teal-text); outline-offset: 2px; }

/* ---------- 4. Header (메인 사이트 헤더와 같은 반투명 종이 바탕) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-4);
  padding-inline: var(--gutter);
  background: rgba(251, 251, 250, .88);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s-3);
  min-height: 44px; min-width: 0;
  color: var(--navy); text-decoration: none;
}
.brand-mark { width: 30px; height: 30px; flex: none; --mark-accent: var(--teal); --mark-body: var(--navy); }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: var(--tracking-mark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub {
  padding-left: var(--s-3); border-left: 1px solid var(--border-strong);
  font-size: 14px; font-weight: 500; color: var(--text-muted); white-space: nowrap;
}
.proto-badge {
  padding: 2px 8px;
  border: 1px solid var(--teal-text);
  color: var(--teal-text);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.user-switch { margin-left: auto; display: inline-flex; align-items: center; gap: var(--s-2); font-size: 14px; color: var(--text-muted); }
.user-switch select { min-height: 40px; max-width: 200px; }
@media (max-width: 640px) {
  .brand-name, .user-switch > span { display: none; }
  .proto-badge { font-size: 11px; }
  .user-switch select { max-width: 150px; }
}

/* 서버 방식: 사용자 상자, 저장 상태 */
.user-box { display: none; margin-left: auto; align-items: center; gap: var(--s-3); font-size: 14px; }
.is-remote .user-box { display: flex; }
.is-remote .user-switch, .is-remote .proto-badge { display: none; }
.user-name { font-weight: 600; color: var(--navy); white-space: nowrap; }
.sync { display: none; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.is-remote .sync { display: inline; }
.sync[data-state="error"] { color: var(--danger); font-weight: 600; }
.user-email { font-size: 12.5px; color: var(--text-muted); overflow-wrap: anywhere; }
@media (max-width: 640px) { .user-name { display: none; } }

/* 로그인, 가입 */
.is-auth .topbar, .is-auth .layout { display: none; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s-8) var(--gutter); background: var(--paper-2); }
.auth-card { width: min(420px, 100%); padding: var(--s-8); background: #fff; border: 1px solid var(--border); border-top: 4px solid var(--navy); }
.auth-brand { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-6); color: var(--navy); }
.auth-brand .brand-mark { width: 34px; height: 34px; }
.auth-brand b { display: block; font-size: 16px; letter-spacing: var(--tracking-mark); }
.auth-brand small { font-size: 13px; color: var(--text-muted); }
.auth-title { margin-bottom: var(--s-5); font-size: 22px; font-weight: 700; letter-spacing: -0.03em; color: var(--navy); }
.auth-lead { margin-bottom: var(--s-4); font-size: 14px; color: var(--text-body); }
.auth-msg { margin-bottom: var(--s-4); padding: var(--s-3) var(--s-4); background: var(--ok-bg); border-left: 3px solid var(--teal); font-size: 14px; }
.auth-msg--error { background: var(--danger-bg); border-left-color: var(--danger); color: var(--danger); }
.auth-submit { width: 100%; margin-top: var(--s-2); }
.auth-links { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-5); font-size: 14px; }
.auth-links a { color: var(--teal-text); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; text-underline-offset: 3px; }


/* ---------- 5. Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); background: linear-gradient(to right, var(--paper-2) calc(var(--sidebar-w) - 1px), var(--border) 0, var(--border) var(--sidebar-w), transparent 0); }
.sidebar {
  position: sticky; top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  padding: var(--s-6) var(--s-4);
  background: var(--paper-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.nav-new { width: 100%; margin-bottom: var(--s-5); }
.nav-list a {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-3) 0 var(--s-4);
  font-size: 15px; font-weight: 500; color: var(--text-body);
  text-decoration: none;
}
.nav-list a::before {   /* 메인 사이트 내비의 청록 강조선을 세로로 */
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  background: var(--teal); transform: scaleY(0); transition: transform .2s var(--ease);
}
.nav-list a:hover { color: var(--navy); background: rgba(24, 43, 74, .04); }
.nav-list a[aria-current="page"] { color: var(--navy); font-weight: 700; background: #fff; }
.nav-list a[aria-current="page"]::before, .nav-list a:hover::before { transform: scaleY(1); }
.nav-list li:nth-child(6) { margin-bottom: var(--s-3); padding-bottom: var(--s-3); border-bottom: 1px solid var(--border); }
.nav-count {
  min-width: 24px; padding: 1px 7px;
  background: var(--navy); color: var(--paper);
  font-size: 12px; font-weight: 700; text-align: center;
}
main { padding: var(--s-8) var(--gutter) var(--s-16); min-width: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; background: none; }
  .sidebar {
    position: sticky; top: var(--header-h); z-index: 40;
    height: auto; padding: var(--s-2) var(--gutter);
    display: flex; align-items: center; gap: var(--s-2);
    border-right: 0; border-bottom: 1px solid var(--border);
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .nav-new { width: auto; margin: 0; flex: none; min-height: 40px; }
  .nav-list { display: flex; gap: var(--s-1); }
  .nav-list li:nth-child(6) { margin: 0; padding: 0; border: 0; }
  .nav-list a { min-height: 40px; padding: 0 var(--s-3); white-space: nowrap; }
  .nav-list a::before { left: var(--s-3); right: var(--s-3); top: auto; bottom: 4px; width: auto; height: 2px; transform: scaleX(0); }
  .nav-list a[aria-current="page"]::before, .nav-list a:hover::before { transform: scaleX(1); }
  .nav-list a[aria-current="page"] { background: transparent; }
  main { padding-top: var(--s-6); }
}

/* ---------- 6. Page heading ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-6); min-height: 45px; margin-bottom: var(--s-6); }   /* 오른쪽 버튼이 있든 없든 제목 위치를 같게 */
.page-head--doc { align-items: flex-end; }
.page-title {
  font-size: clamp(22px, 2.4vw, 30px); line-height: 1.3; font-weight: 700;
  letter-spacing: -0.04em; color: var(--navy); text-wrap: balance;
}
.eyebrow { margin-bottom: var(--s-1); font-size: 13px; font-weight: 600; color: var(--teal-text); letter-spacing: .01em; }
.page-lead { margin: calc(var(--s-6) * -1 + var(--s-2)) 0 var(--s-6); color: var(--text-muted); }
.empty {
  padding: var(--s-12) var(--s-6);
  border: 1px dashed var(--border-strong);
  text-align: center; color: var(--text-muted);
}
.empty + p { margin-top: var(--s-4); }

/* ---------- 7. Forms ---------- */
input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  background: #fff;
  font: 400 15px/1.5 var(--font-ko);
  color: var(--ink);
  transition: border-color .15s var(--ease);
}
select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; min-height: 88px; }
#f-body { font-size: 15px; line-height: 1.75; }
input:hover, select:hover, textarea:hover { border-color: rgba(24, 43, 74, .4); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal-text); outline-offset: 0; border-color: var(--teal-text); }
.is-invalid { border-color: var(--danger) !important; background: var(--danger-bg) !important; }
::placeholder { color: #8890A0; }

.field { margin: 0 0 var(--s-5); padding: 0; border: 0; min-width: 0; }
.label { display: block; margin-bottom: var(--s-2); padding: 0; font-size: 14px; font-weight: 600; color: var(--navy); }
.req { margin-left: 4px; font-style: normal; font-size: 12px; font-weight: 600; color: var(--danger); }
.opt { margin-left: 4px; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.hint { margin-top: var(--s-2); font-size: 13px; color: var(--text-muted); line-height: 1.55; }

/* 분할 선택 (문서 구분, 발송 방법) */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.seg--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span {
  display: flex; flex-direction: column; gap: 2px;
  height: 100%; padding: var(--s-3) var(--s-4);
  border: 1.5px solid var(--border-strong); background: #fff;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.seg b { font-size: 15px; color: var(--navy); }
.seg small { font-size: 12.5px; color: var(--text-muted); }
.seg label:hover span { border-color: rgba(24, 43, 74, .45); }
.seg input:checked + span { border-color: var(--navy); background: var(--ok-bg); box-shadow: inset 3px 0 0 var(--teal); }
.seg input:focus-visible + span { outline: 3px solid var(--teal-text); outline-offset: 2px; }

.attach-list li, .file-list li {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.attach-list:not(:empty) { margin-bottom: var(--s-3); border-top: 1px solid var(--border); }
.attach-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.attach-size { font-size: 12.5px; color: var(--text-muted); }
.file-list a { color: var(--teal-text); font-weight: 500; overflow-wrap: anywhere; }

.guide { margin-top: var(--s-2); padding: var(--s-3) var(--s-4); background: var(--paper-2); border-left: 3px solid var(--teal); font-size: 13px; line-height: 1.6; color: var(--text-body); }
.guide p + p { margin-top: var(--s-2); }
.guide b { color: var(--navy); }
.guide-ex { padding: var(--s-2) var(--s-3); background: #fff; border: 1px solid var(--border); }
.guide-ex span { display: inline-block; width: 3em; font-weight: 600; color: var(--text-muted); }
.guide .btn { margin: var(--s-2) 0 0 calc(var(--s-2) * -1); min-height: 32px; color: var(--teal-text); }
.check { display: flex; gap: var(--s-3); align-items: flex-start; margin-top: var(--s-3); cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--navy); flex: none; }
.check span { display: grid; gap: 2px; }
.check b, .check span { color: var(--navy); font-weight: 600; }
.check small { font-weight: 400; font-size: 13px; color: var(--text-muted); }

/* 결재선 */
.line-builder { counter-reset: step; border: 1px solid var(--border); background: #fff; }
.line-step {
  counter-increment: step;
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 48px; padding: var(--s-2) var(--s-3);
  font-size: 14px;
}
.line-step + .line-step { border-top: 1px solid var(--border); }
.line-step::before { content: counter(step); width: 22px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-align: center; }
.line-role { padding: 1px 8px; background: var(--paper-2); font-size: 12px; font-weight: 600; color: var(--navy); }
.line-step--fixed .line-role { background: var(--navy); color: var(--paper); }
.line-tools { margin-left: auto; display: flex; gap: var(--s-1); }
.line-add { display: flex; gap: var(--s-2); margin-top: var(--s-2); }
.line-add select { flex: 1; min-width: 0; }
.line-approver { margin-top: var(--s-4); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.form-actions .btn--danger { margin-left: auto; }

/* ---------- 8. Document list ---------- */
.doc-list { border-top: 2px solid var(--navy); }
.doc-row {
  display: grid;
  grid-template-columns: 11em minmax(0, 1fr) auto;
  grid-template-areas: "no title badge" "no meta badge";
  column-gap: var(--s-5);
  align-items: center;
  padding: var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background-color .15s var(--ease);
}
.doc-row:hover { background: #fff; }
.doc-row:hover .doc-row-title { text-decoration: underline; text-decoration-color: var(--teal); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.doc-row-no { grid-area: no; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-muted); overflow-wrap: anywhere; }
.doc-row-title { grid-area: title; font-size: 16px; font-weight: 600; color: var(--navy); }
.doc-row-meta { grid-area: meta; font-size: 13px; color: var(--text-muted); }
.doc-row-badge { grid-area: badge; }
@media (max-width: 640px) {
  .doc-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title badge" "meta meta" "no no"; row-gap: 2px; padding-inline: 0; }
  .doc-row-no:empty, .doc-row-no:only-child { display: none; }
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border-strong);
  background: var(--paper-2);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; color: var(--text-body);
}
.badge--progress { border-color: rgba(24, 43, 74, .3); background: #fff; color: var(--navy); }
.badge--done { border-color: rgba(31, 114, 119, .35); background: var(--ok-bg); color: var(--ok); }
.badge--warn { border-color: rgba(138, 75, 8, .35); background: var(--warn-bg); color: var(--warn); }
.badge--danger { border-color: rgba(180, 35, 24, .35); background: var(--danger-bg); color: var(--danger); }

.search { flex: 1 1 280px; max-width: 420px; }
.head-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-3); flex: 1 1 420px; }
.head-tools .search { flex: 1 1 240px; }
.head-tools select { width: auto; min-width: 8.5em; }

/* 접수 정보, 회신 */
.meta-list > div { display: grid; grid-template-columns: 5.5em minmax(0, 1fr); gap: var(--s-2); padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.meta-list > div:last-child { border-bottom: 0; }
.meta-list--box { padding: var(--s-1) var(--s-4); background: #fff; border: 1px solid var(--border); }
.hint--warn { color: var(--warn); }
.hint a { color: var(--teal-text); }
.meta-list dt { color: var(--text-muted); }
.meta-list dd { overflow-wrap: anywhere; }
.meta-list a, .reply-state a { color: var(--teal-text); }
.rec-file { width: 100%; height: min(80vh, 1000px); border: 1px solid var(--border); background: #fff; }
.rec-img { width: 100%; height: auto; border: 1px solid var(--border); background: #fff; }
.reply-list { margin-top: var(--s-3); border-top: 1px solid var(--border); }
.reply-list li { display: grid; gap: 2px; padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.reply-to { font-weight: 600; color: var(--navy); }
.reply-state { font-size: 13px; color: var(--text-muted); }
.reply-state--done { color: var(--ok); }
.reply-actions { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-left: calc(var(--s-2) * -1); }
.reply-actions .btn { min-height: 32px; color: var(--teal-text); }
.card .line-add input { flex: 1; min-width: 0; }

/* ---------- 9. Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-8); }
.editor-form { max-width: 640px; }
.preview-label { margin-bottom: var(--s-3); font-size: 13px; font-weight: 600; color: var(--text-muted); }
@media (min-width: 1280px) {
  .editor { grid-template-columns: minmax(380px, 520px) minmax(0, 1fr); align-items: start; }
  .editor-preview { position: sticky; top: calc(var(--header-h) + var(--s-6)); max-height: calc(100vh - var(--header-h) - var(--s-10)); overflow: auto; }
}

/* ---------- 10. Document view ---------- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s-8); align-items: start; }
@media (max-width: 1100px) { .doc-layout { grid-template-columns: minmax(0, 1fr); } }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.toolbar-note { font-size: 13px; color: var(--text-muted); }
.panel { display: grid; gap: var(--s-4); }

.card { padding: var(--s-5); background: #fff; border: 1px solid var(--border); }
.card--accent { border-top: 3px solid var(--teal); }
.card-title { margin-bottom: var(--s-3); font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--navy); }
.card-text { margin-bottom: var(--s-4); font-size: 14px; color: var(--text-muted); }
.card textarea { margin-bottom: var(--s-3); }
.card .hint { margin-top: var(--s-3); }

.timeline li { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--s-3); padding-bottom: var(--s-4); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.tl-dot { width: 16px; height: 16px; margin-top: 3px; border: 2px solid var(--border-strong); background: #fff; }
.tl--done .tl-dot { border-color: var(--teal-text); background: var(--teal-text); }
.tl--current .tl-dot { border-color: var(--navy); box-shadow: inset 0 0 0 3px #fff; background: var(--navy); }
.tl--rejected .tl-dot { border-color: var(--danger); background: var(--danger); }
.tl-who { font-size: 14.5px; font-weight: 600; color: var(--navy); }
.tl-role { margin-right: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.tl-pos { font-weight: 400; font-size: 13px; color: var(--text-muted); }
.tl-state { font-size: 13px; color: var(--text-muted); }
.tl--current .tl-state { color: var(--navy); font-weight: 600; }
.tl--rejected .tl-state { color: var(--danger); font-weight: 600; }
.tl-comment { margin-top: var(--s-1); padding: var(--s-2) var(--s-3); background: var(--paper-2); font-size: 13.5px; white-space: pre-wrap; }

.dispatch-list { margin-bottom: var(--s-4); }
.dispatch-list li { padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.dispatch-meta { display: block; font-size: 12.5px; color: var(--text-muted); }

.history li { display: grid; gap: 1px; padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.history li:last-child { border-bottom: 0; }
.history time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.history-comment { color: var(--text-muted); white-space: pre-wrap; }

/* ---------- 11. 공문 (A4 실측, 참고: IYFS-002) ---------- */
/* 굴림·돋움·바탕: Google Fonts가 OFL 1.1로 공개한 글꼴을 WOFF2로 변환해 함께 배포 (fonts/OFL-*.txt) */
@font-face { font-family: "IYFS Gulim";   src: url("fonts/gulim.woff2") format("woff2");   font-display: block; }
@font-face { font-family: "IYFS Dotum";   src: url("fonts/dotum.woff2") format("woff2");   font-display: block; }
@font-face { font-family: "IYFS Batang";  src: url("fonts/batang.woff2") format("woff2");  font-display: block; }
@font-face { font-family: "IYFS BatangChe"; src: url("fonts/batangche.woff2") format("woff2"); font-display: block; }
/* 쪽 여백은 @page와 같다: 위 25 · 오른쪽 18 · 아래 20 · 왼쪽 20mm. 쪽 수(--pages)는 app.js가 계산한다. */
.paper-fit { width: 100%; }
.paper-fit + .paper-fit { margin-top: var(--s-6); }
.paper {
  --pfont: "IYFS Gulim", "Gulim", "굴림", sans-serif;
  position: relative;
  display: flex; flex-direction: column;
  width: 210mm;
  min-height: calc(var(--pages, 1) * 297mm);
  padding: 25mm 18mm 20mm 20mm;
  transform-origin: top left;
  background: #fff;
  color: #000;
  font-family: var(--pfont);
  font-size: 12pt; line-height: 1.63;
  box-shadow: 0 1px 2px rgba(16, 26, 43, .06), 0 12px 32px -12px rgba(16, 26, 43, .18);
  border: 1px solid var(--border);
}
/* 굴림·돋움·바탕에는 굵은 서체가 없어 획을 덧그려 굵게 보이게 한다 */
.paper :is(.p-sender, .p-stack b) { -webkit-text-stroke: .03em currentColor; }
.paper--dotum { --pfont: "IYFS Dotum", "Dotum", "돋움", sans-serif; }
.paper--batang { --pfont: "IYFS Batang", "Batang", "바탕", serif; }
.p-ribbon {
  position: absolute; top: 8mm; right: 8mm;
  padding: 1px 8px;
  border: 1px solid var(--danger); color: var(--danger);
  font: 600 8pt/1.6 var(--font-ko);
}

/* 머리: 로고 · 기관명 */
.p-head { display: grid; grid-template-columns: 20mm minmax(0, 1fr) 20mm; align-items: center; margin-bottom: 8mm; }
.p-logo { width: 20mm; height: 20mm; display: grid; place-items: center; background: var(--navy); }
.p-logo svg { width: 12mm; height: 12mm; --mark-accent: var(--teal-light); --mark-body: #fff; }
.p-title-block { display: grid; justify-items: center; gap: 2.5mm; text-align: center; }
.p-slogan { font-size: 8.5pt; letter-spacing: .02em; color: #182B4A; line-height: 1.3; }
.p-org { font-size: 19pt; font-weight: 400; letter-spacing: -0.01em; line-height: 1.3; }

/* 수신 · 제목 */
.p-row { display: grid; grid-template-columns: 12mm minmax(0, 1fr); }
.p-meta { padding-bottom: 3mm; border-bottom: 1px solid #000; margin-bottom: 5mm; }
.p-meta .p-row { padding-left: 1mm; }

/* 본문: 한글 공문처럼 글자 단위 줄바꿈 + 양쪽 정렬 */
.p-body { white-space: pre-wrap; word-break: break-all; text-align: justify; }
.p-attach { display: grid; grid-template-columns: 12mm minmax(0, 1fr); margin-top: 1.63em; }
.p-end { white-space: pre; }

/* 맺음: 발신명의 · 결재란 — 마지막 쪽 아래에 붙는다 */
.p-close { margin-top: auto; padding-top: 14mm; break-inside: avoid; }
.p-sender { margin-bottom: 18mm; text-align: center; font-size: 16pt; font-weight: 700; letter-spacing: -0.01em; }
.p-seal-anchor { position: relative; display: inline-block; }
/* 직인: 8푼 도장 = 24mm (1푼 = 3mm). 올린 이미지는 여백을 잘라 인영만 남긴다(app.js trimSeal). */
.p-seal { position: absolute; left: 50%; top: 50%; width: 24mm; height: 24mm; max-width: none; object-fit: contain; transform: translate(-46%, -50%); }
img.p-seal { mix-blend-mode: multiply; pointer-events: none; }
.p-seal--ph {
  display: grid; place-items: center;
  border: 1.5px dashed #C8102E; color: #C8102E;
  font: 500 9pt/1 var(--font-ko); letter-spacing: 0;
}
.p-recips { margin-bottom: 4mm; font-size: 10.5pt; }
.p-bar { height: 3mm; background: #C8C8C8; }
.p-signs { display: flex; flex-wrap: wrap; gap: 0 6mm; padding: 1mm 0 .5mm; }
.p-signer { display: grid; grid-template-columns: auto 30mm; align-items: center; column-gap: 4mm; min-height: 10.5mm; }
.p-pos { font-size: 10pt; }
.p-stack { display: grid; line-height: 1.25; }
.p-stack small { font-size: 7.5pt; }
.p-stack b { font-size: 10pt; }
.p-reject { color: #B42318; }
.p-exec, .p-contact { display: grid; font-size: 10pt; line-height: 2.1; }
.p-exec { grid-template-columns: 48mm 37mm auto; }
.p-contact { grid-template-columns: 20mm auto; }
.p-sep { margin-left: 6mm; }   /* 주소 ↔ 홈페이지: 우편번호 칸에서 줄인 3mm만큼 넓힘 */
.p-contact + .p-contact { grid-template-columns: 48mm 46mm 42mm auto; }
.p-contact span { overflow-wrap: anywhere; }
.ph { color: #9AA1AE; }

/* 재임증명서: 재임증명서.hwpx 양식 실측 (바탕체, 여백 상하좌우 25mm) */
.paper.cert { --pfont: "IYFS BatangChe", "BatangChe", "바탕체", "IYFS Batang", serif; padding: 25mm; font-size: 11pt; line-height: 1.6; }
.cert-title { width: 43mm; margin: 0 auto 8mm; text-align: center; font-size: 18pt; font-weight: 400; -webkit-text-stroke: .03em currentColor; }
.cert-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cert-table th, .cert-table td { height: 13.4mm; padding: 0 2mm; border: .5pt solid #000; font-weight: 400; text-align: center; vertical-align: middle; word-break: keep-all; }
.cert-table th { padding: 0 2.5mm; white-space: nowrap; }
.dist { display: flex; justify-content: space-between; }
.dist--wide { width: 14mm; margin: 0 auto; }
/* 주소 칸: 한 줄이면 가운데, 두 줄 이상이면 양쪽 정렬 */
.cert-table td.addr { text-align: center; padding: 0 3mm; }
.cert-table td.addr > span { display: inline-block; max-width: 100%; text-align: justify; }
.cert-group { line-height: 1.5; }
.cert-text { margin-top: 11mm; text-align: center; font-size: 12pt; }
.cert-date { margin-top: 13mm; text-align: center; font-size: 12pt; }
.cert-issuer { margin-top: 9mm; text-align: center; font-size: 15pt; -webkit-text-stroke: .03em currentColor; }
.cert-pos { letter-spacing: 8mm; margin-right: 0; }
.cert-name { letter-spacing: 5mm; }
/* 직인: 가로는 이름 마지막 글자, 세로는 명의 두 줄 사이 (줄 상자 위쪽 경계에 인영 중심) */
.cert-issuer p { line-height: 1.6; }
.cert-issuer .p-seal-anchor { letter-spacing: 0; display: inline-block; height: 1.6em; line-height: 1.6em; vertical-align: top; }
.cert-issuer .p-seal { top: 0; }
.cert .cert-no { margin-bottom: 8mm; font-size: 11pt; }
/* 진위 확인: 쪽 아래에 문서확인번호 */
.cert-verify { margin-top: auto; padding-top: 10mm; font-size: 8pt; line-height: 1.6; color: #222; break-inside: avoid; }
.cert-verify a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.cv-top { display: flex; justify-content: space-between; gap: 4mm; }
/* 안내문: 양쪽 정렬, 줄이 넘어가면 ※ 다음에 맞춰 들여쓰기 */
.cv-note { margin-top: 1mm; text-align: justify; word-break: break-all; padding-left: 1.6em; text-indent: -1.6em; }

/* ---------- 12. Dialog ---------- */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0; border: 0; border-top: 4px solid var(--navy);
  background: var(--paper); color: var(--text-body);
  box-shadow: 0 24px 64px -16px rgba(16, 26, 43, .4);
}
dialog::backdrop { background: rgba(16, 26, 43, .5); }
.dlg { padding: var(--s-6); }
.dlg-title { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; color: var(--navy); }
.dlg-sub { margin: var(--s-1) 0 var(--s-5); font-size: 13.5px; color: var(--text-muted); }
.steps { counter-reset: s; margin: 0 0 var(--s-5); padding: var(--s-4); background: #fff; border: 1px solid var(--border); }
.steps li { counter-increment: s; position: relative; padding-left: 28px; font-size: 14px; }
.steps li + li { margin-top: var(--s-2); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 2px;
  width: 20px; height: 20px; display: grid; place-items: center;
  background: var(--navy); color: var(--paper); font-size: 12px; font-weight: 700;
}
.steps b { color: var(--navy); }
.dlg-actions { position: sticky; bottom: 0; margin: 0 calc(var(--s-6) * -1) calc(var(--s-6) * -1); padding: var(--s-4) var(--s-6) var(--s-6); background: var(--paper); display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding-top: var(--s-4); border-top: 1px solid var(--border); }
.dlg-spacer { flex: 1; }
@media (max-width: 480px) {
  .seg--3 { grid-template-columns: minmax(0, 1fr); }
  .dlg { padding: var(--s-5) var(--s-4); }
  .dlg-actions { margin: 0 calc(var(--s-4) * -1) calc(var(--s-5) * -1); padding: var(--s-3) var(--s-4) var(--s-4); }
}

/* ---------- 13. Settings ---------- */
.settings { display: grid; gap: var(--s-5); max-width: 860px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s-5); }
.grid-form .field--full, .grid-form .form-actions { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid-form { grid-template-columns: minmax(0, 1fr); } }
.seal-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-5); }
.seal-preview {
  width: 112px; height: 112px; flex: none;
  display: grid; place-items: center;
  border: 1px dashed var(--border-strong); background: var(--paper);
  font-size: 12px; color: var(--text-muted); text-align: center;
}
.seal-preview img { width: 88px; height: 88px; object-fit: contain; }
.user-table { margin-bottom: var(--s-4); border-top: 1px solid var(--border); }
.user-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 120px 64px; gap: var(--s-2); align-items: center; padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
.user-row--head { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.is-remote .user-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 110px minmax(0, 1.3fr); }
@media (max-width: 560px) {
  .user-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .user-row--head { display: none; }
}

/* ---------- 14. Toast ---------- */
.toast-region { position: fixed; z-index: 100; right: var(--s-5); bottom: var(--s-5); left: auto; display: grid; gap: var(--s-2); max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: var(--s-3) var(--s-4);
  background: var(--navy); color: var(--paper);
  border-left: 4px solid var(--teal-light);
  font-size: 14px; box-shadow: 0 12px 32px -12px rgba(16, 26, 43, .5);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast--error { border-left-color: #F97066; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
@media (max-width: 640px) { .toast-region { left: var(--s-4); right: var(--s-4); bottom: var(--s-4); max-width: none; } }

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

/* ---------- 15. Print: 공문만 A4로 ---------- */
@page { size: A4; margin: 25mm 18mm 20mm 20mm; }
@page cert { size: A4; margin: 0; }   /* 증명서는 화면의 A4 한 장을 그대로 찍는다 (여백은 증명서 안쪽에) */
@media print {
  html { scrollbar-gutter: auto; }
  body { background: #fff; }
  .skip-link, .topbar, .sidebar, .page-head, .toolbar, .panel, .editor-form, .preview-label, .toast-region, dialog { display: none !important; }
  .layout, main, .doc-layout, .editor, .editor-preview, .paper-wrap { display: block !important; padding: 0 !important; margin: 0 !important; max-height: none !important; overflow: visible !important; position: static !important; background: none !important; }
  .paper-fit { height: auto !important; margin: 0 !important; }
  .paper-fit + .paper-fit { break-before: page; }
  .paper {
    width: auto; padding: 0; border: 0; box-shadow: none; transform: none !important;
    min-height: calc(var(--pages, 1) * (297mm - 45mm) - 6mm);
  }
  /* 쪽 이름은 문서 전체에 준다. 중간에 쪽 이름이 바뀌면 앞뒤로 빈 장이 생길 수 있다. */
  body[data-route="cert"], body[data-route="certs"] { page: cert; }
  /* 쪽 높이에 6mm 여유: 프린터 여백이 조금 커도 다음 장으로 넘치지 않게 */
  .paper.cert { width: 210mm; height: 296mm; min-height: 0; padding: 25mm; overflow: hidden; }
  .p-ribbon { top: 0; right: 0; }
  .p-seal--ph { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
