:root {
  color-scheme: light;
  --ivory: #f6f1e6;
  --paper: #eee4d2;
  --brown: #482f1e;
  --gold: #e0c477;
  --muted: #78614e;
  --line: rgba(72, 47, 30, .20);
  --white: #fffdf8;
  font-family: Pretendard, "Noto Sans KR", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); scroll-behavior: smooth; }
body { margin: 0; color: var(--brown); background: radial-gradient(ellipse at 50% 0, #fffaf0, var(--paper) 68%); font-size: 14px; line-height: 1.65; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, select, summary { cursor: pointer; }
button, input, select { color: inherit; }
button { touch-action: manipulation; }
a { color: inherit; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 3px solid #94701e; outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
.skip-link { position: fixed; z-index: 200; left: 18px; top: -70px; padding: 12px 18px; border-radius: 10px; color: var(--gold); background: var(--brown); }
.skip-link:focus { top: 12px; }
.site-shell { width: 100%; margin: 0 auto; padding: 12px clamp(10px, 1vw, 18px) 24px; }
.site-nav { position: static; display: flex; align-items: center; gap: 8px; min-height: 56px; margin: 0 0 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(246, 241, 230, .96); box-shadow: 0 4px 16px rgba(72, 47, 30, .07); }
.site-brand { margin-right: auto; padding: 7px 11px; font-family: Georgia, "Times New Roman", serif; font-size: 19px; font-weight: 900; white-space: nowrap; text-decoration: none; }
.site-link { padding: 10px 14px; border: 1px solid transparent; border-radius: 12px; color: #684a32; font-size: 14px; font-weight: 800; white-space: nowrap; text-decoration: none; }
.site-link:hover, .site-link[aria-current="page"] { border-color: var(--line); color: var(--gold); background: var(--brown); }
.gallery-shell { min-height: 65vh; padding: clamp(12px, 1.4vw, 18px); border: 1px solid var(--line); border-radius: 18px; background: var(--ivory); box-shadow: 0 12px 36px rgba(72, 47, 30, .07); }
.character-nav { position: sticky; top: 8px; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 0 0 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--ivory); box-shadow: 0 3px 12px #482f1e0d; }
.character-chip { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; min-height: 28px; padding: 4px 8px; border: 1px solid #482f1e36; border-radius: 6px; color: var(--brown); background: var(--white); font: 700 12px/1.35 Consolas, "Courier New", monospace; text-decoration: none; white-space: nowrap; }
.character-chip:hover { border-color: #8f7542; background: #eee4d2; }
.character-chip[aria-pressed="true"] { border-color: var(--brown); color: var(--gold); background: var(--brown); }
.character-chip:focus-visible { position: relative; z-index: 1; outline-offset: 2px; }
.directory-chip { padding-right: 10px; padding-left: 10px; font-family: inherit; font-size: 11px; }
.gallery-shell[data-view="detail"] > .page-heading { display: none; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; padding: 0 0 26px; border-bottom: 1px solid var(--line); }
.eyebrow { margin-bottom: 4px; color: #80652e; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
h1 { font-size: clamp(27px, 3.2vw, 42px); font-weight: 850; letter-spacing: -.055em; line-height: 1.3; }
.page-intro { margin-top: 10px; color: var(--muted); font-size: 14px; word-break: keep-all; }
.gallery-help { position: relative; flex: 0 0 auto; margin-top: 9px; color: var(--muted); font-size: 12px; }
.gallery-help summary { padding: 8px 0; text-decoration: underline; text-underline-offset: 4px; }
.help-content { position: absolute; z-index: 20; top: 44px; right: 0; width: 320px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); box-shadow: 0 12px 30px #482f1e1a; word-break: keep-all; }
.help-content p + p { margin-top: 9px; }
.catalog-status { min-height: 18px; margin: 6px 0 8px; color: var(--muted); font-size: 11px; }
.catalog-status:empty { display: none; }
.directory-toolbar { display: flex; align-items: flex-end; gap: 12px; margin: 25px 0 28px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.field label, .field-label { font-size: 12px; font-weight: 750; }
.search-field { flex: 1 1 400px; }
.region-field { flex: 0 1 240px; }
.search-control { position: relative; }
.search-control svg { position: absolute; top: 50%; left: 15px; transform: translateY(-50%); color: #91785b; pointer-events: none; }
input[type="search"], select { width: 100%; min-height: 46px; border: 1px solid #482f1e36; border-radius: 11px; background: var(--white); padding: 10px 13px; font-size: 13px; }
input[type="search"] { padding-left: 44px; }
input::placeholder { color: #998776; }
select { padding-right: 28px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 9px 15px; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; font-weight: 750; line-height: 1.5; text-align: center; text-decoration: none; transition: background .15s, border-color .15s; }
.button-primary { color: var(--gold); background: var(--brown); border-color: var(--brown); }
.button-primary:hover { background: #63452e; border-color: #63452e; }
.button-quiet { color: var(--brown); background: transparent; }
.button-quiet:hover { background: #eadfc9; border-color: #482f1e66; }
.reset-filters { min-height: 46px; flex-shrink: 0; }
.section-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin: 0 0 15px; }
.section-caption h2, .section-caption h3 { font-size: 17px; font-weight: 800; letter-spacing: -.03em; }
.section-caption p { color: var(--muted); font-size: 12px; text-align: right; }
.character-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; align-items: start; }
.scene-grid { display: grid; grid-template-columns: repeat(var(--scene-columns, 4), minmax(0, 1fr)); gap: 8px; align-items: start; }
.character-card, .scene-card { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--white); overflow: hidden; box-shadow: 0 3px 10px #482f1e05; }
.scene-card { border-radius: 6px; box-shadow: none; }
.character-card { display: block; width: 100%; padding: 0; text-align: left; transition: transform .18s, box-shadow .18s, border-color .18s; }
.character-card:hover { transform: translateY(-3px); border-color: #9f8244; box-shadow: 0 10px 24px #482f1e15; }
.character-card:focus-visible { outline-offset: 3px; }
.character-media, .scene-media { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; width: 100%; background: linear-gradient(145deg, #f9f6ef, #ece6d9); overflow: hidden; }
.character-media::after, .scene-media::after { position: absolute; inset: 0; border-bottom: 1px solid #482f1e0d; content: ""; pointer-events: none; }
.character-media img, .scene-media img { display: block; width: 100%; height: 100%; min-width: 0; object-fit: contain; object-position: center; }
.image-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; color: var(--muted); font-size: 12px; text-align: center; line-height: 1.7; }
.image-placeholder::before { content: "◇"; color: #b49a60; font-family: Georgia, serif; font-size: 36px; line-height: 1; }
.character-media { aspect-ratio: 1216 / 832; }
.scene-media { aspect-ratio: 1; }
.scene-number-badge { position: absolute; z-index: 2; bottom: 6px; left: 6px; min-width: 22px; padding: 3px 5px; border: 1px solid #ffffff30; border-radius: 4px; color: #fff; background: rgba(27, 20, 15, .8); font: 700 11px/1.2 Consolas, "Courier New", monospace; text-align: center; box-shadow: 0 1px 4px #0003; pointer-events: none; }
.character-info { display: block; padding: 15px 17px 17px; }
.card-overline { display: block; margin-bottom: 5px; color: #8b743f; font-size: 10px; font-weight: 750; letter-spacing: .025em; overflow-wrap: anywhere; }
.character-info h2 { display: inline; margin-right: 8px; font-size: 18px; font-weight: 850; letter-spacing: -.045em; }
.character-code { display: inline-block; color: #8b796a; font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.card-description { display: -webkit-box; min-height: 40px; margin: 7px 0 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.empty-state { padding: 64px 20px; border: 1px dashed #482f1e42; border-radius: 16px; background: #ffffff38; text-align: center; }
.empty-mark { display: block; margin-bottom: 13px; color: #b49a60; font-family: Georgia, serif; font-size: 35px; }
.empty-state h3 { margin-bottom: 7px; font-size: 17px; }
.empty-state p { color: var(--muted); font-size: 13px; word-break: keep-all; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 22px 0; padding: 20px; border: 1px solid #b88858; border-radius: 12px; background: #f1e5d2; font-size: 13px; }
.back-link { text-decoration: none; display: inline-flex; align-items: center; gap: 7px; margin: 0 0 5px; padding: 4px 0; border: 0; color: var(--muted); background: none; font-size: 11px; font-weight: 750; }
.back-link:hover { color: var(--brown); text-decoration: underline; text-underline-offset: 4px; }
.back-link span { font-size: 19px; line-height: 1; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.detail-identity { min-width: 0; }
.detail-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.detail-name h2 { font-size: clamp(21px, 2vw, 26px); font-weight: 850; letter-spacing: -.055em; line-height: 1.3; }
.detail-code { padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #e9dfcc66; font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.detail-description { max-width: 740px; margin-top: 5px; color: var(--muted); font-size: 12px; word-break: keep-all; }
.detail-background { max-width: 860px; margin: 0 0 16px; font-size: 13px; line-height: 1.8; word-break: keep-all; overflow-wrap: anywhere; }
.detail-background-title { margin: 0 0 6px; color: var(--brown); font-size: 14px; font-weight: 800; line-height: 1.5; }
.detail-background > p + p { margin-top: 6px; }
.detail-default-mode { color: inherit; font: inherit; }
.detail-background[data-layout="compact"] { line-height: 1.5; }
.detail-background[data-layout="compact"] > p { white-space: pre-line; }
.detail-background[data-layout="compact"] > .detail-default-mode { margin-top: 4px; }
.detail-default-mode-title { margin: 8px 0 6px; color: var(--brown); font-size: 14px; font-weight: 800; line-height: 1.5; }
.detail-background[data-layout="compact"] > .detail-default-mode-title + .detail-default-mode { margin-top: 0; }
.character-picker-field { flex: 0 0 230px; padding-top: 3px; }
.scene-toolbar { margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #eee4d266; }
.scene-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; }
.scene-filter-section { flex: 0 0 auto; }
.density-control { display: grid; flex: 1 1 260px; grid-template-columns: minmax(0, 1fr); gap: 3px; min-width: 180px; max-width: 420px; margin-left: auto; }
.density-control label { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 12px; font-weight: 750; }
.density-control output { min-width: 24px; padding: 1px 6px; border-radius: 5px; color: var(--gold); background: var(--brown); font: 700 12px/1.5 Consolas, "Courier New", monospace; text-align: center; }
.density-control input[type="range"] { display: block; width: 100%; min-width: 0; height: 26px; margin: 0; border-radius: 5px; accent-color: var(--brown); cursor: pointer; }
.density-control input[type="range"]:focus-visible { outline: 3px solid #94701e; outline-offset: 2px; }
.density-control small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.scene-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.scene-filters .filter-chip { min-height: 28px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--ivory); font-size: 11px; line-height: 1.5; }
.scene-filters button:hover { border-color: #8f7542; color: var(--brown); }
.scene-filters .filter-chip.active { border-color: var(--brown); color: var(--gold); background: var(--brown); }
.scene-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; padding-top: 8px; border-top: 1px solid #482f1e1c; }
.scene-actions .button { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; cursor: pointer; }
.checkbox-label input { width: 16px; height: 16px; margin: 0; accent-color: var(--brown); }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.scene-caption { align-items: flex-start; margin-bottom: 8px; }
.scene-caption h3 { font-size: 15px; }
.scene-caption p { max-width: 72%; }
.scene-open { display: block; width: 100%; padding: 0; border: 0; background: none; }
.scene-open:hover .scene-media { background: #e8dfce; }
.scene-open:focus-visible { position: relative; z-index: 1; outline-offset: -4px; }
.scene-card[data-state="loading"] .scene-media { animation: loading-soft 1.8s ease-in-out infinite alternate; }
.scene-card[data-state="error"] { border-style: dashed; }
.scene-card[data-state="error"] .scene-media { background: #f0e9dc; }
.site-footer { margin-top: 23px; color: #806c58; font-size: 11px; letter-spacing: .04em; text-align: center; }
.site-footer span { margin: 0 7px; color: #aa925c; }
.image-viewer { width: min(1040px, calc(100% - 36px)); max-width: none; max-height: calc(100dvh - 36px); padding: 0; border: 1px solid #d4c4a3; border-radius: 18px; color: var(--brown); background: var(--ivory); box-shadow: 0 30px 100px #0005; overflow: hidden; }
.image-viewer[open] { display: flex; flex-direction: column; }
.image-viewer::backdrop { background: rgba(32, 22, 16, .79); backdrop-filter: blur(5px); }
.viewer-heading { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 20px; min-height: 62px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.viewer-heading h2 { font-size: 16px; letter-spacing: -.025em; }
.icon-button { display: flex; flex-shrink: 0; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--brown); background: transparent; font-size: 28px; line-height: 1; }
.icon-button:hover { background: #e7dbc6; }
.viewer-stage { position: relative; display: flex; flex: 1 1 auto; align-items: center; justify-content: center; min-height: 120px; height: min(69dvh, 900px); padding: 14px 58px; background: #e9e2d5; overflow: hidden; }
.viewer-stage img { display: block; width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.viewer-arrow { position: absolute; z-index: 2; top: 50%; display: flex; align-items: center; justify-content: center; width: 38px; height: 48px; transform: translateY(-50%); padding: 0 0 4px; border: 1px solid var(--line); border-radius: 10px; color: var(--brown); background: #fffdf8e8; box-shadow: 0 2px 10px #482f1e0d; font-family: Georgia, serif; font-size: 36px; line-height: 1; }
.viewer-arrow:hover { background: var(--gold); }
.viewer-prev { left: 11px; }
.viewer-next { right: 11px; }
.viewer-error { position: absolute; max-width: 360px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--white); font-size: 13px; text-align: center; }
.viewer-footer { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--line); }
.viewer-footer > p { min-width: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.viewer-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.toast { position: fixed; z-index: 100; bottom: 28px; left: 50%; max-width: calc(100% - 32px); transform: translateX(-50%); padding: 12px 20px; border: 1px solid #e0c47766; border-radius: 12px; color: var(--ivory); background: var(--brown); box-shadow: 0 8px 28px #24180f38; font-size: 13px; text-align: center; pointer-events: none; }
.toast:empty { display: none; }
.copy-fallback { width: min(520px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 16px; color: var(--brown); background: var(--ivory); }
.copy-fallback::backdrop { background: #201610b0; }
.copy-fallback label { display: block; font-size: 13px; }
.copy-fallback textarea { display: block; width: 100%; min-height: 110px; margin: 15px 0; padding: 12px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font: 12px/1.7 Consolas, monospace; }
.copy-fallback button { min-height: 42px; padding: 8px 18px; border: 1px solid var(--brown); border-radius: 9px; background: var(--brown); color: var(--gold); }
@keyframes loading-soft { from { opacity: .6; } to { opacity: 1; } }
@media (max-width: 1150px) {
  .site-nav { gap: 3px; padding: 10px; }
  .site-brand { font-size: 17px; padding-left: 7px; }
  .site-link { padding: 9px 10px; font-size: 13px; }
  .character-grid { gap: 15px; }
  .character-info { padding: 13px; }
  .character-info h2 { font-size: 17px; }
}
@media (max-width: 980px) {
  .character-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-heading { gap: 18px; }
  .gallery-help { font-size: 11px; }
  .site-brand { font-size: 15px; }
  .site-link { padding: 9px 8px; font-size: 12px; }
}
@media (max-width: 720px) {
  .site-shell { padding: 8px 10px 24px; }
  .site-nav { flex-wrap: wrap; justify-content: center; gap: 3px; padding: 8px 7px; border-radius: 12px; margin-bottom: 8px; }
  .site-brand { flex-basis: 100%; margin-right: 0; padding: 3px 5px 6px; font-size: 14px; text-align: center; }
  .site-link { min-height: 35px; padding: 6px 10px; border-radius: 8px; font-size: 11px; }
  .gallery-shell { padding: 12px; border-radius: 14px; }
  .character-nav { position: static; gap: 5px; padding: 7px; }
  .character-chip { min-height: 28px; padding-right: 7px; padding-left: 7px; }
  .page-heading { flex-direction: column; gap: 8px; padding-bottom: 20px; }
  .page-intro { max-width: 340px; font-size: 12px; line-height: 1.8; }
  .gallery-help { align-self: flex-start; margin-top: 0; font-size: 11px; }
  .help-content { position: static; width: auto; max-width: 440px; margin-top: 7px; box-shadow: none; }
  .directory-toolbar { flex-wrap: wrap; gap: 12px 9px; margin: 23px 0; }
  .search-field { flex-basis: 100%; }
  .region-field { flex: 1 1 180px; }
  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .detail-heading { flex-wrap: wrap; gap: 10px; }
  .character-picker-field { flex: 1 1 100%; max-width: 320px; }
  .scene-toolbar { padding: 10px; }
  .scene-controls { gap: 10px 14px; }
  .density-control { flex-basis: 180px; min-width: 140px; }
  .scene-actions { align-items: flex-start; }
  .scene-filters { gap: 6px; }
  .scene-filters .filter-chip { padding: 4px 9px; font-size: 11px; }
  .action-buttons { width: 100%; }
  .action-buttons .button { flex: 1 1 auto; }
  .scene-caption { flex-wrap: wrap; gap: 5px; }
  .scene-caption p { max-width: 100%; text-align: left; }
  .notice { align-items: flex-start; flex-direction: column; gap: 13px; }
  .image-viewer { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 13px; }
  .viewer-heading { min-height: 55px; padding: 9px 12px; }
  .viewer-heading h2 { font-size: 14px; }
  .viewer-stage { height: 64dvh; padding: 8px 0; }
  .viewer-arrow { width: 31px; height: 43px; background: #fffdf8d9; font-size: 30px; }
  .viewer-prev { left: 6px; }
  .viewer-next { right: 6px; }
  .viewer-footer { gap: 9px; padding: 11px 12px; }
  .viewer-footer > p { flex-basis: 100%; }
  .viewer-actions { width: 100%; gap: 5px; }
  .viewer-actions .button { flex: 1 1 auto; min-height: 39px; padding: 8px; font-size: 10px; }
}
@media (max-width: 410px) {
  .site-link { padding-right: 8px; padding-left: 8px; }
  .gallery-shell { padding: 12px; }
  .eyebrow { font-size: 10px; }
  h1 { font-size: 28px; }
  .character-grid { gap: 10px; }
  .character-card { border-radius: 11px; }
  .character-info { padding: 11px; }
  .character-info h2 { display: block; margin-right: 0; font-size: 16px; }
  .character-code { font-size: 10px; }
  .card-overline { font-size: 9px; }
  .card-description { margin-top: 5px; font-size: 11px; min-height: 36px; }
  .section-caption h2, .section-caption h3 { font-size: 16px; }
  .section-caption p { font-size: 11px; }
  .empty-state { padding: 40px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
