/* ═══════════════════════════════════════════════════════════════
   학생 포트폴리오 — 앱 공통 스타일
   모티프: 책상 위 A4 서류. 색인 탭이 달린 시트, 완성 도장(紅印), 대장(ledger) 행.
   ═══════════════════════════════════════════════════════════════ */

/* ── 토큰: 화이트 단일 테마 (OS 다크 모드를 따라가지 않음) ──────────── */
:root {
  color-scheme: only light;   /* 브라우저 자동 다크(강제 반전) 거부 */
  --ground: #F4F6F7;
  --paper: #FFFFFF;
  --paper-2: #F3F5F6;
  --ink: #14201C;
  --ink-2: #5B6B66;
  --ink-3: #74827D;           /* 작은 보조 글씨도 흰 바탕에서 4:1 이상 */
  --line: #E4E9E7;
  --line-2: #EEF1F0;
  --accent: #0EA47E;          /* 민트 그린: 텍스트·테두리용 */
  --accent-bright: #15C596;   /* 채움·그라데이션·글로우용 */
  --accent-deep: #0B8A69;
  --accent-hover: #0C8F6E;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1F6EF;
  --stamp: #E2483D;           /* 완성 도장 · 삭제 */
  --stamp-soft: #FDEAE8;
  --warn: #C7860A;
  --warn-soft: #FFF4DA;
  --focus: #2F7DE1;
  --shadow: 0 1px 2px rgba(20, 32, 28, .04), 0 12px 32px -14px rgba(20, 32, 28, .14);
  --shadow-lg: 0 10px 40px -10px rgba(20, 32, 28, .28);
  /* 분류 색 (분필색 7종) */
  --cat-a: #2E8BE0; --cat-b: #7A63E8; --cat-c: #F0663F; --cat-d: #0EA47E;
  --cat-e: #D9930F; --cat-f: #2F5FCF; --cat-g: #6B7A88;
  /* 활동 잔디 단계 */
  --hm0: #EEF1F0; --hm1: #BFEEDD; --hm2: #6EDCBA; --hm3: #15C596; --hm4: #0B8A69;
  --r-sm: 8px; --r: 14px;
  --font-ui: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --font-display: "Gothic A1", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "D2Coding", Consolas, monospace;
}

/* ── 기본 ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 15px/1.6 var(--font-ui); word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1.3; letter-spacing: -.015em; text-wrap: balance; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ── 상단 바 ───────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .in { max-width: 1120px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand .mark { width: 28px; height: 28px; border-radius: 9px; position: relative; flex: none; background: linear-gradient(135deg, var(--accent-bright), var(--accent-deep)); box-shadow: 0 6px 14px -6px rgba(14, 164, 126, .7); }
.brand .mark::before { content: ""; position: absolute; left: 8px; right: 8px; top: 9px; height: 2.5px; border-radius: 2px; background: #fff; box-shadow: 0 5px 0 #fff, 0 10px 0 rgba(255,255,255,.55); }
.brand .mark::after { content: none; }
.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav a { padding: 7px 11px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px; }
.nav a:hover { background: var(--paper-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13.5px; }
.me b { color: var(--ink); font-weight: 600; }
.role { font-size: 11.5px; letter-spacing: .04em; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 720px) {
  .topbar .in { height: 52px; gap: 8px; }
  .brand span { display: none; }
  .me .who { display: none; }
}

/* ── 페이지 컬럼 ───────────────────────────────────────────────── */
.page { max-width: 1120px; margin: 0 auto; padding: 26px 20px 72px; }
.page.narrow { max-width: 820px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.toolbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

/* ── 시트(종이) + 색인 탭 ──────────────────────────────────────── */
.sheet { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); margin-top: 0; }
.sheet + .sheet { margin-top: 18px; }
.sheet > .tab {
  display: inline-flex; align-items: center; gap: 6px; margin: 16px 20px 0; height: 22px; padding: 0 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; white-space: nowrap;
}
.sheet > .tab::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-bright); }
.sheet-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 10px 22px 16px; border-bottom: 1px solid var(--line-2); }
.sheet > .tab + .sheet-head { padding-top: 10px; }
.sheet-head h1 { font-size: 24px; }
.sheet-head .sub { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.sheet-body { padding: 18px 22px 22px; }
.sheet-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--ink-2); font-size: 13.5px; }
@media (max-width: 720px) { .sheet-head, .sheet-body, .sheet-foot { padding-left: 16px; padding-right: 16px; } }

/* ── 버튼 ──────────────────────────────────────────────────────── */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-weight: 500; font-size: 14px; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--paper-2); }
.btn.primary { background: linear-gradient(180deg, var(--accent-bright), var(--accent)); border-color: transparent; color: var(--accent-ink); box-shadow: 0 8px 18px -8px rgba(14, 164, 126, .75), inset 0 1px 0 rgba(255,255,255,.25); font-weight: 600; }
.btn.primary:hover { background: linear-gradient(180deg, var(--accent), var(--accent-hover)); box-shadow: 0 10px 22px -8px rgba(14, 164, 126, .85), inset 0 1px 0 rgba(255,255,255,.2); }
.btn.danger { color: var(--stamp); border-color: color-mix(in srgb, var(--stamp) 45%, var(--line)); }
.btn.danger:hover { background: var(--stamp-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ── 입력 ──────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input {
  height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); font-size: 14px; width: 100%;
}
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.input::placeholder { color: var(--ink-3); }
select.input { padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; appearance: none; }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input.mono { font-family: var(--font-mono); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.help { font-size: 12.5px; color: var(--ink-3); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 16px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.error { color: var(--stamp); font-size: 13.5px; }
.notice { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; border: 1px solid; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--ink); }
.notice.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ── 분류 칩 · 상태 도장 ────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  color: color-mix(in srgb, var(--c, var(--ink-2)) 72%, #000); background: color-mix(in srgb, var(--c, var(--ink-2)) 14%, transparent);
}
.chip[data-cat="자율"] { --c: var(--cat-a); } .chip[data-cat="진로"] { --c: var(--cat-b); }
.chip[data-cat="동아리"] { --c: var(--cat-c); } .chip[data-cat="봉사"] { --c: var(--cat-d); }
.chip[data-cat="독서"] { --c: var(--cat-e); } .chip[data-cat="교과"] { --c: var(--cat-f); }
.chip[data-cat="기타"] { --c: var(--cat-g); }
.stamp {
  display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 7px;
  border: 1.5px solid currentColor; border-radius: 4px; font-size: 12px; font-weight: 700;
  letter-spacing: .14em; line-height: 1; white-space: nowrap; user-select: none;
}
.stamp.done { color: var(--stamp); background: var(--stamp-soft); transform: rotate(-4deg); }   /* 손으로 찍은 인장처럼 살짝 기울임 */
.stamp.draft { color: var(--ink-3); border-style: dashed; letter-spacing: .1em; }

/* ── 대장(ledger) 목록 ─────────────────────────────────────────── */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 6px 18px; align-items: center; padding: 15px 26px; border-top: 1px solid var(--line-2); transition: background .12s; }
.ledger li:first-child { border-top: 0; }
.ledger li:hover { background: var(--paper-2); }
.ledger .date { font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ledger .date small { display: block; font-size: 11px; color: var(--ink-3); }
.ledger .main { min-width: 0; }
.ledger .kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.ledger .title { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink); text-decoration: none; display: block; line-height: 1.35; }
.ledger .title:hover { color: var(--accent); }
.ledger .excerpt { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.ledger .side { display: flex; align-items: center; gap: 12px; }
.ledger .thumb { width: 58px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: var(--paper-2); }
.ledger .acts { display: flex; gap: 4px; }
@media (max-width: 720px) {
  .ledger li { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; }
  .ledger .date { order: 3; }
  .ledger .side { justify-content: space-between; }
}

/* ── 표 ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--paper-2); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, #fff); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .acts { display: flex; gap: 4px; justify-content: flex-end; }
.table tr.inactive td { color: var(--ink-3); }
.table tr.selected td { background: var(--accent-soft); }

/* ── 통계 띠 ───────────────────────────────────────────────────── */
.stats { display: flex; gap: 28px; flex-wrap: wrap; padding: 14px 26px; border-bottom: 1px solid var(--line-2); }
.stats div { display: flex; align-items: baseline; gap: 8px; }
.stats b { font-family: var(--font-mono); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stats span { color: var(--ink-2); font-size: 13px; }

/* ── 2단 (학급 | 학생) ─────────────────────────────────────────── */
.two { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 880px) { .two { grid-template-columns: 1fr; } }
.classlist { list-style: none; margin: 0; padding: 8px; }
.classlist li + li { margin-top: 2px; }
.classlist button { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 12px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; }
.classlist button:hover { background: var(--paper-2); }
.classlist button[aria-selected="true"] { background: var(--accent-soft); }
.classlist .name { font-weight: 600; }
.classlist .cnt { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); }
.classlist .teacher { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); }
.classlist .teacher.none { color: var(--warn); }

/* ── 빈 상태 · 페이지 ─────────────────────────────────────────── */
.empty { padding: 48px 26px; text-align: center; color: var(--ink-2); }
.empty h3 { font-size: 18px; margin-bottom: 6px; color: var(--ink); }
.pager { display: flex; align-items: center; gap: 6px; }
.pager .cur { font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); padding: 0 6px; }

/* ── 토스트 · 대화상자 ─────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow-lg); animation: toast-in .18s ease-out; max-width: min(92vw, 520px); }
.toast.error { background: var(--stamp); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
dialog.modal { border: 1px solid var(--line); border-radius: var(--r); padding: 0; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lg); width: min(92vw, 520px); }
dialog.modal::backdrop { background: rgba(10, 14, 20, .45); }
dialog.modal .m-head { padding: 18px 22px 0; }
dialog.modal .m-head h2 { font-size: 19px; }
dialog.modal .m-body { padding: 16px 22px 4px; display: flex; flex-direction: column; gap: 14px; }
dialog.modal .m-foot { padding: 16px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ── 본문 렌더(서버 HTML) : 화면용 ─────────────────────────────── */
.doc-body { font-size: 16px; line-height: 1.8; max-width: 720px; }
.doc-body h1 { font-size: 26px; } .doc-body h2 { font-size: 22px; margin: 1.3em 0 .45em; } .doc-body h3 { font-size: 19px; margin: 1.1em 0 .4em; }
.doc-body h4, .doc-body h5, .doc-body h6 { font-size: 16.5px; margin: 1em 0 .3em; font-family: var(--font-ui); font-weight: 700; }
.doc-body p { margin: 0 0 .7em; } .doc-body p.empty { min-height: 1em; }
.doc-body ul, .doc-body ol { margin: 0 0 .8em; padding-left: 1.6em; } .doc-body li { margin: .15em 0; }
.doc-body ul.checklist { list-style: none; padding-left: .1em; }
.doc-body li.check { display: flex; gap: .5em; align-items: flex-start; flex-wrap: wrap; }
.doc-body li.check .box { color: var(--ink-3); } .doc-body li.check.checked .box { color: var(--accent); }
.doc-body li.check.checked .txt { color: var(--ink-2); }
.doc-body li.check .checklist { flex-basis: 100%; margin-left: 1.4em; }
.doc-body blockquote { margin: 1em 0; padding: .6em 1em; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.doc-body blockquote p { margin: 0; } .doc-body blockquote cite { display: block; font-style: normal; color: var(--ink-2); font-size: 13.5px; margin-top: .3em; }
.doc-body blockquote.align-center { text-align: center; border-left: 0; border-top: 3px solid var(--accent); }
.doc-body hr.delimiter { border: 0; height: 1.2em; margin: 1.2em 0; text-align: center; }
.doc-body hr.delimiter::after { content: "* * *"; color: var(--ink-3); letter-spacing: .6em; }
.doc-body pre { background: var(--paper-2); border: 1px solid var(--line); border-radius: 6px; padding: .8em 1em; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.doc-body code { font-family: var(--font-mono); } .doc-body code.inline-code { background: var(--paper-2); padding: .05em .35em; border-radius: 3px; font-size: .92em; }
.doc-body mark { background: #FFE97A; color: #1B2430; padding: 0 .1em; }
.doc-body table { border-collapse: collapse; width: 100%; margin: .8em 0; font-size: 14.5px; }
.doc-body th, .doc-body td { border: 1px solid var(--line); padding: .45em .65em; vertical-align: top; text-align: left; }
.doc-body th { background: var(--paper-2); font-weight: 600; }
.doc-body figure { margin: 1.2em 0; text-align: center; } .doc-body figure img { max-width: 100%; height: auto; border-radius: 4px; }
.doc-body figure.bordered img { border: 1px solid var(--line); } .doc-body figure.bg { background: var(--paper-2); padding: 14px; border-radius: 6px; }
.doc-body figcaption { font-size: 13.5px; color: var(--ink-2); margin-top: .4em; }
.doc-body .callout { border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); border-radius: 6px; padding: .6em .9em; margin: .8em 0; }
.doc-body a { color: var(--accent); }
.doc-body a:not([href]) { color: inherit; text-decoration: none; }
.doc-body .empty-note { color: var(--ink-3); font-style: italic; }
