/* 청명검전 — 한지와 먹, 인주 빛 낙관 */

:root {
  --paper: #f3ecdf;
  --paper-2: #ebe2d0;
  --paper-3: #e2d7c2;
  --ink: #27221d;
  --ink-2: #5b5248;
  --ink-3: #8c8274;
  --line: #d4c8b2;
  --seal: #b1362b;
  --seal-2: #8f2a21;
  --on-seal: #fbf3e6;
  --sky: #3f6c82;
  --plum: #c05a68;
  --gold: #9c7629;
  --shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 8px 24px -16px rgba(60, 40, 20, .35);
  --grain-opacity: .35;
  --font-body: 'Gowun Batang', 'Noto Serif KR', 'Nanum Myeongjo', serif;
  --font-title: 'Song Myung', 'Gowun Batang', serif;
  --font-ui: 'Gowun Dodum', 'Noto Sans KR', system-ui, sans-serif;
  --read-size: 1.075rem;
  --measure: 34rem;
  --top: 3.25rem;
  --nav: 3.75rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14110e;
    --paper-2: #1c1814;
    --paper-3: #26211b;
    --ink: #ebe3d3;
    --ink-2: #bdb2a0;
    --ink-3: #887d6e;
    --line: #342d25;
    --seal: #c9483b;
    --seal-2: #a3372c;
    --on-seal: #fff4e8;
    --sky: #86aec2;
    --plum: #e08894;
    --gold: #d2aa5c;
    --shadow: 0 10px 28px -18px rgba(0, 0, 0, .8);
    --grain-opacity: .12;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14110e;
  --paper-2: #1c1814;
  --paper-3: #26211b;
  --ink: #ebe3d3;
  --ink-2: #bdb2a0;
  --ink-3: #887d6e;
  --line: #342d25;
  --seal: #c9483b;
  --seal-2: #a3372c;
  --on-seal: #fff4e8;
  --sky: #86aec2;
  --plum: #e08894;
  --gold: #d2aa5c;
  --shadow: 0 10px 28px -18px rgba(0, 0, 0, .8);
  --grain-opacity: .12;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
/* 한지 결: 아주 옅은 섬유 무늬 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .38  0 0 0 0 .28  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
#app { position: relative; z-index: 1; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 3px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── 낙관(도장) ── */
.seal {
  display: inline-grid;
  place-items: center;
  background: var(--seal);
  color: var(--on-seal);
  font-family: var(--font-title);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .05) inset, 0 0 0 3px color-mix(in srgb, var(--seal) 18%, transparent);
  line-height: 1;
}
.seal.sm { width: 1.75rem; height: 1.75rem; font-size: 1rem; }

/* ── 윗줄 ── */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  height: calc(var(--top) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: .75rem;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.top .brand { display: flex; align-items: center; gap: .55rem; min-width: 0; flex: 1; text-decoration: none; color: inherit; }
.top .brand-text { min-width: 0; display: grid; }
.top .brand b { font-family: var(--font-title); font-weight: 400; font-size: 1.15rem; letter-spacing: .04em; white-space: nowrap; }
.top .brand small { color: var(--ink-3); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 2.4rem; height: 2.4rem;
  display: grid; place-items: center;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2);
}
.icon-btn:active { background: var(--paper-3); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.progress { position: fixed; top: calc(var(--top) + env(safe-area-inset-top)); left: 0; height: 2px; background: var(--seal); z-index: 11; width: 0; transition: width .12s linear; opacity: .85; }

/* ── 본문 틀 ── */
.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.5rem max(1.25rem, env(safe-area-inset-right)) calc(var(--nav) + 2.5rem + env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
}
.page.no-nav { padding-bottom: calc(2.5rem + env(safe-area-inset-bottom)); }

/* ── 문(로그인) ── */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1.5rem; }
.gate-inner { width: min(21rem, 100%); display: grid; justify-items: center; gap: 1.6rem; text-align: center; }
.gate .seal.tall { writing-mode: vertical-rl; font-size: 2.4rem; letter-spacing: .14em; padding: 1.1rem .7rem; border-radius: 6px; transform: rotate(-1.5deg); }
.gate blockquote { margin: 0; font-family: var(--font-body); color: var(--ink-2); font-size: .98rem; line-height: 1.9; }
.gate form { width: 100%; display: grid; gap: .9rem; }
.field {
  width: 100%;
  border: 0; border-bottom: 1.5px solid var(--line);
  background: transparent;
  padding: .7rem .25rem;
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: .1em;
}
.field:focus { outline: none; border-color: var(--seal); }
.err { color: var(--seal); font-size: .9rem; min-height: 1.3em; }

/* ── 단추 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3rem; padding: 0 1.3rem;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--paper-2); color: var(--ink);
  font-family: var(--font-ui); font-size: 1rem;
  box-shadow: var(--shadow);
  transition: transform .12s ease, background .2s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--seal); border-color: var(--seal-2); color: var(--on-seal); }
.btn.primary:active { background: var(--seal-2); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ── 서재 ── */
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; margin: .5rem 0 1.25rem; }
.shelf-head h1 { font-family: var(--font-title); font-weight: 400; font-size: 1.6rem; margin: 0; letter-spacing: .06em; }
.shelf-head span { color: var(--ink-3); font-size: .85rem; }
.book {
  position: relative;
  margin-bottom: .9rem;
  border-radius: 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.book > a {
  display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center;
  padding: 1.1rem 3rem 1.1rem 1rem;
  text-decoration: none; color: inherit;
}
.book .del { position: absolute; top: .45rem; right: .4rem; color: var(--ink-3); width: 2.2rem; height: 2.2rem; }
.book .del svg { width: 1.05rem; height: 1.05rem; }
.spine {
  width: 3.1rem; height: 4.3rem; flex: none;
  border-radius: 4px 8px 8px 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--sky) 85%, black) 0 14%, var(--sky) 14%);
  display: grid; place-items: center;
  color: #f4efe6; font-family: var(--font-title); writing-mode: vertical-rl; font-size: .95rem; letter-spacing: .12em;
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .5);
}
.spine.ash { background: linear-gradient(90deg, #2c2a2a 0 14%, #4a4643 14%), #4a4643; color: #e6d9c2; font-family: var(--font-ui); font-size: .8rem; letter-spacing: .2em; }
.book .kind { font-size: .7rem; letter-spacing: .2em; color: var(--seal); }
.book h2 { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 1.2rem; }
.book p { margin: .15rem 0 0; color: var(--ink-2); font-size: .9rem; }
.book .meta { color: var(--ink-3); font-size: .78rem; margin-top: .35rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.book-text { min-width: 0; display: block; }
.shelf-sub { font-family: var(--font-title); font-weight: 400; font-size: 1.1rem; color: var(--ink-2); margin: 2rem 0 .8rem; letter-spacing: .06em; }
.tiles { display: grid; gap: .75rem; }
@media (min-width: 34rem) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile {
  display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: center;
  text-align: left; padding: .9rem 1rem;
  border-radius: 16px; border: 1px dashed color-mix(in srgb, var(--ink-3) 60%, var(--line));
  background: transparent; transition: background .2s, transform .12s;
}
.tile { color: inherit; text-decoration: none; }
.tile:active { transform: scale(.99); background: var(--paper-2); }
.tile .spine { width: 2.5rem; height: 3.5rem; }
.spine.mark { writing-mode: horizontal-tb; font-size: 1.35rem; letter-spacing: 0; }
.spine.mark svg { width: 1.4rem; height: 1.4rem; }
.tile b { display: block; font-family: var(--font-title); font-weight: 400; font-size: 1.12rem; }
.tile small { display: block; color: var(--ink-3); font-size: .8rem; line-height: 1.5; margin-top: .15rem; }
.tile[disabled] { opacity: .5; }
.tag { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--seal) 12%, transparent); color: var(--seal); font-size: .75rem; }
.tag.ok { background: color-mix(in srgb, var(--sky) 14%, transparent); color: var(--sky); }
.empty { text-align: center; color: var(--ink-3); padding: 2.5rem 1rem 1.5rem; display: grid; justify-items: center; gap: 1rem; font-family: var(--font-body); }
.empty svg { width: 9rem; height: auto; opacity: .85; }
.foot-actions { display: grid; gap: .75rem; margin-top: 1.5rem; }
.small-link { background: none; border: 0; color: var(--ink-3); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; padding: .5rem; }

/* ── 새로 펼치기: 분위기 고르기 ── */
.new-head { margin: .4rem 0 1.3rem; }
.new-head h1 { font-family: var(--font-title); font-weight: 400; font-size: 1.6rem; margin: 0 0 .4rem; letter-spacing: .04em; }
.new-head p { margin: 0; color: var(--ink-2); font-family: var(--font-body); font-size: .93rem; line-height: 1.75; word-break: keep-all; }
.moods { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.mood-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; gap: .15rem .6rem; align-items: center;
  text-align: left; padding: .8rem .8rem .85rem; border-radius: 14px;
  background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color .2s, background .2s, transform .12s;
}
.mood-card .seal { grid-row: 1; width: 1.8rem; height: 1.8rem; font-size: 1rem; background: transparent; color: var(--seal); box-shadow: 0 0 0 1.5px var(--seal) inset; }
.mood-card .seal svg { width: 1.1rem; height: 1.1rem; }
.mood-card b { font-family: var(--font-title); font-weight: 400; font-size: 1.12rem; }
.mood-card small { grid-column: 1 / -1; color: var(--ink-3); font-size: .78rem; line-height: 1.5; align-self: start; word-break: keep-all; }
.mood-card[aria-pressed="true"] { border-color: var(--seal); background: color-mix(in srgb, var(--seal) 8%, var(--paper-2)); }
.mood-card[aria-pressed="true"] .seal { background: var(--seal); color: var(--on-seal); }
.mood-card:active { transform: scale(.99); }
.mood-card.random { border-style: dashed; }
.note-label { display: block; margin: 1.4rem 0 .45rem; font-size: .9rem; color: var(--ink-2); }
.note-label small { color: var(--ink-3); font-size: .78rem; }
.note-field { width: 100%; padding: .75rem .9rem; margin-bottom: 1.1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-family: var(--font-body); font-size: .98rem; line-height: 1.6; resize: vertical; }
.note-field:focus { outline: none; border-color: var(--sky); }
.tag.mood { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-2); }

/* ── 회차 ── */
.chapter-head { text-align: center; margin: 1rem 0 2rem; }
.chapter-head .no { color: var(--seal); font-family: var(--font-ui); font-size: .82rem; letter-spacing: .3em; }
.chapter-head h1 { font-family: var(--font-title); font-weight: 400; font-size: 1.85rem; line-height: 1.35; margin: .5rem 0 .9rem; letter-spacing: .03em; word-break: keep-all; }
.brush { display: block; width: 7.5rem; height: .8rem; margin: 0 auto; color: var(--ink); opacity: .75; }
.prose { font-family: var(--font-body); font-size: var(--read-size); line-height: 2; word-break: keep-all; overflow-wrap: anywhere; letter-spacing: -.003em; }
.prose p { margin: 0 0 1.05em; text-indent: 1em; }
.prose p.talk { text-indent: 0; padding-left: .2em; }
.prose p.first { text-indent: 0; }
.prose strong { font-weight: 700; }
.prose em { font-style: normal; color: var(--sky); }
.prose .break { text-align: center; color: var(--ink-3); letter-spacing: 1.2em; margin: 1.8em 0; text-indent: 1.2em; font-size: .9em; }
.caret { display: inline-block; width: .55em; height: 1.05em; margin-left: .1em; vertical-align: -.15em; border-radius: 2px; background: var(--seal); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }

.writing-chip {
  position: sticky; top: calc(var(--top) + env(safe-area-inset-top) + .6rem); z-index: 5;
  width: fit-content; margin: 0 auto 1.25rem;
  display: flex; align-items: center; gap: .55rem;
  padding: .35rem .85rem .35rem .55rem;
  border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line);
  color: var(--ink-2); font-size: .82rem; box-shadow: var(--shadow);
}
.ink-drop { width: .9rem; height: .9rem; border-radius: 50%; background: var(--ink); animation: drop 1.6s ease-in-out infinite; }
@keyframes drop { 0%, 100% { transform: scale(.55); opacity: .5; } 50% { transform: scale(1); opacity: 1; } }
.grinding { display: grid; justify-items: center; gap: 1rem; padding: 3rem 0 2rem; color: var(--ink-3); font-family: var(--font-body); }
.inkstone { width: 4.5rem; height: 4.5rem; border-radius: 50%; position: relative; background: radial-gradient(circle at 50% 50%, var(--ink) 0 30%, transparent 31%); }
.inkstone::before, .inkstone::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--ink); opacity: 0; animation: ripple 2.4s ease-out infinite; }
.inkstone::after { animation-delay: 1.2s; }
@keyframes ripple { 0% { transform: scale(.35); opacity: .55; } 100% { transform: scale(1.15); opacity: 0; } }

/* ── 갈림길 ── */
.fork { margin-top: 2.5rem; }
.ornament { display: flex; align-items: center; gap: .9rem; color: var(--ink-3); font-family: var(--font-title); font-size: 1rem; margin: 2.2rem 0 1.25rem; }
.ornament::before, .ornament::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
.ornament svg { width: 1.1rem; height: 1.1rem; color: var(--plum); }
.hook { font-family: var(--font-body); text-align: center; color: var(--ink-2); font-size: .95rem; margin: -.3rem 0 1.4rem; }
.choice {
  width: 100%;
  display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: center;
  text-align: left;
  padding: .95rem 1rem;
  margin-bottom: .7rem;
  border-radius: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.6;
  transition: border-color .2s, background .2s, transform .12s;
}
.choice .num { width: 2rem; height: 2rem; font-size: 1.05rem; }
.choice .num.seal { background: transparent; color: var(--seal); box-shadow: 0 0 0 1.5px var(--seal) inset; }
.choice[aria-pressed="true"] { border-color: var(--seal); background: color-mix(in srgb, var(--seal) 8%, var(--paper-2)); }
.choice[aria-pressed="true"] .num.seal { background: var(--seal); color: var(--on-seal); }
.choice:active { transform: scale(.995); }
.confirm { display: grid; gap: .5rem; margin-top: .4rem; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.own { margin-top: 1.1rem; border-top: 1px dashed var(--line); padding-top: 1rem; }
.own summary { color: var(--ink-3); font-size: .9rem; cursor: pointer; list-style: none; text-align: center; }
.own summary::-webkit-details-marker { display: none; }
.own textarea {
  width: 100%; min-height: 5.5rem; margin: .8rem 0 .6rem;
  padding: .8rem .9rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.7; resize: vertical;
}
.own textarea:focus { outline: none; border-color: var(--sky); }
.picked {
  margin-top: 2rem; padding: .9rem 1rem; border-left: 3px solid var(--seal);
  background: color-mix(in srgb, var(--seal) 6%, transparent); border-radius: 0 10px 10px 0;
  font-family: var(--font-body); color: var(--ink-2);
}
.picked small { display: block; color: var(--ink-3); font-family: var(--font-ui); font-size: .75rem; letter-spacing: .15em; margin-bottom: .2rem; }
.nav-chapters { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.5rem; }
.nav-chapters .btn { flex: 1; min-height: 2.75rem; font-size: .9rem; }
.error-card { margin-top: 2rem; padding: 1.1rem; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--seal) 40%, var(--line)); background: color-mix(in srgb, var(--seal) 7%, var(--paper-2)); }
.error-card p { margin: 0 0 .9rem; color: var(--ink-2); font-size: .9rem; word-break: break-word; }
.finis { display: grid; justify-items: center; gap: .8rem; margin: 3rem 0 1rem; text-align: center; }
.finis .seal { width: 4rem; height: 4rem; font-size: 2rem; }
.finis b { font-family: var(--font-title); font-weight: 400; font-size: 1.3rem; }

/* ── 진하 ── */
.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.1rem; }
.card h2 { margin: 0 0 1rem; font-family: var(--font-title); font-weight: 400; font-size: 1.15rem; letter-spacing: .05em; display: flex; align-items: center; gap: .5rem; }
.card h2 .seal { width: 1.5rem; height: 1.5rem; font-size: .85rem; }
.hero { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; }
.hero .portrait { width: 4.25rem; height: 4.25rem; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--paper), var(--paper-3)); border: 1px solid var(--line); display: grid; place-items: center; }
.hero .portrait svg { width: 2.6rem; height: 2.6rem; color: var(--ink-2); }
.hero h1 { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 1.6rem; }
.hero .alias { color: var(--ink-3); font-size: .85rem; }
.hero .situ { grid-column: 1 / -1; margin: .25rem 0 0; font-family: var(--font-body); color: var(--ink-2); font-size: .95rem; }
.realms { display: grid; grid-template-columns: repeat(7, 1fr); gap: .3rem; margin-top: .3rem; }
.realm { text-align: center; font-size: .72rem; color: var(--ink-3); padding-top: .55rem; position: relative; }
.realm::before { content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: .3rem; border-radius: 99px; background: var(--paper-3); }
.realm.on::before { background: var(--ink-2); }
.realm.now { color: var(--seal); font-weight: 700; }
.realm.now::before { background: var(--seal); }
.realm-note { margin: .8rem 0 0; color: var(--ink-2); font-size: .88rem; font-family: var(--font-body); text-align: center; }
.axis { margin: 1.05rem 0 0; }
.axis:first-of-type { margin-top: .2rem; }
.axis .labels { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-3); }
.axis .labels .lean { color: var(--ink); font-weight: 700; }
.axis .track { position: relative; height: 1.4rem; margin: .3rem 0 .15rem; }
.axis .track::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; transform: translateY(-50%); background: linear-gradient(90deg, var(--plum), var(--line) 45% 55%, var(--sky)); border-radius: 2px; opacity: .55; }
.axis .notch { position: absolute; left: 50%; top: 22%; bottom: 22%; width: 1px; background: var(--ink-3); opacity: .6; }
.axis .tick { position: absolute; top: 50%; width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); opacity: .45; transform: translate(-50%, -50%); }
.axis .dot { position: absolute; top: 50%; width: 1.1rem; height: 1.1rem; border-radius: 50%; transform: translate(-50%, -50%); background: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 12%, transparent); transition: left .6s cubic-bezier(.2, .8, .2, 1); }
.axis .say { font-size: .8rem; color: var(--ink-3); text-align: center; font-family: var(--font-body); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.list li { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: baseline; font-family: var(--font-body); }
.list li::before { content: ''; width: .45rem; height: .45rem; border-radius: 2px; background: var(--seal); transform: rotate(45deg) translateY(-.1rem); }
.list.plain li::before { background: var(--ink-3); }
.muted { color: var(--ink-3); font-size: .88rem; font-family: var(--font-body); margin: 0; }

/* ── 인연 ── */
.person { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; align-items: center; padding: .9rem 0; border-top: 1px solid var(--line); }
.person:first-of-type { border-top: 0; padding-top: .2rem; }
.person b { font-family: var(--font-title); font-weight: 400; font-size: 1.12rem; }
.person p { grid-column: 1 / -1; margin: 0; color: var(--ink-2); font-size: .88rem; font-family: var(--font-body); }
.petals { display: flex; gap: .2rem; align-items: center; }
.petals svg { width: 1rem; height: 1rem; color: var(--plum); }
.petals svg.off { color: var(--line); }
.petals small { margin-left: .35rem; color: var(--ink-3); font-size: .75rem; }
.fame { display: grid; grid-template-columns: 2.6rem 1fr; gap: .4rem .8rem; align-items: center; font-size: .9rem; }
.fame .bar { position: relative; height: .5rem; border-radius: 99px; background: var(--paper-3); overflow: hidden; }
.fame .bar::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--ink-3); opacity: .6; }
.fame .fill { position: absolute; top: 0; bottom: 0; border-radius: 99px; transition: all .6s; }
.fame .fill.up { background: var(--sky); }
.fame .fill.down { background: var(--seal); }

/* ── 목차 ── */
.toc h3 { font-family: var(--font-title); font-weight: 400; font-size: 1.05rem; color: var(--ink-2); margin: 1.6rem 0 .5rem; letter-spacing: .08em; }
.toc a { display: grid; grid-template-columns: 2.6rem 1fr; gap: .6rem; padding: .8rem .2rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.toc a .n { color: var(--ink-3); font-size: .85rem; padding-top: .1rem; }
.toc a .t { font-family: var(--font-body); }
.toc a .p { display: block; color: var(--ink-3); font-size: .8rem; margin-top: .15rem; }
.toc a.now .n { color: var(--seal); }

/* ── TRPG: 잿빛 변경 ── */
:root { --ash: #4a4643; --ember: #c7782f; --slate: #191b1d; --slate-2: #23262a; --good: #3f7f6a; }
.center { text-align: center; }
.small { font-size: .8rem; }
.t-page { padding-top: 1rem; }
.meter { display: inline-block; position: relative; height: .42rem; border-radius: 99px; background: var(--paper-3); overflow: hidden; min-width: 3rem; }
.meter > span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--good); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.meter.mid > span { background: var(--gold); }
.meter.low > span { background: var(--seal); }
.meter.xp > span { background: var(--sky); }

.scene-card { position: relative; padding: 1rem 1.1rem 1.05rem; margin-bottom: 1.4rem; border-radius: 18px; background: linear-gradient(160deg, var(--paper-2), var(--paper-3)); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.scene-card::after { content: ''; position: absolute; right: -1.5rem; top: -1.5rem; width: 6rem; height: 6rem; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--ember) 22%, transparent), transparent 70%); pointer-events: none; }
.scene-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .78rem; color: var(--ink-3); }
.scene-top .when { letter-spacing: .12em; margin-right: auto; }
.clock-mini { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem .1rem .25rem; border-radius: 99px; background: color-mix(in srgb, var(--paper) 70%, transparent); color: var(--ink-2); text-decoration: none; font-size: .74rem; }
.clock-mini .clock { width: 1.05rem; height: 1.05rem; }
.scene-card h1 { margin: .3rem 0 .7rem; font-family: var(--font-title); font-weight: 400; font-size: 1.45rem; line-height: 1.35; word-break: keep-all; }
.party, .foes { display: grid; gap: .35rem; }
.foes { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line); }
.who-hp, .foe { display: grid; grid-template-columns: minmax(4.5rem, auto) 1fr auto; gap: .6rem; align-items: center; font-size: .85rem; }
.who-hp b, .foe b { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foe b { color: var(--seal); }
.who-hp small, .foe small { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.feed { display: grid; gap: 1.1rem; }
.more-btn { justify-self: center; border: 1px dashed var(--line); background: transparent; color: var(--ink-3); border-radius: 99px; padding: .4rem 1rem; font-size: .82rem; }
#latest { scroll-margin-top: calc(var(--top) + env(safe-area-inset-top) + .5rem); }
.gm-say { line-height: 1.95; }
.gm-say p { text-indent: 0; margin: 0 0 .8em; }
.gm-say p:last-child, .gm-say > :last-child { margin-bottom: 0; }
.gm-say h4 { font-family: var(--font-title); font-weight: 400; font-size: 1.15em; margin: .6em 0 .4em; }
.gm-say ul, .gm-say ol { margin: 0 0 .8em; padding-left: 1.3em; }
.gm-say li { margin: .15em 0; }
.gm-say blockquote { margin: 0 0 .9em; padding: .55em .9em; border-left: 3px solid var(--ember); background: color-mix(in srgb, var(--ember) 8%, transparent); border-radius: 0 10px 10px 0; color: var(--ink-2); }
.gm-say code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; background: var(--paper-3); padding: .05em .35em; border-radius: 5px; }
.gm-say .table { overflow-x: auto; margin: 0 0 .9em; }
.gm-say table { border-collapse: collapse; font-size: .88em; line-height: 1.6; min-width: 60%; }
.gm-say th, .gm-say td { border-bottom: 1px solid var(--line); padding: .35em .7em; text-align: left; }
.gm-say th { font-family: var(--font-ui); font-weight: 400; color: var(--ink-3); }
.me-say { justify-self: end; max-width: 85%; padding: .6rem .9rem .65rem; border-radius: 16px 16px 4px 16px; background: color-mix(in srgb, var(--sky) 13%, var(--paper-2)); border: 1px solid color-mix(in srgb, var(--sky) 25%, var(--line)); }
.me-say small { display: block; font-size: .7rem; color: var(--sky); letter-spacing: .1em; }
.me-say p { margin: 0; font-family: var(--font-body); white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }

.roll { justify-self: center; width: min(19rem, 100%); padding: .75rem .95rem; border-radius: 16px; background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow); }
.roll-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .78rem; color: var(--ink-3); }
.roll-head b { color: var(--ink); font-weight: 400; }
.roll-head .expr { font-variant-numeric: tabular-nums; white-space: nowrap; }
.roll-body { display: flex; align-items: center; justify-content: center; gap: .55rem; margin: .55rem 0 .35rem; }
.dice { display: inline-flex; gap: .4rem; }
.die { width: 2.3rem; height: 2.3rem; border-radius: 9px; background: var(--paper); border: 1.5px solid var(--ink-2); box-shadow: 0 2px 0 var(--ink-3); }
.die.d6 { display: grid; grid-template-columns: repeat(3, 1fr); padding: .32rem; gap: .1rem; }
.die.d6 i { display: block; border-radius: 50%; margin: auto; width: .38rem; height: .38rem; }
.die.d6 i.on { background: var(--ink); }
.die.dn { display: grid; place-items: center; align-content: center; line-height: 1; }
.die.dn b { font-size: 1rem; }
.die.dn small { font-size: .55rem; color: var(--ink-3); }
.roll .mod { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.roll .eq { color: var(--ink-3); }
.roll .total { font-family: var(--font-title); font-size: 1.9rem; line-height: 1; min-width: 2.2rem; text-align: center; }
.roll-foot { display: flex; justify-content: center; gap: .6rem; font-size: .82rem; }
.roll .tier { padding: .05rem .65rem; border-radius: 99px; }
.roll.strong { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.roll.strong .tier { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.roll.weak .tier { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.roll.miss { border-color: color-mix(in srgb, var(--seal) 40%, var(--line)); }
.roll.miss .tier { background: color-mix(in srgb, var(--seal) 13%, transparent); color: var(--seal); }
.roll .dealt { color: var(--seal); }
.roll.tumble .die { animation: tumble .9s cubic-bezier(.2, .7, .3, 1); }
.roll.tumble .die:nth-child(2) { animation-delay: .06s; }
.roll.tumble .total, .roll.tumble .roll-foot { animation: rise .35s ease .75s both; }
@keyframes tumble {
  0% { transform: translate(-2.5rem, -1.2rem) rotate(-200deg) scale(.7); opacity: 0; }
  55% { transform: translate(.3rem, .2rem) rotate(25deg) scale(1.05); opacity: 1; }
  75% { transform: translate(-.1rem, 0) rotate(-8deg); }
  100% { transform: none; }
}

.turn { margin-top: 1.6rem; display: grid; gap: .8rem; scroll-margin-bottom: calc(var(--nav) + 1rem + env(safe-area-inset-bottom)); }
.gm-busy { justify-self: center; display: flex; align-items: center; gap: .55rem; padding: .45rem 1rem .45rem .7rem; border-radius: 99px; background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-2); font-size: .85rem; box-shadow: var(--shadow); }
.ask-card { padding: 1rem 1.1rem 1.1rem; border-radius: 18px; border: 1.5px solid color-mix(in srgb, var(--ember) 55%, var(--line)); background: color-mix(in srgb, var(--ember) 7%, var(--paper-2)); box-shadow: var(--shadow); text-align: center; animation: rise .3s ease; }
.ask-move { display: flex; justify-content: center; align-items: center; gap: .45rem; font-family: var(--font-title); font-size: 1.25rem; }
.ask-move svg { width: 1.3rem; height: 1.3rem; color: var(--ember); }
.ask-move b { font-weight: 400; }
.ask-card p { margin: .3rem 0 .2rem; font-family: var(--font-body); color: var(--ink-2); font-size: .95rem; }
.ask-expr { font-size: .8rem; color: var(--ink-3); margin-bottom: .85rem; }
.roll-btn svg { width: 1.2rem; height: 1.2rem; }
.t-choices { display: grid; gap: .55rem; }
.t-choice { display: grid; grid-template-columns: auto 1fr; gap: .7rem; align-items: baseline; text-align: left; padding: .8rem 1rem; border-radius: 14px; background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow); font-family: var(--font-body); font-size: .98rem; line-height: 1.55; transition: transform .12s, border-color .2s; }
.t-choice .arrow { color: var(--seal); font-size: .75rem; }
.t-choice:active { transform: scale(.99); border-color: var(--seal); }
.t-choice[disabled] { opacity: .5; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: end; padding: .4rem .4rem .4rem .9rem; border-radius: 20px; border: 1px solid var(--line); background: var(--paper); }
.composer:focus-within { border-color: var(--sky); }
.composer textarea { border: 0; background: transparent; resize: none; padding: .5rem 0; font-family: var(--font-body); font-size: 1rem; line-height: 1.55; min-height: 2.6rem; max-height: 11rem; }
.composer textarea:focus { outline: none; }
.composer .send { width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--seal); color: var(--on-seal); }
.composer .send svg { width: 1.15rem; height: 1.15rem; }
.composer .send[disabled] { opacity: .45; }

.sheet-head { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; }
.sheet-head .portrait { width: 3.8rem; height: 3.8rem; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--paper), var(--paper-3)); border: 1px solid var(--line); display: grid; place-items: center; }
.sheet-head .portrait svg { width: 2.3rem; height: 2.3rem; color: var(--ink-2); }
.sheet-head h1 { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 1.5rem; }
.sheet-head .alias { color: var(--ink-3); font-size: .85rem; }
.sheet-head .situ { grid-column: 1 / -1; margin: 0; font-family: var(--font-body); color: var(--ink-2); font-size: .92rem; }
.vitals { display: grid; gap: .5rem; margin: 1.1rem 0 .9rem; }
.vitals > div { display: grid; grid-template-columns: 1.6rem 1fr 3.4rem; gap: .7rem; align-items: center; }
.vitals small { color: var(--ink-3); font-size: .75rem; }
.vitals .meter { height: .55rem; }
.vitals b { text-align: right; font-weight: 400; font-variant-numeric: tabular-nums; }
.vitals b span { color: var(--ink-3); font-size: .8em; }
.facts { display: flex; flex-wrap: wrap; gap: .5rem; }
.facts span { flex: 1; min-width: 4.5rem; display: grid; justify-items: center; padding: .45rem .3rem; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); }
.facts small { font-size: .7rem; color: var(--ink-3); }
.facts b { font-weight: 400; font-size: 1.05rem; }
h2.sub { font-family: var(--font-title); font-weight: 400; font-size: 1rem; color: var(--ink-2); margin: 1.3rem 0 .6rem; letter-spacing: .06em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.stat { display: grid; justify-items: center; padding: .5rem .2rem; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); }
.stat small { font-size: .75rem; color: var(--ink-3); }
.stat b { font-family: var(--font-title); font-weight: 400; font-size: 1.3rem; line-height: 1.2; }
.stat.up b { color: var(--good); }
.stat.down b { color: var(--seal); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips.warn { margin-top: .7rem; }
.chip { padding: .2rem .7rem; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); font-size: .85rem; }
.chips.warn .chip { border-color: color-mix(in srgb, var(--seal) 45%, var(--line)); color: var(--seal); }
.list .qty { color: var(--ink-3); font-size: .85em; }
.list .note { display: block; color: var(--ink-3); font-size: .8rem; font-family: var(--font-ui); }

.quest { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; align-items: baseline; padding: .7rem 0; border-top: 1px solid var(--line); }
.quest:first-of-type { border-top: 0; padding-top: .1rem; }
.quest .q-state { font-size: .72rem; padding: .05rem .5rem; border-radius: 99px; background: color-mix(in srgb, var(--ember) 14%, transparent); color: var(--ember); }
.quest.ok .q-state { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.quest.bad .q-state { background: color-mix(in srgb, var(--seal) 12%, transparent); color: var(--seal); }
.quest.ok b, .quest.bad b { color: var(--ink-3); }
.quest b { font-weight: 400; font-family: var(--font-body); }
.quest p { grid-column: 2; margin: 0; font-size: .85rem; color: var(--ink-2); font-family: var(--font-body); }
.person .met { color: var(--ink-3); font-size: .75rem; }
.person .list { grid-column: 1 / -1; margin-top: .3rem; font-size: .88rem; }

.map-card { margin: 0 -.5rem 1.1rem; padding: .8rem .7rem .9rem; border-radius: 18px; background: var(--slate); color: #c9c4ba; box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .7); }
.map-head { display: flex; align-items: center; gap: .5rem; margin: 0 .2rem .7rem; }
.map-head b { margin-right: auto; font-family: var(--font-title); font-weight: 400; font-size: 1.05rem; color: #ece6da; }
.chip-btn { border: 1px solid #3a3e44; background: var(--slate-2); color: #c9c4ba; border-radius: 99px; padding: .2rem .75rem; font-size: .8rem; }
.map-wrap { container-type: inline-size; border-radius: 10px; }
.map { font-family: ui-monospace, 'SF Mono', Menlo, 'DejaVu Sans Mono', 'Roboto Mono', monospace; font-size: calc(100cqw / (var(--cols) * .6)); line-height: 1.18; color: #8a8a8a; white-space: nowrap; }
.map .r { height: 1.18em; }
.map .c { display: inline-block; width: .6em; text-align: center; overflow: visible; }
.map .c.w { width: 1.2em; }
.map .c.at { color: #ffd75f; font-weight: 700; animation: here 1.6s ease-in-out infinite; }
@keyframes here { 50% { opacity: .45; } }
.map-wrap.big { overflow: auto; max-height: 70dvh; }
.map-wrap.big .map { font-size: 15px; width: max-content; padding: .2rem; }
.legend .leg { display: grid; grid-template-columns: 2rem 1fr; gap: .6rem; padding: .35rem 0; font-family: var(--font-body); font-size: .92rem; }
.legend .key { display: grid; place-items: center; height: 1.6rem; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }
.legend .leg.here .key { background: var(--seal); border-color: var(--seal); color: var(--on-seal); }
.legend small { color: var(--ink-3); }
.scene-text { margin: 0; font-family: var(--font-body); color: var(--ink-2); }

.clocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .8rem; }
.clock-item { display: grid; justify-items: center; text-align: center; gap: .25rem; }
.clock-item .clock { width: 3.6rem; height: 3.6rem; }
.clock-item b { font-weight: 400; font-family: var(--font-body); font-size: .92rem; line-height: 1.35; }
.clock-item small { color: var(--ink-3); font-size: .75rem; }
.clock path { fill: var(--paper); stroke: var(--ink-3); stroke-width: .8; }
.clock path.on { fill: var(--seal); }
.log-line { display: grid; grid-template-columns: 2.6rem 1fr; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); font-size: .88rem; font-family: var(--font-body); }
.log-line:first-of-type { border-top: 0; }
.log-line .k { justify-self: start; font-family: var(--font-ui); font-size: .7rem; color: var(--ink-3); padding-top: .2rem; }
.log-line .k.strong { color: var(--good); font-size: .9rem; padding-top: 0; }
.log-line .k.weak { color: var(--gold); font-size: .9rem; padding-top: 0; }
.log-line .k.miss { color: var(--seal); font-size: .9rem; padding-top: 0; }

/* ── 아래 길잡이 ── */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--nav) + env(safe-area-inset-bottom));
  padding: 0 max(.5rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(.5rem, env(safe-area-inset-left));
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.nav.five { grid-template-columns: repeat(5, 1fr); }
.nav a { display: grid; justify-items: center; align-content: center; gap: .15rem; color: var(--ink-3); text-decoration: none; font-size: .72rem; }
.nav a svg { width: 1.35rem; height: 1.35rem; }
.nav a[aria-current="page"] { color: var(--seal); }
@media (min-width: 46rem) {
  .nav { left: 50%; right: auto; width: 30rem; transform: translateX(-50%); bottom: 1rem; border-radius: 18px; border: 1px solid var(--line); height: var(--nav); padding: 0; box-shadow: var(--shadow); }
}

/* ── 알림 ── */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + 1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: 999px; font-size: .88rem; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); animation: rise .25s ease; max-width: calc(100% - 2rem); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
