:root {
  color-scheme: light;
  --bg: #f5eee1;
  --paper: #fbf7ef;
  --ink: #2a2320;
  --ink-2: #55493f;
  --ink-3: #8a7a6c;
  --line: #e1d5c3;
  --accent: #c8553d;
  --accent-ink: #fbf7ef;
  --sub: #f1dccf;
  --done: #efc9ba;
  --serif: "Noto Serif KR", "Apple SD Gothic Neo", serif;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #171513; --paper: #201d1a; --ink: #eee7dc; --ink-2: #c7bcae; --ink-3: #958879;
    --line: #3a342d; --accent: #e0705a; --accent-ink: #171513; --sub: #3a2a24; --done: #4a2a22;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0 auto; max-width: 46rem; padding: 0 16px; background: var(--bg); word-break: keep-all; overflow-wrap: anywhere; line-height: 1.6; }
a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: .5rem; background: var(--bg); padding: .4rem .8rem; z-index: 10; }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .4rem 1.2rem; padding: 1rem 0 .8rem; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.brand span { margin-left: .4rem; font-size: .72rem; font-weight: 500; letter-spacing: .06em; color: var(--ink-3); }
.top nav { display: flex; flex-wrap: wrap; gap: .2rem 1rem; font-size: .9rem; }
.top nav a { text-decoration: none; color: var(--ink-2); }

.intro { padding: 2rem 0 1.2rem; position: relative; }
.year { margin: 0; font-family: var(--serif); font-weight: 700; font-size: clamp(3.4rem, 17vw, 6.5rem); line-height: .9; color: var(--accent); letter-spacing: -.03em; }
h1, h2, h3 { font-family: var(--serif); letter-spacing: -.02em; line-height: 1.3; }
h1 { font-size: clamp(1.45rem, 5.6vw, 2.1rem); margin: .5rem 0 .6rem; }
.lead { margin: 0; color: var(--ink-2); max-width: 36em; }

/* 만들기 */
.maker { border-top: 2px solid var(--ink); padding-top: 1rem; }
.controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 4px; overflow: hidden; }
.seg[hidden] { display: none; }
.seg button { border: 0; background: transparent; padding: .5rem .9rem; font-size: .95rem; min-height: 40px; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }

.field { display: block; margin: 1rem 0 .4rem; }
.field span { display: block; font-size: .85rem; color: var(--ink-3); margin-bottom: .25rem; }
.field input { width: 100%; font: inherit; font-size: 1rem; padding: .55rem .7rem; border: 1.5px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); }
.field input:focus { border-color: var(--ink); outline: none; }

.step { margin: 1.1rem 0 .4rem; font-family: var(--serif); font-weight: 700; }
.step small { font-family: system-ui, sans-serif; font-weight: 400; color: var(--ink-3); margin-left: .4rem; font-size: .8rem; }
.hint { font-size: .86rem; color: var(--ink-2); margin: .7rem 0 .5rem; min-height: 1.4em; }

.block-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; max-width: 22rem; }
.nav-cell { position: relative; min-height: 3.3rem; padding: .35rem .3rem 1rem; border: 1.5px solid var(--accent); border-radius: 2px; background: var(--paper); font-size: .8rem; line-height: 1.25; text-align: center; overflow: hidden; }
.nav-cell.is-core { background: var(--sub); font-weight: 700; }
.nav-cell.is-empty { color: var(--ink-3); }
.nav-cell small { position: absolute; right: .3rem; bottom: .15rem; font-size: .68rem; color: var(--ink-3); }
.nav-cell[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.nav-cell[aria-pressed="true"] small { color: var(--accent-ink); }

.grid3, .bingo-grid { display: grid; gap: 4px; }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bingo-grid { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
.cell { position: relative; aspect-ratio: 1; background: var(--paper); border: 1.5px solid var(--line); border-radius: 2px; }
.cell.is-sub { background: var(--sub); border-color: var(--accent); }
.cell.is-core { background: var(--accent); border-color: var(--accent); }
.cell.is-core textarea { color: var(--accent-ink); font-weight: 700; }
.cell.is-core textarea::placeholder { color: var(--accent-ink); opacity: .7; }
.cell.is-sub textarea { font-weight: 600; }
.cell.is-done { background: var(--done); }
.cell.in-line { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.cell textarea { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: clamp(.72rem, 3.4vw, .95rem); line-height: 1.3; padding: .45rem .4rem 0; text-align: center; word-break: keep-all; overflow-wrap: anywhere; }
.bingo-grid.n5 .cell textarea { font-size: clamp(.66rem, 2.8vw, .85rem); padding: .3rem .2rem 0; }
.cell textarea::placeholder { color: var(--ink-3); opacity: .6; }
.cell textarea:focus { outline: 2px solid var(--ink); outline-offset: -2px; }
.chk { position: absolute; right: 2px; bottom: 2px; width: 24px; height: 24px; padding: 0; border: 0; background: transparent; }
.chk::before { content: ""; position: absolute; inset: 5px; border: 1.5px solid var(--ink-3); border-radius: 2px; background: var(--paper); }
.chk[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }
.chk[aria-pressed="true"]::after { content: ""; position: absolute; left: 9.5px; top: 7px; width: 5px; height: 9px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }

.tools-row { display: flex; gap: 1.2rem; margin: .6rem 0 0; }
.link-btn { border: 0; background: none; padding: .3rem 0; text-decoration: underline; text-underline-offset: .2em; color: var(--ink-2); font-size: .92rem; }

.output { margin-top: 1.4rem; border-top: 1px solid var(--line); }
.out-opts { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; }
.themes { display: flex; flex-wrap: wrap; gap: .4rem; }
.themes button { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .6rem .35rem .4rem; border: 1.5px solid var(--line); border-radius: 4px; background: var(--paper); font-size: .88rem; min-height: 40px; }
.themes button[aria-pressed="true"] { border-color: var(--ink); font-weight: 600; }
.swatch { position: relative; width: 22px; height: 22px; border: 2px solid; border-radius: 2px; }
.swatch i { position: absolute; inset: 5px; }
.preview-wrap { margin: .8rem 0; border: 1px solid var(--line); background: var(--paper); }
#preview { display: block; width: 100%; height: auto; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem; }
.actions button { padding: .75rem .3rem; border: 1.5px solid var(--ink); border-radius: 4px; background: var(--paper); font-weight: 600; font-size: .95rem; min-height: 46px; }
.actions .primary { background: var(--ink); color: var(--bg); }
.msg { min-height: 1.5em; font-size: .88rem; color: var(--accent); margin: .4rem 0 0; }

/* 본문 */
.content { margin-top: 2.6rem; }
.content section { border-top: 2px solid var(--ink); padding: 1rem 0 1.6rem; }
.content h2 { font-size: 1.35rem; margin: 0 0 .6rem; }
.content h3 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; }
.content p, .content li { color: var(--ink-2); }
.content ol { padding-left: 1.3rem; }
.content li { margin: .4rem 0; }
.mini { display: grid; grid-template-columns: repeat(3, 2.2rem); gap: 3px; margin: .8rem 0; }
.mini span { aspect-ratio: 1; border: 1.5px solid var(--accent); background: var(--sub); }
.mini span.c { background: var(--accent); color: var(--accent-ink); font-size: .62rem; display: grid; place-items: center; font-weight: 700; }
table.ex { border-collapse: collapse; width: 100%; max-width: 30rem; table-layout: fixed; font-size: .85rem; }
.ex td, .ex th { border: 1.5px solid var(--accent); padding: .5rem .3rem; text-align: center; height: 4.2rem; background: var(--paper); line-height: 1.3; }
.ex th { background: var(--sub); font-family: var(--serif); }
details { border-bottom: 1px solid var(--line); padding: .6rem 0; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: .5rem 0 .2rem; }

.foot { border-top: 1px solid var(--line); margin-top: 1rem; padding: 1.2rem 0 2rem; font-size: .82rem; color: var(--ink-3); }
.foot nav { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-bottom: .6rem; }
.foot p { margin: .3rem 0; }

/* 개인정보 등 읽기 페이지 */
.reading { padding: 1.5rem 0 2rem; }
.reading h1 { font-size: 1.6rem; }
.reading h2 { font-size: 1.15rem; margin-top: 1.6rem; }
.reading p, .reading li { color: var(--ink-2); }
