/* 한지와 먹: 미색 종이 바탕, 먹색 글씨, 주홍 낙관 하나 */
:root {
  --bg: #F6F2EA;
  --surface: #FFFDF8;
  --ink: #1E1E1E;
  --muted: #6E675C;
  --line: #E2DBCD;
  --line-soft: #ECE6DA;
  --gold: #B23A2B;
  --teal: #2F6B6F;   --teal-soft: #E3ECEA;
  --navy: #3A4A7A;   --navy-soft: #E6E8F1;
  --olive: #5E6B2A;  --olive-soft: #ECEEDD;
  --amber: #9A5B1E;  --amber-soft: #F3E6D6;
  --hero: #FFFDF8;   --hero-ink: #1E1E1E; --hero-muted: #B23A2B;
  --diagram-ground: #FFFFFF;
  --f-display: "Gowun Batang", "AppleMyungjo", serif;
  --f-body: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --f-quote: "IBM Plex Sans KR", "Apple SD Gothic Neo", sans-serif;
  color-scheme: light;
}
.c-teal  { --c: var(--teal);  --c-soft: var(--teal-soft); }
.c-navy  { --c: var(--navy);  --c-soft: var(--navy-soft); }
.c-olive { --c: var(--olive); --c-soft: var(--olive-soft); }
.c-amber { --c: var(--amber); --c-soft: var(--amber-soft); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16.5px; line-height: 1.8;
  word-break: keep-all; overflow-wrap: break-word; }
a { color: var(--teal); }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 머리말 */
.top { background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 26px; padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { font-family: var(--f-display); font-size: 1.25rem; font-weight: 700; color: var(--gold); text-decoration: none; }
.cats, .util { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.util { margin-left: auto; }
.cats a, .util a { color: var(--muted); text-decoration: none; font-size: .93rem; }
.cats a:hover, .util a:hover { color: var(--gold); }
.util .lockbar { color: var(--amber); }

.shell { max-width: 820px; margin: 0 auto; padding-block: 36px 72px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.shell.home { max-width: 1180px; padding-top: 24px; }
.shell.with-side { max-width: 1180px; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; }
main { min-width: 0; --c: var(--teal); --c-soft: var(--teal-soft); }

/* 첫 화면 */
.hero { background: var(--hero); color: var(--hero-ink); border: 1px solid var(--line); border-radius: 16px; padding: 36px 36px 32px; }
.hero-in { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 36px; align-items: center; }
.hanja { font-family: var(--f-display); font-size: clamp(2.6rem, 6vw, 4rem); letter-spacing: .12em; line-height: 1.1; margin: 0; color: var(--hero-ink); }
.reading { margin: 10px 0 14px; color: var(--hero-muted); font-size: 1rem; }
.chars { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.ch { display: inline-flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 10px; border: 1px solid rgba(178,58,43,.3); border-radius: 10px; }
.ch b { font-family: var(--f-display); font-size: 1.35rem; font-weight: 700; color: var(--hero-ink); line-height: 1.3; }
.ch small { font-size: .75rem; color: var(--hero-muted); }
.line { font-family: var(--f-display); font-size: 1.15rem; line-height: 1.7; margin: 0 0 18px; color: var(--hero-ink); }
.stats { display: flex; gap: 22px; margin: 0; color: var(--hero-muted); font-size: .9rem; }
.stats b { color: var(--gold); font-size: 1.5rem; font-weight: 700; margin-right: 4px; font-variant-numeric: tabular-nums; }
.feature { display: block; background: var(--diagram-ground); border-radius: 12px; padding: 10px; text-decoration: none; color: var(--ink); }
.feature img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid #E1E8EA; }
.feature span { display: block; font-size: .85rem; margin: 8px 2px 0; color: #1F2A33; }

.home-body { margin-top: 28px; }
.mine { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--gold); border-radius: 12px; padding: 14px 18px; margin-bottom: 20px; }
.mine p { margin: 0; }
.btn { display: inline-block; background: var(--gold); color: #FFFDF8; text-decoration: none; padding: 7px 16px; border-radius: 8px; font-size: .93rem; }

.cards { list-style: none; margin: 0 0 36px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.cards a { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--c); }
.icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--c-soft); color: var(--c);
  font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; }
.cards .t { font-family: var(--f-display); font-size: 1.25rem; font-weight: 700; margin-top: 8px; }
.cards .desc { color: var(--muted); font-size: .9rem; line-height: 1.6; }
.cards .meta { margin-top: auto; padding-top: 10px; color: var(--c); font-size: .82rem; }

.home-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 28px; }
h2.sec { font-family: var(--f-display); font-size: 1.2rem; margin: 0 0 10px; }
aside h2.sec + * { margin-bottom: 26px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.tag { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 3px 14px; font-size: .88rem; color: var(--ink); text-decoration: none; }
.tag:hover { border-color: var(--gold); color: var(--gold); }
.now { list-style: none; margin: 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: .92rem; }
.now li + li { margin-top: 6px; }

.chip { display: inline-block; font-size: .72rem; font-weight: 400; background: var(--c-soft); color: var(--c); border-radius: 5px; padding: 1px 7px; margin-right: 8px; vertical-align: 2px; }

/* 목록 */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { border-bottom: 1px solid var(--line); }
.list a { display: flex; flex-direction: column; gap: 2px; padding: 12px 4px; text-decoration: none; color: var(--ink); }
.list a:hover .t { color: var(--c, var(--teal)); }
.list .t { font-weight: 700; }
.list .desc { color: var(--muted); font-size: .9rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list .meta { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.list.boxed { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.list.boxed li:last-child { border-bottom: 0; }
.list.boxed a { padding: 12px 16px; }
.sub { margin-bottom: 36px; }
.sub h2 { font-family: var(--f-display); font-size: 1.2rem; margin: 0 0 10px; color: var(--c); }

/* 글 */
.eyebrow { font-size: .85rem; color: var(--c); margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.eyebrow a { color: inherit; text-decoration: none; }
.lock { font-size: .72rem; border: 1px solid var(--amber); color: var(--amber); border-radius: 5px; padding: 0 6px; margin-left: 6px; }
h1 { font-family: var(--f-display); font-weight: 700; color: var(--ink); font-size: clamp(1.7rem, 3.6vw, 2.3rem); line-height: 1.35; margin: 6px 0 12px; text-wrap: balance; }
h1 .icon { margin-right: 12px; vertical-align: 6px; }
.lead { color: var(--muted); margin: 0 0 28px; }
.lead p { margin: 0 0 8px; }
.dateline { color: var(--muted); font-size: .88rem; margin: 0 0 4px; }
.source { color: var(--amber); }
.edit { margin-left: 12px; font-size: .82rem; border: 1px solid var(--line); border-radius: 6px; padding: 1px 10px; text-decoration: none; color: var(--ink); background: var(--surface); }
.edit:hover { border-color: var(--gold); color: var(--gold); }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin: 16px 0 26px; }

.diagram { margin: 0 0 32px; }
.diagram a { display: block; background: var(--diagram-ground); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.diagram img { display: block; width: 100%; }
.diagram figcaption { color: var(--muted); font-size: .8rem; margin-top: 6px; }

.note { margin-top: 24px; }
.note h2 { font-family: var(--f-display); font-size: 1.35rem; line-height: 1.45; margin: 40px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); text-wrap: balance; }
.note h3 { font-family: var(--f-display); font-size: 1.1rem; color: var(--c); margin: 26px 0 8px; }
.note p, .note ul, .note ol { margin: 0 0 14px; }
.note ul, .note ol { padding-left: 1.4em; }
.note li { margin-bottom: 4px; }
.note li ul, .note li ol { padding-left: 1.1em; margin: 4px 0 6px; }
.note strong { font-weight: 700; }
.note blockquote { margin: 0 0 18px; padding: 14px 20px; background: var(--c-soft); border-radius: 10px;
  font-family: var(--f-quote); font-size: .96rem; line-height: 1.8; }
.note blockquote p:last-child, .note blockquote ul:last-child { margin-bottom: 0; }
.note hr { border: 0; border-top: 1px dashed var(--line); margin: 28px 0; }
.note img { border-radius: 6px; }
.table-wrap { overflow-x: auto; margin: 0 0 18px; }
.note table { border-collapse: collapse; font-size: .9rem; line-height: 1.55; width: 100%; }
.note th, .note td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.note th { color: var(--muted); font-size: .82rem; }
.supp { font-size: .78em; color: var(--amber); white-space: nowrap; }
.orig { margin-top: 40px; font-size: .9rem; }

/* 노트 묶음 목차 */
.side { min-width: 0; position: sticky; top: 20px; align-self: start; max-height: calc(100vh - 40px); overflow-y: auto; }
.side .coll { display: block; font-family: var(--f-display); font-weight: 700; color: var(--ink); text-decoration: none; margin-bottom: 10px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side .grp { font-size: .74rem; letter-spacing: .06em; color: var(--muted); margin: 14px 0 2px; }
.side a:not(.coll) { display: flex; gap: 10px; padding: 6px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .9rem; line-height: 1.45; }
.side a:not(.coll):hover { background: var(--line-soft); }
.side a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.side .code { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2.4em; }
.side a[aria-current="page"] .code { color: inherit; opacity: .75; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 52px; padding-top: 18px; border-top: 1px solid var(--line); }
.pager a { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--ink); font-size: .9rem; }
.pager .next { margin-left: auto; }

/* 구조도 모아보기 */
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.gallery li.wide { grid-column: 1 / -1; }
.gallery a { display: flex; flex-direction: column; gap: 2px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; background: var(--diagram-ground); border-radius: 6px; border: 1px solid var(--line-soft); margin-bottom: 6px; }
.gallery li.wide img { aspect-ratio: auto; }
.gallery .t { font-weight: 700; }
.gallery .meta { color: var(--muted); font-size: .8rem; }

/* 검색 */
.search input { width: 100%; font: inherit; font-size: 1.05rem; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); margin: 6px 0 12px; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.foot p { max-width: 1180px; margin: 0 auto; padding-block: 20px 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

@media (max-width: 900px) {
  .hero-in { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-cols { grid-template-columns: minmax(0, 1fr); }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell.with-side { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .side { position: static; max-height: none; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface); }
  .side ul { max-height: 220px; overflow-y: auto; }
}
@media (max-width: 560px) {
  .hero { padding: 26px 20px; border-radius: 12px; }
  .util { margin-left: 0; }
  .gallery { grid-template-columns: minmax(0, 1fr); }
}
.brand small { font-family: var(--f-display); font-size: .78rem; font-weight: 400; color: var(--muted); margin-left: 8px; letter-spacing: .08em; }
.hanja { text-shadow: none; }
.cards a { background: var(--surface); }
.cards a:hover, .gallery a:hover { border-color: var(--gold); }
a { color: var(--teal); }
.orig a { color: var(--gold); }

/* 첫 화면 전시실: 이름 줄 + 구조도 벽(큰 작품 하나, 작은 작품 둘) */
.hero { padding: 30px 32px 22px; }
.hero-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 28px; align-items: center; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.hero-head .hanja { font-size: clamp(2.2rem, 5vw, 3.2rem); }
.hero-head .reading { margin: 0 0 8px; }
.hero-head .chars { margin: 0; }
.hero-head .ch { min-width: 54px; padding: 4px 8px; }
.hero-head .ch b { font-size: 1.1rem; }
.hero-head .stats { flex-direction: column; gap: 2px; text-align: right; }
.gallery-wall { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); grid-template-rows: auto auto; gap: 18px 22px; margin-top: 24px; }
.work { margin: 0; }
.work.main { grid-row: 1 / span 2; }
.work a { display: block; background: var(--diagram-ground); padding: 12px; border-radius: 4px; box-shadow: 0 8px 24px rgba(60, 45, 20, .12); border: 1px solid var(--line); transition: transform .2s ease; }
.work a:hover { transform: translateY(-2px); }
.work img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; }
.work.main img { aspect-ratio: 4 / 3; }
.work figcaption { margin-top: 10px; font-size: .82rem; color: var(--muted); }
.work .no { color: var(--gold); margin-right: 8px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.wall-more { text-align: right; margin: 14px 0 0; font-size: .88rem; }
.wall-more a { color: var(--gold); text-decoration: none; }
@media (max-width: 900px) {
  .hero-head { grid-template-columns: minmax(0, 1fr); }
  .hero-head .stats { flex-direction: row; text-align: left; }
  .gallery-wall { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .work.main { grid-column: 1 / -1; grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { .work a { transition: none; } }
