/* ── 색상 ───────────────────────────────── */
:root {
  --bg: #f6f6f4; --panel: #ffffff; --panel-2: #efefec; --line: #e2e2dd;
  --text: #1b1c1f; --muted: #6b6d74; --accent: #ff4655; --accent-ink: #d92a3a; --accent-soft: #ff465514;
  --ok: #1f9d55; --warn: #c27c0e; --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px #0000000d, 0 8px 24px #0000000a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f12; --panel: #16181d; --panel-2: #1d2027; --line: #2a2d35;
    --text: #e9e9ec; --muted: #9a9ca6; --accent: #ff4655; --accent-ink: #ff6b77; --accent-soft: #ff46551f;
    --ok: #3ecf7c; --warn: #f0b44a; --shadow: 0 1px 2px #0006, 0 8px 30px #0005;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; background: var(--panel-2); padding: .1em .35em; border-radius: 5px; }
img { max-width: 100%; height: auto; }

/* ── 버튼 ───────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: .6rem 1rem; border-radius: 10px; font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none !important; transition: transform .08s, background .15s, border-color .15s; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--accent-ink); border-color: var(--accent); }
.btn-lg { padding: .9rem 1.4rem; font-size: 1.05rem; width: 100%; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn .g { width: 20px; height: 20px; background: #fff; border-radius: 50%; padding: 2px; }

/* ── 브랜드 ─────────────────────────────── */
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; color: var(--text); letter-spacing: -.01em; text-decoration: none !important; }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }

/* ── 입장 화면 ──────────────────────────── */
.gate { min-height: 100vh; background:
  radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%),
  repeating-linear-gradient(90deg, transparent 0 79px, color-mix(in srgb, var(--line) 50%, transparent) 79px 80px),
  var(--bg); }
.gate-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.gate-card h1 { font-size: 1.6rem; line-height: 1.3; margin: 1.6rem 0 .6rem; letter-spacing: -.02em; }
.gate-card .lead { color: var(--muted); margin: 0 0 1.6rem; }
.gate-card .fine { color: var(--muted); font-size: .88rem; margin: 1.2rem 0 0; text-align: center; }
.gate-card .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.gate-card.tone-warn { border-top: 4px solid var(--accent); }
.gate-foot { margin-top: 1.2rem; font-size: .85rem; }
.gate-foot a { color: var(--muted); }
.who { display: flex; align-items: center; gap: .7rem; margin-top: 1.4rem; padding: .7rem .8rem; background: var(--panel-2); border-radius: 10px; }
.who img { width: 36px; height: 36px; border-radius: 50%; }
.who small { display: block; color: var(--muted); font-size: .75rem; line-height: 1.2; }
.who b { display: block; line-height: 1.3; }

/* ── 상단바 ─────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .8rem; height: 56px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .brand { font-size: .98rem; min-width: 0; }
.topbar .brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.3rem; cursor: pointer; padding: .2rem .4rem; }
.search-trigger { margin-left: auto; display: flex; align-items: center; gap: 1.5rem; background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 9px; padding: .35rem .5rem .35rem .8rem; font: inherit; font-size: .9rem; cursor: pointer; }
.search-trigger kbd { font-family: var(--mono); font-size: .75rem; border: 1px solid var(--line); border-radius: 5px; padding: 0 .35rem; }
.account { position: relative; }
.account summary { list-style: none; display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .9rem; font-weight: 600; }
.account summary::-webkit-details-marker { display: none; }
.account summary img { width: 30px; height: 30px; border-radius: 50%; }
.account .menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .4rem; box-shadow: var(--shadow); }
.account .menu a { display: block; padding: .5rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; }
.account .menu a:hover { background: var(--panel-2); }
.menu-meta { padding: .4rem .7rem; color: var(--muted); font-size: .82rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }

/* ── 본문 레이아웃 ──────────────────────── */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; padding: 18px 12px 40px; border-right: 1px solid var(--line); font-size: .92rem; }
.home-link { display: block; padding: .4rem .6rem; border-radius: 8px; color: var(--text); font-weight: 700; margin-bottom: .4rem; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: .9rem; border-left: 1px solid var(--line); margin-left: .75rem; }
.tree a { display: flex; gap: .4rem; padding: .3rem .6rem; border-radius: 7px; color: var(--muted); text-decoration: none; line-height: 1.45; }
.tree a:hover, .home-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.tree a.active, .home-link.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.tree summary { list-style: none; position: relative; cursor: pointer; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "›"; position: absolute; left: -.85rem; top: .3rem; color: var(--muted); transition: transform .15s; font-size: .9rem; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree li { position: relative; }
.tree > li > details > summary::before { left: -.55rem; }
.tree > li { padding-left: .3rem; }

.content { padding: 36px clamp(16px, 5vw, 64px) 120px; max-width: 920px; width: 100%; }
.crumbs { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.crumbs a { color: var(--muted); }
.page-title { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.25; letter-spacing: -.025em; margin: 0 0 1.6rem; }
.page-title .ico { margin-right: .5rem; }

/* ── 노션 본문 ──────────────────────────── */
.notion > * + * { margin-top: .55rem; }
.notion p { margin: .4rem 0; }
.notion p.empty { height: .6rem; margin: 0; }
.notion h2, .notion h3, .notion h4 { line-height: 1.35; letter-spacing: -.015em; margin: 2rem 0 .6rem; scroll-margin-top: 72px; }
.notion h2 { font-size: 1.55rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }
.notion h3 { font-size: 1.25rem; }
.notion h4 { font-size: 1.08rem; }
.notion ul, .notion ol { padding-left: 1.5rem; margin: .4rem 0; }
.notion li { margin: .2rem 0; }
.notion li::marker { color: var(--muted); }
.notion ul.todo { list-style: none; padding-left: .2rem; }
.notion ul.todo li.done { color: var(--muted); text-decoration: line-through; }
.notion .indent { padding-left: 1.5rem; }
.notion blockquote { margin: .8rem 0; padding: .2rem 0 .2rem 1rem; border-left: 3px solid var(--text); }
.notion hr { border: 0; border-top: 1px solid var(--line); margin: 1.6rem 0; }
.notion figure { margin: 1rem 0; }
.notion figure img, .notion figure video { border-radius: 10px; display: block; max-width: 100%; }
.notion figcaption { color: var(--muted); font-size: .85rem; margin-top: .4rem; }
.notion .ratio { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.notion .ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.notion .callout { display: flex; gap: .8rem; padding: 1rem 1.1rem; border-radius: 12px; margin: 1rem 0; }
.notion .callout > .ico { font-size: 1.2rem; line-height: 1.5; }
.notion .callout > div > *:first-child { margin-top: 0; }
.notion details.toggle { margin: .3rem 0; }
.notion details.toggle > summary { cursor: pointer; padding: .15rem 0; }
.notion details.toggle > summary::marker { color: var(--accent); }
.notion .toggle-body { padding-left: 1.4rem; }
.notion .toggle-h > summary { cursor: pointer; list-style: none; }
.notion .toggle-h > summary > * { display: inline; }
.notion .toggle-h > summary::before { content: "▸ "; color: var(--accent); }
.notion .toggle-h[open] > summary::before { content: "▾ "; }
.notion .columns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1.6rem; }
.notion .column > *:first-child { margin-top: 0; }
.notion figure.code pre { margin: 0; padding: 1rem 1.1rem; background: var(--panel-2); border-radius: 10px; overflow-x: auto; }
.notion figure.code code { background: none; padding: 0; font-size: .86rem; }
.notion .page-link { display: flex; align-items: center; gap: .55rem; padding: .45rem .6rem; margin: .15rem -.6rem; border-radius: 8px; color: var(--text); font-weight: 600; text-decoration: none; }
.notion .page-link:hover { background: var(--panel-2); }
.notion .page-link .ico { width: 1.4rem; text-align: center; }
.notion a[data-dead] { color: var(--muted); cursor: default; text-decoration: none; }
.notion .bookmark { display: flex; gap: .8rem; align-items: center; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; margin: .6rem 0; }
.notion .bookmark small { display: block; color: var(--muted); font-size: .8rem; }
.notion .file { font-weight: 600; }
.notion .toc { display: flex; flex-direction: column; gap: .1rem; padding: .8rem 1rem; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 10px 10px 0; }
.notion .toc a { color: var(--muted); font-size: .92rem; }
.notion .toc a.l3 { padding-left: 1rem; } .notion .toc a.l4 { padding-left: 2rem; }
.notion .muted { color: var(--muted); }
.notion .eq-block { text-align: center; margin: 1rem 0; }

/* 표 */
.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tr:last-child > td { border-bottom: 0; }
th { background: var(--panel-2); font-weight: 700; white-space: nowrap; font-size: .85rem; color: var(--muted); }
table.simple td + td, table.simple th + td, table.simple th + th, table.simple td + th { border-left: 1px solid var(--line); }
.db-table th { cursor: pointer; user-select: none; position: sticky; top: 0; }
.db-table th:hover { color: var(--text); }
.db-table th[data-sort="asc"]::after { content: " ↑"; color: var(--accent); }
.db-table th[data-sort="desc"]::after { content: " ↓"; color: var(--accent); }
.db-table td.title-cell a { font-weight: 700; color: var(--text); white-space: nowrap; }
.db-table td.title-cell .ico { margin-right: .35rem; }
.db-table tbody tr:hover { background: var(--accent-soft); }
.num, td[data-type="number"], td[data-type="formula"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.thumb { height: 36px; width: auto; border-radius: 6px; vertical-align: middle; }
.db-tools { display: flex; align-items: center; gap: .8rem; margin-top: .6rem; }
.db-filter { flex: 1; max-width: 320px; }
.db-count { color: var(--muted); font-size: .85rem; }
.inline-db { margin: 1.4rem 0; }
.db-title { margin: 0 !important; font-size: 1.1rem !important; border: 0 !important; }
.db-title a { color: var(--text); }
.db-desc { color: var(--muted); }
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 5px; font-size: .82rem; background: var(--panel-2); white-space: nowrap; }
dl.props { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: .4rem 1.4rem; padding: 0 0 1.2rem; margin: 0 0 1.4rem; border-bottom: 1px solid var(--line); font-size: .93rem; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

/* 노션 색상 */
.c-gray { color: #787774; } .c-brown { color: #9f6b53; } .c-orange { color: #d9730d; } .c-yellow { color: #cb912f; } .c-green { color: #448361; } .c-blue { color: #337ea9; } .c-purple { color: #9065b0; } .c-pink { color: #c14c8a; } .c-red { color: #d44c47; }
.c-gray-bg { background: #8a87821f; } .c-brown-bg { background: #a0705a24; } .c-orange-bg { background: #f2994a29; } .c-yellow-bg { background: #f2c94c33; } .c-green-bg { background: #4dab9a29; } .c-blue-bg { background: #529cca29; } .c-purple-bg { background: #9a6dd729; } .c-pink-bg { background: #e255a129; } .c-red-bg { background: #ff737329; }
@media (prefers-color-scheme: dark) {
  .c-gray { color: #9b9b9b; } .c-brown { color: #ba856f; } .c-orange { color: #e58a3a; } .c-yellow { color: #dfab43; } .c-green { color: #5fae86; } .c-blue { color: #5aa2d4; } .c-purple { color: #a985cc; } .c-pink { color: #d46ba0; } .c-red { color: #ea6b65; }
}

/* ── 검색 ───────────────────────────────── */
.search { position: fixed; inset: 0; z-index: 50; background: #0008; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.search[hidden] { display: none; }
.search-box { width: 100%; max-width: 620px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.search-box input { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 1rem 1.1rem; font-size: 1.05rem; }
.search-box ul { list-style: none; margin: 0; padding: .4rem; max-height: 60vh; overflow-y: auto; }
.search-box li a { display: block; padding: .6rem .8rem; border-radius: 8px; color: var(--text); text-decoration: none; }
.search-box li a:hover, .search-box li a.sel { background: var(--accent-soft); }
.search-box li small { display: block; color: var(--muted); font-size: .83rem; line-height: 1.5; }
.search-box mark { background: none; color: var(--accent-ink); font-weight: 700; }
.search-box .empty { padding: 1rem; color: var(--muted); text-align: center; }

/* ── 입력칸 ─────────────────────────────── */
input[type="text"], input[type="search"], select, textarea { font: inherit; font-size: .95rem; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: .55rem .75rem; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; font-family: var(--mono); font-size: .85rem; resize: vertical; }

/* ── 관리자 ─────────────────────────────── */
.admin-wrap { max-width: 920px; margin: 0 auto; padding: 28px 16px 80px; }
.admin-wrap.narrow { max-width: 620px; }
.admin-wrap h1 { letter-spacing: -.02em; margin: .4rem 0 1.2rem; }
.back { color: var(--muted); font-size: .9rem; }
.flash { padding: .8rem 1rem; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin: 1rem 0; }
.card h2 { font-size: 1.08rem; margin: 0 0 .7rem; display: flex; align-items: center; gap: .6rem; }
.card.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.card.danger { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .5rem 0; }
.row input[type="text"] { flex: 1; min-width: 200px; }
.stack { display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.stack textarea, .stack input[type="text"] { width: 100%; }
.radio { display: flex; gap: .5rem; align-items: center; cursor: pointer; }
.hint { color: var(--muted); font-size: .88rem; margin: .3rem 0 .7rem; }
.err { color: var(--accent-ink); font-size: .88rem; }
.pill { font-size: .75rem; font-weight: 700; padding: .1rem .55rem; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stats b { display: block; font-size: 1.6rem; font-family: var(--mono); line-height: 1.2; }
.stats span { color: var(--muted); font-size: .82rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 1rem 0 1.2rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
table.log td { font-size: .85rem; }
table.log tr.no td { color: var(--muted); }
table.log code { font-size: .75rem; }

/* 안내 문서 */
.plain { max-width: 720px; margin: 0 auto; padding: 40px 16px 80px; }
.plain h1 { margin-top: 1.6rem; }
.plain h2 { font-size: 1.15rem; margin-top: 1.8rem; }

/* ── 모바일 ─────────────────────────────── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .sidebar { position: fixed; top: 56px; left: 0; bottom: 0; width: min(86vw, 320px); height: auto; z-index: 30; background: var(--bg); transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 56px 0 0; background: #0006; z-index: 25; }
  .content { padding-top: 24px; }
  .search-trigger { gap: .4rem; } .search-trigger kbd { display: none; }
  .account summary span { display: none; }
  .notion .columns { grid-auto-flow: row; }
  .card.two, .stats { grid-template-columns: 1fr 1fr; }
  .card.two { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .topbar .brand span:last-child { display: none; } .gate-card { padding: 26px 20px; } }
