:root {
  --bg: #faf7f5;
  --surface: #ffffff;
  --surface-2: #f3eeea;
  --text: #2b2420;
  --muted: #8a7e76;
  --line: #e7dfd8;
  --accent: #d0587e;
  --accent-soft: #fbe4ec;
  --accent-text: #a8345a;
  --badge: #efe9e4;
  --shadow: 0 1px 2px rgba(60, 40, 30, .06), 0 4px 16px rgba(60, 40, 30, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17141a; --surface: #211d24; --surface-2: #2a252e; --text: #ece6ef; --muted: #9d93a3;
    --line: #36303b; --accent: #ef7fa3; --accent-soft: #3b2431; --accent-text: #f5a3be; --badge: #2f2934;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17141a; --surface: #211d24; --surface-2: #2a252e; --text: #ece6ef; --muted: #9d93a3;
  --line: #36303b; --accent: #ef7fa3; --accent-soft: #3b2431; --accent-text: #f5a3be; --badge: #2f2934;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", sans-serif;
  font-size: 15px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; color: var(--text); white-space: nowrap; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; font-weight: 600; }
.nav a:hover { text-decoration: none; background: var(--surface-2); }
.nav a.on { background: var(--accent-soft); color: var(--accent-text); }
.theme-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; width: 34px; height: 34px; cursor: pointer; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 80px; }

/* profile hero */
.hero { display: flex; gap: 20px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 24px; }
.hero img { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; flex: none; }
.hero h1 { margin: 0; font-size: 22px; }
.hero .meaning { color: var(--muted); font-size: 13px; }
.hero .stats { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--muted); }
.hero .stats b { color: var(--text); }
.hero .links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--badge); color: var(--text); font-size: 12.5px; font-weight: 600; border: 0; cursor: pointer; white-space: nowrap; }
.chip:hover { text-decoration: none; filter: brightness(.97); }
.chip.on { background: var(--accent); color: #fff; }
.chip.adult { background: var(--accent-soft); color: var(--accent-text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.search { flex: 1 1 240px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select.sel { padding: 9px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; max-width: 100%; }
.count { color: var(--muted); font-size: 13px; }

h2.sec { font-size: 18px; margin: 32px 0 12px; display: flex; align-items: baseline; gap: 8px; }
h2.sec small { color: var(--muted); font-weight: 500; font-size: 13px; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); color: var(--text); display: flex; flex-direction: column; transition: transform .15s; }
.card:hover { text-decoration: none; transform: translateY(-2px); }
.card .thumb { aspect-ratio: 3 / 4; background: var(--surface-2); overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card .body { padding: 10px 12px 12px; }
.card .name { font-weight: 700; }
.card .sub { color: var(--muted); font-size: 12.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.grid.works { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card .thumb { position: relative; }
.marks { position: absolute; left: 8px; top: 8px; display: flex; gap: 4px; }
.mark { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.92); color: #2b2420; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.mark.adult { color: #b02a55; }
.mark.safe { color: #2e7d4f; }

/* version links */
.chat + .chat { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.chat > a { font-weight: 700; font-size: 14px; }
.vers { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.ver { text-align: center; padding: 8px 6px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.ver:hover { text-decoration: none; filter: brightness(.96); }
.ver.adult { background: var(--accent-soft); color: var(--accent-text); }
.ver.safe { background: color-mix(in srgb, #3fa36b 18%, var(--surface)); color: color-mix(in srgb, #2e7d4f 80%, var(--text)); }
.ver.none { background: var(--surface-2); color: var(--muted); font-weight: 500; }

/* detail */
.detail { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; }
.detail .side { position: sticky; top: 72px; }
.detail .cover { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); cursor: zoom-in; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-top: 14px; }
.panel h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 700; }
.kv { display: grid; grid-template-columns: 70px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.title-block h1 { margin: 0; font-size: 28px; line-height: 1.3; }
.title-block .work-of { color: var(--muted); margin-top: 2px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* character profile */
.profile { margin-top: 18px; }
.chip.kw { background: var(--accent-soft); color: var(--accent-text); }
.summary { margin: 0 0 16px; font-size: 15px; line-height: 1.75; }
.basics { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0; margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.basics > div { padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.basics dt { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.basics dd { margin: 2px 0 0; font-weight: 600; }

.variant + .variant { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.vname { font-weight: 800; font-size: 14px; margin-bottom: 6px; color: var(--accent-text); }
.vnote { font-size: 12px; color: var(--muted); margin-top: -4px; }
.taglabel { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tagbox { position: relative; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; margin: 6px 0 12px; }
.copy { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-family: inherit; }

.md { font-size: 14.5px; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .4em; line-height: 1.35; }
.md h2 { font-size: 17px; } .md h3 { font-size: 15.5px; }
.md p { margin: .5em 0; }
.md img { max-width: min(100%, 420px); border-radius: 10px; margin: 8px 0; cursor: zoom-in; }
.md pre { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: .6em 0; padding: 4px 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.md ul { padding-left: 1.3em; margin: .4em 0; }

details.fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; box-shadow: var(--shadow); }
details.fold > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "＋"; color: var(--muted); }
details.fold[open] > summary::after { content: "－"; }
details.fold > .inner { padding: 0 16px 14px; }

/* gallery */
.gallery { columns: 4 180px; column-gap: 10px; }
.gallery img { width: 100%; margin: 0 0 10px; border-radius: 10px; break-inside: avoid; cursor: zoom-in; background: var(--surface-2); }
.memo { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; break-inside: avoid; font-size: 14px; white-space: pre-wrap; }

/* qna */
.qa { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.qa .q { white-space: pre-wrap; font-size: 14px; color: var(--muted); }
.qa .q::before { content: "Q. "; font-weight: 800; color: var(--accent-text); }
.qa .a { white-space: pre-wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.qa .a::before { content: "A. "; font-weight: 800; color: var(--accent-text); }
.qa .foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.qa .foot .date { margin-right: 4px; }
mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.more { display: block; margin: 16px auto; padding: 10px 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* birthdays */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.month h3 { margin: 0 0 8px; color: var(--accent-text); }
.bday { display: flex; gap: 10px; align-items: center; padding: 6px 0; color: var(--text); }
.bday:hover { text-decoration: none; }
.bday img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: top; flex: none; background: var(--surface-2); }
.bday .d { font-weight: 800; width: 44px; color: var(--muted); font-size: 13px; }
.bday.today { background: var(--accent-soft); border-radius: 10px; padding: 6px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(10, 6, 12, .92); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 999px; width: 44px; height: 44px; font-size: 26px; cursor: pointer; }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 14px; color: #ddd; font-size: 13px; }

@media (max-width: 820px) {
  .detail { grid-template-columns: 1fr; }
  .detail .side { position: static; }
  .detail .cover { max-width: 360px; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 16px; gap: 8px; flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; }
  main { padding: 16px 16px 64px; }
  .hero { flex-direction: column; text-align: center; }
  .hero .stats, .hero .links { justify-content: center; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid.works { grid-template-columns: 1fr 1fr; }
  .gallery { columns: 2; }
  .title-block h1 { font-size: 23px; }
}
