:root {
    --bg: #ffffff;
    --fg: #1f2328;
    --muted: #656d76;
    --line: #d8dee4;
    --panel: #f6f8fa;
    --accent: #0969da;
    --radius: 8px;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-hanja: "LXGW WenKai TC", "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: #4493f8;
    }
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-ui);
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 20px 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 { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
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.6em; 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); }
p.lead { color: var(--muted); margin-top: 0; }

textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    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: #fff; }
button:hover { filter: brightness(1.06); }
.status { color: var(--muted); font-size: .9em; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(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); 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: 24px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.entry-head .glyph { font-family: var(--font-hanja); font-size: 6em; line-height: 1; }
.entry-head .facts { flex: 1; min-width: 220px; }
.entry-head .korean { font-size: 1.35em; font-weight: 600; margin: 6px 0 10px; }

dl.facts-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts-list dt { color: var(--muted); font-size: .9em; }
dl.facts-list dd { margin: 0; }

.dict-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; font-size: .92em; }

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 { font-family: var(--font-hanja); font-size: 1.5em; line-height: 1.2; }

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