/* =========================================================
   별을 키우는 집 — in-game dashboard shell
   Palette: cream parchment / forest green / antique gold / ink brown
   ========================================================= */

:root{
  /* surfaces */
  --paper:        oklch(95.5% 0.018 88);
  --paper-2:      oklch(92.8% 0.020 86);
  --paper-3:      oklch(89.5% 0.022 84);
  --paper-sunk:   oklch(87.0% 0.024 82);
  --ink:          oklch(28.0% 0.020 60);
  --ink-soft:     oklch(42.0% 0.019 62);
  --ink-faint:    oklch(56.0% 0.016 64);

  /* accents — same C/L, hue only varies */
  --green:        oklch(43.0% 0.072 155);
  --gold:         oklch(43.0% 0.072 82);
  --green-lift:   oklch(62.0% 0.058 155);
  --gold-lift:    oklch(62.0% 0.058 82);
  --green-wash:   oklch(43.0% 0.072 155 / 0.10);
  --gold-wash:    oklch(43.0% 0.072 82 / 0.12);

  --rule:         oklch(43.0% 0.030 90 / 0.28);
  --rule-soft:    oklch(43.0% 0.030 90 / 0.15);
  --ledger-line:  oklch(43.0% 0.045 160 / 0.13);

  --warn:         oklch(45.0% 0.090 55);
  --warn-wash:    oklch(45.0% 0.090 55 / 0.12);

  --shadow-1: 0 1px 0 oklch(100% 0 0 / .55) inset, 0 1px 2px oklch(28% .02 60 / .12);
  --shadow-2: 0 2px 10px oklch(28% .02 60 / .13), 0 1px 0 oklch(100% 0 0 / .5) inset;

  --serif: "Gowun Batang", "Nanum Myeongjo", serif;
  --sans: "IBM Plex Sans KR", system-ui, "Malgun Gothic", sans-serif;

  --r: 3px;

  /* HUD v2 토큰 (main-hud-v2 시안). 기존 토큰(--paper, --paper-2, --ink, --ink-soft)은 위의 값을 그대로 쓴다.
     --hud-corner 는 data: URL이 CSP(img-src 'self')에 막혀 none으로 둔다. */
  --hud-bg: oklch(24% 0.045 15);
  --hud-bg-2: oklch(30% 0.05 18);
  --hud-bg-3: oklch(18.5% 0.04 15);
  --hud-line: oklch(74% 0.07 55);
  --hud-line-soft: oklch(74% 0.07 55 / 0.35);
  --hud-text: oklch(94% 0.02 85);
  --hud-text-soft: oklch(80% 0.03 70);
  --hud-accent: oklch(80% 0.10 75);
  --hud-good: oklch(72% 0.10 150);
  --hud-warn: oklch(72% 0.13 45);
  --paper-line: oklch(68% 0.04 60);
  --ink-good: oklch(40% 0.09 150);
  --ink-warn: oklch(44% 0.13 40);

  --stat-stamina: oklch(68% 0.14 25);
  --stat-intellect: oklch(70% 0.10 240);
  --stat-charm: oklch(72% 0.13 350);
  --stat-kindness: oklch(74% 0.11 150);
  --stat-sword: oklch(72% 0.11 70);
  --stat-magic: oklch(68% 0.12 300);
  --stat-stress: oklch(62% 0.03 60);
  --stat-affinity: var(--hud-accent);

  --hud-serif: "Gowun Batang", "Noto Serif KR", "Batang", serif;
  --hud-sans: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --hud-mono: ui-monospace, "Cascadia Mono", Consolas, "D2Coding", monospace;
  --hud-shadow: 0 1px 0 oklch(15% 0.03 15 / .55), 0 12px 26px -10px oklch(22% 0.04 25 / .5);
  --hud-corner: none;
  --hud-stripes: repeating-linear-gradient(135deg,var(--hud-bg-2) 0 8px,oklch(35% 0.05 20) 8px 16px);
}

*,*::before,*::after{ box-sizing:border-box; }

html{ -webkit-text-size-adjust:100%; }

body{
  margin:0;
  font-family:var(--sans);
  font-size:15px;
  line-height:1.6;
  color:var(--ink);
  background-color:var(--paper-3);
  background-image:
    repeating-linear-gradient(0deg,
      oklch(28% .02 60 / .022) 0 1px, transparent 1px 3px),
    radial-gradient(120% 80% at 50% -10%, oklch(98% .012 90) 0%, transparent 60%);
  min-height:100vh;
}

[hidden]{ display:none !important; }

/* =========================================================
   Account gate — Claude account-component study integration
   ========================================================= */
#auth-shell{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:clamp(1rem, 5vw, 3rem);
  background:
    linear-gradient(90deg, oklch(43% .06 155 / .10) 0 6px, transparent 6px 10px),
    repeating-linear-gradient(0deg, transparent 0 27px, var(--ledger-line) 27px 28px),
    var(--paper);
}
.auth-panel{
  width:min(100%, 380px);
  padding:1.35rem;
  border:1px solid var(--rule);
  border-top:3px solid var(--green);
  border-radius:var(--r);
  background:var(--paper);
  box-shadow:var(--shadow-2);
  position:relative;
}
.auth-brand{
  display:flex;
  align-items:center;
  gap:.75rem;
  padding:.15rem 0 1rem;
}
.auth-brand .sub{
  display:block;
  font-family:var(--sans);
  font-size:.68rem;
  font-weight:500;
  color:var(--ink-faint);
  letter-spacing:.14em;
}
#auth-session-state{
  border-top:1px solid var(--rule);
  padding-top:1rem;
  color:var(--ink-soft);
}
#auth-session-state p{ margin:0 0 .75rem; }
.auth-tabs{
  display:flex;
  gap:.2rem;
  margin-bottom:1rem;
  border-bottom:1px solid var(--rule);
}
.auth-tab{
  flex:1;
  appearance:none;
  border:0;
  border-bottom:3px solid transparent;
  background:transparent;
  color:var(--ink-faint);
  font:500 .9rem/1 var(--sans);
  padding:.75rem .5rem;
  cursor:pointer;
}
.auth-tab[aria-selected="true"]{
  color:var(--green);
  border-bottom-color:var(--gold);
  font-weight:600;
}
#auth-form{ display:grid; gap:.9rem; }
.auth-field{ display:grid; gap:.2rem; }
.auth-field label{ font-size:.8rem; color:var(--ink-soft); font-weight:600; }
.auth-field .hint{ margin:0; }
.auth-submit{ width:100%; margin-top:.15rem; }
.auth-status{
  margin-top:1rem;
  padding:.65rem .75rem;
  border:1px solid var(--warn);
  border-left-width:4px;
  background:var(--warn-wash);
  color:var(--ink-soft);
}
.auth-status p{ margin:0; }
.auth-status .btn{ margin-top:.55rem; }
.auth-panel[aria-busy="true"] button,
.auth-panel[aria-busy="true"] input{ cursor:wait; }

/* ---------- typography ---------- */
h1,h2,h3,h4{ font-family:var(--serif); font-weight:700; margin:0; letter-spacing:-.01em; }
h1{ font-size:1.25rem; line-height:1.2; }
h2{ font-size:1.02rem; }
h3{ font-size:.95rem; }

.eyebrow{
  font-family:var(--sans);
  font-size:.72rem;
  font-weight:600;
  color:var(--ink-faint);
  letter-spacing:.06em;
}

.num{ font-variant-numeric: tabular-nums lining-nums; }

/* ---------- focus ---------- */
:where(a,button,input,select,summary,[tabindex]):focus-visible{
  outline:2px solid var(--green);
  outline-offset:2px;
  border-radius:var(--r);
}

/* =========================================================
   Bookbinding shell
   ========================================================= */
.book{
  max-width:1420px;
  margin:0 auto;
  padding:0 0 4rem;
  min-height:100vh;
  background:var(--paper);
  background-image:
    linear-gradient(90deg, oklch(43% .06 155 / .10) 0 6px, transparent 6px 10px),
    repeating-linear-gradient(0deg, transparent 0 27px, var(--ledger-line) 27px 28px);
  background-position:0 0, 0 0;
  box-shadow:0 0 0 1px var(--rule-soft), 0 10px 40px oklch(28% .02 60 / .16);
}
.book[aria-busy="true"]{ cursor:wait; }
@media (min-width:1000px){
  .book{ border-left:10px solid var(--green); }
  .book::before{
    content:"";
    position:fixed; left:0; top:0; bottom:0; width:10px;
    background:
      repeating-linear-gradient(0deg,
        oklch(43% .072 82 / .55) 0 2px, transparent 2px 26px);
    pointer-events:none;
  }
}

/* =========================================================
   Header
   ========================================================= */
#app-header{
  position:sticky; top:0; z-index:40;
  background:var(--paper-2);
  border-bottom:2px solid var(--green);
  box-shadow:0 2px 0 var(--gold-wash), 0 6px 14px oklch(28% .02 60 / .10);
}
.header-inner{
  display:flex; flex-wrap:wrap; gap:.75rem 1rem;
  align-items:center;
  padding:.7rem clamp(.85rem, 2.2vw, 1.6rem) .55rem;
}

.brand{ display:flex; align-items:center; gap:.6rem; min-width:0; }
.brand-mark{
  width:22px; height:22px; flex:none;
  background:var(--gold);
  transform:rotate(45deg);
  box-shadow:0 0 0 3px var(--paper-2), 0 0 0 4px var(--gold-lift);
}
.brand h1{ white-space:nowrap; }
.brand .sub{
  display:block; font-family:var(--sans);
  font-size:.68rem; font-weight:500; color:var(--ink-faint); letter-spacing:.14em;
}

/* status ledger strip — 요소는 HUD 안에서 .sr-only 로 숨겨 둔다(시각 규칙 없음) */

.header-spacer{ flex:1 1 auto; }

/* nav tabs */
#main-nav{ margin-left:auto; }
.tabs{
  display:flex; gap:.25rem; list-style:none; margin:0; padding:0;
}
.tab{
  appearance:none;
  font-family:var(--serif); font-weight:700; font-size:.95rem;
  color:var(--ink-soft);
  background:var(--paper-3);
  border:1px solid var(--rule);
  border-bottom-color:transparent;
  border-radius:var(--r) var(--r) 0 0;
  padding:.42rem 1.05rem;
  margin-bottom:-.56rem;
  cursor:pointer;
  transition:background .14s ease, color .14s ease, transform .14s ease;
}
.tab:hover{ background:var(--paper-2); color:var(--ink); }
.tab[aria-current="page"]{
  background:var(--paper);
  color:var(--green);
  border-color:var(--green);
  border-bottom-color:var(--paper);
  box-shadow:inset 0 3px 0 var(--gold);
}

/* utility buttons — #utility-bar 는 #main-menu 안에서 display:contents 로 녹아든다(HUD 절 참조) */
#account-bar{
  display:flex;
  align-items:center;
  gap:.4rem;
  padding-left:.8rem;
  border-left:1px solid var(--rule);
  font-size:.75rem;
  color:var(--ink-faint);
}
#account-bar strong{
  max-width:12rem;
  overflow:hidden;
  text-overflow:ellipsis;
  color:var(--ink-soft);
  font-weight:600;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn{
  appearance:none;
  font-family:var(--sans); font-size:.82rem; font-weight:500;
  color:var(--ink);
  background:linear-gradient(oklch(97% .014 88), var(--paper-2));
  border:1px solid var(--rule);
  border-radius:var(--r);
  padding:.42rem .8rem;
  min-height:38px;
  cursor:pointer;
  box-shadow:var(--shadow-1);
  transition:background .14s ease, border-color .14s ease, transform .1s ease;
}
.btn:hover:not(:disabled){ border-color:var(--green); background:var(--paper); }
.btn:active:not(:disabled){ transform:translateY(1px); box-shadow:none; }
.btn:disabled{
  color:var(--ink-faint); background:var(--paper-sunk);
  border-style:dashed; cursor:not-allowed; box-shadow:none;
}
.btn-quiet{ background:transparent; box-shadow:none; }
.btn-primary{
  font-family:var(--serif); font-weight:700; font-size:1rem;
  color:oklch(97% .012 88);
  background:linear-gradient(oklch(48% .072 155), var(--green));
  border-color:var(--green);
  box-shadow:0 2px 0 oklch(33% .05 155), 0 4px 10px oklch(28% .02 60 / .2);
  padding:.68rem 1.1rem;
  min-height:46px;
}
.btn-primary:hover:not(:disabled){
  background:linear-gradient(oklch(52% .072 155), oklch(45% .072 155));
  border-color:var(--green);
}
.btn-primary:active:not(:disabled){ box-shadow:0 1px 0 oklch(33% .05 155); }
.btn-gold{ border-color:var(--gold); color:var(--gold); }
.btn-danger{ border-color:var(--warn); color:var(--warn); }
.btn-sm{ font-size:.75rem; padding:.28rem .55rem; min-height:32px; }
.btn-icon{
  min-width:34px; min-height:34px; padding:.2rem .4rem;
  font-family:var(--serif); line-height:1;
}

/* =========================================================
   Panels
   ========================================================= */
.panel{
  background:var(--paper);
  border:1px solid var(--rule);
  border-radius:var(--r);
  box-shadow:var(--shadow-2);
  position:relative;
}
.panel + .panel{ margin-top:1rem; }
.panel-hd{
  display:flex; align-items:center; gap:.5rem;
  padding:.55rem .85rem;
  border-bottom:1px solid var(--rule);
  background:
    linear-gradient(var(--paper-2), var(--paper-3));
}
.panel-hd h2, .panel-hd h3{ color:var(--green); }
.panel-hd .meta{ margin-left:auto; font-size:.72rem; color:var(--ink-faint); }
.panel-bd{ padding:.85rem; }
.panel-bd.tight{ padding:.6rem .85rem; }

/* botanical corner ornament — pure CSS, basic shapes only */
.ornate::before, .ornate::after{
  content:""; position:absolute; width:14px; height:14px; pointer-events:none;
  border:1px solid var(--gold-lift);
}
.ornate::before{ top:5px; left:5px; border-right:0; border-bottom:0; }
.ornate::after{ bottom:5px; right:5px; border-left:0; border-top:0; }

/* =========================================================
   Layout — schedule view
   ========================================================= */
main{ padding:1rem clamp(.85rem, 2.2vw, 1.6rem) 0; }
.view[hidden]{ display:none; }

/* 옛 3열 화면(#view-schedule .columns)은 v7 HUD 격자로 대체돼 규칙을 모두 없앴다.
   #col-planner·#col-profile 에 grid-area 를 주면 .hud-screen 격자에 암시적 열이 생겨
   일정 패널을 열 때 무대 높이가 무너진다. 배치는 .hud-planner-layer 등 클래스가 맡는다. */

/* =========================================================
   Left column — profile & stats
   ========================================================= */
.id-block{
  display:grid; grid-template-columns:auto 1fr; gap:.15rem .7rem;
  align-items:baseline;
}
.id-name{
  grid-column:1 / -1;
  font-family:var(--serif); font-size:1.5rem; font-weight:700;
  color:var(--ink);
  border-bottom:2px solid var(--gold);
  padding-bottom:.2rem; margin-bottom:.45rem;
  display:flex; align-items:baseline; gap:.5rem;
}
.id-name small{ font-family:var(--sans); font-size:.72rem; color:var(--ink-faint); font-weight:500; }
.id-block dt{ font-size:.76rem; color:var(--ink-faint); }
.id-block dd{ margin:0; font-size:.84rem; }

.chips{ display:flex; flex-wrap:wrap; gap:.3rem; margin:.7rem 0 0; padding:0; list-style:none; }
.chip{
  font-size:.72rem; line-height:1.5;
  padding:.12rem .5rem;
  border:1px solid var(--rule);
  border-radius:999px;
  background:var(--paper-2);
  color:var(--ink-soft);
  white-space:nowrap;
}
.chip-good{ border-color:var(--green); color:var(--green); background:var(--green-wash); }
.chip-warn{ border-color:var(--warn); color:var(--warn); background:var(--warn-wash); }
.chip-gold{ border-color:var(--gold); color:var(--gold); background:var(--gold-wash); }
.chip-mute{ color:var(--ink-faint); border-style:dashed; background:transparent; }

/* stat rows */
#stat-list{ margin:0; padding:0; }
.stat{
  display:grid;
  grid-template-columns:4.6em 1fr 3.2em;
  align-items:center;
  gap:.5rem;
  padding:.36rem 0;
  border-bottom:1px dotted var(--rule-soft);
}
.stat:last-child{ border-bottom:0; }
.stat dt{ font-size:.82rem; color:var(--ink-soft); }
.stat .track{
  height:11px;
  background:var(--paper-sunk);
  border:1px solid var(--rule-soft);
  border-radius:2px;
  box-shadow:inset 0 1px 2px oklch(28% .02 60 / .18);
  overflow:hidden;
}
.stat .fill{
  display:block; height:100%;
  background:
    repeating-linear-gradient(135deg,
      oklch(48% .072 155) 0 4px, oklch(43% .072 155) 4px 8px);
}
.stat[data-stat="스트레스"] .fill{
  background:repeating-linear-gradient(135deg,
    oklch(50% .09 55) 0 4px, oklch(45% .09 55) 4px 8px);
}
.stat dd{ margin:0; }
.stat .val{
  font-family:var(--serif); font-weight:700; font-size:.92rem;
  text-align:right; color:var(--ink);
}
.stat .val .delta{ font-family:var(--sans); font-size:.68rem; font-weight:600; color:var(--green-lift); }

/* household ledger */
.ledger{ width:100%; border-collapse:collapse; font-size:.8rem; }
.ledger th, .ledger td{
  padding:.3rem .2rem;
  border-bottom:1px solid var(--rule-soft);
  text-align:left;
}
.ledger th{ font-weight:500; color:var(--ink-faint); }
.ledger td{ text-align:right; font-family:var(--serif); font-weight:700; }
.ledger tr:last-child th, .ledger tr:last-child td{ border-bottom:0; }

/* =========================================================
   Center — portrait stage
   ========================================================= */
#portrait-stage{
  --rule-strong:oklch(62% 0.026 82);
  --shadow:oklch(28% 0.020 60 / 0.16);
  padding:clamp(.9rem, 2.4vw, 1.6rem);
  background:
    radial-gradient(90% 70% at 50% 8%, oklch(97% .016 90), var(--paper-2));
  border:1px solid var(--rule);
  border-radius:var(--r);
  box-shadow:var(--shadow-2);
}
.portrait-frame{
  position:relative;
  margin:0 auto;
  max-width:460px;
  padding:12px;
  background:linear-gradient(160deg, var(--gold-lift), var(--gold));
  border-radius:2px;
  box-shadow:
    0 0 0 1px oklch(35% .05 82),
    0 14px 26px oklch(28% .02 60 / .25);
}
.portrait-inner{
  position:relative;
  border:3px double oklch(96% .015 88 / .75);
  background-color:var(--paper-2);
  aspect-ratio:4 / 5;
  overflow:hidden;
  display:grid; place-items:center;
}
#portrait-image{
  position:relative; z-index:1;
  display:block; width:100%; height:100%;
  object-fit:cover;
  background:transparent;
}
.frame-plate{
  margin:.75rem auto 0;
  max-width:460px;
  text-align:center;
  font-family:var(--serif); font-weight:700;
  color:var(--gold);
  letter-spacing:.16em;
  font-size:.82rem;
  border-top:1px solid var(--rule);
  padding-top:.5rem;
}
#portrait-stage .convo__side{
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:0;
  max-width:460px;
  margin:10px auto 0;
}
#portrait-stage .mood{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:8px;
  margin:0;
  border-bottom:1px solid var(--rule);
  padding-bottom:5px;
}
#portrait-stage #daughter-mood{
  font-family:var(--serif);
  font-weight:700;
  font-size:1rem;
  color:var(--ink);
}
#portrait-stage #daughter-mood[data-mood="happy"]{ color:var(--green); }
#portrait-stage #daughter-mood[data-mood="tired"]{ color:var(--gold); }
#portrait-stage #daughter-conversation-status{
  display:flex;
  align-items:center;
  gap:7px;
  margin:0;
  padding:6px 8px;
  font-size:.78rem;
  font-weight:500;
  background:var(--paper-2);
  border-left:3px solid var(--green);
  border-radius:var(--r);
}
#portrait-stage #daughter-conversation-status::before{
  content:"";
  width:7px;
  height:7px;
  flex:0 0 auto;
  background:var(--green);
  transform:rotate(45deg);
}
#portrait-stage #daughter-conversation-status[data-conversation="done"]{ border-left-color:var(--gold); }
#portrait-stage #daughter-conversation-status[data-conversation="done"]::before{ background:var(--gold); }
#portrait-stage .bubble{
  position:relative;
  flex:1 1 auto;
  min-height:60px;
  display:grid;
  align-items:center;
  gap:2px;
  margin:0;
  padding:10px 12px;
  font-family:var(--serif);
  font-size:.95rem;
  letter-spacing:.08em;
  color:var(--ink-soft);
  background:var(--paper);
  border:2px solid var(--ink);
  border-radius:var(--r);
  box-shadow:2px 2px 0 var(--shadow);
}
#portrait-stage .bubble::before{
  content:"";
  position:absolute;
  top:-7px;
  left:22px;
  width:10px;
  height:10px;
  background:var(--paper);
  border-left:2px solid var(--ink);
  border-top:2px solid var(--ink);
  transform:rotate(45deg);
}
#portrait-stage .bubble__speaker{ display:block; }
#portrait-stage .convo__actions{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:6px;
  max-width:460px;
  margin:10px auto 0;
}
#portrait-stage .act{
  font:inherit;
  font-size:.82rem;
  font-weight:600;
  min-height:44px;
  padding:0 4px;
  color:var(--ink);
  background:var(--paper);
  border:2px solid var(--ink);
  border-radius:var(--r);
  box-shadow:2px 2px 0 var(--ink);
  cursor:pointer;
  transition:transform 90ms ease, box-shadow 90ms ease, background-color 110ms ease;
}
#portrait-stage .act:hover:not(:disabled){ background:var(--paper-2); }
#portrait-stage .act:active:not(:disabled){
  transform:translate(2px, 2px);
  box-shadow:0 0 0 var(--ink);
}
#portrait-stage .act:disabled{
  color:var(--ink-soft);
  background:var(--paper-3);
  border-color:var(--rule-strong);
  border-style:dashed;
  box-shadow:none;
  cursor:not-allowed;
}
#portrait-stage .stage__foot{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
  margin:10px auto 0;
  max-width:460px;
  padding-top:10px;
  border-top:1px solid var(--rule);
}
#portrait-stage .stage__wearing{
  flex:1 1 auto;
  min-width:0;
  font-size:.8rem;
  color:var(--ink-soft);
}
#portrait-stage .stage__wearing b{
  color:var(--ink);
  font-weight:600;
}

/* narrative / status change */
.record-box{
  margin-top:1rem;
  border:1px solid var(--rule);
  background:var(--paper);
  border-radius:var(--r);
}
.record-empty{
  padding:1.4rem .9rem;
  text-align:center;
  color:var(--ink-faint);
  font-family:var(--serif);
  font-size:.92rem;
  background:
    repeating-linear-gradient(0deg, transparent 0 25px, var(--ledger-line) 25px 26px);
}
.record-empty .mark{
  display:block; width:10px; height:10px; margin:0 auto .55rem;
  border:1px solid var(--gold-lift); transform:rotate(45deg);
}
.delta-grid{
  display:flex; flex-wrap:wrap; gap:.35rem;
  padding:.7rem .85rem;
  border-top:1px solid var(--rule-soft);
}

/* =========================================================
   Right — planner
   ========================================================= */
#slot-list{ list-style:none; margin:0; padding:0; display:grid; gap:.55rem; }
.slot{
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:center;
  gap:.6rem;
  padding:.6rem .65rem;
  border:1px solid var(--rule);
  border-radius:var(--r);
  background:var(--paper-2);
  min-height:66px;
}
.slot-no{
  width:26px; height:26px; flex:none;
  display:grid; place-items:center;
  font-family:var(--serif); font-weight:700; font-size:.82rem;
  color:var(--paper);
  background:var(--green);
  border-radius:50%;
}
.slot-main{ min-width:0; }
.slot-title{ font-family:var(--serif); font-weight:700; font-size:.98rem; }
.slot-scope{ font-size:.72rem; color:var(--ink-faint); }
.slot.is-filled{
  background:var(--paper);
  border-color:var(--green);
  box-shadow:inset 3px 0 0 var(--gold);
}
.slot.is-empty{
  background:transparent;
  border-style:dashed;
  border-color:var(--rule);
}
.slot.is-empty .slot-no{ background:var(--paper-sunk); color:var(--ink-faint); }
.slot.is-empty .slot-title{ color:var(--ink-faint); font-weight:400; }
.slot.is-drop-target{
  border-color:var(--gold); background:var(--gold-wash);
  box-shadow:0 0 0 2px var(--gold-wash);
}
.slot:hover{ border-color:var(--green-lift); }

/* activity library */
.cat-tabs{ display:flex; flex-wrap:wrap; gap:.25rem; padding:0; margin:0 0 .7rem; list-style:none; }
.cat-tab{
  appearance:none; cursor:pointer;
  font-family:var(--sans); font-size:.8rem; font-weight:500;
  padding:.3rem .75rem; min-height:34px;
  border:1px solid var(--rule);
  border-radius:999px;
  background:var(--paper-2);
  color:var(--ink-soft);
}
.cat-tab:hover{ border-color:var(--green); color:var(--ink); }
.cat-tab[aria-selected="true"]{
  background:var(--green); border-color:var(--green); color:oklch(97% .012 88);
}

.activity-grid{ display:grid; gap:.45rem; grid-template-columns:repeat(auto-fill, minmax(150px,1fr)); }
.activity{
  text-align:left;
  appearance:none; cursor:pointer;
  border:1px solid var(--rule);
  border-radius:var(--r);
  background:var(--paper);
  padding:.5rem .6rem;
  min-height:58px;
  box-shadow:var(--shadow-1);
  display:grid; gap:.1rem;
  transition:border-color .14s ease, transform .1s ease;
}
.activity .an{ font-family:var(--serif); font-weight:700; font-size:.92rem; }
.activity .am{ font-size:.7rem; color:var(--ink-faint); font-variant-numeric:tabular-nums; }
.activity:hover:not(:disabled){ border-color:var(--green); transform:translateY(-1px); }
.activity[aria-pressed="true"]{
  border-color:var(--green); background:var(--green-wash);
  box-shadow:inset 0 0 0 1px var(--green);
}
.activity[aria-pressed="true"] .an::after{
  content:"◆"; color:var(--gold); font-size:.7em; margin-left:.35em; vertical-align:2px;
}
.activity:disabled{
  color:var(--ink-faint); background:var(--paper-sunk);
  border-style:dashed; cursor:not-allowed; box-shadow:none;
}
.advance-bar{
  margin-top:.85rem; padding-top:.75rem;
  border-top:2px solid var(--rule);
  display:flex; align-items:center; gap:.7rem; flex-wrap:wrap;
}
.advance-bar .note{ font-size:.74rem; color:var(--ink-faint); flex:1 1 140px; }

/* =========================================================
   Diary view
   ========================================================= */
.filter-row{
  display:flex; flex-wrap:wrap; gap:.6rem; align-items:flex-end;
}
.field{ display:grid; gap:.2rem; }
.field label{ font-size:.74rem; color:var(--ink-faint); }
.field select, .field input[type="text"]{
  font-family:var(--sans); font-size:.86rem;
  padding:.4rem .5rem; min-height:38px;
  color:var(--ink);
  background:var(--paper);
  border:1px solid var(--rule);
  border-radius:var(--r);
}

#diary-list{ list-style:none; margin:0; padding:0; }
.entry{
  display:grid;
  grid-template-columns:auto 1fr;
  gap:.2rem .9rem;
  padding:.75rem 0 .75rem .2rem;
  border-bottom:1px solid var(--rule-soft);
  position:relative;
}
.entry::before{
  content:""; position:absolute; left:-.55rem; top:1.15rem;
  width:7px; height:7px; background:var(--gold); transform:rotate(45deg);
}
@media (min-width:640px){
  #diary-list{ padding-left:1rem; border-left:1px solid var(--rule); margin-left:.4rem; }
  .entry::before{ left:-1.35rem; }
}
.entry-date{
  font-family:var(--serif); font-weight:700; font-size:.86rem; color:var(--green);
  white-space:nowrap;
}
.entry-body{ display:grid; gap:.35rem; }
.entry-label{ font-size:.88rem; }
.entry-label b{ font-family:var(--serif); }

.empty-state{
  padding:2rem 1rem;
  text-align:center;
  border:1px dashed var(--rule);
  border-radius:var(--r);
  background:var(--paper-2);
  color:var(--ink-faint);
}
.empty-state p{ margin:.25rem 0; }
.empty-state .head{ font-family:var(--serif); font-weight:700; color:var(--ink-soft); font-size:1rem; }

/* =========================================================
   Endings view
   ========================================================= */
.progress-band{
  display:flex; flex-wrap:wrap; align-items:center; gap:1rem;
  padding:.85rem;
}
.progress-band .big{
  font-family:var(--serif); font-weight:700; font-size:1.8rem; color:var(--green);
}
.bar-wide{
  flex:1 1 200px; height:14px;
  background:var(--paper-sunk);
  border:1px solid var(--rule-soft);
  box-shadow:inset 0 1px 3px oklch(28% .02 60 / .2);
  border-radius:2px; overflow:hidden;
}
.bar-wide > span{
  display:block; height:100%;
  background:repeating-linear-gradient(135deg, var(--gold-lift) 0 5px, var(--gold) 5px 10px);
}

.ending-card{
  border:1px solid var(--rule);
  border-radius:var(--r);
  background:var(--paper);
  padding:.7rem;
  display:grid; gap:.3rem;
  box-shadow:var(--shadow-1);
  min-height:112px;
}
.ending-card .no{
  font-family:ui-monospace, Consolas, monospace;
  font-size:.68rem; color:var(--ink-faint); letter-spacing:.08em;
}
.ending-card h3{ font-size:1rem; }
.ending-card.found{ border-color:var(--green); box-shadow:inset 0 0 0 1px var(--green-wash), var(--shadow-1); }
.ending-card.found h3{ color:var(--green); }
.ending-card.locked{
  background:var(--paper-sunk);
  border-style:dashed;
  color:var(--ink-faint);
}
.ending-card.locked h3{ color:var(--ink-faint); font-family:var(--serif); letter-spacing:.3em; }
.ending-card .date{ font-size:.74rem; color:var(--ink-faint); }

/* =========================================================
   Dialogs
   ========================================================= */
dialog{
  padding:0;
  border:1px solid var(--green);
  border-radius:var(--r);
  background:var(--paper);
  color:var(--ink);
  max-width:min(94vw, 560px);
  width:100%;
  box-shadow:0 20px 50px oklch(28% .02 60 / .4);
}
dialog::backdrop{ background:oklch(28% .02 60 / .55); }

/* Claude wardrobe component — scoped to avoid changing existing dialogs. */
#wardrobe-dialog{
  --rule-strong:oklch(62% 0.026 82);
  --red:oklch(43% 0.072 28);
  --shadow:oklch(28% 0.020 60 / 0.16);
  width:min(100%, 380px);
  margin:auto;
  padding:0;
  color:var(--ink);
  background:var(--paper);
  border:2px solid var(--ink);
  border-radius:var(--r);
  box-shadow:4px 4px 0 var(--shadow);
}
#wardrobe-dialog::backdrop{ background:oklch(28% 0.020 60 / 0.45); }
#wardrobe-dialog .dlg__spine{
  height:7px;
  border-bottom:1px solid var(--ink);
  background:repeating-linear-gradient(90deg, var(--gold) 0 5px, transparent 5px 11px);
  opacity:.85;
}
#wardrobe-dialog .dlg__head{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-bottom:2px solid var(--ink);
  background:var(--paper-2);
}
#wardrobe-dialog #wardrobe-title{
  font-size:1.15rem;
  flex:0 0 auto;
}
#wardrobe-dialog .dlg__tag{
  flex:1 1 auto;
  font-size:.7rem;
  letter-spacing:.14em;
  color:var(--ink-soft);
  border-bottom:1px dotted var(--rule-strong);
  align-self:flex-end;
  padding-bottom:2px;
}
#wardrobe-dialog .dlg__close{
  flex:0 0 auto;
  font:inherit;
  font-size:1rem;
  line-height:1;
  width:44px;
  height:44px;
  color:var(--ink);
  background:var(--paper);
  border:2px solid var(--ink);
  border-radius:var(--r);
  cursor:pointer;
}
#wardrobe-dialog .dlg__close:hover:not(:disabled){ background:var(--paper-3); }
#wardrobe-dialog .dlg__close:disabled{ cursor:progress; opacity:.55; }
#wardrobe-dialog .dlg__body{ padding:12px; }
#wardrobe-dialog .preview{
  margin:0;
  position:relative;
  background:var(--paper-2);
  border:1px solid var(--rule-strong);
  border-radius:var(--r);
  padding:10px;
  display:grid;
  place-items:center;
}
#wardrobe-dialog #wardrobe-preview-image{
  display:block;
  width:100%;
  max-width:236px;
  aspect-ratio:3 / 4;
  object-fit:cover;
  border-radius:var(--r);
  background:transparent;
  transition:opacity 160ms ease;
}
#wardrobe-dialog .statusline{
  display:flex;
  align-items:center;
  gap:8px;
  margin:10px 0 12px;
  padding:7px 9px;
  font-size:.82rem;
  background:var(--paper-2);
  border-left:3px solid var(--green);
  border-radius:var(--r);
  min-height:34px;
}
#wardrobe-dialog .statusline__dot{
  width:7px;
  height:7px;
  flex:0 0 auto;
  background:var(--green);
  transform:rotate(45deg);
}
#wardrobe-dialog #wardrobe-status{ font-weight:500; }
#wardrobe-dialog #wardrobe-current-label{
  margin-left:auto;
  font-family:var(--serif);
  font-weight:700;
}
#wardrobe-dialog .wardrobe-walletline{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  margin:0 0 12px;
  padding:0 2px 7px;
  font-size:.82rem;
  color:var(--ink-soft);
  border-bottom:1px dotted var(--rule-strong);
}
#wardrobe-dialog #wardrobe-wallet{
  color:var(--gold);
  font-family:var(--serif);
  font-size:.9rem;
}
#wardrobe-dialog .choices__label{
  font-size:.72rem;
  letter-spacing:.16em;
  color:var(--ink-soft);
  margin:0 0 7px;
}
#wardrobe-dialog .choices{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:8px;
}
#wardrobe-dialog .choice{
  font:inherit;
  display:grid;
  gap:6px;
  padding:7px 5px 8px;
  min-height:44px;
  color:var(--ink);
  background:var(--paper);
  border:2px solid var(--rule-strong);
  border-radius:var(--r);
  cursor:pointer;
  text-align:center;
  transition:border-color 110ms ease, background-color 110ms ease;
}
#wardrobe-dialog .choice img{
  display:block;
  width:100%;
  aspect-ratio:3 / 4;
  object-fit:cover;
  border-radius:var(--r);
  background:transparent;
}
#wardrobe-dialog .choice__name{
  font-size:.8rem;
  font-weight:500;
  letter-spacing:.01em;
}
#wardrobe-dialog .choice__meta{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  min-height:1.2em;
  font-size:.68rem;
  color:var(--ink-soft);
}
#wardrobe-dialog .choice__owned{
  color:var(--green);
  font-weight:600;
}
#wardrobe-dialog .choice__action{
  padding-top:5px;
  border-top:1px dotted var(--rule-strong);
  font-size:.7rem;
  font-weight:600;
  color:var(--green);
}
#wardrobe-dialog .choice[data-affordable="false"] .choice__action{ color:var(--red); }
#wardrobe-dialog .choice:hover:not(:disabled){
  border-color:var(--ink);
  background:var(--paper-2);
}
#wardrobe-dialog .choice.is-selected{
  border-color:var(--green);
  background:var(--paper-2);
  box-shadow:inset 0 0 0 1px var(--green);
}
#wardrobe-dialog .choice.is-selected .choice__name{
  color:var(--green);
  font-weight:600;
}
#wardrobe-dialog .choice:disabled{
  cursor:progress;
  opacity:.55;
}
#wardrobe-dialog #wardrobe-error{
  display:none;
  margin-top:10px;
  padding:8px 10px;
  font-size:.82rem;
  color:var(--red);
  background:var(--paper-2);
  border:1px solid var(--red);
  border-left-width:3px;
  border-radius:var(--r);
}
#wardrobe-dialog[data-state="equipping"] #wardrobe-preview-image{ opacity:.45; }
#wardrobe-dialog[data-state="equipping"] .statusline{ border-left-color:var(--gold); }
#wardrobe-dialog[data-state="equipping"] .statusline__dot{
  background:var(--gold);
  animation:wardrobe-tick 900ms steps(2, end) infinite;
}
#wardrobe-dialog[data-state="failed"] .statusline{ border-left-color:var(--red); }
#wardrobe-dialog[data-state="failed"] .statusline__dot{ background:var(--red); }
#wardrobe-dialog[data-state="failed"] #wardrobe-error{ display:block; }
#wardrobe-dialog[data-state="failed"] .preview{ border-color:var(--red); }
#wardrobe-dialog[data-state="failed"] .choice.is-selected{
  border-color:var(--red);
  box-shadow:inset 0 0 0 1px var(--red);
}
#wardrobe-dialog[data-state="failed"] .choice.is-selected .choice__name{ color:var(--red); }
@keyframes wardrobe-tick{ 50%{ opacity:.25; } }
@media (min-width:560px){
  #wardrobe-dialog{ max-width:420px; width:min(100%, 420px); }
  #wardrobe-dialog .dlg__body{ padding:14px; }
}

/* Claude activity-scene component — scoped to the activity dialog. */
#activity-scene-dialog{
  --rule-strong:oklch(62% 0.026 82);
  --shadow:oklch(28% 0.020 60 / 0.16);
  width:min(calc(100vw - 24px), 380px);
  max-height:calc(100dvh - 24px);
  padding:0;
  overflow-y:auto;
  color:var(--ink);
  background:var(--paper);
  border:2px solid var(--ink);
  border-radius:var(--r);
  box-shadow:4px 4px 0 var(--shadow);
}
#activity-scene-dialog::backdrop{ background:oklch(28% 0.020 60 / 0.45); }
#activity-scene-dialog .dlg__spine{
  height:7px;
  border-bottom:1px solid var(--ink);
  background:repeating-linear-gradient(90deg, var(--gold) 0 5px, transparent 5px 11px);
  opacity:.85;
}
#activity-scene-dialog .dlg__head{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-bottom:2px solid var(--ink);
  background:var(--paper-2);
}
#activity-scene-dialog .dlg__body{ padding:12px; }
#activity-scene-dialog #activity-scene-title{
  font-size:1.15rem;
  flex:0 0 auto;
}
#activity-scene-dialog .dlg__tag{
  flex:1 1 auto;
  font-size:.7rem;
  letter-spacing:.14em;
  color:var(--ink-soft);
  border-bottom:1px dotted var(--rule-strong);
  align-self:flex-end;
  padding-bottom:2px;
}
#activity-scene-dialog #activity-scene-step{
  flex:0 0 auto;
  min-width:52px;
  margin:0;
  padding:4px 8px;
  font-size:.8rem;
  font-weight:600;
  letter-spacing:.06em;
  text-align:center;
  color:var(--ink);
  background:var(--paper);
  border:1px solid var(--rule-strong);
  border-radius:var(--r);
}
#activity-scene-dialog .scene{
  display:grid;
  grid-template-columns:minmax(0, 40%) minmax(0, 1fr);
  gap:10px;
  align-items:stretch;
}
#activity-scene-dialog .scene__figure{
  margin:0;
  padding:7px;
  display:grid;
  place-items:center;
  background:var(--paper-2);
  border:1px solid var(--rule-strong);
  border-radius:var(--r);
}
#activity-scene-dialog #activity-scene-portrait{
  display:block;
  width:100%;
  max-width:170px;
  aspect-ratio:3 / 4;
  object-fit:cover;
  border-radius:var(--r);
  background:repeating-linear-gradient(135deg, var(--paper-3) 0 6px, var(--paper-2) 6px 12px);
}
#activity-scene-dialog .scene__side{
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:0;
}
#activity-scene-dialog .scene__motion{
  display:flex;
  align-items:center;
  gap:9px;
  margin:0;
  padding:5px 8px 5px 5px;
  background:var(--paper-2);
  border:1px solid var(--rule-strong);
  border-radius:var(--r);
}
#activity-scene-dialog #activity-scene-motion-label{
  font-family:var(--serif);
  font-weight:700;
  font-size:.95rem;
  color:var(--green);
}
#activity-scene-dialog #activity-scene-narration{
  margin:0;
  padding:6px 8px;
  font-size:.8rem;
  letter-spacing:.06em;
  color:var(--ink-soft);
  background:var(--paper-2);
  border-left:3px solid var(--gold);
  border-radius:var(--r);
}
#activity-scene-dialog .bubble{
  position:relative;
  flex:1 1 auto;
  min-height:60px;
  display:grid;
  align-items:center;
  gap:2px;
  margin:0;
  padding:10px 12px;
  font-family:var(--serif);
  font-size:.95rem;
  letter-spacing:.08em;
  color:var(--ink-soft);
  background:var(--paper);
  border:2px solid var(--ink);
  border-radius:var(--r);
  box-shadow:2px 2px 0 var(--shadow);
}
#activity-scene-dialog .bubble::before{
  content:"";
  position:absolute;
  top:18px;
  left:-7px;
  width:10px;
  height:10px;
  background:var(--paper);
  border-left:2px solid var(--ink);
  border-bottom:2px solid var(--ink);
  transform:rotate(45deg);
}
#activity-scene-dialog .scene__actions{
  display:grid;
  grid-template-columns:minmax(0, 1fr) minmax(0, 1fr);
  gap:8px;
  margin-top:12px;
}
#activity-scene-dialog .act{
  font:inherit;
  font-size:.82rem;
  font-weight:600;
  min-height:44px;
  padding:0 4px;
  color:var(--ink);
  background:var(--paper);
  border:2px solid var(--ink);
  border-radius:var(--r);
  box-shadow:2px 2px 0 var(--ink);
  cursor:pointer;
}
#activity-scene-dialog .act:hover{ background:var(--paper-2); }
#activity-scene-dialog .act:active{
  transform:translate(2px, 2px);
  box-shadow:0 0 0 var(--ink);
}
#activity-scene-dialog .activity-motion{
  position:relative;
  flex:0 0 auto;
  width:48px;
  height:32px;
  overflow:hidden;
  background:var(--paper);
  border:1px solid var(--rule);
  border-radius:var(--r);
}
#activity-scene-dialog .activity-motion > span{
  display:none;
  position:absolute;
  inset:0;
}
#activity-scene-dialog .activity-motion span span{ position:absolute; display:block; }
#activity-scene-dialog[data-motion="study"] .motion-study,
#activity-scene-dialog[data-motion="work"] .motion-work,
#activity-scene-dialog[data-motion="rest"] .motion-rest,
#activity-scene-dialog[data-motion="magic"] .motion-magic,
#activity-scene-dialog[data-motion="travel"] .motion-travel,
#activity-scene-dialog[data-motion="physical"] .motion-physical{ display:block; }
#activity-scene-dialog .motion-study .m-page{
  top:5px;
  width:18px;
  height:22px;
  background:var(--paper);
  border:2px solid var(--ink);
}
#activity-scene-dialog .motion-study .m-page--l{ left:6px; }
#activity-scene-dialog .motion-study .m-page--r{ left:22px; }
#activity-scene-dialog .motion-study .m-turn{
  top:5px;
  left:23px;
  width:17px;
  height:22px;
  background:var(--paper-3);
  border:2px solid var(--gold);
  transform-origin:0 50%;
  animation:activity-page-turn 2600ms ease-in-out infinite;
}
@keyframes activity-page-turn{
  0%,18%{ transform:rotateY(0deg); opacity:1; }
  82%{ transform:rotateY(-180deg); opacity:1; }
  100%{ transform:rotateY(-180deg); opacity:0; }
}
#activity-scene-dialog .motion-work .m-row{ left:8px; right:8px; height:6px; }
#activity-scene-dialog .motion-work .m-row:nth-child(1){ top:4px; }
#activity-scene-dialog .motion-work .m-row:nth-child(2){ top:13px; }
#activity-scene-dialog .motion-work .m-row:nth-child(3){ top:22px; }
#activity-scene-dialog .motion-work .m-row::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  width:6px;
  height:6px;
  border:1px solid var(--ink);
}
#activity-scene-dialog .motion-work .m-row::after{
  content:"";
  position:absolute;
  left:11px;
  right:0;
  top:2px;
  height:2px;
  background:var(--rule-strong);
}
#activity-scene-dialog .motion-work .m-box{
  left:0;
  top:0;
  width:6px;
  height:6px;
  background:var(--green);
  animation:activity-check 2700ms ease-in-out infinite backwards;
}
#activity-scene-dialog .motion-work .m-row:nth-child(2) .m-box{ animation-delay:450ms; }
#activity-scene-dialog .motion-work .m-row:nth-child(3) .m-box{ animation-delay:900ms; }
@keyframes activity-check{
  0%{ opacity:0; }
  18%,82%{ opacity:1; }
  100%{ opacity:0; }
}
#activity-scene-dialog .motion-rest .m-cloud{
  border-radius:50%;
  animation:activity-breathe 3200ms ease-in-out infinite alternate;
}
#activity-scene-dialog .motion-rest .m-cloud--a{
  left:7px;
  top:13px;
  width:22px;
  height:12px;
  background:var(--rule);
}
#activity-scene-dialog .motion-rest .m-cloud--b{
  left:19px;
  top:8px;
  width:22px;
  height:15px;
  background:var(--paper-3);
  border:1px solid var(--rule-strong);
  animation-delay:400ms;
}
@keyframes activity-breathe{
  from{ transform:scale(1); opacity:.75; }
  to{ transform:scale(1.08); opacity:1; }
}
#activity-scene-dialog .motion-magic .m-spark{
  background:var(--gold);
  transform:rotate(45deg);
  animation:activity-twinkle 1800ms ease-in-out infinite;
}
#activity-scene-dialog .motion-magic .m-spark:nth-child(1){ left:9px; top:14px; width:8px; height:8px; }
#activity-scene-dialog .motion-magic .m-spark:nth-child(2){ left:23px; top:6px; width:6px; height:6px; background:var(--green); animation-delay:600ms; }
#activity-scene-dialog .motion-magic .m-spark:nth-child(3){ left:34px; top:18px; width:5px; height:5px; animation-delay:1200ms; }
@keyframes activity-twinkle{
  0%,100%{ transform:rotate(45deg) scale(.5); opacity:.3; }
  50%{ transform:rotate(45deg) scale(1); opacity:1; }
}
#activity-scene-dialog .motion-travel .m-trail{
  left:8px;
  right:8px;
  top:15px;
  height:0;
  border-top:2px dashed var(--rule-strong);
}
#activity-scene-dialog .motion-travel .m-stop{
  top:13px;
  width:6px;
  height:6px;
  background:var(--ink);
  transform:rotate(45deg);
}
#activity-scene-dialog .motion-travel .m-stop--a{ left:4px; }
#activity-scene-dialog .motion-travel .m-stop--b{ right:4px; }
#activity-scene-dialog .motion-travel .m-dot{
  left:5px;
  top:12px;
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--gold);
  animation:activity-walk 2600ms ease-in-out infinite alternate;
}
@keyframes activity-walk{
  from{ transform:translateX(0); }
  to{ transform:translateX(30px); }
}
#activity-scene-dialog .motion-physical .m-core{
  left:calc(50% - 4px);
  top:calc(50% - 4px);
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--green);
}
#activity-scene-dialog .motion-physical .m-ring{
  left:calc(50% - 11px);
  top:calc(50% - 11px);
  width:22px;
  height:22px;
  border-radius:50%;
  border:2px solid var(--gold);
  opacity:.7;
  animation:activity-pulse 1700ms ease-out infinite;
}
@keyframes activity-pulse{
  from{ transform:scale(.5); opacity:.9; }
  to{ transform:scale(1.15); opacity:0; }
}
@media (min-width:560px){
  #activity-scene-dialog{ width:min(calc(100vw - 24px), 420px); }
  #activity-scene-dialog .dlg__body{ padding:14px; }
}
@media (prefers-reduced-motion:reduce){
  #activity-scene-dialog .activity-motion,
  #activity-scene-dialog .activity-motion *,
  #activity-scene-dialog .activity-motion *::before,
  #activity-scene-dialog .activity-motion *::after{
    animation:none !important;
    transition:none !important;
  }
}
.dlg-hd{
  display:flex; align-items:center; gap:.6rem;
  padding:.7rem .95rem;
  border-bottom:2px solid var(--green);
  background:linear-gradient(var(--paper-2), var(--paper-3));
}
.dlg-hd h2{ color:var(--green); }
.dlg-bd{ padding:.95rem; max-height:min(66vh, 560px); overflow:auto; }
.dlg-ft{
  display:flex; gap:.5rem; flex-wrap:wrap; justify-content:flex-end;
  padding:.75rem .95rem;
  border-top:1px solid var(--rule);
  background:var(--paper-2);
}
.dlg-close{ margin-left:auto; }

.report-grid{
  display:grid; gap:.5rem;
  grid-template-columns:repeat(auto-fit, minmax(150px,1fr));
  margin-bottom:.9rem;
}
.report-cell{
  border:1px solid var(--rule); border-radius:var(--r);
  padding:.5rem .6rem; background:var(--paper-2);
}
.report-cell .k{ font-size:.72rem; color:var(--ink-faint); }
.report-cell .v{ font-family:var(--serif); font-weight:700; font-size:1.1rem; }
.report-cell .v.up{ color:var(--green); }
.report-cell .v.down{ color:var(--warn); }

.data-table{ width:100%; border-collapse:collapse; font-size:.84rem; }
.data-table caption{
  text-align:left; font-family:var(--serif); font-weight:700;
  color:var(--green); padding:.45rem 0 .35rem;
}
.data-table th, .data-table td{
  padding:.38rem .45rem; border-bottom:1px solid var(--rule-soft); text-align:left;
}
.data-table thead th{
  font-size:.72rem; font-weight:600; color:var(--ink-faint);
  border-bottom:1px solid var(--rule);
}
.data-table td.n{ text-align:right; font-variant-numeric:tabular-nums; font-family:var(--serif); font-weight:700; }
.up{ color:var(--green); }
.down{ color:var(--warn); }

fieldset{
  border:1px solid var(--rule); border-radius:var(--r);
  margin:0 0 .85rem; padding:.7rem .85rem;
}
legend{
  font-family:var(--serif); font-weight:700; font-size:.9rem;
  color:var(--green); padding:0 .35rem;
}
.form-row{
  display:grid; gap:.3rem .8rem; align-items:center;
  grid-template-columns:1fr; margin-bottom:.6rem;
}
@media (min-width:520px){ .form-row{ grid-template-columns:8.5em 1fr; } }
.form-row:last-child{ margin-bottom:0; }
.form-row > label:first-child{ font-size:.84rem; color:var(--ink-soft); }
input[type="text"], input[type="password"], select{
  font-family:var(--sans); font-size:.9rem; color:var(--ink);
  background:var(--paper); border:1px solid var(--rule);
  border-radius:var(--r); padding:.45rem .55rem; min-height:40px; width:100%;
}

.legacy-import{
  display:flex;
  align-items:center;
  gap:.75rem;
  margin:0 0 1rem;
  padding:.7rem .8rem;
  border:1px solid var(--gold);
  border-left-width:4px;
  background:var(--gold-wash);
}
.legacy-import > div{ flex:1; min-width:0; }
.legacy-import h2{ color:var(--gold); font-size:.9rem; }
.legacy-import p{ margin:.1rem 0 0; font-size:.78rem; color:var(--ink-soft); }
input[type="range"]{ width:100%; accent-color:oklch(43% .072 155); min-height:34px; }
.radio-set{ display:flex; flex-wrap:wrap; gap:.7rem; }
.radio-set label, .switch-row label{ display:flex; align-items:center; gap:.35rem; font-size:.86rem; }
input[type="radio"], input[type="checkbox"]{ accent-color:oklch(43% .072 155); width:18px; height:18px; }
.switch-row{ display:flex; flex-direction:column; gap:.5rem; }
.hint{ font-size:.74rem; color:var(--ink-faint); margin:.25rem 0 0; }
.date-fields{ display:flex; gap:.4rem; }
.date-fields select{ min-width:0; }

/* =========================================================
   Toast region
   ========================================================= */
#toast-region{
  position:fixed; left:50%; bottom:1rem; transform:translateX(-50%);
  z-index:80;
  display:grid; gap:.4rem; width:min(92vw, 420px);
  pointer-events:none;
}
.toast{
  pointer-events:auto;
  display:flex; align-items:center; gap:.55rem;
  padding:.55rem .75rem;
  border:1px solid var(--green);
  border-left-width:5px;
  border-radius:var(--r);
  background:var(--paper);
  box-shadow:0 8px 22px oklch(28% .02 60 / .3);
  font-size:.86rem;
}
.toast .tm{
  width:8px; height:8px; flex:none; transform:rotate(45deg); background:var(--green);
}
.toast.is-warn{ border-color:var(--warn); }
.toast.is-warn .tm{ background:var(--warn); }
.toast.is-gold{ border-color:var(--gold); }
.toast.is-gold .tm{ background:var(--gold); }

/* =========================================================
   Utility
   ========================================================= */
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}
.stack-sm > * + *{ margin-top:.55rem; }
.rule-note{
  margin:.7rem 0 0; padding-top:.55rem;
  border-top:1px dotted var(--rule);
  font-size:.75rem; color:var(--ink-faint);
}

/* phone tuning */
@media (max-width:519px){
  .header-inner{ padding:.6rem .85rem .5rem; }
  #main-nav{ width:100%; margin-left:0; }
  .tabs{ width:100%; }
  .tab{ flex:1 1 0; text-align:center; padding:.42rem .3rem; }
  #account-bar{
    order:4;
    width:100%;
    padding:.45rem 0 0;
    border-left:0;
    border-top:1px solid var(--rule);
  }
  #account-bar .btn{ margin-left:auto; }
  .legacy-import{ align-items:flex-start; flex-wrap:wrap; }
  .legacy-import > div{ flex-basis:100%; }
  .activity-grid{ grid-template-columns:1fr 1fr; }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
    scroll-behavior:auto !important;
  }
}

/* Functional states added during integration; all tokens inherit the Claude source. */
.slot.is-selected{ outline:3px solid var(--gold-lift); outline-offset:2px; }
.slot.is-locked,.activity:disabled{ opacity:.58; cursor:not-allowed; }
.activity[hidden]{ display:none; }
.activity .am{ text-wrap:balance; }
.preview-list,.choice-list,.target-list{ display:grid; gap:.55rem; margin-top:.8rem; }
.preview-line{ display:flex; justify-content:space-between; gap:1rem; padding:.35rem 0; border-bottom:1px solid var(--rule-soft); }
.choice-list .btn{ width:100%; justify-content:flex-start; text-align:left; min-height:44px; }
#event-dialog[open]{display:flex;flex-direction:column;max-height:calc(100dvh - 24px);overflow:hidden}
#event-dialog .dlg-hd{flex:0 0 auto}
#event-dialog .dlg-bd{min-height:0;max-height:none;overflow-y:auto}
#event-choices .btn{white-space:normal;overflow-wrap:anywhere;word-break:keep-all}
#event-choices .btn>span{min-width:0;width:100%}
#event-choices .btn small{display:block;white-space:normal;line-height:1.45;margin-top:.25rem}
.event-check-badge{display:inline-block;margin-left:.45rem;padding:.08rem .35rem;border:1px solid var(--rule);border-radius:.25rem;font-size:.73em;font-weight:600;vertical-align:middle}
.help-copy h3{ font-family:var(--serif); color:var(--green); margin:1rem 0 .2rem; }
.help-copy h3:first-child{ margin-top:0; }
.help-copy p{ margin:.2rem 0; }
.record-empty small{ display:block; width:100%; color:var(--ink-faint); margin-top:.35rem; }
.target-row{ display:grid; grid-template-columns:minmax(7rem,1fr) 4fr auto; gap:.6rem; align-items:center; }
.target-row progress{ width:100%; accent-color:var(--green); }
.empty-inline{ color:var(--ink-faint); padding:1rem 0; text-align:center; }
.toast{ transition:opacity .2s ease, transform .2s ease; }
.toast.is-leaving{ opacity:0; transform:translateY(5px); }
body.high-contrast{ --ink:oklch(18% .02 60); --ink-soft:oklch(28% .02 60); --rule:oklch(30% .03 90 / .55); --green:oklch(30% .09 155); --gold:oklch(32% .09 82); }
dialog.blocking::backdrop{ backdrop-filter:blur(2px); }
@media (max-width:519px){
  .target-row{ grid-template-columns:1fr auto; }
  .target-row progress{ grid-column:1 / -1; }
  dialog{ max-height:calc(100dvh - 1rem); }
}

/* daughter-layout-fix — #activity-scene-dialog / #wardrobe-dialog 한정 */
#activity-scene-dialog, #activity-scene-dialog *, #activity-scene-dialog *::before, #activity-scene-dialog *::after,
#wardrobe-dialog, #wardrobe-dialog *, #wardrobe-dialog *::before, #wardrobe-dialog *::after { box-sizing: border-box; }
#activity-scene-dialog [hidden], #wardrobe-dialog [hidden] { display: none !important; }

/* 공통 골격: 열린 상태에서만 flex, 머리말 고정, 본문이 스크롤 영역 */
#activity-scene-dialog[open], #wardrobe-dialog[open] {
  display: flex; flex-direction: column;
  width: calc(100% - 24px); max-width: none;
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow: hidden;
}
#activity-scene-dialog .dlg__head, #wardrobe-dialog .dlg__head {
  flex: 0 0 auto; position: sticky; top: 0; z-index: 2; min-width: 0; background: var(--paper);
}
#activity-scene-dialog .dlg__head > *, #wardrobe-dialog .dlg__head > * { min-width: 0; }
#activity-scene-dialog #activity-scene-title, #wardrobe-dialog #wardrobe-title { overflow-wrap: anywhere; }
#activity-scene-dialog #activity-scene-step { margin-top: 0; margin-bottom: 0; }
#wardrobe-dialog .dlg__close { flex: 0 0 auto; }
#activity-scene-dialog .dlg__body, #wardrobe-dialog .dlg__body {
  flex: 1 1 auto; min-height: 0; min-width: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}

/* 활동 장면 — 모바일 기본 */
#activity-scene-dialog .scene {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px;
  align-items: start; min-width: 0;
}
#activity-scene-dialog .scene__figure { margin: 0; min-width: 0; align-self: start; }
#activity-scene-dialog #activity-scene-portrait {
  display: block; width: 100%; max-width: none; height: 164px;
  aspect-ratio: auto; object-fit: cover; object-position: 50% 18%;
}
#activity-scene-dialog .scene__side {
  display: flex; flex-direction: column; justify-content: flex-start;
  gap: 8px; min-width: 0; align-self: start;
}
#activity-scene-dialog .scene__side > * { min-width: 0; margin-top: 0; margin-bottom: 0; }
#activity-scene-dialog .scene__motion { flex: 0 0 auto; }
#activity-scene-dialog #activity-scene-narration { overflow-wrap: anywhere; }
#activity-scene-dialog #activity-scene-dialogue {
  flex: 0 0 auto; align-self: stretch; height: auto; min-height: 0; overflow-wrap: anywhere;
}
#activity-scene-dialog #activity-scene-dialogue > * { min-width: 0; max-width: 100%; }
#activity-scene-dialog .scene__actions {
  position: sticky; bottom: 0; z-index: 2;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  margin-top: 10px; padding-top: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  background: var(--paper); border-top: 1px solid var(--rule);
}
#activity-scene-dialog .scene__actions > * { min-width: 0; }

/* 옷장 — 모바일 기본: 두 칸 */
#wardrobe-dialog .preview { margin: 0 0 8px; min-width: 0; }
#wardrobe-dialog #wardrobe-preview-image {
  display: block; width: 100%; max-width: none; height: 160px;
  aspect-ratio: auto; object-fit: contain; object-position: 50% 50%;
}
#wardrobe-dialog .statusline, #wardrobe-dialog .wardrobe-walletline, #wardrobe-dialog .choices__label { min-width: 0; }
#wardrobe-dialog .statusline__dot { flex: 0 0 auto; }
#wardrobe-dialog #wardrobe-status, #wardrobe-dialog #wardrobe-current-label, #wardrobe-dialog #wardrobe-wallet {
  min-width: 0; overflow-wrap: anywhere;
}
#wardrobe-dialog .choices {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  align-items: start; min-width: 0;
}
#wardrobe-dialog .choice {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  min-width: 0; height: auto; overflow: visible; text-align: center;
}
#wardrobe-dialog .choice > * { flex: 0 0 auto; min-width: 0; max-width: 100%; }
#wardrobe-dialog .choice img {
  display: block; width: 100%; max-width: none; height: 150px;
  aspect-ratio: auto; object-fit: cover; object-position: 50% 12%;
}
#wardrobe-dialog .choice__name, #wardrobe-dialog .choice__action { overflow-wrap: anywhere; }
#wardrobe-dialog .choice__meta {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px;
}
#wardrobe-dialog #wardrobe-error { min-width: 0; overflow-wrap: anywhere; }

/* 옷장 — 넓은 화면 */
@media (min-width: 560px) {
  #wardrobe-dialog[open] { width: min(690px, calc(100% - 24px)); max-width: 690px; }
  #wardrobe-dialog #wardrobe-preview-image { height: 200px; }
  #wardrobe-dialog .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  #wardrobe-dialog .choice img { height: 168px; }
}

/* 활동 장면 — 중간 폭: 아직 한 칸, 폭만 제한 */
@media (min-width: 560px) and (max-width: 719.98px) {
  #activity-scene-dialog[open] { width: min(540px, calc(100% - 24px)); max-width: 540px; }
  #activity-scene-dialog #activity-scene-portrait { height: 200px; }
}

/* 활동 장면 — 데스크톱: 초상 옆에 본문 */
@media (min-width: 720px) {
  #activity-scene-dialog[open] { width: min(800px, calc(100% - 24px)); max-width: 820px; }
  #activity-scene-dialog .scene {
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 16px; align-items: start;
  }
  #activity-scene-dialog #activity-scene-portrait { height: 232px; }
  #activity-scene-dialog .scene__actions { position: static; margin-top: 12px; }
}

/* 낮은 가로 화면 (휴대폰 눕힘) */
@media (max-height: 480px) and (orientation: landscape) {
  #activity-scene-dialog .scene { grid-template-columns: minmax(0, 132px) minmax(0, 1fr); gap: 10px; }
  #activity-scene-dialog #activity-scene-portrait { height: 120px; }
  #activity-scene-dialog .scene__actions { position: sticky; bottom: 0; margin-top: 8px; padding-top: 6px; }
  #wardrobe-dialog #wardrobe-preview-image { height: 110px; }
  #wardrobe-dialog .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #wardrobe-dialog .choice img { height: 110px; }
}

/* ==========================================================================
   activity-animation-stage — 붙여 넣기용 컴포넌트 (여기서부터)
   ========================================================================== */

/* 1. 토큰 -------------------------------------------------------------- */
#activity-scene-dialog {
  --aas-paper: oklch(0.955 0.016 88);
  --aas-paper-deep: oklch(0.918 0.02 86);
  --aas-cream: oklch(0.968 0.02 94);
  --aas-ink: oklch(0.26 0.018 72);
  --aas-ink-soft: oklch(0.44 0.02 72);
  --aas-rule: oklch(0.26 0.018 72 / 0.24);
  --aas-green: oklch(0.5 0.095 150);
  --aas-gold: oklch(0.5 0.095 82);
  --aas-mono: ui-monospace, "Cascadia Mono", Consolas, "D2Coding", monospace;
  --aas-stripes: repeating-linear-gradient(135deg, var(--aas-paper-deep) 0 6px, var(--aas-paper) 6px 12px);
}

/* hidden 상태는 항상 숨김. */
#activity-scene-dialog [hidden] { display: none !important; }

/* 호환 훅용 시각적 숨김. 보조기술에는 남는다. */
#activity-scene-dialog .activity-animation-sr {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* 2. 배치: 모바일 = 환경 → 동작 행(스프라이트 | 버튼) → 텍스트 ------------------ */
#activity-scene-dialog .activity-animation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
#activity-scene-dialog .activity-animation-visuals {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  min-inline-size: 0;
}

/* 두 틀이 같은 테두리를 쓴다: 먹선 + 안쪽 이중 괘선 */
#activity-scene-dialog .activity-animation-environment,
#activity-scene-dialog .activity-animation-stage {
  position: relative;
  box-sizing: border-box;
  margin: 0;
  min-inline-size: 0;
  border: 1px solid var(--aas-ink);
  background: var(--aas-paper-deep);
  box-shadow: inset 0 0 0 3px var(--aas-paper), inset 0 0 0 4px var(--aas-rule);
}

/* 3. 환경 그림 (정지, 주 시각) ------------------------------------------------ */
#activity-scene-dialog .activity-animation-environment {
  padding: 6px;
}
#activity-scene-dialog #activity-scene-video[hidden] {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  #activity-scene-dialog #activity-scene-video { display: none; }
}
#activity-scene-dialog .activity-animation-environment-frame {
  position: relative;
  box-sizing: border-box;
  inline-size: 100%;
  block-size: clamp(170px, 48vw, 260px); /* 390px 폭에서 약 187px */
  border: 1px solid var(--aas-ink);
  background: var(--aas-stripes);
  overflow: hidden;
}
#activity-scene-dialog #activity-scene-illustration,
#activity-scene-dialog #activity-scene-video {
  position: absolute;
  inset: 0;
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  font-size: 0;
  color: transparent;
}

/* 4. 동작 (2×2 스프라이트, 작은 창) + 버튼 ------------------------------------ */
#activity-scene-dialog .activity-animation-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 12px;
  padding: 8px;
}
#activity-scene-dialog .activity-animation-frame {
  position: relative;
  box-sizing: border-box;
  inline-size: 104px;
  block-size: 104px;
  border: 1px solid var(--aas-ink);
  outline: 1px solid var(--aas-gold);
  outline-offset: 2px;
  background: var(--aas-stripes);
  overflow: hidden;
}

/* 2×2 시트: 한 프레임 전체를 자르지 않고 표시. 기본값 = 첫 프레임 정지. */
#activity-scene-dialog .activity-animation-sprite {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-position: 0% 0%;
  animation: none;
}

#activity-scene-dialog .activity-animation-controls {
  display: flex;
  justify-content: flex-end;
  min-inline-size: 0;
}

/* 5. 재생 계약 ------------------------------------------------------------ */
/* 재생은 [open] + data-animation-playing="true" 이고 모션 줄이기가 꺼져 있을 때만.
   그 밖의 상태는 위 기본값(첫 프레임 정지) 또는 숨김으로 남는다. 환경 그림은 언제나 정지.
   close/cancel 시 playing="false" 와 aria-pressed 동기화는 제품 로직 몫이다. */
#activity-scene-dialog[open][data-animation-playing="true"] .activity-animation-sprite {
  animation: activity-animation-sheet-2x2 1s steps(1, end) infinite;
}

@keyframes activity-animation-sheet-2x2 {
  0%        { background-position: 0% 0%; }
  25%       { background-position: 100% 0%; }
  50%       { background-position: 0% 100%; }
  75%, 100% { background-position: 100% 100%; }
}

/* 모션 줄이기는 절대 규칙이다. 되돌리는 예외 선택자는 없다.
   아래 선택자는 재생 규칙과 같거나 더 높은 명시도로 뒤에 오므로 항상 이긴다. */
@media (prefers-reduced-motion: reduce) {
  #activity-scene-dialog .activity-animation-sprite,
  #activity-scene-dialog[open][data-animation-playing="true"] .activity-animation-sprite {
    animation: none;
    background-position: 0% 0%;
  }
}

/* 6. 재생/일시정지 버튼 — 상태는 data-animation-playing + aria-pressed 에서 읽는다 --- */
#activity-scene-dialog #activity-animation-toggle {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  min-inline-size: 104px;
  max-inline-size: 220px;
  min-block-size: 44px;
  padding: 0 12px;
  border: 1px solid var(--aas-ink);
  border-radius: 2px;
  background: var(--aas-paper);
  color: var(--aas-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--aas-ink);
}
#activity-scene-dialog #activity-animation-toggle[aria-pressed="true"] {
  background: var(--aas-paper-deep);
  box-shadow: inset 0 2px 0 var(--aas-rule);
}
#activity-scene-dialog #activity-animation-toggle::before {
  content: "";
  flex: none;
  box-sizing: content-box;
  inline-size: 0;
  block-size: 0;
  border-block: 6px solid transparent;
  border-inline-start: 10px solid currentColor;
  border-inline-end: 0;
}
#activity-scene-dialog[data-animation-playing="true"] #activity-animation-toggle::before {
  inline-size: 4px;
  block-size: 12px;
  border-block: 0;
  border-inline: 3px solid currentColor;
}
#activity-scene-dialog #activity-animation-toggle:hover {
  background: var(--aas-cream);
}

/* 비활성(모션 줄이기): 그림자를 걷고 점선 테두리 + 줄무늬 바탕. 글자 대비는 AA 유지. 아이콘은 정지 사각형. */
#activity-scene-dialog #activity-animation-toggle:disabled,
#activity-scene-dialog #activity-animation-toggle[aria-disabled="true"] {
  border-style: dashed;
  border-color: var(--aas-ink-soft);
  background: var(--aas-stripes);
  color: var(--aas-ink-soft);
  box-shadow: none;
  cursor: not-allowed;
}
#activity-scene-dialog #activity-animation-toggle:disabled:hover,
#activity-scene-dialog #activity-animation-toggle[aria-disabled="true"]:hover {
  background: var(--aas-stripes);
}
#activity-scene-dialog #activity-animation-toggle:disabled::before,
#activity-scene-dialog #activity-animation-toggle[aria-disabled="true"]::before {
  inline-size: 8px;
  block-size: 8px;
  border: 0;
  background: currentColor;
}

#activity-scene-dialog #activity-animation-toggle:focus-visible,
#activity-scene-dialog #activity-scene-next:focus-visible,
#activity-scene-dialog #activity-scene-skip:focus-visible {
  outline: 3px solid var(--aas-green);
  outline-offset: 2px;
}

/* 7. 텍스트 열 ------------------------------------------------------------ */
#activity-scene-dialog .activity-animation-text {
  display: grid;
  gap: 10px;
  min-inline-size: 0;
}
#activity-scene-dialog #activity-scene-narration {
  margin: 0;
  min-block-size: 1.75em;
  line-height: 1.75;
  color: var(--aas-ink);
  background-image: linear-gradient(to bottom, transparent calc(100% - 1px), var(--aas-rule) calc(100% - 1px));
  background-size: 100% 1.75em;
}
#activity-scene-dialog #activity-scene-dialogue {
  padding: 8px 12px 10px;
  border: 1px solid var(--aas-rule);
  border-inline-start: 3px solid var(--aas-green);
  background: var(--aas-cream);
}
#activity-scene-dialog #activity-scene-speaker {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--aas-gold);
}
#activity-scene-dialog #activity-scene-dialogue-text {
  margin: 2px 0 0;
  line-height: 1.65;
  color: var(--aas-ink);
}

/* 8. 반응형 --------------------------------------------------------------- */
/* 넓은 화면: 환경(남는 폭 × 260) | 동작 열 236px (스프라이트 200 + 아래 버튼). 두 틀 높이가 같다. */
@media (min-width: 720px) {
  #activity-scene-dialog .activity-animation-layout {
    gap: 16px;
  }
  #activity-scene-dialog .activity-animation-visuals {
    grid-template-columns: minmax(0, 1fr) 236px;
    gap: 10px;
  }
  #activity-scene-dialog .activity-animation-environment-frame {
    block-size: 260px;
  }
  #activity-scene-dialog .activity-animation-stage {
    grid-template-columns: minmax(0, 1fr);
    align-content: space-between;
    justify-items: center;
    gap: 10px;
    padding: 12px;
  }
  #activity-scene-dialog .activity-animation-frame {
    inline-size: 200px;
    block-size: 200px;
  }
  #activity-scene-dialog .activity-animation-controls {
    justify-self: stretch;
  }
  #activity-scene-dialog #activity-animation-toggle {
    max-inline-size: none;
    min-block-size: 38px;
  }
  #activity-scene-dialog #activity-scene-narration {
    min-block-size: 3.5em;
  }
}

/* 낮은 가로 화면: 나란히 두고 환경 높이만 줄인다. 나머지는 본문 내부 스크롤. */
@media (max-height: 540px) and (min-width: 560px) {
  #activity-scene-dialog .activity-animation-visuals {
    grid-template-columns: minmax(0, 1fr) 148px;
    gap: 8px;
  }
  #activity-scene-dialog .activity-animation-environment-frame {
    block-size: clamp(170px, calc(100vh - 230px), 260px);
    block-size: clamp(170px, calc(100dvh - 230px), 260px);
  }
  #activity-scene-dialog .activity-animation-stage {
    grid-template-columns: minmax(0, 1fr);
    align-content: space-between;
    justify-items: center;
    gap: 8px;
    padding: 8px;
  }
  #activity-scene-dialog .activity-animation-frame {
    inline-size: 112px;
    block-size: 112px;
  }
  #activity-scene-dialog .activity-animation-controls {
    justify-self: stretch;
  }
  #activity-scene-dialog #activity-animation-toggle {
    max-inline-size: none;
    min-block-size: 40px;
  }
  #activity-scene-dialog #activity-scene-narration {
    min-block-size: 1.75em;
  }
}

/* schedule-batch-design — actual Claude component; scoped to distributed wrappers */
.schedule-batch-design {
  --sbd-paper: oklch(0.955 0.018 88);
  --sbd-paper-deep: oklch(0.925 0.02 86);
  --sbd-paper-lift: oklch(0.975 0.014 90);
  --sbd-ink: oklch(0.29 0.02 60);
  --sbd-ink-soft: oklch(0.43 0.02 62);
  --sbd-rule: oklch(0.8 0.02 80);
  --sbd-rule-strong: oklch(0.66 0.02 75);
  --sbd-green: oklch(0.4 0.075 150);
  --sbd-green-deep: oklch(0.33 0.07 150);
  --sbd-gold: oklch(0.4 0.075 85);
  --sbd-gold-line: oklch(0.7 0.075 85);
  --sbd-r: 3px;
  --sbd-serif: "Noto Serif KR", "Nanum Myeongjo", Batang, serif;
  --sbd-sans: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", Helvetica, Arial, sans-serif;

  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 14px 12px 16px;
  font-family: var(--sbd-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--sbd-ink);
  background:
    repeating-linear-gradient(180deg, transparent 0 27px, oklch(0.8 0.02 80 / 0.28) 27px 28px),
    linear-gradient(180deg, var(--sbd-paper-lift), var(--sbd-paper) 40%, var(--sbd-paper-deep));
  border: 1px solid var(--sbd-rule-strong);
  border-radius: var(--sbd-r);
  box-shadow: inset 0 0 0 3px var(--sbd-paper), inset 0 0 0 4px var(--sbd-gold-line);
  overflow-wrap: anywhere;
}
.schedule-batch-design *,
.schedule-batch-design *::before,
.schedule-batch-design *::after { box-sizing: border-box; }
.schedule-batch-design [hidden] { display: none !important; }

.schedule-batch-design .sbd-section {
  margin: 0;
  padding: 12px 4px 14px;
  border-top: 1px solid var(--sbd-rule-strong);
}
.schedule-batch-design .sbd-section:first-of-type { border-top: 0; padding-top: 4px; }
.schedule-batch-design .sbd-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 0 0 10px;
}
.schedule-batch-design h2 {
  margin: 0;
  padding-left: 9px;
  border-left: 3px solid var(--sbd-gold-line);
  font-family: var(--sbd-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--sbd-green-deep);
}

.schedule-batch-design label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sbd-ink-soft);
}
.schedule-batch-design select {
  appearance: auto;
  min-height: 40px;
  padding: 6px 8px;
  font: 500 14px/1.3 var(--sbd-sans);
  color: var(--sbd-ink);
  background-color: var(--sbd-paper-lift);
  border: 1px solid var(--sbd-rule-strong);
  border-radius: var(--sbd-r);
  box-shadow: inset 1px 1px 2px oklch(0.29 0.02 60 / 0.12);
}
.schedule-batch-design button {
  min-height: 40px;
  padding: 7px 16px;
  font: 700 14px/1.3 var(--sbd-sans);
  border-radius: var(--sbd-r);
  cursor: pointer;
}
.schedule-batch-design select:focus-visible,
.schedule-batch-design button:focus-visible {
  outline: 3px solid var(--sbd-gold);
  outline-offset: 2px;
}

.schedule-batch-design .sbd-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  background: var(--sbd-paper-deep);
  border: 1px solid var(--sbd-rule);
  border-radius: var(--sbd-r);
  box-shadow: inset 1px 1px 3px oklch(0.29 0.02 60 / 0.1);
}
.schedule-batch-design .sbd-action-row label { flex: 1 0 100%; }
.schedule-batch-design #schedule-duration {
  flex: 0 1 112px;
  min-width: 96px;
}
.schedule-batch-design #btn-advance {
  flex: 1 1 150px;
  color: var(--sbd-paper-lift);
  background: var(--sbd-green);
  border: 1px solid var(--sbd-green-deep);
  box-shadow: 0 2px 0 var(--sbd-green-deep), inset 0 1px 0 oklch(0.975 0.014 90 / 0.22);
}
.schedule-batch-design #btn-advance:hover { background: var(--sbd-green-deep); }
.schedule-batch-design #btn-advance:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 3px oklch(0.2 0.03 150 / 0.5);
}
.schedule-batch-design #advance-note {
  display: block;
  min-height: 1.5em;
  margin: 8px 2px 0;
  font-size: 13px;
  color: var(--sbd-ink-soft);
}

.schedule-batch-design .sbd-receipt {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  background: var(--sbd-paper-lift);
  border: 1px solid var(--sbd-rule-strong);
  border-top: 2px solid var(--sbd-gold-line);
  border-radius: var(--sbd-r);
}
.schedule-batch-design .sbd-receipt > div {
  min-width: 0;
  padding: 8px 10px 9px;
}
.schedule-batch-design .sbd-receipt > div + div { border-left: 1px solid var(--sbd-rule); }
.schedule-batch-design .sbd-receipt > .sbd-cell-wide {
  grid-column: 1 / -1;
  border-left: 0;
  border-top: 1px dashed var(--sbd-rule-strong);
}
.schedule-batch-design .sbd-receipt dt {
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sbd-ink-soft);
}
.schedule-batch-design .sbd-receipt dd {
  margin: 2px 0 0;
  font-family: var(--sbd-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  color: var(--sbd-ink);
}
.schedule-batch-design .sbd-receipt .sbd-cell-wide dd {
  font-family: var(--sbd-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}
.schedule-batch-design .sbd-after {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}
.schedule-batch-design #btn-replay-activities,
.schedule-batch-design .sbd-after button {
  color: var(--sbd-green-deep);
  background: var(--sbd-paper-lift);
  border: 1px solid var(--sbd-green);
  box-shadow: 0 2px 0 var(--sbd-rule-strong);
}
.schedule-batch-design #btn-replay-activities:hover { background: var(--sbd-paper-deep); }

.schedule-batch-design .sbd-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}
.schedule-batch-design .sbd-record-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--sbd-rule);
}
.schedule-batch-design h3 {
  margin: 0;
  font-family: var(--sbd-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--sbd-ink);
}
.schedule-batch-design .sbd-first {
  margin: 0;
  font-size: 12.5px;
  color: var(--sbd-ink-soft);
}
.schedule-batch-design .sbd-first time {
  margin-left: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--sbd-gold);
}
.schedule-batch-design .sbd-snapshot {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 8px 0 0;
  border-top: 1px solid var(--sbd-rule);
  border-left: 1px solid var(--sbd-rule);
}
.schedule-batch-design .sbd-snapshot > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 6px;
  min-width: 0;
  padding: 5px 7px;
  border-right: 1px solid var(--sbd-rule);
  border-bottom: 1px solid var(--sbd-rule);
}
.schedule-batch-design .sbd-snapshot dt {
  margin: 0;
  font-size: 12.5px;
  color: var(--sbd-ink-soft);
}
.schedule-batch-design .sbd-snapshot dd {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--sbd-ink);
}

@media (min-width: 560px) {
  .schedule-batch-design { padding: 18px 20px 20px; }
  .schedule-batch-design .sbd-action-row { flex-wrap: nowrap; align-items: center; }
  .schedule-batch-design .sbd-action-row label { flex: 0 0 auto; padding: 0 4px; }
  .schedule-batch-design #btn-advance { flex: 1 1 auto; }
  .schedule-batch-design .sbd-receipt { grid-template-columns: 1fr 1fr 2fr; }
  .schedule-batch-design .sbd-receipt > .sbd-cell-wide {
    grid-column: auto;
    border-top: 0;
    border-left: 1px dashed var(--sbd-rule-strong);
  }
  .schedule-batch-design .sbd-snapshot > div { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .schedule-batch-design #btn-advance:active { transform: none; }
}

/* Wardrobe atlas crops reuse the existing portrait and Claude wardrobe frames. */
.portrait-inner,
#wardrobe-dialog .preview,
#wardrobe-dialog .choice__figure {
  background-color: var(--paper-2);
  background-image: url("/assets/wardrobe-room-background.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.wardrobe-art {
  position: relative;
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  background: transparent;
}
.wardrobe-art[data-asset-kind="atlas"],
.wardrobe-art[data-asset-kind="image"] {
  width: auto;
  height: 100%;
  margin-inline: auto;
}
.wardrobe-art[data-asset-kind="image"] { aspect-ratio: 2 / 3; }
.wardrobe-art > img {
  display: block;
  border-radius: 0;
  background: transparent;
}
.wardrobe-art.is-fallback { outline: 1px dashed var(--rule-strong); outline-offset: -1px; }

#portrait-art {
  z-index: 1;
  width: 100%;
  height: 100%;
  margin-inline: auto;
}
#portrait-art[data-asset-kind="atlas"],
#portrait-art[data-asset-kind="image"] { width: auto; }
#portrait-art #portrait-image { max-width: none; }

#wardrobe-dialog .preview { min-height: 180px; }
#wardrobe-dialog #wardrobe-preview-art {
  width: 100%;
  height: 160px;
  margin-inline: auto;
}
#wardrobe-dialog #wardrobe-preview-art[data-asset-kind="atlas"],
#wardrobe-dialog #wardrobe-preview-art[data-asset-kind="image"] { width: auto; }
#wardrobe-dialog #wardrobe-preview-image {
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
}
#wardrobe-dialog .choice__figure {
  display: grid;
  place-items: center;
  width: 100%;
  height: 150px;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--r);
  background-color: var(--paper-2);
}
#wardrobe-dialog .choice__figure .wardrobe-art { height: 100%; }
#wardrobe-dialog .choice__figure .wardrobe-art[data-asset-state="unavailable"] { width: 100%; }
#wardrobe-dialog .choice__figure img {
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
}

@media (min-width: 560px) {
  #wardrobe-dialog #wardrobe-preview-art { height: 200px; }
  #wardrobe-dialog .choice__figure { height: 168px; }
}

@media (max-height: 480px) and (orientation: landscape) {
  #wardrobe-dialog .preview { min-height: 130px; }
  #wardrobe-dialog #wardrobe-preview-art,
  #wardrobe-dialog .choice__figure { height: 110px; }
}

/* ==================== ENDING PRESENTATION START ==================== */
.end-dialog, .end-archive { --mono: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ==========================================================
   end- : 공용 조각 (그림 액자, 자리표시, 장서표, 능력치 표)
   ========================================================== */
.end-sr{
  position:absolute; width:1px; height:1px; margin:-1px; padding:0;
  overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0;
}

/* 금색 이중 괘선 액자 */
.end-art{
  margin:0; padding:4px;
  background:var(--paper); border:1px solid var(--gold-lift); border-radius:var(--r);
}
.end-art-inner{
  display:block; position:relative; overflow:hidden;
  aspect-ratio:3 / 2; border:1px solid var(--gold);
}

/* 그림 자리표시 — 통합 시 <img>로 치환 */
.end-ph{
  display:grid; place-items:center; width:100%; height:100%; padding:10px;
  background:repeating-linear-gradient(135deg, var(--paper-2) 0 9px, var(--paper-3) 9px 18px);
}
.end-ph-label{
  max-width:34em; padding:3px 8px;
  font:400 0.75rem/1.5 var(--mono); color:var(--ink-soft); text-align:center;
  background:var(--paper); border:1px solid var(--rule-soft);
}

/* B3 장서표 — 그림 파일이 없는 엔딩의 대체 표시 (CSS만) */
.end-plate{
  container-type:inline-size;
  display:grid; place-items:center; align-content:center; width:100%; height:100%;
  background:var(--paper);
  box-shadow:inset 0 0 0 1px var(--gold), inset 0 0 0 4px var(--paper), inset 0 0 0 5px var(--gold-lift);
}
.end-plate-letter{
  font:700 46cqw/1 var(--serif); color:var(--gold);
}
.end-plate-wide .end-plate-letter{font-size:30cqw}
.end-plate::before,.end-plate::after{
  content:""; width:max(4px,3.5cqw); height:max(4px,3.5cqw);
  background:var(--gold-lift); transform:rotate(45deg);
}
.end-plate::before{margin-bottom:5cqw}
.end-plate::after{margin-top:6cqw}
.end-plate-wide::before{margin-bottom:3cqw}
.end-plate-wide::after{margin-top:4cqw}

/* 능력치 9칸 표 (가계부 괘선) */
.end-stats{
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr));
  margin:0; background:var(--paper);
  border:1px solid var(--rule); border-radius:var(--r);
}
.end-stats > div{
  padding:9px 12px 10px;
  border-right:1px solid var(--ledger-line); border-bottom:1px solid var(--ledger-line);
}
.end-stats > div:nth-child(3n){border-right:0}
.end-stats > div:nth-last-child(-n+3){border-bottom:0}
.end-stats dt{font:400 0.75rem/1.4 var(--sans); color:var(--ink-soft)}
.end-stats dd{
  margin:1px 0 0; font:600 1.25rem/1.3 var(--sans); color:var(--ink);
  font-variant-numeric:tabular-nums; letter-spacing:-0.01em;
}
.end-stats dd small{font:500 0.75rem/1 var(--sans); color:var(--ink-soft); margin-left:2px}


/* ==========================================================
   A. 엔딩 연출 dialog
   ========================================================== */
.end-dialog{
  container:end-dialog / inline-size;
  width:min(960px, calc(100vw - 24px)); max-width:none;
  max-height:calc(100dvh - 24px);
  padding:0; color:var(--ink); background:var(--paper);
  border:1px solid var(--rule); border-radius:var(--r);
  box-shadow:0 0 0 4px var(--paper), 0 0 0 5px var(--rule-soft), 0 24px 48px -28px oklch(28% 0.02 60 / 0.5);
}
.end-dialog[open]{display:flex; flex-direction:column}
.end-dialog::backdrop{background:oklch(28% 0.020 60 / 0.62)}

/* 상단: 단계 표시 + 닫기 불가 안내 (닫기 버튼 없음) */
.end-head{
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:2px 16px;
  padding:8px 16px; border-bottom:1px solid var(--rule);
  background:var(--paper-2);
}
.end-steps{display:flex; align-items:center; margin:0; padding:0; list-style:none}
.end-steps li{
  display:flex; align-items:center; gap:6px; padding:6px 0;
  font:500 0.8125rem/1 var(--sans); color:var(--ink-soft);
}
.end-steps li + li::before{content:""; width:14px; height:1px; margin:0 8px 0 4px; background:var(--rule)}
.end-step-no{
  display:grid; place-items:center; width:20px; height:20px;
  font:600 0.75rem/1 var(--sans); font-variant-numeric:tabular-nums;
  border:1px solid var(--rule); border-radius:var(--r); background:var(--paper);
}
/* 현재 단계 */
.end-dialog[data-ending-step="cover"] [data-end-mark="cover"],
.end-dialog[data-ending-step="story"] [data-end-mark="story"],
.end-dialog[data-ending-step="record"] [data-end-mark="record"]{color:var(--ink); font-weight:600}
.end-dialog[data-ending-step="cover"] [data-end-mark="cover"] .end-step-no,
.end-dialog[data-ending-step="story"] [data-end-mark="story"] .end-step-no,
.end-dialog[data-ending-step="record"] [data-end-mark="record"] .end-step-no{
  background:var(--ink); border-color:var(--ink); color:var(--paper);
}
/* 지난 단계 */
.end-dialog[data-ending-step="story"] [data-end-mark="cover"] .end-step-no,
.end-dialog[data-ending-step="record"] [data-end-mark="cover"] .end-step-no,
.end-dialog[data-ending-step="record"] [data-end-mark="story"] .end-step-no{
  background:var(--green-wash); border-color:var(--green-lift); color:var(--green);
}
.end-lock{margin:0; font:400 0.75rem/1.4 var(--sans); color:var(--ink-soft)}

/* 본문: 폰 기준 한 단 (그림 → 제목 → 본문 → 버튼) */
.end-body{
  display:grid; grid-template-columns:minmax(0,1fr); gap:16px;
  padding:20px 16px 24px; overflow-y:auto;
}
.end-eyebrow{
  margin:0; font:400 0.875rem/1.5 var(--serif); color:var(--ink-soft);
  letter-spacing:0.04em; text-align:center;
}
.end-main{display:grid; gap:14px; min-width:0}
.end-title{
  margin:0; font:700 1.75rem/1.35 var(--serif); letter-spacing:-0.01em; color:var(--ink);
}
.end-title:focus{outline:none}
.end-summary{margin:0; font:400 1.0625rem/1.8 var(--serif); color:var(--ink-soft)}
.end-actions{display:flex; flex-wrap:wrap; gap:8px}

/* 단계별 표시 전환 */
.end-dialog:not([data-ending-step="cover"]) .end-cover-actions,
.end-dialog:not([data-ending-step="story"]) .end-story,
.end-dialog:not([data-ending-step="record"]) .end-record,
.end-dialog[data-ending-step="story"] .end-summary{display:none}

/* A1 표지 */
.end-dialog[data-ending-step="cover"] .end-main{justify-items:center; text-align:center}
.end-dialog[data-ending-step="cover"] .end-dialog-art{width:100%; max-width:640px; justify-self:center}
.end-dialog[data-ending-step="cover"] .end-title{
  padding-top:14px; position:relative;
}
.end-dialog[data-ending-step="cover"] .end-title::before{
  content:""; position:absolute; top:0; left:50%; width:48px; height:1px;
  margin-left:-24px; background:var(--gold-lift);
}
.end-cover-actions{justify-content:center; margin-top:4px}
.end-cover-actions .btn{min-width:180px}

/* A2·A3 폰: 그림을 위에 작게 */
.end-dialog:not([data-ending-step="cover"]) .end-dialog-art{width:min(100%,260px); justify-self:center}
.end-dialog:not([data-ending-step="cover"]) .end-title{font-size:1.375rem}

/* A2 이야기 */
.end-story{display:grid; gap:14px}
.end-story-page{
  max-width:32em; min-height:13em;
  padding:14px 0 0; border-top:1px solid var(--rule-soft);
  transition:opacity .22s ease;
}
.end-story-page.end-is-fading{opacity:0}
.end-story-page p{margin:0; font:400 1.0625rem/2.05 var(--serif); color:var(--ink)}
.end-story-nav{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  max-width:34em; padding-top:12px; border-top:1px solid var(--rule-soft);
}
.end-page-count{
  margin:0; font:500 0.875rem/1 var(--sans); color:var(--ink-soft);
  font-variant-numeric:tabular-nums;
}
.end-story-nav .end-actions{flex-wrap:nowrap}

/* A3 성장 기록 */
.end-record{display:grid; gap:16px}
.end-record-h{
  margin:0 0 6px; font:600 0.8125rem/1.4 var(--sans); color:var(--ink-soft);
}
.end-badge{
  display:flex; align-items:center; gap:10px; padding:8px 12px;
  background:var(--gold-wash); border:1px solid var(--gold-lift); border-radius:var(--r);
  box-shadow:inset 0 0 0 2px var(--paper), inset 0 0 0 3px var(--gold-lift);
}
.end-badge-mark{width:9px; height:9px; flex:none; background:var(--gold); transform:rotate(45deg); margin-left:4px}
.end-badge strong{font:700 1rem/1.4 var(--serif); color:var(--gold); font-variant-numeric:tabular-nums}
.end-badge span:last-child{font-size:0.8125rem; color:var(--ink-soft)}
.end-summary-rows{display:grid; gap:8px; margin:0}
.end-summary-rows > div{display:grid; gap:4px}
.end-summary-rows dt{font:400 0.75rem/1.4 var(--sans); color:var(--ink-soft)}
.end-summary-rows dd{display:flex; flex-wrap:wrap; gap:6px; margin:0}
.end-record-actions{justify-content:flex-end; padding-top:14px; border-top:1px solid var(--rule-soft)}

@container end-dialog (max-width: 480px){
  .end-record-actions .btn,.end-cover-actions .btn{flex:1 1 140px}
  .end-story-nav{flex-wrap:wrap}
  .end-story-nav .end-actions{flex:1 1 100%}
  .end-story-nav .end-actions .btn{flex:1 1 0; padding:0 10px}
  .end-page-count{flex:1 1 100%; text-align:center; order:-1; padding-bottom:4px}
  .end-stats > div{padding:8px 8px 9px}
  .end-stats dd{font-size:1.0625rem}
}

/* 데스크톱 폭: A2·A3은 왼쪽 그림 고정 + 오른쪽 본문 */
@container end-dialog (min-width: 720px){
  .end-head{padding:8px 24px}
  .end-steps li + li::before{width:28px; margin:0 12px 0 8px}
  .end-body{padding:28px 48px 36px; gap:20px}
  .end-title{font-size:2.375rem}
  .end-dialog:not([data-ending-step="cover"]) .end-body{
    grid-template-columns:288px minmax(0,1fr); column-gap:44px;
  }
  .end-dialog:not([data-ending-step="cover"]) .end-eyebrow{grid-column:1 / -1; text-align:left}
  .end-dialog:not([data-ending-step="cover"]) .end-dialog-art{
    width:100%; justify-self:stretch; align-self:start; position:sticky; top:0;
  }
  .end-dialog:not([data-ending-step="cover"]) .end-title{font-size:1.625rem}
  .end-story-page p{font-size:1.125rem}
  .end-story-page{min-height:15em}
}


/* ==========================================================
   B. 엔딩 기록부
   ========================================================== */
.end-archive{display:grid; gap:14px}
.end-archive-head{
  display:flex; flex-wrap:wrap; align-items:flex-end; justify-content:space-between; gap:10px 16px;
  padding-bottom:12px; border-bottom:1px solid var(--rule);
}
.end-archive-head h2{margin:0; font:700 1.5rem/1.3 var(--serif)}
.end-count{margin:2px 0 0; font-size:0.875rem; color:var(--ink-soft); font-variant-numeric:tabular-nums}
.end-filter{display:flex; align-items:center; gap:8px; font-size:0.875rem; color:var(--ink-soft)}
.end-filter select{
  min-height:40px; padding:0 30px 0 10px;
  font:500 0.875rem/1 var(--sans); color:var(--ink);
  background:var(--paper); border:1px solid var(--rule); border-radius:var(--r);
}
.end-state,.end-empty{margin:0; font-size:0.8125rem; color:var(--ink-soft)}
.end-empty{padding:20px; text-align:center; border:1px dashed var(--rule); border-radius:var(--r)}

/* B1 격자 — 발견한 칸도 같은 크기의 한 칸 */
.end-grid{
  display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); grid-auto-rows:1fr; gap:6px;
  margin:0; padding:0; list-style:none;
}
.end-grid > li{display:flex; min-width:0}
.end-grid[data-end-filter="found"] > li[data-ending-state="locked"],
.end-grid[data-end-filter="locked"] > li[data-ending-state="found"]{display:none}

.end-cell{
  display:flex; flex-direction:column; width:100%; min-width:0; min-height:40px;
  border-radius:var(--r); font-family:var(--sans);
}
.end-cell-locked{
  align-items:center; justify-content:center;
  font:400 1.5rem/1 var(--serif); color:var(--ink-faint);
  border:1px dashed var(--ink-faint); background:transparent;
}
button.end-cell{
  padding:3px; text-align:left; color:var(--ink); cursor:pointer;
  background:var(--paper); border:1px solid var(--gold-lift);
  transition:border-color .15s ease, background-color .15s ease;
}
button.end-cell:hover{border-color:var(--gold); background:var(--paper-3)}
button.end-cell[aria-expanded="true"]{border-color:var(--gold); box-shadow:0 0 0 2px var(--gold-wash), 0 0 0 1px var(--gold)}
.end-thumb{display:block; aspect-ratio:1 / 1; overflow:hidden; border:1px solid var(--gold)}
.end-thumb .end-ph{padding:2px}
.end-thumb .end-ph-label{font-size:0.625rem; line-height:1.3; padding:1px 3px; border:0}
.end-cell-title{
  display:block; margin-top:4px; padding:0 2px;
  font:700 0.6875rem/1.4 var(--serif); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.end-cell-date{
  display:block; padding:0 2px 1px;
  font:400 0.6875rem/1.4 var(--sans); color:var(--ink-soft); font-variant-numeric:tabular-nums;
  white-space:nowrap; overflow:hidden;
}

/* B2 상세 패널 */
.end-detail{
  display:grid; gap:18px; padding:16px;
  background:var(--paper); border:1px solid var(--rule); border-radius:var(--r);
  border-top:2px solid var(--gold-lift);
}
.end-detail[hidden]{display:none}
.end-detail:focus{outline:none}
.end-detail-side{display:grid; gap:14px; align-content:start; min-width:0}
.end-detail-main{display:grid; gap:12px; align-content:start; min-width:0}
.end-detail-main h3{margin:0; font:700 1.5rem/1.35 var(--serif)}
.end-detail-date{margin:0; font-size:0.8125rem; color:var(--ink-soft); font-variant-numeric:tabular-nums}
.end-detail-story{display:grid; gap:14px; max-width:33em; padding-top:12px; border-top:1px solid var(--rule-soft)}
.end-detail-story p{margin:0; font:400 1rem/2 var(--serif)}
.end-detail-foot{display:flex; justify-content:flex-end}

@media (max-width:599px){
  .end-thumb .end-ph-label{position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%)}
}
@media (min-width:600px){
  .end-grid{grid-template-columns:repeat(8,minmax(0,1fr)); gap:8px}
  .end-cell-title{font-size:0.75rem}
}
@media (min-width:900px){
  .end-grid{grid-template-columns:repeat(10,minmax(0,1fr))}
  .end-cell-title{font-size:0.8125rem}
  .end-cell-date{font-size:0.75rem}
  .end-detail{grid-template-columns:minmax(0,5fr) minmax(0,6fr); column-gap:36px; padding:24px 28px}
  .end-detail-foot{grid-column:1 / -1}
}


/* Integration: real art and the existing reduced-motion preference. */
.end-image { display:block; width:100%; height:100%; object-fit:cover; }
.end-story-page.end-no-motion { transition:none; }
@media (prefers-reduced-motion: reduce) {
  .end-dialog *, .end-dialog *::before, .end-dialog *::after,
  .end-archive *, .end-archive *::before, .end-archive *::after {
    transition:none !important; animation:none !important; scroll-behavior:auto !important;
  }
}
/* ==================== ENDING PRESENTATION END ====================== */

/* ==========================================================================
   무사수행 · 상점·가방 dialog — 시안 이식 (worklog/adventure-design/adventure-shop-ui.html)
   ========================================================================== */
.adv-dialog{
  width:min(920px,100%);max-width:none;padding:0;
  border:1px solid var(--rule);border-radius:var(--r);
  background:var(--paper);color:var(--ink);
  box-shadow:0 1px 0 var(--rule-soft),0 10px 28px oklch(28% 0.02 60 / 0.10);
}
.adv-dialog:modal{max-height:calc(100dvh - 24px);overflow:auto}
.adv-dialog::backdrop{background:oklch(28% 0.02 60 / 0.45)}
.adv-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

.adv-head{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:10px 12px;border-bottom:3px double var(--rule);
}
.adv-title{font:700 1.25rem/1.3 var(--serif)}
.adv-head-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}

.adv-view{padding:14px 12px 18px;border-bottom:1px solid var(--rule)}
.adv-view:last-of-type{border-bottom:0}
.adv-h{font:700 1.0625rem/1.35 var(--serif);margin-bottom:10px}
.adv-sub{font:600 0.8125rem/1.4 var(--sans);color:var(--ink-soft);margin-bottom:6px}
.adv-note{font-size:0.8125rem;color:var(--ink-soft)}
.adv-slot-text{color:var(--ink-soft);font-style:normal;border-bottom:1px dashed var(--rule)}

.adv-art{
  display:grid;place-items:center;width:100%;
  border:1px solid var(--rule);border-radius:var(--r);
  background-color:var(--paper-3);
  background-image:repeating-linear-gradient(135deg,var(--rule-soft) 0 1px,transparent 1px 9px);
}
.adv-art[data-ratio="16x9"]{aspect-ratio:16/9}
.adv-art[data-ratio="1x1"]{aspect-ratio:1}
.adv-art span{
  padding:2px 8px;background:var(--paper);border:1px solid var(--rule-soft);
  font:400 0.75rem/1.4 var(--mono);color:var(--ink-soft);text-align:center;
}

.adv-stat{display:grid;grid-template-columns:auto 1fr;gap:2px 8px;align-items:baseline}
.adv-stat-name{font-weight:600;font-size:0.8125rem}
.adv-stat-val{justify-self:end;font-variant-numeric:tabular-nums;font-size:0.875rem}
.adv-meter{
  grid-column:1/-1;height:10px;overflow:hidden;
  background:var(--paper-sunk);border:1px solid var(--rule);border-radius:2px;
}
.adv-meter>span{display:block;height:100%;width:var(--v,0%);background:var(--green);transition:width .25s ease-out}
.adv-meter[data-kind="mp"]>span{background:var(--gold)}
.adv-meter[data-kind="steps"]>span{background:var(--ink-soft)}
.adv-meter[data-kind="enemy"]>span{background:var(--warn)}

.adv-ready{
  display:grid;gap:10px;margin-bottom:14px;padding:10px;
  background:var(--paper-2);border:1px solid var(--rule-soft);border-radius:var(--r);
}
.adv-ready-line{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-weight:600}
.adv-gear{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.adv-gear-slot{
  padding:6px 8px;background:var(--paper);border:1px solid var(--rule-soft);border-radius:var(--r);min-width:0;
}
.adv-gear-slot dt{font-size:0.75rem;color:var(--ink-soft)}
.adv-gear-slot dd{margin:0;font-weight:500;font-size:0.875rem;word-break:keep-all;overflow-wrap:normal}
.adv-gear-slot[data-empty="true"]{border-style:dashed;border-color:var(--rule)}
.adv-gear-slot[data-empty="true"] dd{color:var(--ink-soft);font-weight:400}
.adv-bag{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.adv-bag-label{font-size:0.8125rem;color:var(--ink-soft);margin-right:2px}

.adv-regions{display:grid;gap:10px}
.adv-region{
  display:grid;gap:8px;padding:8px;
  background:var(--paper);border:1px solid var(--rule);border-radius:var(--r);
}
.adv-region[data-state="locked"]{background:var(--paper-2)}
.adv-region[data-state="locked"] .adv-art{opacity:.55}
.adv-region-top{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.adv-region-name{font:700 1rem/1.3 var(--serif)}
.adv-region-tier{font-size:0.8125rem;color:var(--ink-soft);white-space:nowrap}
.adv-region-intro{font-size:0.8125rem;color:var(--ink-soft)}
.adv-region-row{
  display:flex;justify-content:space-between;align-items:center;gap:8px;
  padding-top:6px;border-top:1px solid var(--ledger-line);
}
.adv-region-cost{font-variant-numeric:tabular-nums}
.adv-region-cost b{font-weight:600}
.adv-region-chips{display:flex;flex-wrap:wrap;gap:4px}
.adv-region .btn{min-width:88px}

.adv-explore{
  display:grid;gap:12px;
  grid-template-columns:minmax(0,1fr);
  grid-template-areas:"map" "controls" "status" "log";
}
.adv-map-wrap{grid-area:map;min-width:0}
.adv-controls{grid-area:controls}
.adv-status{grid-area:status}
.adv-log-wrap{grid-area:log}

.adv-map{
  display:grid;grid-template-columns:repeat(9,minmax(0,1fr));gap:2px;
  padding:4px;background:var(--paper-3);
  border:1px solid var(--rule);border-radius:var(--r);
  box-shadow:inset 0 0 0 3px var(--paper),inset 0 0 0 4px var(--rule-soft);
}
.adv-map-row{display:contents}
.adv-tile{
  position:relative;aspect-ratio:1;min-width:0;
  display:grid;place-items:center;
  background:var(--paper);border-radius:1px;
}
.adv-tile::before,.adv-tile::after{content:"";position:absolute;display:none}
.adv-tile:is([data-tile="wall"],[data-key="wall"]){
  background-color:var(--paper-3);
  background-image:repeating-linear-gradient(45deg,oklch(43% 0.072 155 / .75) 0 1.5px,transparent 1.5px 6px);
}
.adv-tile:is([data-tile="start"],[data-key="start"])::before{
  display:block;width:46%;height:46%;border:2px solid var(--green);border-radius:50%;
}
.adv-tile:is([data-tile="treasure"],[data-key="treasure"])::before{
  display:block;width:38%;height:38%;transform:rotate(45deg);
  background:var(--gold-lift);border:2px solid var(--gold);
}
.adv-tile:is([data-tile="treasure-open"],[data-key="treasure-open"])::before{
  display:block;width:38%;height:38%;transform:rotate(45deg);
  border:1.5px dashed var(--gold-lift);
}
.adv-tile:is([data-tile="event"],[data-key="event"])::before{
  display:block;width:40%;height:40%;border-radius:50%;background:var(--green);
}
.adv-tile:is([data-tile="event-done"],[data-key="event-done"])::before{
  display:block;width:40%;height:40%;border-radius:50%;border:1.5px solid var(--ink-faint);
}
.adv-tile:is([data-tile="boss"],[data-key="boss"]){background:var(--gold-wash)}
.adv-tile:is([data-tile="boss"],[data-key="boss"])::before{
  display:block;width:52%;height:52%;transform:rotate(45deg);background:var(--ink);
}
.adv-tile:is([data-tile="boss"],[data-key="boss"])::after{
  display:block;width:16%;height:16%;border-radius:50%;background:var(--gold-lift);
}
.adv-tile:is([data-tile="fog"],[data-key="fog"]){
  background:var(--paper-sunk);box-shadow:inset 0 0 0 1px var(--rule-soft);
}
.adv-tile[data-here="true"]{box-shadow:inset 0 0 0 2px var(--gold)}
.adv-here{position:absolute;inset:0;z-index:1}
.adv-here::before{
  content:"";position:absolute;left:50%;top:15%;width:28%;height:28%;
  transform:translateX(-50%);border-radius:50%;background:var(--ink);
}
.adv-here::after{
  content:"";position:absolute;left:50%;top:47%;width:46%;height:36%;
  transform:translateX(-50%);border-radius:50% 50% 2px 2px;background:var(--green);
}

.adv-legend{display:flex;flex-wrap:wrap;gap:4px 12px;margin-top:8px;font-size:0.75rem;color:var(--ink-soft)}
.adv-legend li{display:inline-flex;align-items:center;gap:5px}
.adv-legend .adv-tile{width:18px;flex:none;border:1px solid var(--rule-soft)}

.adv-controls{display:grid;grid-template-columns:auto minmax(0,1fr);gap:12px;align-items:center}
.adv-pad{
  display:grid;grid-template-columns:repeat(3,48px);grid-template-rows:repeat(3,48px);gap:4px;
  grid-template-areas:". up ." "left hint right" ". down .";
}
.adv-pad .btn{padding:0;min-height:48px}
.adv-pad [data-adv-action="move-up"]{grid-area:up}
.adv-pad [data-adv-action="move-down"]{grid-area:down}
.adv-pad [data-adv-action="move-left"]{grid-area:left}
.adv-pad [data-adv-action="move-right"]{grid-area:right}
.adv-pad [data-adv-action="move"][data-dir="up"]{grid-area:up}
.adv-pad [data-adv-action="move"][data-dir="down"]{grid-area:down}
.adv-pad [data-adv-action="move"][data-dir="left"]{grid-area:left}
.adv-pad [data-adv-action="move"][data-dir="right"]{grid-area:right}
.adv-pad-hint{
  grid-area:hint;display:grid;place-items:center;text-align:center;
  font-size:0.6875rem;line-height:1.25;color:var(--ink-soft);
  border:1px dashed var(--rule);border-radius:var(--r);
}
.adv-arrow{width:0;height:0;border:8px solid transparent;border-top-width:0;border-bottom:11px solid currentColor}
.adv-arrow[data-dir="down"]{transform:rotate(180deg)}
.adv-arrow[data-dir="left"]{transform:rotate(-90deg)}
.adv-arrow[data-dir="right"]{transform:rotate(90deg)}
.adv-side-actions{display:grid;gap:6px}
.adv-side-actions .btn{width:100%;min-height:44px}
.adv-item-panel{display:grid;gap:4px;padding:6px;border:1px dashed var(--rule-soft);border-radius:var(--r)}
.adv-item-panel .btn{width:100%;min-height:36px}

.adv-status{
  display:grid;gap:10px;padding:10px;
  background:var(--paper-2);border:1px solid var(--rule-soft);border-radius:var(--r);
}
.adv-pouch{padding-top:8px;border-top:1px solid var(--ledger-line)}
.adv-pouch-row{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:6px}
.adv-pouch-gold{font:700 1.0625rem var(--serif);color:var(--gold);font-variant-numeric:tabular-nums}
.adv-loot{display:flex;flex-wrap:wrap;gap:4px}

.adv-log{
  border:1px solid var(--rule);border-radius:var(--r);background:var(--paper);
  font-size:0.875rem;
}
.adv-log li{
  display:grid;grid-template-columns:4.5em minmax(0,1fr);gap:8px;
  padding:5px 10px;border-bottom:1px solid var(--ledger-line);
}
.adv-log li:last-child{border-bottom:0;background:var(--gold-wash)}
.adv-log li>span:only-child{grid-column:1/-1}
.adv-log-step{font:400 0.75rem/1.8 var(--mono);color:var(--ink-soft)}

.adv-battle{display:grid;gap:12px;grid-template-columns:minmax(0,1fr)}
.adv-enemy{
  display:grid;gap:8px;padding:10px;align-content:start;
  background:var(--paper-2);border:1px solid var(--rule);border-radius:var(--r);
}
.adv-enemy .adv-art{max-width:220px;justify-self:center}
.adv-enemy-name{font:700 1.125rem/1.3 var(--serif);display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.adv-enemy-line{
  padding:6px 8px;border-left:3px solid var(--rule);background:var(--paper);
  font-family:var(--serif);color:var(--ink-soft);
}
.adv-battle-side{display:grid;gap:12px;align-content:start;min-width:0}
.adv-self{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.adv-cmds{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
.adv-cmd{flex-direction:column;gap:1px;min-height:52px;padding:4px 8px}
.adv-cmd:first-child{grid-column:1/-1}
.adv-cmd-note{font-size:0.75rem;font-weight:400;opacity:.92}
.adv-cmds-off{
  padding:8px;border:1px dashed var(--rule);border-radius:var(--r);
}

.adv-event{
  display:grid;gap:10px;padding:12px;margin-bottom:12px;
  background:var(--paper-2);border:1px solid var(--rule);border-radius:var(--r);
}
.adv-event:last-child{margin-bottom:0}
.adv-event-title{font:700 1.125rem/1.35 var(--serif)}
.adv-event-body{
  min-height:4.6em;padding:8px 10px;background:var(--paper);
  border:1px solid var(--rule-soft);border-radius:var(--r);
  background-image:repeating-linear-gradient(to bottom,transparent 0 1.5em,var(--ledger-line) 1.5em calc(1.5em + 1px));
  line-height:calc(1.5em + 1px);color:var(--ink-soft);
}
.adv-choices{display:grid;gap:6px}
.adv-choices .btn{justify-content:flex-start;min-height:44px;text-align:left}
.adv-choices .btn[aria-pressed="true"]{background:var(--green-wash);border-color:var(--green);color:var(--green);opacity:1}
.adv-outcome{
  display:grid;gap:8px;padding:10px;
  border:1px solid oklch(43% 0.072 155 / 0.35);border-radius:var(--r);background:var(--green-wash);
}
.adv-outcome-chips{display:flex;flex-wrap:wrap;gap:4px}
.adv-end{display:flex;justify-content:flex-end}

.adv-result{
  display:grid;gap:12px;padding:12px;margin-bottom:12px;
  background:var(--paper);border:1px solid var(--rule);border-radius:var(--r);
}
.adv-result:last-child{margin-bottom:0}
.adv-result-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.adv-result-head h4{font:700 1.0625rem var(--serif)}
.adv-table{width:100%;border-collapse:collapse;border-top:2px solid var(--rule)}
.adv-table th,.adv-table td{padding:8px 6px;border-bottom:1px solid var(--ledger-line);vertical-align:top;text-align:left}
.adv-table th{width:7.5em;font-weight:600;font-size:0.8125rem;color:var(--ink-soft)}
.adv-table td{font-variant-numeric:tabular-nums}
.adv-table .adv-loot{gap:4px}
.adv-num{font:700 1.0625rem var(--serif)}
.adv-num-gold{color:var(--gold)}
.adv-strike{text-decoration:line-through;color:var(--ink-soft);margin-right:6px}
.adv-alert{
  display:grid;grid-template-columns:auto 1fr;gap:10px;align-items:start;
  padding:10px;border:1px solid var(--warn);border-radius:var(--r);background:var(--warn-wash);color:var(--ink);
}
.adv-alert-mark{width:14px;height:14px;margin-top:4px;transform:rotate(45deg);background:var(--warn)}
.adv-alert b{color:var(--warn)}

@media (min-width:600px){
  .adv-head{padding:12px 20px}
  .adv-title{font-size:1.375rem}
  .adv-view{padding:18px 20px 22px}
  .adv-regions{grid-template-columns:repeat(2,minmax(0,1fr))}
  .adv-ready{grid-template-columns:auto 1fr;align-items:center}
  .adv-ready-line{grid-column:1/-1}
  .adv-bag{justify-content:flex-end}
  .adv-gear{min-width:340px}
}
@media (min-width:780px){
  .adv-explore{
    grid-template-columns:minmax(0,1fr) 296px;
    grid-template-rows:auto 1fr;
    grid-template-areas:"map status" "map controls" "log log";
    gap:14px 16px;
  }
  .adv-controls{align-self:start;grid-template-columns:auto minmax(0,1fr)}
  .adv-battle{grid-template-columns:minmax(0,300px) minmax(0,1fr);gap:16px}
  .adv-enemy .adv-art{max-width:none}
  .adv-event,.adv-result{padding:16px}
}

/* ---------- 상점·가방 dialog ---------- */
.shop-dialog{
  width:min(920px,100%);max-width:none;padding:0;
  border:1px solid var(--rule);border-radius:var(--r);
  background:var(--paper);color:var(--ink);
  box-shadow:0 1px 0 var(--rule-soft),0 10px 28px oklch(28% 0.02 60 / 0.10);
}
.shop-dialog:modal{max-height:calc(100dvh - 24px);overflow:auto}
.shop-dialog::backdrop{background:oklch(28% 0.02 60 / 0.45)}
.shop-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

.shop-head{
  display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;
  padding:10px 12px;border-bottom:3px double var(--rule);
}
.shop-title{font:700 1.25rem/1.3 var(--serif)}
.shop-head-meta{display:flex;align-items:center;gap:10px}
.shop-wallet{
  display:inline-flex;align-items:baseline;gap:8px;padding:4px 10px;
  background:var(--gold-wash);border:1px solid oklch(43% 0.072 82 / 0.38);border-radius:var(--r);
}
.shop-wallet-label{font-size:0.75rem;color:var(--ink-soft)}
.shop-wallet output{font:700 1.125rem var(--serif);color:var(--gold);font-variant-numeric:tabular-nums}

.shop-run-notice{
  margin:0;padding:8px 12px;border-bottom:1px solid var(--rule);
  background:var(--warn-wash);color:var(--warn);font-size:0.8125rem;font-weight:600;
}

.shop-tabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));border-bottom:1px solid var(--rule);background:var(--paper-2)}
.shop-tab{
  min-height:46px;border:0;border-right:1px solid var(--rule-soft);border-bottom:3px solid transparent;
  background:transparent;color:var(--ink-soft);font:600 0.9375rem var(--sans);cursor:pointer;
}
.shop-tab:last-child{border-right:0}
.shop-tab:hover{background:var(--paper-3)}
.shop-tab[aria-selected="true"]{background:var(--paper);color:var(--ink);border-bottom-color:var(--gold)}
.shop-tab:focus-visible{outline-offset:-3px}

.shop-panel{padding:14px 12px 18px;border-bottom:1px solid var(--rule)}
.shop-panel:last-of-type{border-bottom:0}
.shop-h{font:700 1.0625rem/1.35 var(--serif);margin-bottom:10px}
.shop-sub{font:600 0.8125rem/1.4 var(--sans);color:var(--ink-soft);margin-bottom:6px}
.shop-slot-text{color:var(--ink-soft);font-size:0.8125rem;border-bottom:1px dashed var(--rule)}

.shop-filter{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
.shop-filter .btn[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--paper)}

.shop-list{border-top:2px solid var(--rule)}
.shop-row{
  display:grid;gap:8px 10px;align-items:center;padding:10px 2px;
  border-bottom:1px solid var(--ledger-line);
  grid-template-columns:minmax(0,1fr) auto;
  grid-template-areas:"info info" "meta meta" "qty act";
}
.shop-row[data-state="short"],.shop-row[data-state="locked"]{background:var(--paper-2)}
.shop-info{grid-area:info;min-width:0;display:grid;gap:3px}
.shop-name{font-weight:600;display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.shop-kind{font-size:0.75rem;font-weight:400;color:var(--ink-soft)}
.shop-desc{font-size:0.8125rem;color:var(--ink-soft)}
.shop-fx{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}
.shop-meta{grid-area:meta;display:flex;gap:12px;align-items:baseline;font-variant-numeric:tabular-nums}
.shop-price{font:700 1rem var(--serif);color:var(--gold)}
.shop-row[data-state="short"] .shop-price{color:var(--warn)}
.shop-own{font-size:0.8125rem;color:var(--ink-soft)}
.shop-qty{grid-area:qty;display:inline-grid;grid-template-columns:40px 48px 40px;justify-self:start}
.shop-qty .btn{padding:0;border-radius:0;font-size:1.125rem}
.shop-qty .btn:first-child{border-radius:var(--r) 0 0 var(--r)}
.shop-qty .btn:last-child{border-radius:0 var(--r) var(--r) 0}
.shop-qty input{
  width:100%;min-height:40px;padding:0;text-align:center;
  border:1px solid var(--rule);border-left:0;border-right:0;border-radius:0;
  background:var(--paper);font-variant-numeric:tabular-nums;-moz-appearance:textfield;appearance:textfield;
}
.shop-qty input::-webkit-outer-spin-button,.shop-qty input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
.shop-qty input:disabled{background:var(--paper-3);color:var(--ink-faint)}
.shop-act{grid-area:act;display:grid;gap:3px;justify-items:end}
.shop-act .btn{min-width:84px}
.shop-why{font-size:0.75rem;color:var(--warn);text-align:right}

.shop-equip{display:grid;gap:14px}
.shop-slots{display:grid;gap:6px}
.shop-slot{
  display:grid;grid-template-columns:3.5em minmax(0,1fr) auto;gap:8px;align-items:center;
  padding:8px 10px;background:var(--paper-2);border:1px solid var(--rule);border-radius:var(--r);
}
.shop-slot-kind{font-size:0.8125rem;color:var(--ink-soft);font-weight:600}
.shop-slot-item{display:grid;gap:3px;min-width:0}
.shop-slot-item b{font-weight:600}
.shop-slot[data-empty="true"]{background:var(--paper);border-style:dashed}
.shop-slot[data-empty="true"] .shop-slot-item{color:var(--ink-soft)}
.shop-slot[data-target="true"]{box-shadow:inset 3px 0 0 var(--gold)}

.shop-preview{width:100%;border-collapse:collapse;border-top:2px solid var(--rule);font-variant-numeric:tabular-nums}
.shop-preview caption{text-align:left;padding-bottom:6px;font:600 0.8125rem var(--sans);color:var(--ink-soft)}
.shop-preview th,.shop-preview td{padding:7px 6px;border-bottom:1px solid var(--ledger-line);text-align:right}
.shop-preview th[scope="row"],.shop-preview thead th:first-child{text-align:left}
.shop-preview thead th{font-size:0.75rem;font-weight:500;color:var(--ink-soft)}
.shop-preview th[scope="row"]{font-weight:500}
.shop-preview td[data-delta="up"]{color:var(--green);font-weight:600}
.shop-preview td[data-delta="down"]{color:var(--warn);font-weight:600}

.shop-row-equip{grid-template-areas:"info info" "meta act"}
.shop-row-equip[data-preview="true"]{background:var(--gold-wash);box-shadow:inset 3px 0 0 var(--gold)}
.shop-row-equip .shop-act{grid-auto-flow:column;gap:6px}
.shop-row-equip .btn[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--paper)}

@media (min-width:600px){
  .shop-head{padding:12px 20px}
  .shop-title{font-size:1.375rem}
  .shop-panel{padding:18px 20px 22px}
  .shop-row{
    grid-template-columns:minmax(0,1fr) 108px auto 96px;
    grid-template-areas:"info meta qty act";padding:10px 6px;
  }
  .shop-meta{flex-direction:column;gap:0;align-items:flex-end}
  .shop-row-equip{grid-template-columns:minmax(0,1fr) 108px auto;grid-template-areas:"info meta act"}
}
@media (min-width:780px){
  .shop-equip{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px 20px}
  .shop-equip-list{grid-column:1/-1}
}

@media (prefers-reduced-motion:reduce){
  .adv-dialog *,.adv-dialog *::before,.adv-dialog *::after,
  .shop-dialog *,.shop-dialog *::before,.shop-dialog *::after{transition:none !important;animation:none !important}
}

/* 무사수행 그림 자리표시 — adventure-art-manifest에 없는 적·지역 (end- 장서표와 같은 방식) */
.adv-art .adv-plate{
  container-type:inline-size;
  display:grid; place-items:center; align-content:center; width:100%; height:100%;
  padding:0; border:0;
  background:var(--paper);
  box-shadow:inset 0 0 0 1px var(--gold), inset 0 0 0 4px var(--paper), inset 0 0 0 5px var(--gold-lift);
}
.adv-art .adv-plate-letter{
  padding:0; border:0; background:none;
  font:700 22cqw/1 var(--serif); color:var(--gold);
}
.adv-art .adv-plate::before,.adv-art .adv-plate::after{
  content:""; width:max(3px,2.5cqw); height:max(3px,2.5cqw);
  background:var(--gold-lift); transform:rotate(45deg);
}
.adv-art .adv-plate::before{margin-bottom:4cqw}
.adv-art .adv-plate::after{margin-top:5cqw}
.adv-art-img{ display:block; width:100%; height:100%; object-fit:cover; }

/* ---------- 라운드 E: 무사수행 화면 시각 결함 수정 (전역 .btn/.chip 은 두고 adv- 스코프만 추가) ---------- */
/* 결함 1: 방향 패드 — .adv-arrow 는 span(비치환 인라인)이라 transform 이 적용되지 않는다. 블록화하고 버튼을 flex 컨테이너로. */
.adv-pad .btn{display:inline-flex;align-items:center;justify-content:center}
.adv-arrow{display:block}
/* 결함 2: 전투 명령 버튼 — 3027행의 flex-direction:column 이 살아나도록 flex 컨테이너화. */
.adv-cmd{display:inline-flex;align-items:center;justify-content:center}
/* 결함 3: 전투 뷰 HP/MP — .adv-log-wrap{grid-area:log} 는 탐색 뷰(.adv-explore 의 areas)용인데
   전투 뷰에도 걸려 .adv-battle-side 에 암시적 2열을 만들고 .adv-self 행을 늘려 막대를 밀어낸다.
   전투 뷰에서는 배치를 되돌리고, 남은 늘어남도 위쪽 정렬로 막는다. */
.adv-battle .adv-log-wrap{grid-area:auto}
.adv-battle-self{align-items:start;align-content:start}
.adv-battle-self .adv-stat{align-content:start}
/* 결함 4: 귀환 정산 전리품·능력치 목록 — 불릿 제거, 칩이 줄어 글자가 잘리지 않게. */
.adv-loot{list-style:none;margin:0;padding:0}
.adv-loot .chip{flex:0 0 auto}


/* =========================================================
   HUD v7 (main-hud-v7 시안 이식)
   - 장면 그림이 틀 안쪽 전체를 채우는 바탕이고, 상자들은 그 위에 따로 떠 있다.
   - 홈 기본 상태에서 얼굴 안전 구역(가로 25~75%, 세로 18~62%)은 어떤 상자도 덮지 않는다.
   - 시안 진열 전용 규칙(.hud-demo-*, 안전 구역 점선, 자리표시 라벨)은 옮기지 않았다.
   - 시안의 data-stat="sword"/"affinity" 는 엔진 키 combat/affection 에 맞춰 바꿨다.
   - --hud-corner 는 CSP(img-src 'self') 때문에 :root에서 none이다(모서리 장식 없음).
   ========================================================= */

/* ---------- 컨테이너 ---------- */
.hud-viewport{
  container-type:inline-size;container-name:hud;
  font-family:var(--hud-sans);color:var(--hud-text);
  /* 떠 있는 상자의 바탕: 그림이 살짝만 비친다 */
  --hud-glass: oklch(22% 0.045 18 / .92);
}
.hud-viewport button,.hud-viewport select{font:inherit}
.hud-screen p{margin:0}

/* 넓은 화면 격자 — 격자는 상자를 놓을 자리만 정한다. 면을 칠하지 않는다.
   1열 메뉴 120 | 2열 빈 자리(아이와 방) | 3열 상태 한 열 230
   1행 본문 | 2행 아래 상자 둘 | 3행 표어 띠 */
.hud-screen{
  position:relative;
  display:grid;
  grid-template-columns:120px minmax(0,1fr) 230px;
  grid-template-rows:minmax(0,1fr) auto auto;
  gap:8px;
  padding:18px;
  height:var(--hud-screen-h,100dvh);
  min-height:640px;
  overflow:hidden;
  background:var(--hud-bg-3);
  font-size:14px;
  line-height:1.5;
}
.hud-screen > *{position:relative;z-index:1;min-width:0}

/* ---------- 전체 장식 틀: 와인색 띠 + 로즈골드 이중 괘선 + 모서리 마름모 ---------- */
.hud-screen > .hud-frame{
  position:absolute;inset:0;z-index:2;pointer-events:none;
  border:10px solid var(--hud-bg);
  box-shadow:inset 0 0 0 1px var(--hud-line);
}
.hud-frame::before{content:"";position:absolute;inset:-7px;border:1px solid var(--hud-line)}
.hud-frame i{
  position:absolute;width:16px;height:16px;
  background:var(--hud-bg-3);border:1px solid var(--hud-line);
  box-shadow:15px -15px 0 -5px var(--hud-accent),15px 15px 0 -5px var(--hud-accent);
}
.hud-frame i::before{content:"";position:absolute;inset:4px;background:var(--hud-accent)}
.hud-frame i[data-corner="tl"]{left:-6px;top:-6px;transform:rotate(45deg)}
.hud-frame i[data-corner="tr"]{right:-6px;top:-6px;transform:scaleX(-1) rotate(45deg)}
.hud-frame i[data-corner="bl"]{left:-6px;bottom:-6px;transform:scaleY(-1) rotate(45deg)}
.hud-frame i[data-corner="br"]{right:-6px;bottom:-6px;transform:scale(-1) rotate(45deg)}

/* ---------- 무대: 틀 안쪽 전체를 채우는 바탕 ---------- */
#col-portrait.stage-root{
  position:absolute;inset:10px;z-index:0;margin:0;min-height:0;
  grid-column:auto;grid-row:auto;border:0;
}
.stage-scene{
  position:absolute;inset:0;overflow:hidden;
  /* 그림이 없을 때 보이는 자리 표시 */
  background:repeating-linear-gradient(135deg,oklch(80% 0.03 80) 0 10px,oklch(77% 0.035 78) 10px 20px);
}
.stage-scene::after{ /* 가장자리를 살짝 눌러 상자와 그림의 경계를 부드럽게 */
  content:"";position:absolute;inset:0;pointer-events:none;
  box-shadow:inset 0 0 90px oklch(18.5% 0.04 15 / .38);
}
/* 장면 그림 한 장(3:2)을 담는 상자. 무대를 꽉 채운다. */
.stage-art{position:absolute;inset:0;overflow:hidden}
/* 장면 그림: #portrait-image 의 옛 크림 무대 규칙을 덮는다 */
#stage #portrait-image.stage-image{
  position:absolute;inset:0;width:100%;height:100%;max-width:none;
  object-fit:cover;object-position:48% 30%;
  display:block;user-select:none;-webkit-user-drag:none;
  background:transparent;
}
/* 장면 파일이 하나도 없을 때의 아틀라스 폴백: 바닥 중앙, 무대 높이의 78% */
.stage-art[data-fallback="atlas"]{
  position:absolute !important;inset:auto auto 0 50%;
  translate:-50% 0;height:78%;width:auto;margin-inline:0;
}

/* ---------- 장식 패널(떠 있는 상자) ---------- */
.hud-panel{
  position:relative;
  background:var(--hud-glass);color:var(--hud-text);
  border:1px solid var(--hud-line);border-radius:4px;
  box-shadow:var(--hud-shadow);
  padding:12px 14px;
}
.hud-panel::before{content:"";position:absolute;inset:3px;border:1px solid var(--hud-line-soft);border-radius:2px;pointer-events:none}
.hud-panel::after{
  content:"";position:absolute;inset:-6px;pointer-events:none;
  background:var(--hud-corner) left top/11px 11px no-repeat,var(--hud-corner) right top/11px 11px no-repeat,
             var(--hud-corner) left bottom/11px 11px no-repeat,var(--hud-corner) right bottom/11px 11px no-repeat;
}
.hud-panel-title{
  display:flex;align-items:center;gap:10px;
  font-family:var(--hud-serif);font-weight:700;font-size:14px;letter-spacing:.02em;color:var(--hud-accent);
}
.hud-flourish{flex:1;display:flex;align-items:center;gap:6px;min-width:24px}
.hud-flourish::before,.hud-flourish::after{content:"";flex:1;border-top:1px solid var(--hud-line-soft)}
.hud-flourish i{width:6px;height:6px;border:1px solid var(--hud-line);transform:rotate(45deg)}
.hud-num{font-variant-numeric:tabular-nums;font-feature-settings:"tnum"}
.hud-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

/* 상자를 묶는 그릇은 클릭을 통과시킨다(그림 위 빈 곳을 막지 않는다) */
.hud-center,.hud-status,.hud-profile,.hud-bottom,.hud-care{pointer-events:none}
.hud-status > *,.hud-profile > *,.hud-bottom > *,.hud-care > *{pointer-events:auto}
.hud-bottom > .hud-care{pointer-events:none}

/* ---------- 버튼 공통 ---------- */
.hud-btn{
  position:relative;
  display:inline-flex;align-items:center;gap:10px;
  min-height:44px;padding:0 12px;
  background:var(--hud-bg);color:var(--hud-text);
  border:1px solid var(--hud-line-soft);border-radius:4px;
  font-weight:500;text-align:left;cursor:pointer;
  transition:border-color .15s ease,background-color .15s ease,color .15s ease;
}
.hud-btn:hover:not(:disabled){border-color:var(--hud-accent);background:var(--hud-bg-2)}
.hud-btn:active:not(:disabled){background:var(--hud-bg-3)}
.hud-btn[aria-current="page"],.hud-btn[aria-pressed="true"]{
  background:var(--hud-accent);border-color:var(--hud-accent);color:var(--hud-bg-3);font-weight:600;
}
.hud-btn:disabled{cursor:not-allowed;color:oklch(68% 0.025 50);background:var(--hud-bg);border-style:dashed}
.hud-btn:disabled .hud-icon{opacity:.55}
.hud-icon{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
/* 아이콘 상자: 메뉴 버튼의 작은 칸 */
.hud-icon-cell{
  display:grid;place-items:center;width:24px;height:24px;flex:none;
  background:var(--hud-bg-3);border:1px solid var(--hud-line);border-radius:2px;color:var(--hud-accent);
}
.hud-icon-cell .hud-icon{width:16px;height:16px}
.hud-btn:disabled .hud-icon-cell{border-color:var(--hud-line-soft);color:inherit}
.hud-tag{
  margin-left:auto;font-size:11px;font-weight:500;line-height:1;padding:3px 5px;
  border:1px solid currentColor;border-radius:2px;white-space:nowrap;
}
.hud-viewport :focus-visible{outline:2px solid var(--hud-accent);outline-offset:2px}
.hud-sheet :focus-visible{outline-color:var(--hud-bg)}

.hud-btn-primary{
  justify-content:center;text-align:center;min-height:44px;padding:0 20px;
  background:var(--hud-accent);color:var(--hud-bg-3);border-color:var(--hud-accent);
  font-family:var(--hud-serif);font-weight:700;font-size:16px;letter-spacing:.04em;
  box-shadow:inset 0 0 0 3px var(--hud-accent),inset 0 0 0 4px oklch(24% 0.045 15 / .55);
}
.hud-btn-primary:hover:not(:disabled){background:oklch(85% 0.10 78);border-color:var(--hud-text)}
.hud-btn-primary:disabled{background:var(--hud-bg-2);color:var(--hud-text-soft);border:1px dashed var(--hud-line-soft);box-shadow:none}
.hud-btn-primary[aria-busy="true"]{border-style:solid;border-color:var(--hud-line);color:var(--hud-text)}
.hud-busy{width:8px;height:8px;background:var(--hud-accent);transform:rotate(45deg);animation:hud-pulse 1.2s ease-in-out infinite}
@keyframes hud-pulse{50%{opacity:.25}}

.hud-select{
  min-height:44px;padding:0 30px 0 12px;appearance:none;-webkit-appearance:none;cursor:pointer;
  background-color:var(--hud-bg);color:var(--hud-text);
  border:1px solid var(--hud-line-soft);border-radius:4px;
  background-image:linear-gradient(45deg,transparent 50%,var(--hud-line) 50%),linear-gradient(135deg,var(--hud-line) 50%,transparent 50%);
  background-position:calc(100% - 16px) 50%,calc(100% - 11px) 50%;background-size:5px 5px;background-repeat:no-repeat;
}
.hud-select:hover{border-color:var(--hud-accent)}
.hud-select option{background:var(--hud-bg);color:var(--hud-text)}

/* ---------- 폰 전용 상태 띠(넓은 화면에서는 숨긴다) ---------- */
.hud-topbar{display:none}

/* ---------- 왼쪽 레일: 작은 로고 + 메뉴(폭 120) ---------- */
.hud-rail{grid-column:1;grid-row:1;display:flex;flex-direction:column;gap:8px;min-height:0;align-self:start}
.hud-lockup{display:flex;flex-direction:column;align-items:center;gap:2px;padding:8px 6px 7px;text-align:center}
.hud-star{width:16px;height:16px;flex:none;fill:var(--hud-accent)}
.hud-title{font-family:var(--hud-serif);font-weight:700;font-size:13.5px;line-height:1.3;white-space:nowrap}
.hud-subtitle{font-family:var(--hud-serif);font-size:11px;color:var(--hud-text-soft);white-space:nowrap}
.hud-menu{display:grid;gap:3px;padding:6px}
.hud-menu ul{display:grid;gap:3px;list-style:none;margin:0;padding:0}
.hud-menu li{list-style:none;margin:0;padding:0}
/* 모듈이 심은 버튼은 .btn / .social-button 을 달고 오므로 메뉴 안에서는 모양을 여기서 못 박는다 */
.hud-menu .hud-btn{
  width:100%;min-height:36px;padding:0 6px 0 4px;gap:7px;font-size:13px;white-space:nowrap;
  display:inline-flex;align-items:center;justify-content:flex-start;
  background:var(--hud-bg);color:var(--hud-text);
  border:1px solid var(--hud-line-soft);border-radius:4px;
  font-family:var(--hud-sans);font-weight:500;letter-spacing:normal;text-transform:none;box-shadow:none;
}
.hud-menu .hud-btn:hover:not(:disabled){border-color:var(--hud-accent);background:var(--hud-bg-2)}
.hud-menu .hud-btn:disabled{color:oklch(68% 0.025 50);background:var(--hud-bg);border-style:dashed}
.hud-btn-label{min-width:0;overflow:hidden;text-overflow:ellipsis}
/* 좁은 메뉴에서는 '잠김' 꼬리표를 글자로 보이지 않고 점선 테두리로만 알린다(읽기 도구에는 남는다) */
.hud-menu .hud-tag{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);padding:0;border:0}
.hud-menu-more{display:none}

/* 모듈이 심는 버튼(무사수행·상점·교류 광장)은 app.js 가 좌우 메뉴 줄로 옮긴다.
   .btn / .social-button 의 옛 모양이 남지 않도록 여기서 눌러 준다. */
.hud-menu-injected{display:contents}
.hud-menu .hud-btn.btn,.hud-menu .hud-btn.social-button{
  font-family:var(--hud-sans);font-size:13px;letter-spacing:normal;text-transform:none;
  box-shadow:none;min-width:0;width:100%;
}
/* 옮기기 전(또는 옮길 수 없는 버튼)에도 메뉴 모양을 유지한다 */
.hud-menu .hud-menu-injected .btn{
  display:inline-flex;align-items:center;gap:7px;width:100%;
  min-height:36px;padding:0 6px;
  background:var(--hud-bg);color:var(--hud-text);
  border:1px solid var(--hud-line-soft);border-radius:4px;
  font-family:var(--hud-sans);font-size:13px;font-weight:500;text-align:left;cursor:pointer;
  box-shadow:none;
}

/* ---------- 가운데: 토스트·안내 띠만 맨 위에 잠깐 뜬다 ---------- */
.hud-center{grid-column:2;grid-row:1;align-self:start;justify-self:start;max-width:100%}
.hud-status{display:grid;gap:6px;justify-items:start}
.hud-toast,.hud-banner{
  display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  padding:6px 12px;font-size:13px;max-width:100%;
}
.hud-toast::after,.hud-banner::after{display:none}
.hud-pip{width:8px;height:8px;flex:none;transform:rotate(45deg);background:var(--hud-good)}
.hud-toast[data-tone="warn"] .hud-pip,.hud-banner .hud-pip{background:var(--hud-warn)}
.hud-banner .hud-btn{min-height:32px;padding:0 10px;font-size:13px;border-color:var(--hud-line)}

/* 토스트: 옛 고정 위치 규칙을 무대 왼쪽 위 흐름으로 되돌리고 HUD 톤으로 맞춘다 */
.hud-status #toast-region{
  position:static;left:auto;bottom:auto;transform:none;z-index:auto;
  width:100%;max-width:100%;display:grid;gap:6px;pointer-events:none;
}
.hud-status .toast{
  pointer-events:auto;display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  padding:6px 12px;font-size:13px;max-width:100%;
  background:var(--hud-glass);color:var(--hud-text);
  border:1px solid var(--hud-line);border-radius:4px;box-shadow:var(--hud-shadow);
}
.hud-status .toast .tm{background:var(--hud-good)}
.hud-status .toast.is-warn{border-color:var(--hud-line)}
.hud-status .toast.is-warn .tm{background:var(--hud-warn)}
.hud-status .toast.is-gold{border-color:var(--hud-line)}
.hud-status .toast.is-gold .tm{background:var(--hud-accent)}

/* ---------- 오른쪽: 상태 한 열(폭 230) — 날짜 / AGE·GOLD / 능력치 / 한마디 ---------- */
#col-profile.hud-profile{
  grid-area:auto;position:relative;top:auto;
  grid-column:3;grid-row:1;align-self:start;
  display:flex;flex-direction:column;gap:8px;min-height:0;
}
.hud-date{display:flex;align-items:center;justify-content:center;gap:0;padding:8px 12px;text-align:center}
.hud-date-text{display:grid;gap:1px;min-width:0}
.hud-date-main{font-family:var(--hud-serif);font-weight:700;font-size:15.5px;line-height:1.3;letter-spacing:.01em;white-space:nowrap}
.hud-date-sub{font-size:12px;color:var(--hud-text-soft);letter-spacing:.1em}
/* 꽃 장식: 원 다섯 개 */
.hud-flower{
  width:6px;height:6px;flex:none;margin:0 9px;border-radius:50%;background:var(--hud-accent);
  box-shadow:0 -7px 0 1px var(--hud-line),0 7px 0 1px var(--hud-line),7px 0 0 1px var(--hud-line),-7px 0 0 1px var(--hud-line);
}
.hud-identity{display:grid;gap:1px;padding:8px 14px}
.hud-identity p{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
.hud-id-body{font-size:13.5px;color:var(--hud-text)}
.hud-gold{font-weight:600;font-size:15px;color:var(--hud-accent);white-space:nowrap}
.hud-gold-val{font-weight:600}
.hud-kv-key{font-family:var(--hud-mono);font-weight:400;font-size:11px;letter-spacing:.14em;color:var(--hud-text-soft);margin-right:7px}

/* 접힘 상자: 제목 줄이 곧 단추다. data-open 으로 상태를 적는다 */
.hud-fold{padding:5px 14px 10px}
.hud-fold[data-open="false"]{padding-bottom:5px}
.hud-fold h2{margin:0}
.hud-fold-toggle{
  position:relative;display:flex;align-items:center;gap:10px;width:100%;min-height:28px;padding:0;
  background:none;border:0;cursor:pointer;text-align:left;white-space:nowrap;
  font-family:var(--hud-serif);font-weight:700;font-size:14px;letter-spacing:.02em;color:var(--hud-accent);
}
.hud-chevron{width:8px;height:8px;flex:none;border-right:1.5px solid var(--hud-line);border-bottom:1.5px solid var(--hud-line);transform:rotate(-135deg);translate:0 2px;transition:transform .15s ease}
.hud-fold-toggle[aria-expanded="false"] .hud-chevron{transform:rotate(45deg);translate:0 -2px}
.hud-quote .hud-flourish{order:1}
.hud-quote .hud-affinity{order:2}
.hud-quote .hud-chevron{order:3}
.hud-fold-who{font-weight:inherit}
.hud-quote-name{font-weight:inherit}
/* 접힘 칩이 여는 몸통. 접힘은 hidden 속성으로 표현한다([hidden]{display:none !important}) */
.hud-fold-body{display:block;min-width:0}
.hud-stats-body{display:grid;gap:1px}
/* 칸 위치를 명시해 DOM 순서와 무관하게 라벨·숫자·막대 순으로 놓는다 */
.hud-stat{display:grid;grid-template-columns:4.4em 1.9em minmax(0,1fr);align-items:center;gap:8px;min-height:22px;font-size:12.5px}
.hud-stat > *{grid-row:1}
.hud-stat > :first-child{grid-column:1;white-space:nowrap}
.hud-stat .hud-stat-val{grid-column:2}
.hud-stat .hud-meter{grid-column:3}
.hud-stat-val{text-align:right;font-weight:500}
.hud-meter{height:8px;background:var(--hud-bg-3);border:1px solid var(--hud-line-soft);border-radius:2px;overflow:hidden}
.hud-meter span{display:block;height:100%;width:calc(var(--v) * 1%);background:var(--stat)}
.hud-stat-rule{border-top:1px solid var(--hud-line-soft);margin:4px 0 3px}
[data-stat="stamina"]{--stat:var(--stat-stamina)}
[data-stat="intellect"]{--stat:var(--stat-intellect)}
[data-stat="charm"]{--stat:var(--stat-charm)}
[data-stat="kindness"]{--stat:var(--stat-kindness)}
[data-stat="combat"]{--stat:var(--stat-sword)}
[data-stat="magic"]{--stat:var(--stat-magic)}
[data-stat="stress"]{--stat:var(--stat-stress)}
[data-stat="affection"]{--stat:var(--stat-affinity)}
.hud-quote-text{margin-top:2px;font-family:var(--hud-serif);font-size:14px;line-height:1.6;word-break:keep-all}
/* 친밀도: 하트(마름모 + 원 두 개) + 숫자 */
.hud-affinity{display:inline-flex;align-items:center;gap:8px;font-family:var(--hud-sans);font-weight:600;font-size:13px;color:var(--hud-text)}
.hud-affinity-val{font-variant-numeric:tabular-nums}
.hud-heart{position:relative;width:8px;height:8px;flex:none;margin:3px 2px 0;background:var(--stat-charm);transform:rotate(-45deg)}
.hud-heart::before,.hud-heart::after{content:"";position:absolute;width:8px;height:8px;border-radius:50%;background:var(--stat-charm)}
.hud-heart::before{left:0;top:-50%}
.hud-heart::after{left:50%;top:0}

/* ---------- 아래: 대화창(46%) · 일정 칩 + 보내기 + 장소 썸네일 상자(54%) ---------- */
.hud-bottom{
  grid-column:1 / -1;grid-row:2;display:grid;align-items:stretch;gap:8px;min-height:0;
  grid-template-columns:minmax(0,46fr) minmax(0,54fr);
}
/* 돌봄: 작은 칩 세 개. 세로 묶음 상자는 없다 */
.hud-care{display:flex;align-items:center;gap:4px}
.hud-care-title,.hud-wearing{
  padding:0 9px;font-size:11.5px;line-height:24px;color:var(--hud-text-soft);white-space:nowrap;
  background:var(--hud-glass);border:1px solid var(--hud-line-soft);border-radius:999px;
}
.hud-wearing b{color:var(--hud-text);font-weight:600}
.hud-care .hud-btn{
  min-height:26px;padding:0 11px;gap:5px;font-size:12px;white-space:nowrap;border-radius:999px;
  background:var(--hud-glass);border-color:var(--hud-line);box-shadow:var(--hud-shadow);
}
.hud-care .hud-btn:hover:not(:disabled){background:var(--hud-bg-2);border-color:var(--hud-accent)}
.hud-care .hud-btn:disabled{border-color:var(--hud-line-soft)}
.hud-care .hud-tag{margin-left:0;font-size:10px;padding:2px 3px}

.hud-dialogue{grid-column:1;display:grid;grid-template-columns:84px minmax(0,1fr);gap:14px;padding:9px 16px 9px 9px}
.hud-speaker-art{
  aspect-ratio:1;display:grid;place-items:center;text-align:center;padding:6px;
  background:var(--hud-stripes);
  border:1px solid var(--hud-line);border-radius:3px;
  font:400 10px/1.4 var(--hud-mono);color:var(--hud-text-soft);
}
.hud-speaker-art img{grid-area:1/1;width:100%;height:100%;object-fit:cover;object-position:center 25%;border-radius:2px;display:block}
.hud-speaker-art img[hidden]{display:none}
.hud-speaker-placeholder{grid-area:1/1}
.hud-speech{position:relative;display:flex;flex-direction:column;gap:3px;min-width:0;padding-right:18px}
.hud-speaker{font-family:var(--hud-serif);font-weight:700;font-size:13.5px;color:var(--hud-accent);padding:0 18px 3px 0;border-bottom:1px solid var(--hud-line-soft);align-self:flex-start}
.hud-line{font-family:var(--hud-serif);font-size:15.5px;line-height:1.6;word-break:keep-all}
.hud-line[data-empty]{color:var(--hud-text-soft)}
/* ▼ 는 "누르면 다음 대사가 나오는 상태"에서만 보인다. 넘길 것이 없으면 대화창도 누를 수 없는 모양이다. */
.hud-next{display:none;position:absolute;right:0;bottom:0;padding:0;border:0;background:none;font:inherit;font-size:12px;line-height:1;color:var(--hud-accent);cursor:pointer}
.hud-dialogue[data-has-more="true"]{cursor:pointer}
.hud-dialogue[data-has-more="true"] .hud-next{display:block;animation:hud-bob 1.4s ease-in-out infinite}
@keyframes hud-bob{50%{translate:0 3px}}
@media (prefers-reduced-motion:reduce){
  .hud-dialogue[data-has-more="true"] .hud-next{animation:none}
}

.hud-go{grid-column:2;display:grid;grid-template-columns:minmax(0,1fr) 344px;align-items:center;gap:14px;min-width:0;padding:9px 12px}
.hud-go-main{display:grid;gap:6px;min-width:0}
.hud-go-label{font-family:var(--hud-sans);font-weight:400;font-size:12px;color:var(--hud-text-soft);white-space:nowrap;margin:0}
/* 이달 일정: 가로 3칩 */
.hud-sched{display:grid;grid-template-columns:50px minmax(0,1fr);align-items:center;gap:8px}
.hud-sched-rows{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;list-style:none;margin:0;padding:0}
.hud-sched-rows li{list-style:none;margin:0;padding:0;display:flex;min-width:0}
.hud-sched-row{
  display:grid;gap:0;align-content:center;justify-items:start;
  width:100%;min-width:0;min-height:36px;padding:2px 7px;line-height:1.25;
}
.hud-sched-term{font-size:11px;font-weight:400;color:var(--hud-text-soft)}
.hud-sched-name{font-size:12.5px;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hud-sched-row .hud-tag{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);padding:0;border:0}
.hud-sched-row[data-state="empty"]{border-style:dashed;border-color:var(--hud-line)}
.hud-sched-row[data-state="empty"] .hud-sched-name{color:var(--hud-text-soft);font-weight:400}
/* 보내기 줄: 칸 폭을 grid로 고정해 버튼 문구가 길어져도 select가 밀리지 않는다 */
.hud-go-row{display:grid;grid-template-columns:50px 92px minmax(0,1fr);align-items:center;gap:8px}
.hud-go-row .hud-select{width:100%;min-width:0;min-height:36px;font-size:13px}
.hud-go-row .hud-btn-primary{width:100%;min-width:0;min-height:36px;padding:0 8px;font-size:15px;white-space:nowrap;overflow:hidden}
.hud-go-row .hud-btn-primary:disabled{font-size:12.5px;letter-spacing:0}
.hud-go-row .hud-btn-primary:not(:disabled){
  box-shadow:inset 0 0 0 3px var(--hud-accent),inset 0 0 0 4px oklch(24% 0.045 15 / .55),0 6px 16px -6px oklch(80% 0.10 75 / .7);
}
/* 장소 썸네일 7칸(44px) */
.hud-places{min-width:0}
.hud-places ul{display:grid;grid-template-columns:repeat(7,44px);gap:6px;list-style:none;margin:0;padding:0}
.hud-places li{list-style:none;margin:0;padding:0}
.hud-thumb{
  position:relative;
  display:grid;gap:2px;width:100%;padding:0;background:none;border:0;border-radius:3px;cursor:pointer;
  color:var(--hud-text);font-size:11px;line-height:1.4;text-align:center;
}
.hud-thumb-art{
  width:44px;height:44px;display:block;overflow:hidden;
  background:var(--hud-stripes);border:1px solid var(--hud-line);border-radius:3px;
  transition:border-color .15s ease;
}
.hud-thumb-art img{width:100%;height:100%;object-fit:cover;border-radius:2px;display:block}
/* 썸네일 칸이 44px 이라 '무사수행' 같은 네 글자 이름이 옆 칸으로 새지 않게 가둔다 */
.hud-thumb-label{white-space:nowrap;justify-self:stretch;max-width:100%;overflow:hidden;text-overflow:ellipsis;font-size:9.5px;letter-spacing:-.02em}
.hud-thumb:hover:not(:disabled) .hud-thumb-art{border-color:var(--hud-accent);box-shadow:0 0 0 1px var(--hud-accent)}
.hud-thumb:hover:not(:disabled) .hud-thumb-label{color:var(--hud-accent)}
.hud-thumb:disabled{cursor:not-allowed;color:oklch(68% 0.025 50)}
.hud-thumb:disabled .hud-thumb-art{border-style:dashed;border-color:var(--hud-line-soft);opacity:.6}

/* 맨 아래 표어 띠 */
.hud-hint{
  grid-column:1 / -1;grid-row:3;min-height:26px;
  display:flex;justify-content:space-between;align-items:center;gap:16px;padding:3px 16px;
  background:var(--hud-glass);border:1px solid var(--hud-line-soft);border-radius:4px;
  font-family:var(--hud-serif);font-size:12.5px;color:var(--hud-text-soft);
}
.hud-hint-brand{color:var(--hud-accent);letter-spacing:.06em;white-space:nowrap}
.hud-hint-season{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ---------- 일정 패널: 가운데 빈 자리에 뜨는 큰 상자(펼침 칸이므로 그림을 가려도 된다) ---------- */
.hud-planner-layer{grid-column:2;grid-row:1;z-index:5;display:flex;min-height:0}
.hud-planner-layer[hidden]{display:none}
.hud-planner{flex:1;display:flex;flex-direction:column;min-height:0;padding:10px}
.hud-planner:focus{outline:none}
.hud-planner-head{display:flex;align-items:center;gap:12px;padding:2px 6px 9px}
.hud-planner-head .hud-panel-title{flex:1;font-size:16px;margin:0}
.hud-planner-month{font-size:12.5px;color:var(--hud-text-soft)}
.hud-planner-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 4px 0;font-size:12.5px;color:var(--hud-text-soft)}
.hud-planner-foot .hud-btn{min-width:96px;justify-content:center;border-color:var(--hud-line)}
.hud-sheet{
  flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:11px;
  background:var(--paper);color:var(--ink);padding:13px;
  border:1px solid var(--hud-line);border-radius:3px;
  box-shadow:inset 0 0 0 3px var(--paper),inset 0 0 0 4px oklch(68% 0.04 60 / .5);
}
.hud-sheet-label{font-size:12px;font-weight:600;letter-spacing:.06em;color:var(--ink-soft)}
.hud-slots{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;list-style:none;margin:0;padding:0}
.hud-slot{position:relative;display:flex;list-style:none;margin:0;padding:0}
.hud-slot-main{
  flex:1;min-width:0;display:grid;gap:0;text-align:left;min-height:58px;padding:6px 40px 6px 12px;cursor:pointer;
  background:var(--paper-2);color:var(--ink);border:1px solid var(--paper-line);border-radius:4px;
  transition:border-color .15s ease,background-color .15s ease;word-break:keep-all;
}
.hud-slot-main:hover:not(:disabled){border-color:var(--hud-bg)}
.hud-slot-term{font-size:11.5px;color:var(--ink-soft)}
.hud-slot-name{font-family:var(--hud-serif);font-weight:700;font-size:15.5px}
.hud-slot-meta{font-size:12px;color:var(--ink-soft)}
.hud-slot[data-state="filled"] .hud-slot-main{box-shadow:inset 4px 0 0 var(--hud-accent)}
.hud-slot[data-state="empty"] .hud-slot-main{background:var(--paper);border-style:dashed;padding-right:12px}
.hud-slot-main[aria-pressed="true"]{border:1px solid var(--hud-bg);box-shadow:inset 0 0 0 2px var(--hud-accent)}
.hud-slot[data-state="locked"] .hud-slot-main{cursor:not-allowed;background:repeating-linear-gradient(135deg,var(--paper-2) 0 6px,var(--paper) 6px 12px);padding-right:12px}
.hud-slot-clear{
  position:absolute;right:4px;top:50%;translate:0 -50%;width:36px;height:36px;
  display:grid;place-items:center;background:none;border:1px solid transparent;border-radius:4px;
  font-size:18px;line-height:1;color:var(--ink-soft);cursor:pointer;
}
.hud-slot[data-state="invalid"] .hud-slot-main{border-color:var(--ink-warn);box-shadow:inset 4px 0 0 var(--ink-warn)}
.hud-slot[data-state="invalid"] .hud-slot-meta,.hud-sched-row[data-state="invalid"] .hud-tag{color:var(--ink-warn)}
.hud-sched-row[data-state="invalid"]{border-color:var(--ink-warn)}
.hud-slot-clear:hover{border-color:var(--hud-bg);color:var(--ink)}
.hud-tabs{display:flex;gap:4px;border-bottom:1px solid var(--paper-line)}
.hud-tab{
  min-height:40px;padding:0 16px;cursor:pointer;
  background:none;border:1px solid transparent;border-bottom:0;border-radius:4px 4px 0 0;
  font-weight:500;color:var(--ink-soft);
}
.hud-tab:hover{color:var(--ink);border-color:var(--paper-line)}
.hud-tab[aria-selected="true"]{background:var(--hud-accent);color:var(--hud-bg-3);font-weight:600;border-color:var(--hud-accent)}
.hud-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:8px}
.hud-card{
  display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 8px;align-content:start;text-align:left;
  min-height:76px;padding:9px 11px;cursor:pointer;
  background:var(--paper-2);color:var(--ink);border:1px solid var(--paper-line);border-radius:4px;
  transition:border-color .15s ease,background-color .15s ease;
}
.hud-card:hover:not(:disabled){border-color:var(--hud-bg);background:oklch(93.5% 0.03 85)}
.hud-card[aria-pressed="true"]{border-color:var(--hud-bg);background:oklch(92% 0.05 82);box-shadow:inset 4px 0 0 var(--hud-accent),inset 0 0 0 1px var(--hud-bg)}
.hud-card:disabled{cursor:not-allowed;background:var(--paper);border-style:dashed;color:var(--ink-soft)}
.hud-card[data-restricted]:not(:disabled){opacity:.65}
.hud-card-name .hud-chip{margin-left:4px;font-family:var(--hud-sans);font-weight:500}
.hud-card-name{font-family:var(--hud-serif);font-weight:700;font-size:15px}
.hud-card-cost{font-size:13px;font-weight:600;white-space:nowrap}
.hud-card-cost[data-kind="cost"]{color:var(--ink-warn)}
.hud-card-cost[data-kind="pay"]{color:var(--ink-good)}
.hud-card:disabled .hud-card-cost{color:inherit}
.hud-chips{grid-column:1 / -1;display:flex;flex-wrap:wrap;gap:4px}
.hud-chip{
  display:inline-flex;align-items:center;gap:5px;padding:1px 7px 1px 6px;
  font-size:12px;font-weight:500;color:var(--ink);
  background:var(--paper);border:1px solid var(--paper-line);border-radius:999px;
}
.hud-chip::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--stat,var(--ink-soft));box-shadow:0 0 0 1px oklch(28% 0.02 60 / .35)}
.hud-chip[data-note]::before{display:none}
.hud-forecast{
  display:flex;flex-wrap:wrap;align-items:center;gap:6px 16px;margin-top:auto;
  padding-top:10px;border-top:3px double var(--paper-line);
}
.hud-forecast-note{font-size:13px;color:var(--ink-soft)}

/* ---------- 넓은 화면(721px~): 돌봄 칩은 대화창 위쪽 모서리에 붙는다 ---------- */
@container hud (min-width: 721px){
  .hud-care{position:absolute;left:0;bottom:calc(100% + 3px)}
}

/* ---------- 태블릿(721~1199px): 장소 썸네일은 접고 아래 오른쪽 상자를 한 열로 ---------- */
@container hud (min-width: 721px) and (max-width: 1199px){
  .hud-screen{grid-template-columns:108px minmax(0,1fr) 200px;font-size:13.5px}
  .hud-title{font-size:12.5px}
  .hud-subtitle{display:none}
  .hud-menu .hud-btn{font-size:12px;gap:6px;padding-right:4px}
  .hud-date-main{font-size:14px}
  .hud-flower{margin:0 7px}
  .hud-bottom{grid-template-columns:minmax(0,1fr) 300px}
  .hud-go{grid-template-columns:minmax(0,1fr)}
  .hud-places{display:none}
  .hud-sched{grid-template-columns:minmax(0,1fr)}
  .hud-go-row{grid-template-columns:84px minmax(0,1fr)}
  .hud-go-label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .hud-dialogue{grid-template-columns:72px minmax(0,1fr);gap:10px}
  .hud-line{font-size:14.5px}
  .hud-care-note,.hud-wearing{display:none}
  .hud-planner-layer{grid-column:2 / 4}
}

/* ---------- 폰(~720px): 스크롤 없는 한 화면 ----------
   1행 상태 띠 44 | 2행 접힘 칩 32 | 3행 빈 자리(토스트만 위에 잠깐) | 4행 돌봄 칩 + 대화창 + 주 버튼 110 | 5행 표어 띠 24
   메뉴는 격자 밖: 좌우 가장자리에서 8px 띄운 56px 정사각 버튼 4개씩, 세로 42% 지점 가운데 정렬. */
@container hud (max-width: 720px){
  .hud-screen{
    --hud-phone-padding:8px;
    --hud-phone-topbar-height:44px;
    --stage-phone-offset:calc(var(--hud-phone-padding) + var(--hud-phone-topbar-height) + 4px);
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:var(--hud-phone-topbar-height) 32px minmax(0,1fr) auto 24px;
    gap:6px;padding:var(--hud-phone-padding);font-size:12.5px;min-height:0;
  }
  #col-portrait.stage-root{inset:0}
  #stage .stage-art:not([data-fallback="atlas"]) > #portrait-image.stage-image{
    top:var(--stage-phone-offset);
  }
  #stage .stage-art[data-asset-state="ready"]:not([data-fallback="atlas"])::before{
    content:"";position:absolute;inset:-36px;pointer-events:none;
    background-image:var(--stage-blur-image);background-size:cover;background-position:center;
    filter:blur(18px) brightness(.75);
  }
  #stage #portrait-image.stage-image{object-position:var(--stage-phone-focus, 50% 40%)}
  #stage #portrait-image.stage-image[data-phone-transform]{
    transform:translateY(var(--stage-phone-shift, 0px)) scale(var(--stage-phone-zoom, 1));
    transform-origin:50% 0;
  }
  #stage .stage-art:has(> #portrait-image[data-phone-transform]){background:var(--hud-bg)}
  .hud-screen > .hud-frame,.hud-lockup,.hud-date,.hud-identity,.hud-hint-brand,.hud-places,.hud-sched,
  .hud-menu-extra,.hud-care-note,.hud-wearing,.hud-fold-who,.hud-fold .hud-flourish{display:none}

  /* 위: 얇은 상태 띠 한 줄 */
  .hud-topbar{
    grid-column:1;grid-row:1;z-index:2;
    display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:8px;
    padding:0 12px;font-size:12.5px;white-space:nowrap;
  }
  .hud-topbar-title{display:flex;align-items:center;justify-self:start;font-family:var(--hud-sans);font-weight:600;color:var(--hud-accent);min-width:0}
  /* 왼쪽 칸은 기어 + "설정" 두 글자짜리 작은 버튼이다(폰 전용 설정 경로).
     칸 높이가 32px 이라 ::after 로 위아래를 넓혀 44px 터치 영역을 만든다 */
  .hud-topbar-settings{
    position:relative;display:inline-flex;align-items:center;gap:4px;flex:none;
    margin:0;padding:0 9px;height:32px;border:1px solid var(--hud-line);border-radius:16px;
    background:var(--hud-glass);color:inherit;font:inherit;font-size:12.5px;line-height:1;cursor:pointer;
  }
  .hud-topbar-settings::after{content:"";position:absolute;inset:-6px -8px}
  .hud-topbar-settings .hud-icon{width:15px;height:15px}
  .hud-topbar-name{white-space:nowrap}
  .hud-topbar-settings:focus-visible{outline:2px solid var(--hud-accent);outline-offset:2px}
  .hud-topbar-date{font-family:var(--hud-serif);font-weight:700;text-align:center}
  .hud-topbar-id{justify-self:end;color:var(--hud-accent);font-weight:600}

  /* 좌우 가장자리 메뉴: 레일은 화면 전체를 덮는 투명한 층이고, 목록 둘만 가장자리에 붙는다. */
  .hud-viewport .hud-screen > .hud-rail{
    position:absolute;inset:0;width:100%;height:100%;min-height:0;z-index:3;
    grid-column:auto;grid-row:auto;align-self:stretch;justify-self:stretch;
    display:block;pointer-events:none;
  }
  .hud-menu{position:static;display:block;padding:0;background:none;border:0;border-radius:0;box-shadow:none}
  .hud-menu::before,.hud-menu::after{display:none}
  /* 세로 22~62% 구간의 가운데(42%)에 목록의 가운데를 맞춘다. 퍼센트 높이에 기대지 않는다 */
  .hud-menu ul{
    position:absolute;top:42%;height:auto;transform:translateY(-50%);
    display:flex;flex-direction:column;justify-content:flex-start;gap:6px;pointer-events:none;
  }
  .hud-menu ul[data-side="left"]{left:8px}
  .hud-menu ul[data-side="right"]{right:8px}
  .hud-menu .hud-btn{
    width:56px;height:56px;min-height:0;padding:5px 2px 4px;
    flex-direction:column;justify-content:center;gap:3px;
    font-size:10.5px;line-height:1.2;text-align:center;pointer-events:auto;
    background:var(--hud-glass);border-color:var(--hud-line);box-shadow:var(--hud-shadow);
  }
  .hud-menu .hud-btn[aria-current="page"]{background:var(--hud-accent)}
  .hud-menu .hud-btn:disabled{border-color:var(--hud-line-soft)}
  .hud-menu .hud-icon-cell{width:26px;height:26px}
  .hud-menu .hud-btn.btn,.hud-menu .hud-btn.social-button{font-size:10.5px;width:56px}

  /* 상태 띠 바로 아래: 왼쪽 한마디 칩, 오른쪽 능력치 칩. 펼치면 아래로 내려와 그림을 덮는다(허용) */
  #col-profile.hud-profile{
    grid-column:1;grid-row:2;z-index:4;height:32px;align-self:start;
    flex-direction:row;justify-content:space-between;align-items:flex-start;gap:6px;
  }
  .hud-quote{order:-1}
  .hud-fold,.hud-fold[data-open="false"]{flex:none;padding:0 10px;border-radius:16px}
  .hud-fold[data-open="false"]::before,.hud-fold[data-open="false"]::after{display:none}
  .hud-fold[data-open="true"]{padding:0 10px 8px;border-radius:4px}
  .hud-stats{width:96px}
  .hud-stats[data-open="true"]{width:176px}
  .hud-quote[data-open="true"]{width:190px}
  .hud-fold-toggle{min-height:30px;gap:6px;font-size:12.5px;justify-content:space-between}
  .hud-fold-toggle::after{content:"";position:absolute;inset:-6px -10px} /* 터치 영역을 44px로 넓힌다 */
  .hud-quote .hud-affinity{order:-1;gap:5px;font-size:12.5px}
  .hud-stat{grid-template-columns:4.1em 1.6em minmax(0,1fr);gap:5px;min-height:18px;font-size:12px}
  .hud-meter{height:7px}
  .hud-stat-rule{margin:3px 0 2px}
  .hud-quote-text{margin-top:0;font-size:12.5px;line-height:1.55}

  /* 토스트: 접힘 칩 아래 가운데에 잠깐 뜨는 한 줄 칩 */
  .hud-center{grid-column:1;grid-row:3;justify-self:center;align-self:start;z-index:3}
  .hud-status{justify-items:center}
  .hud-toast,.hud-banner,.hud-status .toast{font-size:12.5px;padding:5px 12px;gap:8px;border-radius:16px;flex-wrap:nowrap;white-space:nowrap}
  .hud-banner .hud-btn{min-height:30px;border-radius:15px}

  /* 아래: 돌봄 칩 줄 + 기간 칩(36) / 대화창 + 정사각 주 버튼(70) — 합쳐 110.
     대사가 길면 대화창 행만 위로 자란다(70~132). 위 3행이 1fr 이라 그만큼 줄어들고 화면은 그대로다. */
  .hud-bottom{grid-column:1;grid-row:4;grid-template-columns:minmax(0,1fr) 70px;grid-template-rows:36px minmax(70px,auto);gap:4px 6px}
  .hud-care{grid-column:1;grid-row:1;gap:5px;position:static}
  .hud-care-title{line-height:26px;font-size:12px}
  .hud-care .hud-btn{min-height:36px;padding:0 12px;font-size:12.5px}
  .hud-go,.hud-go-main,.hud-go-row{display:contents}
  .hud-go::before,.hud-go::after{display:none}
  .hud-go-label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .hud-go-row .hud-select{
    grid-column:2;grid-row:1;align-self:center;min-height:32px;height:32px;padding:0 20px 0 10px;font-size:12px;
    background-color:var(--hud-glass);border-color:var(--hud-line);border-radius:16px;
    background-position:calc(100% - 13px) 50%,calc(100% - 8px) 50%;
  }
  .hud-dialogue{grid-column:1;grid-row:2;grid-template-columns:56px minmax(0,1fr);align-items:stretch;gap:8px;padding:6px 8px 6px 6px;max-height:132px}
  /* 초상은 상자 안 위쪽에 붙인다. 상자가 자라도 아래로 삐져나오지 않는다 */
  .hud-speaker-art{width:56px;height:56px;font-size:8.5px;padding:2px;align-self:start}
  .hud-speech{gap:1px;padding-right:12px}
  .hud-speaker{font-size:12px;line-height:1.3;padding-bottom:1px}
  /* 최대 4줄까지 보인다. 더 길면 ▼ 로 다음 대사를 넘기고, 전문은 title/aria 로 읽힌다 */
  .hud-line{
    font-size:13px;line-height:1.45;
    display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;line-clamp:4;overflow:hidden;
  }
  .hud-line[hidden]{display:none}
  /* 대화창이 자라도 정사각 버튼은 아래쪽에 붙어 70x70 을 지킨다 */
  .hud-go-row .hud-btn-primary{
    grid-column:2;grid-row:2;align-self:end;height:70px;min-height:70px;padding:0 4px;
    font-size:14px;line-height:1.35;white-space:normal;word-break:keep-all;
  }
  .hud-go-row .hud-btn-primary:disabled{font-size:11.5px}

  .hud-hint{grid-column:1;grid-row:5;min-height:24px;justify-content:center;padding:0 10px;font-size:12px;text-align:center;white-space:nowrap;overflow:hidden}

  /* 폰에서 일정 패널은 화면 전체를 덮는 시트 */
  .hud-planner-layer{position:absolute;inset:0;z-index:20;grid-column:auto;grid-row:auto}
  .hud-planner{border-radius:0;background:var(--hud-bg)}
  .hud-slots{grid-template-columns:minmax(0,1fr)}
  .hud-slot-clear{width:44px;height:44px;right:2px}
  .hud-tab{min-height:44px;padding:0 12px;flex:1}
  .hud-planner-foot .hud-btn{min-height:44px}
}

/* HUD 범위 동작 줄이기 */
@media (prefers-reduced-motion: reduce){
  .hud-viewport *,.hud-viewport *::before,.hud-viewport *::after{
    animation:none !important;transition:none !important;scroll-behavior:auto !important;
  }
}

/* ---------- HUD v4 통합 다리 (기존 규칙과의 충돌 해소) ---------- */
/* #app-main 은 전역 main{padding} 을 받지 않게 한다(무대가 전체 폭을 쓴다). */
#app-main{padding:0}
/* 페이지 배경을 HUD 톤으로. 인증 화면(#auth-shell)은 자체 배경을 쓰므로 변하지 않는다. */
body{background-color:var(--hud-bg-3);background-image:none}
/* F4: 홈 화면에서 본문 세로 스크롤이 생기지 않게 한다.
   .book 의 아래 여백 4rem 과 min-height:100vh 가 100dvh 짜리 .hud-screen 위에 더해져 넘쳤다. */
.book{background:var(--hud-bg-3);background-image:none;box-shadow:none;max-width:none;padding:0;min-height:0}
@media (min-width:1000px){
  .book{border-left:0}
  .book::before{content:none}
}
/* 설정 dialog 안으로 옮긴 보조 항목(불러오기·도움말·새로 시작)과 계정 표시 */
.settings-aux{display:flex;gap:8px;flex-wrap:wrap}
.bgm-volume-row{display:flex;align-items:center;gap:.65rem;min-width:0}
.bgm-volume-row input[type="range"]{flex:1;min-width:0;max-width:100%}
.bgm-volume-row output{min-width:2.2em;text-align:right;font-variant-numeric:tabular-nums}
#settings-dialog #account-bar{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
  margin-top:12px;padding-top:10px;border-top:1px solid var(--rule);
  font-size:.8rem;color:var(--ink-faint);
}
#settings-dialog #account-bar strong{color:var(--ink)}
#settings-dialog #account-bar .btn{margin-left:auto}

.public-links{display:flex;flex-wrap:wrap;justify-content:center;gap:.3rem .75rem;font-size:.8rem;padding:1rem;text-align:center}
.public-links a{color:var(--ink);text-decoration:underline;text-underline-offset:3px}
#settings-dialog .public-links{border-top:1px solid var(--rule);margin-top:.8rem}
#delete-account-error{color:var(--warn);font-weight:700}

/* ---------- 고대비("글자 또렷하게") HUD 덮어쓰기 ----------
   body.high-contrast 의 옛 크림 테마 토큰(--ink 등)은 HUD 가 쓰지 않는다.
   HUD 는 --hud-* 토큰만 쓰고, --hud-glass 는 .hud-viewport 가 스스로 정의하므로
   body 에만 걸면 내려가지 않는다. 그래서 .hud-viewport 에 직접 건다. */
body.high-contrast .hud-viewport,
body.high-contrast #prologue-dialog{
  --hud-bg: oklch(10% 0.008 15);
  --hud-bg-2: oklch(17% 0.012 18);
  --hud-bg-3: oklch(7% 0.006 15);
  /* 떠 있는 상자의 바탕: 불투명하게 막아 그림이 비치지 않는다 */
  --hud-glass: oklch(10% 0.008 15);
  --hud-line: oklch(95% 0.04 85);
  --hud-line-soft: oklch(95% 0.04 85 / 0.85);
  --hud-text: oklch(99% 0 0);
  --hud-text-soft: oklch(89% 0.01 85);
  --hud-accent: oklch(91% 0.13 85);
  --hud-good: oklch(88% 0.15 150);
  --hud-warn: oklch(85% 0.15 45);
  --hud-stripes: repeating-linear-gradient(135deg,oklch(17% 0.012 18) 0 8px,oklch(27% 0.02 20) 8px 16px);
  --hud-shadow: 0 0 0 1px oklch(7% 0.006 15);
  /* 능력치 막대: 찬 부분을 밝게 */
  --stat-stamina: oklch(84% 0.15 25);
  --stat-intellect: oklch(86% 0.12 240);
  --stat-charm: oklch(86% 0.14 350);
  --stat-kindness: oklch(88% 0.14 150);
  --stat-sword: oklch(88% 0.13 70);
  --stat-magic: oklch(84% 0.14 300);
  --stat-stress: oklch(84% 0.02 60);
}
/* 상자·버튼 테두리와 괘선을 굵게 */
body.high-contrast .hud-panel,
body.high-contrast .hud-btn,
body.high-contrast .hud-status .toast{ border-width:2px; }
body.high-contrast .hud-panel{ border-color:var(--hud-line); }
body.high-contrast .hud-btn{ border-color:var(--hud-line); }
body.high-contrast .hud-panel::before{ border-color:var(--hud-line-soft); }
body.high-contrast .hud-icon-cell{ border-width:2px; }
body.high-contrast .hud-flourish::before,
body.high-contrast .hud-flourish::after,
body.high-contrast .hud-stat-rule{ border-top-width:2px; border-top-color:var(--hud-line); }
/* 능력치 막대: 빈 부분은 완전한 어둠, 테두리는 밝게 */
body.high-contrast .hud-meter{
  height:10px;background:oklch(7% 0.006 15);border:2px solid var(--hud-line);
}
/* 보조 글자도 또렷하게 */
body.high-contrast .hud-viewport .hud-text-soft,
body.high-contrast .hud-date-sub,
body.high-contrast .hud-go-label,
body.high-contrast .hud-care-title,
body.high-contrast .hud-wearing,
body.high-contrast .hud-sched-term,
body.high-contrast .hud-sched-row[data-state="empty"] .hud-sched-name{ color:var(--hud-text-soft); }
/* 비활성(잠김·완료): 색만이 아니라 굵은 점선 테두리로도 구분한다 */
body.high-contrast .hud-viewport button:disabled,
body.high-contrast .hud-viewport select:disabled{
  border-style:dashed;border-width:2px;border-color:var(--hud-line-soft);
  color:var(--hud-text-soft);opacity:1;
}
body.high-contrast .hud-thumb:disabled .hud-thumb-art{ border-style:dashed;border-width:2px;opacity:1; }
/* 포커스 링 */
body.high-contrast .hud-viewport :focus-visible{
  outline:3px solid var(--hud-text);outline-offset:3px;
  box-shadow:0 0 0 6px oklch(7% 0.006 15);
}
body.high-contrast .hud-sheet :focus-visible{ outline-color:var(--hud-bg);box-shadow:0 0 0 6px oklch(99% 0 0); }

/* =========================================================
   프롤로그 (새 게임을 시작할 때 한 장면씩 넘겨 보는 창)
   v7 HUD 토큰: 와인색 바탕 + 로즈골드 괘선.
   그림이 아직 없거나 로드에 실패하면 data-art 가 ready 가 아니므로
   그림 자리를 감추고 본문만 가운데에 크게 보인다.
   ========================================================= */
#prologue-dialog{
  width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;
  margin:0;padding:0;border:0;border-radius:0;
  background:var(--hud-bg-3);color:var(--hud-text);
  font-family:var(--hud-sans);
  --pro-glass:oklch(22% 0.045 18 / .92);
}
#prologue-dialog::backdrop{ background:oklch(12% .02 15 / .9); }
.pro-sheet{
  box-sizing:border-box;height:100%;
  display:flex;flex-direction:column;gap:14px;
  padding:18px clamp(14px,4vw,40px) 20px;
  background:var(--hud-bg);
  box-shadow:inset 0 0 0 6px var(--hud-bg-3),inset 0 0 0 7px var(--hud-line-soft);
}
.pro-head{
  display:flex;align-items:baseline;justify-content:space-between;gap:12px;
  border-bottom:1px solid var(--hud-line-soft);padding-bottom:10px;flex:none;
}
.pro-title{
  margin:0;font-family:var(--hud-serif);font-weight:700;
  font-size:clamp(16px,2.2vw,22px);letter-spacing:.06em;color:var(--hud-accent);
}
.pro-count{ margin:0;font-family:var(--hud-mono);font-size:14px;color:var(--hud-text-soft); }
.pro-art{
  flex:none;margin:0;align-self:center;
  width:min(100%,860px,calc(50dvh * 1.5));
  aspect-ratio:3 / 2;overflow:hidden;
  border:1px solid var(--hud-line);background:var(--hud-bg-3);
  box-shadow:var(--hud-shadow);
}
.pro-art img{ display:block;width:100%;height:100%;object-fit:cover; }
#prologue-dialog:not([data-art="ready"]) .pro-art{ display:none; }
.pro-body{ flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center; }
.pro-text{
  box-sizing:border-box;width:min(100%,780px);max-height:100%;overflow:auto;
  padding:18px clamp(14px,3vw,26px);
  background:var(--pro-glass);border:1px solid var(--hud-line);border-radius:4px;
  box-shadow:var(--hud-shadow);
}
.pro-line{
  margin:0 0 .6em;font-family:var(--hud-serif);
  font-size:clamp(15px,1.9vw,20px);line-height:1.85;color:var(--hud-text);
}
.pro-line:last-child{ margin-bottom:0; }
.pro-line-quote{ margin-top:.9em;font-size:clamp(18px,2.4vw,25px);font-weight:700;color:var(--hud-accent); }
#prologue-dialog:not([data-art="ready"]) .pro-line{ font-size:clamp(17px,2.4vw,24px); }
#prologue-dialog:not([data-art="ready"]) .pro-line-quote{ font-size:clamp(20px,3vw,30px); }
.pro-actions{
  flex:none;display:flex;gap:10px;align-items:center;justify-content:flex-end;
  border-top:1px solid var(--hud-line-soft);padding-top:12px;
}
.pro-actions .hud-btn{ min-height:44px;min-width:96px;justify-content:center;text-align:center; }
.pro-skip{ margin-right:auto; }
#prologue-dialog :focus-visible{ outline:2px solid var(--hud-accent);outline-offset:2px; }
/* 고대비: 프롤로그도 홈 HUD 와 같은 수준으로. 본문 상자는 불투명하게 막고 테두리는 2px 로 굵힌다. */
body.high-contrast #prologue-dialog{ --pro-glass:oklch(10% 0.008 15); }
body.high-contrast .pro-text,
body.high-contrast .pro-art{ border-width:2px;border-color:var(--hud-line); }
body.high-contrast .pro-head{ border-bottom-width:2px;border-bottom-color:var(--hud-line); }
body.high-contrast .pro-count{ color:var(--hud-text-soft); }
@media (prefers-reduced-motion:no-preference){
  .pro-line{ animation:pro-fade .28s ease-out both; }
}
@keyframes pro-fade{ from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:none} }
@media (max-width:640px){
  .pro-sheet{ gap:10px;padding:12px 14px 14px; }
  .pro-art{ width:min(100%,calc(34dvh * 1.5)); }
  .pro-text{ padding:13px 14px; }
  .pro-line{ font-size:15px;line-height:1.72; }
  .pro-line-quote{ font-size:18px; }
  #prologue-dialog:not([data-art="ready"]) .pro-line{ font-size:16px; }
  #prologue-dialog:not([data-art="ready"]) .pro-line-quote{ font-size:20px; }
  .pro-actions{ gap:8px; }
  .pro-actions .hud-btn{ flex:1 1 0;min-width:0;padding:0 8px; }
  .pro-skip{ margin-right:0; }
}

/* 첫 화면 소개문 */
.auth-intro{
  margin:.1rem 0 1.05rem;text-align:center;
  font-size:.92rem;line-height:1.75;color:var(--ink-faint);
}

/* 엔딩 공통 마무리: 엔딩 본문 뒤에 가는 괘선 하나로 나눠 붙인다 */
.end-closing{ margin-top:1.1rem; }
.end-closing-rule{ border:0;border-top:1px solid var(--rule);margin:0 0 .9rem; }
.end-closing-line{ margin:0 0 .5em; }
.end-closing-line:last-child{ margin-bottom:0; }
.end-closing-quote{ margin-top:.7em;font-weight:700;color:var(--green); }

/* =========================================================
   갈아입기 직후 전신 그림 (화면 전체 위에 잠깐 뜨는 층)
   ========================================================= */
.outfit-reveal{
  position:fixed;inset:0;z-index:90;
  display:grid;place-items:center;
  background:oklch(18.5% 0.04 15 / .5);
  cursor:pointer;
  animation:outfit-reveal-in .22s ease-out;
}
/* 2:3 전신 그림의 폭을 화면 높이와 너비로 제한하고 높이는 자동으로 맞춰 atlas 크롭 비율도 유지한다 */
.outfit-reveal .wardrobe-art{
  width:min(calc(92dvh * 2 / 3), 92vw, calc(1400px * 2 / 3));
  height:auto;
  max-width:92vw;
  max-height:92dvh;
}
.outfit-reveal.is-leaving{animation:outfit-reveal-out .18s ease-in forwards}
@keyframes outfit-reveal-in{from{opacity:0}to{opacity:1}}
@keyframes outfit-reveal-out{from{opacity:1}to{opacity:0}}
/* 운영체제 움직임 줄이기 설정에서는 애니메이션 없이 표시·제거만 한다 */
@media (prefers-reduced-motion:reduce){
  .outfit-reveal,.outfit-reveal.is-leaving{animation:none}
}
/* 고대비: 어둡게 누른 바탕을 더 진하게 해 그림과 무대의 경계를 분명히 한다 */
body.high-contrast .outfit-reveal{background:oklch(7% 0.006 15 / .72)}

/* Deepening: reuse the existing HUD and paper tokens. */
.difficulty-badge {
  width: max-content;
  justify-self: start;
  display: inline-block;
  font-size: .68rem;
  line-height: 1.5;
  padding: .05rem .35rem;
  border: 1px solid currentColor;
  border-radius: var(--r);
  color: var(--ink-faint);
  white-space: nowrap;
}
.hud-date .difficulty-badge, .hud-topbar .difficulty-badge { color: var(--hud-text-soft); }
.hud-topbar-title .difficulty-badge { margin-left: .3rem; }
@container hud (max-width: 360px) {
  .hud-topbar-settings .hud-topbar-name { display: none; }
  .hud-topbar-settings { padding-inline: 4px; }
}
.todo-dot{
  position:absolute;top:2px;right:2px;z-index:3;
  width:8px;height:8px;box-sizing:border-box;border-radius:50%;
  background:var(--red, #d93636);pointer-events:none;
}
body.high-contrast .todo-dot{border:1.5px solid #fff}

/* NPC visit: existing dialog tokens and speaker portrait sizes. No animation. */
#npc-dialog{max-width:min(94vw,960px);max-height:94dvh}
#npc-dialog .dlg-bd{max-height:calc(94dvh - 76px)}
#npc-dialog.npc-result-stage[open]{display:flex;flex-direction:column}
#npc-dialog.npc-result-stage .dlg-bd{min-height:0;overflow:auto}
#npc-dialog .dlg-hd,.npc-result-footer{flex-shrink:0}
.npc-result-footer{display:none;padding:12px 24px;border-top:1px solid var(--rule)}
.npc-result-stage .npc-result-footer{display:block}
.npc-result-stage .npc-art{max-height:140px;aspect-ratio:auto;height:140px}
#npc-scene,.npc-line,.npc-choices .btn{word-break:keep-all}
.npc-header{justify-content:space-between}
.npc-layout{display:grid;grid-template-columns:240px minmax(0,1fr);gap:20px;align-items:start}
#npc-list{list-style:none;padding:0;margin:0;display:grid;gap:8px;min-width:0}
#npc-list li{margin:0;padding:0;list-style:none}
.npc-person{display:flex;align-items:center;gap:10px;width:100%;padding:8px;text-align:left;white-space:normal}
.npc-person img{width:64px;height:64px;flex:none;object-fit:cover;object-position:center 25%;border-radius:var(--r)}
.npc-person-details{display:grid;gap:2px;min-width:0}
.npc-affinity,.npc-note{font-size:.8rem;color:var(--ink-soft)}
.npc-heart{position:relative;display:inline-block;width:max-content;font-family:"Segoe UI Symbol",sans-serif;line-height:1.3;white-space:nowrap;color:var(--ink-soft)}
.npc-heart-fill{position:absolute;inset:0 auto 0 0;overflow:hidden;white-space:nowrap;color:var(--green)}
#npc-block-reason{margin:0 0 12px}
#npc-block-reason:empty{display:none}
#npc-scene{min-width:0;display:grid;gap:12px;overflow-wrap:anywhere}
#npc-scene p,#npc-scene h3{margin:0}
.npc-art{position:relative;aspect-ratio:3/2;overflow:hidden;border:1px solid var(--rule);border-radius:var(--r)}
.npc-background{display:block;width:100%;height:100%;object-fit:cover}
.npc-scene-portrait{position:absolute;bottom:10px;left:10px;width:84px;height:84px;padding:6px;object-fit:cover;object-position:center 25%;background:var(--paper);border:1px solid var(--rule);border-radius:3px}
.npc-line{display:grid;gap:12px;width:100%;text-align:left;white-space:normal;line-height:1.7;padding:12px}
.npc-choices{display:grid;gap:8px}
.npc-choices .btn{min-height:44px;white-space:normal;text-align:left;line-height:1.6}
#npc-result{display:grid;gap:12px;line-height:1.7}
.npc-butler{padding:12px;background:var(--paper-2);border:1px solid var(--rule)}
body.high-contrast #npc-dialog .npc-person:disabled{opacity:1;border-style:dashed;color:var(--ink-soft)}
body.high-contrast #npc-dialog .npc-heart,body.high-contrast #npc-dialog .npc-heart-fill{color:var(--ink)}
body.high-contrast #npc-dialog .npc-art{outline:1px solid var(--ink)}
@media (min-width:721px) and (max-width:960px){
  .npc-scene-portrait{width:72px;height:72px}
}
@media (max-width:720px){
  .npc-layout{grid-template-columns:minmax(0,1fr);gap:14px}
  #npc-list{display:flex;overflow-x:auto;gap:8px;padding-bottom:6px}
  #npc-list li{flex:0 0 215px}
  .npc-scene-portrait{width:56px;height:56px;padding:2px}
  #npc-dialog .dlg-bd{padding:12px}
}
.stage-scene.is-runaway::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--hud-bg-3);
  opacity: .4;
  pointer-events: none;
}
#stage.is-runaway #portrait-image.stage-image { opacity: 1; object-fit: cover; object-position: center; }
.hud-screen .runaway-stage-message {
  position: absolute;
  z-index: 2;
  inset: 38% 0 auto;
  width: fit-content;
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  word-break: keep-all;
  margin: 0 auto;
  text-align: center;
  color: #fff;
  background: rgb(15 18 24 / 78%);
  border-radius: 12px;
  padding: 10px 18px;
  font-family: var(--serif);
  pointer-events: none;
}

body.high-contrast .runaway-stage-message { background: rgb(0 0 0 / 90%); color: #fff; border: 1px solid #fff; }

/* Stage 6 market: text and borders retain grade distinctions without color. */
.shop-tab{white-space:nowrap;min-width:0;padding-inline:4px}
.shop-row[data-grade],.shop-slot[data-grade]{border-left:2px solid var(--grade-color);padding-left:10px}
[data-grade="common"]{--grade-color:#595959}
[data-grade="uncommon"]{--grade-color:#28633c}
[data-grade="rare"]{--grade-color:#245a91}
[data-grade="epic"]{--grade-color:#724491}
[data-grade="legendary"]{--grade-color:#795412}
.item-grade{color:var(--grade-color);font-size:.8em;font-weight:700;white-space:nowrap}
.shop-row[data-grade="uncommon"],.shop-slot[data-grade="uncommon"]{border-left-width:4px}
.shop-row[data-grade="rare"],.shop-slot[data-grade="rare"]{border-left:5px double var(--grade-color)}
.shop-row[data-grade="epic"],.shop-slot[data-grade="epic"]{border-left:6px double var(--grade-color)}
.shop-row[data-grade="legendary"],.shop-slot[data-grade="legendary"]{border-left-width:6px}
.item-grade[data-grade="epic"]::before{content:"◆ ";font-size:.75em}
.item-grade[data-grade="legendary"]::before{content:"★ ";font-size:.85em}
.shop-grade-heading{padding:14px 0 6px;border-bottom:1px solid var(--rule)}
.shop-grade-heading h3{font-size:1rem;color:var(--grade-color)}
.shop-empty{padding:10px 0;color:var(--ink-soft);font-size:.85rem}
.shop-stock{font-size:.8rem;white-space:nowrap}
.shop-meta{flex-wrap:wrap}
.shop-row[data-state="sold-out"]{background:var(--paper-2)}
.shop-row-trade{grid-template-columns:minmax(0,1fr);grid-template-areas:"info" "orders"}
.trade-orders{grid-area:orders;display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;gap:8px;align-items:end}
.trade-orders label{display:grid;gap:4px;font-size:.8rem}
.trade-orders input{width:100%;min-width:0;min-height:40px;padding:4px 8px;border:1px solid var(--rule);background:var(--paper)}
.trade-trend[data-trend="up"]{color:#965020}
.trade-trend[data-trend="down"]{color:#245a91}
.shop-row-craft{grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"info info" "meta act"}
.craft-materials{display:grid;gap:4px;margin-block:8px;font-size:.8125rem}
.shop-craft-warning{font-size:.8125rem;color:var(--warn)}
.shop-filter select{max-width:100%;min-height:36px;border:1px solid var(--rule);background:var(--paper);padding:4px 8px}
.shop-qty [data-shop-max]{font-size:.8rem}
body.high-contrast [data-grade]{--grade-color:currentColor}
body.high-contrast .item-grade,body.high-contrast .trade-trend{color:var(--ink)}
@media(max-width:480px){
  .shop-tab{font-size:.8125rem;letter-spacing:-.02em;padding-inline:2px}
  #category-tabs .cat-tab{font-size:.75rem;letter-spacing:-.04em;padding-inline:5px;white-space:nowrap}
  .shop-why{max-width:165px}
}
.shop-list,.craft-materials{list-style:none;padding-inline-start:0}
.shop-money,.shop-price,.shop-wallet output{white-space:nowrap}
#shop-sell-list .shop-price{white-space:normal}
.shop-money{display:inline-block}
.shop-why{max-width:none;line-height:1.5}
#shop-buy-list .shop-act,#shop-sell-list .shop-act{display:contents}
#shop-buy-list .shop-act>.btn,#shop-sell-list .shop-act>.btn{grid-area:act;justify-self:end}
#shop-buy-list .shop-why,#shop-sell-list .shop-why{grid-area:why;text-align:left}
#shop-buy-list .shop-row:has(.shop-why),#shop-sell-list .shop-row:has(.shop-why){grid-template-areas:"info info" "meta meta" "qty act" "why why"}
body.high-contrast .shop-grade-heading h3{color:var(--ink)}
@media(min-width:600px){
  #shop-buy-list .shop-row:has(.shop-why),#shop-sell-list .shop-row:has(.shop-why){grid-template-areas:"info meta qty act" "why why why why"}
}
#shop-dialog :is(.shop-desc,.shop-craft-warning,.shop-empty,.adv-note,.shop-why){word-break:keep-all;overflow-wrap:anywhere}
@media(min-width:600px){
  #shop-sell-list .shop-row{grid-template-columns:minmax(0,1fr) 144px auto 96px}
}
