:root {
    --bg: #fcfcfa;
    --fg: #252e2c;
    --muted: #68716e;
    --line: #dfe4df;
    --panel: #f1f4f0;
    --accent: #286852;
    /* 부품별 획 색. 밝은 테마와 어두운 테마 양쪽에서 읽히도록
       중간 채도로 고른다. 테마마다 바꾸면 그림과 목록이 어긋난다. */
    --part-1: #2f7fc4;
    --part-2: #c96a2e;
    --part-3: #3f9159;
    --part-4: #8a58ad;
    --radius: 12px;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* 큰 표시 글자에만 쓰는 웹폰트. 목록·칩까지 이걸로 그리면
       한 페이지가 100자 넘게 요구해 폰트 조각을 수십 개 받게 된다. */
    --font-hanja: "LXGW WenKai TC", "Noto Serif KR", "Apple SD Gothic Neo",
        "Malgun Gothic", "Songti SC", "Songti TC", "SimSun", serif;
    --font-hanja-plain: "Noto Serif KR", "Apple SD Gothic Neo", "Malgun Gothic",
        "Songti SC", "Songti TC", "SimSun", serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --fg: #e6edf3;
        --muted: #9198a1;
        --line: #30363d;
        --panel: #161b22;
        --accent: #79c7aa;
    }
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-ui);
    max-width: 1000px;
    margin: 0 auto;
    padding: 28px 32px 64px;
    line-height: 1.65;
    color: var(--fg);
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.site { margin-bottom: 40px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
header.site .bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* 검색창은 브랜드·메뉴 아래 한 줄을 차지한다. 사이에 끼우면 좁은 화면에서
   줄바꿈이 일어나 메뉴가 결과 뒤로 밀린다. */
.search { position: relative; margin-top: 12px; max-width: 100%; }
.search input {
    width: 100%; padding: 12px 16px; font-size: 16px; font-family: inherit;
    color: var(--fg); background: var(--bg);
    border: 1px solid var(--line); border-radius: 6px; box-sizing: border-box;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* 찾아보기에서는 검색창을 본문 제목 아래 둔다. */
main > .search { max-width: 520px; margin-bottom: 26px; }
main > .search input { padding: 11px 14px; font-size: 1.05em; }

/* 결과는 문서 흐름 밖에 띄운다. 흐름 안에 두면 아래 내용을 밀어낸다. */
.search .results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
    max-height: 60vh; overflow-y: auto;
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.search .results a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-bottom: 1px solid var(--line);
    color: var(--fg); text-decoration: none;
}
.search .results a:last-child { border-bottom: none; }
.search .results a:hover, .search .results a:focus { background: var(--panel); }
.result-glyph {
    font-family: var(--font-hanja-plain); font-size: 1.7em; line-height: 1;
    min-width: 1.3em; text-align: center; flex-shrink: 0;
}
.result-readings {
    color: var(--muted); font-size: .9em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
header.site .brand { font-weight: 700; font-size: 1.05em; color: var(--fg); }
header.site nav { display: flex; gap: 14px; font-size: .92em; }

.crumbs { font-size: .87em; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }

h1 { font-size: 1.9em; letter-spacing: -.035em; margin: 0 0 8px; line-height: 1.3; }
h2 { font-size: 1.15em; margin: 32px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
h2.plain { padding-bottom: 0; border-bottom: none; }
p.lead { color: var(--muted); margin-top: 0; }

textarea {
    width: 100%;
    min-height: 180px;
    padding: 16px;
    line-height: 1.8;
    font-size: 16px;
    font-family: inherit;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    resize: vertical;
}

.controls { display: flex; gap: 8px; margin: 10px 0 0; flex-wrap: wrap; align-items: center; }
button {
    padding: 9px 18px;
    font-size: 15px;
    font-family: inherit;
    color: var(--fg);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button:hover { filter: brightness(1.06); }
.status { color: var(--muted); font-size: .9em; }
.order { display: flex; align-items: center; gap: 6px; font-size: .9em; color: var(--muted); }
.order select {
    padding: 7px 8px; font-family: inherit; font-size: .95em;
    color: var(--fg); background: var(--bg);
    border: 1px solid var(--line); border-radius: 6px;
}
.card .sub.ja { color: var(--fg); font-family: var(--font-hanja-plain); }
.card .sub.muted { font-size: .8em; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 12px; }

.card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
}
.card .glyph { font-family: var(--font-hanja); font-size: 2.7em; line-height: 1; min-width: 1.4em; text-align: center; }
.card .body { flex: 1; min-width: 0; }
.card .readings { font-weight: 500; }
.card .sub { color: var(--muted); font-size: .86em; margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
    padding: 4px 11px;
    font-size: .88em;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    white-space: nowrap;
}
.chip .glyph { font-family: var(--font-hanja-plain); font-weight: 700; margin-right: 3px; }

.error { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--muted); }

/* 한자 상세 페이지 */
.entry-head { display: flex; gap: 28px; align-items: flex-start; margin-bottom: 24px; padding: 28px; background: var(--panel); border-radius: var(--radius); }
.entry-head .glyph { font-family: var(--font-hanja); font-size: 6em; line-height: 1; }
.entry-head .facts { flex: 1; min-width: 0; }
.entry-head .korean { font-size: 1.35em; font-weight: 600; margin: 6px 0 10px; }

dl.facts-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
dl.facts-list dt { color: var(--muted); font-size: .9em; }
dl.facts-list dd { margin: 0; overflow-wrap: anywhere; }
.kun-list { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.kun { overflow-wrap: anywhere; }
.kun-ko { color: var(--muted); font-size: .88em; margin-left: 6px; }
.card .sub.ja .kun-ko { color: var(--muted); }
.word-list .word-ko { color: var(--fg); font-size: .93em; margin-right: 8px; }
.variants a { font-family: var(--font-hanja-plain); font-size: 1.25em; margin-right: 8px; }
.tag {
    display: inline-block;
    padding: 1px 9px;
    font-size: .84em;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
}
.tag-joyo { border-color: var(--accent); color: var(--accent); }
.tag-muted { color: var(--muted); }


.word-list { list-style: none; padding: 0; margin: 0; }
.word-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.word-list li:last-child { border-bottom: none; }

/* 부품 풀이. 글자를 크게 세우고 그 옆에 그림과 쓰임을 쌓는다. */
.part-list { list-style: none; padding: 0; margin: 0; }
.part-list li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.part-list li:last-child { border-bottom: none; }
.part-glyph {
    font-family: var(--font-hanja); font-size: 2.4em; line-height: 1;
    min-width: 1.5em; text-align: center; flex-shrink: 0;
}
.part-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.part-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.part-reading { font-weight: 600; }
.part-image { color: var(--fg); }
.part-role { color: var(--muted); font-size: .93em; }

/* 획을 부품별로 색을 달리해 짚어 준다. 목록의 글자도 같은 색으로 물들여
   그림과 이름을 잇는다. 두 테마에서 다 읽히는 중간 채도로 고른다. */
.parts { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.parts .part-list { flex: 1 1 260px; min-width: 0; }
.stroke-map { width: 132px; height: 132px; flex-shrink: 0; }
.stroke-map path {
    fill: none; stroke-width: 3.4;
    stroke-linecap: round; stroke-linejoin: round;
}
.stroke-map .p0 path { stroke: var(--muted); }
.stroke-map .p1 path { stroke: var(--part-1); }
.stroke-map .p2 path { stroke: var(--part-2); }
.stroke-map .p3 path { stroke: var(--part-3); }
.stroke-map .p4 path { stroke: var(--part-4); }
.part-list .p1 .part-glyph, .part-list .p1 .part-glyph a { color: var(--part-1); }
.part-list .p2 .part-glyph, .part-list .p2 .part-glyph a { color: var(--part-2); }
.part-list .p3 .part-glyph, .part-list .p3 .part-glyph a { color: var(--part-3); }
.part-list .p4 .part-glyph, .part-list .p4 .part-glyph a { color: var(--part-4); }

/* 분석기가 무엇을 하는 물건인지 적어 둔다. 붙여넣기 칸 하나뿐이면
   처음 온 사람도, 검색 엔진도 읽을 것이 없다. */
ul.about { padding-left: 20px; }
ul.about li { margin: 7px 0; line-height: 1.7; color: var(--muted); }

/* 자형 유래 한 문장. 부품 목록이 말하지 않는 '그래서 왜 그 뜻인가' 를 맡는다. */
/* 한국 표준이 아닌 자형이라는 알림. 뜻·음 바로 아래에 둔다. */
.notice {
    margin: 8px 0 0; padding: 9px 12px;
    background: var(--panel); border-radius: 6px;
    border-left: 3px solid var(--part-2);
    font-size: .93em; line-height: 1.6;
}

.origin {
    margin: 14px 0 0; padding: 12px 14px;
    background: var(--panel); border-radius: 8px;
    border-left: 3px solid var(--accent);
    line-height: 1.65;
}
.word-list .word { font-weight: 600; }
.word-list .word-hanja { font-family: var(--font-hanja-plain); color: var(--muted); margin: 0 8px 0 4px; }
.word-list .word-gloss { color: var(--muted); font-size: .93em; }
.source { color: var(--muted); font-size: .82em; margin-top: 10px; }

.legal p { margin: 0 0 12px; }
.legal h2 { font-size: 1.05em; }
.link-list { padding-left: 20px; margin: 0; }
.link-list li { margin-bottom: 4px; }
.footer-links { margin-top: 10px; }

footer.site { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .86em; }
footer.site a { color: var(--muted); text-decoration: underline; }

.index-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sound-block { margin-bottom: 20px; }
.sound-block h3 { font-size: 1em; margin: 0 0 6px; color: var(--muted); }
.hanja-list { display: flex; flex-wrap: wrap; gap: 8px; }
.hanja-list a { display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); font-family: var(--font-hanja-plain); font-size: 1.5em; line-height: 1.2; }

@media (max-width: 520px) {
    .entry-head .glyph { font-size: 4.4em; }
    body { padding: 16px 14px 48px; }
}

/* Shared hierarchy: quiet navigation, a primary workspace, and spaced sections. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[id] { scroll-margin-top: 24px; }
.skip-link { position: absolute; top: -100px; padding: 10px 16px; background: var(--bg); z-index: 50; }
.skip-link:focus { top: 8px; }
header.site nav a { color: var(--muted); padding: 8px 0; }
header.site nav a[aria-current] { color: var(--accent); font-weight: 650; }
.page-intro { margin-bottom: 28px; max-width: 680px; }
.page-intro .lead { margin-bottom: 0; }
.analyzer-panel { background: var(--panel); padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); }
.input-label { display: block; font-weight: 600; margin-bottom: 12px; }
.analyzer-panel textarea { display: block; }
.controls { gap: 10px; margin-top: 16px; }
.controls .order { margin-left: auto; }
.controls .status { flex-basis: 100%; font-size: .8em; }
.privacy-note { margin: 8px 0 0; color: var(--muted); font-size: .82em; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 36px 0 16px; }
.section-heading h2 { margin: 0; padding: 0; border: 0; }
.section-heading > a { font-size: .88em; flex-shrink: 0; }
.character-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.character-grid a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 8px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); text-align: center; font-size: .85em; }
.character-grid .glyph { font-family: var(--font-hanja-plain); font-size: 2.4em; line-height: 1.2; }
.character-grid a:hover, .hanja-list a:hover, .index-groups a:hover { background: var(--panel); border-color: var(--accent); text-decoration: none; }
.entry-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 16px 0; border-bottom: 1px solid var(--line); font-size: .88em; }
.entry-nav:empty { display: none; }
.entry-nav a { color: var(--muted); }
.entry-section { margin-top: 36px; }
.entry-section h2 { margin-top: 0; padding-bottom: 12px; }
.entry-head h1 { font-size: 1.6em; }
.entry-head .lead { font-size: .9em; margin-bottom: 20px; }
.entry-head .notice { margin-bottom: 18px; background: var(--bg); }
.word-list li { padding: 14px 0; }
.word-list .word-gloss { display: block; margin-top: 4px; }
.index-groups > a { display: flex; justify-content: space-between; padding: 14px 16px; color: var(--fg); border: 1px solid var(--line); border-radius: 8px; }
footer.site p { margin: 6px 0; }
@media (max-width: 640px) {
    body { padding: 20px 18px 48px; }
    header.site { margin-bottom: 28px; padding-bottom: 18px; }
    header.site .bar { gap: 8px; }
    header.site nav { gap: 12px; font-size: .82em; }
    h1 { font-size: 1.6em; }
    .analyzer-panel { padding: 16px; }
    .controls .order { margin-left: 0; }
    .character-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .entry-head { padding: 20px 16px; flex-direction: column; gap: 20px; }
    .entry-head .facts { width: 100%; }
    .entry-head .glyph { font-size: 4.4em; }
    .section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
    .entry-nav { gap: 10px 16px; }
    dl.facts-list { gap: 10px 12px; font-size: .93em; }
}

@media (min-width: 760px) {
    .entry-section .word-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
    .entry-section .word-list li { min-width: 0; overflow-wrap: anywhere; }
}
