:root {
  --paper: #f7f1e7;
  --paper-2: #f0e6d7;
  --card: #fffcf7;
  --ink: #2b2521;
  --ink-2: #4a413a;
  --muted: #8b7f73;
  --line: #e6dac9;
  --line-2: #efe4d6;
  --accent: #bf6a49;
  --accent-2: #a8583a;
  --accent-soft: #f6e2d5;
  --sage: #7f8f7a;
  --gold: #c7a15a;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 12% -10%, #fdf0e2 0%, rgba(253, 240, 226, 0) 62%),
    radial-gradient(900px 620px at 96% 106%, #eef0e6 0%, rgba(238, 240, 230, 0) 60%),
    linear-gradient(180deg, var(--paper) 0%, #f6efe4 55%, #f4ece0 100%);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='0.12'/></svg>");
}

.app {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------------- topbar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 4vw, 48px) 16px;
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }

.brand-mark { width: 30px; height: 30px; color: var(--accent); flex: 0 0 auto; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.26em;
  font-weight: 600;
}
.brand-text span { font-size: 10.5px; letter-spacing: 0.14em; color: var(--muted); margin-top: 3px; }

.steps { display: flex; align-items: center; gap: 0; }

.step { display: flex; align-items: center; gap: 6px; font-size: 0; color: var(--muted); }
.step i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #d8cbbb;
  transition: all 0.5s var(--ease);
  box-shadow: 0 0 0 0 rgba(191, 106, 73, 0);
}
.step em {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.12em;
  transition: color 0.4s var(--ease);
}
.step:not(:last-child)::after {
  content: "";
  width: clamp(12px, 2.4vw, 34px);
  height: 1px;
  background: linear-gradient(90deg, #ddd0bf, #e9dfd1);
  margin: 0 8px;
}
.step.done i { background: #d8a58a; }
.step.done em { color: #a08a78; }
.step.current i {
  width: 8px; height: 8px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(191, 106, 73, 0.13);
}
.step.current em { color: var(--ink-2); font-weight: 600; }

.restart {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 220px; justify-content: flex-end;
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 12px; letter-spacing: 0.08em;
  padding: 8px 0;
  font-family: inherit;
  transition: color 0.25s var(--ease);
}
.restart:hover { color: var(--accent-2); }
.restart svg { width: 15px; height: 15px; }

/* ---------------- stage ---------------- */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 470px);
  gap: clamp(18px, 4vw, 64px);
  align-items: center;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px) clamp(18px, 3vw, 34px);
}

/* ---------------- portrait ---------------- */

.portrait {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.6vh, 18px);
}

.aura {
  position: absolute;
  top: 50%; left: 50%;
  width: min(620px, 96%);
  aspect-ratio: 1;
  transform: translate(-50%, -54%) scale(calc(1 + var(--rms, 0) * 0.055));
  background: radial-gradient(circle at 50% 46%,
    rgba(240, 181, 141, 0.38) 0%,
    rgba(240, 181, 141, 0.14) 42%,
    rgba(240, 181, 141, 0.04) 62%,
    transparent 72%);
  filter: blur(14px);
  pointer-events: none;
  transition: transform 0.12s linear, background 1.2s var(--ease);
}
.portrait[data-state="speaking"] .aura { background: radial-gradient(circle at 50% 46%, rgba(238, 166, 122, 0.46) 0%, rgba(238, 166, 122, 0.16) 44%, transparent 72%); }
.portrait[data-state="thinking"] .aura { background: radial-gradient(circle at 50% 42%, rgba(199, 161, 90, 0.3) 0%, rgba(199, 161, 90, 0.08) 46%, transparent 70%); }

.portrait-frame {
  position: relative;
  width: min(400px, 74%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 26px 40px rgba(122, 84, 58, 0.16));
}

.orb-halo {
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(240, 181, 141, 0.38) 0%, rgba(240, 181, 141, 0) 66%);
  filter: blur(8px);
  transform: scale(calc(1 + var(--rms, 0) * 0.035));
  transition: transform 0.12s linear;
}

.orb-ring {
  position: absolute;
  inset: -4%;
  border-radius: 50%;
  border: 1px solid rgba(201, 143, 110, 0.26);
  pointer-events: none;
}
.portrait[data-state="speaking"] .ring1 { animation: orbPulse 2.6s ease-out infinite; }
.portrait[data-state="speaking"] .ring2 { animation: orbPulse 2.6s ease-out 0.8s infinite; }
@keyframes orbPulse {
  0% { transform: scale(0.99); opacity: 0.55; }
  75% { transform: scale(1.06); opacity: 0.1; }
  100% { transform: scale(1.07); opacity: 0; }
}

.avatar-orb {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 38% 26%, #fffaf0 0%, #faeddc 58%, #ecd7bf 100%);
  box-shadow:
    inset 0 -18px 42px rgba(197, 151, 112, 0.2),
    inset 0 14px 30px rgba(255, 255, 255, 0.6),
    0 18px 40px -24px rgba(120, 79, 52, 0.45);
}

.avatar-orb canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.orb-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  pointer-events: none;
  transition: opacity 0.6s var(--ease);
}
.orb-loader i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #c9ab90;
  animation: orbLoad 1.4s ease-in-out infinite;
}
.orb-loader i:nth-child(2) { animation-delay: 0.18s; }
.orb-loader i:nth-child(3) { animation-delay: 0.36s; }
@keyframes orbLoad {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}
.portrait.is-ready .orb-loader { opacity: 0; }

.orb-vignette {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, transparent 56%, rgba(150, 108, 76, 0.16) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.avatar-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 40px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: #b08063;
  background: radial-gradient(circle at 38% 26%, #fffaf0, #ecd7bf);
}
.avatar-fallback[hidden] { display: none; }

.identity { text-align: center; margin-top: -4px; }
.identity .name {
  font-family: var(--serif);
  font-size: clamp(26px, 2.6vw, 32px);
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  font-weight: 600;
}
.identity .role {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid rgba(226, 211, 193, 0.9);
  background: rgba(255, 253, 248, 0.62);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  color: #7d6a5c;
  backdrop-filter: blur(6px);
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.status .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 0 0 rgba(127, 143, 122, 0.5);
  animation: dotPulse 2.6s ease-out infinite;
}
@keyframes dotPulse {
  0% { box-shadow: 0 0 0 0 rgba(127, 143, 122, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(127, 143, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(127, 143, 122, 0); }
}
.status[data-state="speaking"] { color: var(--accent-2); border-color: rgba(214, 166, 140, 0.7); }
.status[data-state="speaking"] .pulse { background: var(--accent); animation-duration: 1.4s; }
.status[data-state="thinking"] { color: #a08544; border-color: rgba(214, 190, 140, 0.7); }
.status[data-state="thinking"] .pulse { background: var(--gold); animation-duration: 1s; }

/* ---------------- dialog panel ---------------- */

.dialog {
  position: relative;
  height: min(100%, 760px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 2.4vw, 26px) clamp(16px, 2.2vw, 24px) clamp(16px, 2vw, 20px);
  border-radius: 28px;
  border: 1px solid rgba(230, 218, 201, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.9), rgba(255, 251, 244, 0.78));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 30px 70px -46px rgba(90, 60, 40, 0.42);
  backdrop-filter: blur(10px);
}

.dialog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-2);
  flex: 0 0 auto;
}
.dialog-head h2 {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin: 0;
  color: var(--ink-2);
}
.stage-hint {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--accent);
  white-space: nowrap;
}

.parent-voice {
  position: relative;
  margin-top: 16px;
  padding: 13px 18px 15px 20px;
  border-radius: 14px;
  border: 1px solid #eddcc8;
  background: linear-gradient(135deg, #fff8ef, #f8ecdf);
  overflow: hidden;
  animation: rise 0.7s var(--ease) both;
  flex: 0 0 auto;
}
.parent-voice::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, #d9a678, var(--accent));
}
.pv-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: #a97b57;
}
.pv-text {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.75;
  color: #5c4132;
  margin: 6px 0 0;
}
.parent-voice[hidden] { display: none; }

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #ddd0be transparent;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: #e2d6c5; border-radius: 3px; }

.msg { display: flex; flex-direction: column; animation: rise 0.5s var(--ease) both; }
.msg .who {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin: 0 0 6px 4px;
}
.msg .bubble {
  font-size: 14.8px;
  line-height: 1.9;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.agent .bubble {
  align-self: flex-start;
  max-width: 92%;
  padding: 13px 17px;
  border-radius: 4px 16px 16px 16px;
  background: linear-gradient(180deg, #fffdf9, #fff9f0);
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 26px -24px rgba(90, 60, 40, 0.8);
  color: var(--ink-2);
}
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 86%;
  padding: 11px 16px;
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(180deg, #f7e3d5, #f2d5c3);
  border: 1px solid #eed0bd;
  color: #4d3225;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.typing { display: inline-flex; gap: 4px; align-items: center; height: 1.9em; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: #c9b8a4;
  animation: typing 1.3s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 0.16s; }
.typing i:nth-child(3) { animation-delay: 0.32s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ---------------- composer ---------------- */

.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 8px 8px 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: #fffdf8;
  box-shadow: 0 1px 0 #fff inset, 0 14px 30px -26px rgba(90, 60, 40, 0.7);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.composer:focus-within {
  border-color: #dcb79f;
  box-shadow: 0 1px 0 #fff inset, 0 0 0 4px rgba(191, 106, 73, 0.07);
}

#input {
  flex: 1 1 auto;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 14.8px;
  line-height: 1.65;
  color: var(--ink);
  padding: 9px 0;
  max-height: 116px;
  min-height: 20px;
}
#input::placeholder { color: #b3a495; }

.composer-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

.mic {
  width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: #9c8b7a;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.mic:hover { background: #f4ece0; color: var(--accent); }
.mic svg { width: 19px; height: 19px; }
.mic.active { background: var(--accent); color: #fff; animation: micPulse 1.6s ease-out infinite; }
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(191, 106, 73, 0.4); }
  100% { box-shadow: 0 0 0 12px rgba(191, 106, 73, 0); }
}
.mic[hidden] { display: none; }

.send {
  width: 38px; height: 38px;
  border: 0; border-radius: 50%;
  background: linear-gradient(140deg, #c87654, var(--accent-2));
  color: #fff8f1;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 22px -12px rgba(168, 88, 58, 0.9);
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease), filter 0.25s var(--ease);
}
.send svg { width: 19px; height: 19px; }
.send:hover:not(:disabled) { transform: translateY(-1px) scale(1.03); filter: brightness(1.05); }
.send:disabled { opacity: 0.38; cursor: default; box-shadow: none; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  flex: 0 0 auto;
  min-height: 0;
}
.chip {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: #6f6053;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.85);
  cursor: pointer;
  transition: all 0.25s var(--ease);
  animation: rise 0.5s var(--ease) both;
}
.chip:hover { border-color: #dcb79f; color: var(--accent-2); background: #fff9f2; transform: translateY(-1px); }

.disclaimer {
  flex: 0 0 auto;
  margin: 12px 0 0;
  font-size: 10.5px;
  line-height: 1.7;
  color: #a2958a;
  letter-spacing: 0.02em;
}

/* ---------------- intro ---------------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 50% 8%, #fdf3e7 0%, rgba(253, 243, 231, 0) 70%),
    linear-gradient(180deg, #f9f2e8, #f4ecdf);
  transition: opacity 0.8s var(--ease), visibility 0.8s;
  overflow: hidden;
}
.intro.is-gone { opacity: 0; visibility: hidden; }

.intro-art {
  position: absolute;
  bottom: -4%;
  left: 50%;
  transform: translateX(-50%);
  width: min(1100px, 120vw);
  color: #c8876a;
  opacity: 0.18;
  animation: introArt 2.4s var(--ease) both;
}
.intro-art svg { width: 100%; height: auto; display: block; }
@keyframes introArt {
  from { opacity: 0; transform: translateX(-50%) translateY(24px); }
  to { opacity: 0.18; transform: translateX(-50%) translateY(0); }
}

.intro-card {
  position: relative;
  max-width: 660px;
  text-align: center;
  padding: clamp(20px, 4vw, 40px);
  animation: introIn 1.1s var(--ease) both;
}
@keyframes introIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.34em;
  color: var(--accent);
  margin: 0;
  text-indent: 0.34em;
}

.intro h1 {
  font-family: var(--serif);
  font-size: clamp(36px, 5.6vw, 60px);
  line-height: 1.34;
  letter-spacing: 0.05em;
  margin: 22px 0 0;
  font-weight: 600;
  color: #2f2823;
}

.lede {
  margin: 24px auto 0;
  max-width: 34em;
  font-size: 14.5px;
  line-height: 2.05;
  letter-spacing: 0.03em;
  color: #6d5f52;
}

.begin {
  margin-top: 34px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 30px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(140deg, #c87654, var(--accent-2));
  color: #fff8f2;
  font-family: inherit;
  font-size: 14.5px;
  letter-spacing: 0.14em;
  cursor: pointer;
  box-shadow: 0 22px 44px -20px rgba(168, 88, 58, 0.75);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.begin svg { width: 18px; height: 18px; transition: transform 0.35s var(--ease); }
.begin:hover { transform: translateY(-2px); box-shadow: 0 28px 52px -20px rgba(168, 88, 58, 0.8); }
.begin:hover svg { transform: translateX(3px); }
.begin:active { transform: translateY(0) scale(0.985); }

.tiny {
  font-size: 10.5px;
  line-height: 1.8;
  letter-spacing: 0.04em;
  color: #a2948a;
  margin: 18px 0 0;
}

/* ---------------- letter ---------------- */

.letter-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(47, 37, 30, 0.42);
  backdrop-filter: blur(16px) saturate(1.05);
  animation: fade 0.6s var(--ease) both;
  overflow-y: auto;
}
.letter-layer[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.petal {
  position: absolute;
  top: -8%;
  width: 8px; height: 8px;
  border-radius: 60% 10% 60% 10%;
  opacity: 0;
  animation: fall var(--dur, 9s) linear var(--delay, 0s) infinite;
  background: var(--c, #e2b89c);
}
@keyframes fall {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0deg); }
  8% { opacity: 0.75; }
  92% { opacity: 0.5; }
  100% { opacity: 0; transform: translate3d(var(--drift, 40px), 108vh, 0) rotate(340deg); }
}

.letter-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  padding: clamp(26px, 4.4vw, 46px);
  border-radius: 14px;
  background:
    radial-gradient(700px 300px at 50% -10%, #fffdf8, transparent 70%),
    linear-gradient(180deg, #fffcf6, #faf2e5);
  border: 1px solid #f1e4d2;
  box-shadow: 0 60px 120px -40px rgba(40, 25, 15, 0.65);
  animation: letterIn 0.9s var(--ease) both;
}
@keyframes letterIn {
  from { opacity: 0; transform: translateY(24px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.letter-card h2 {
  font-family: var(--serif);
  font-size: clamp(24px, 3.2vw, 30px);
  letter-spacing: 0.08em;
  font-weight: 600;
  margin: 16px 0 0;
  color: #3a2e26;
}
.letter-body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 2.15;
  letter-spacing: 0.03em;
  color: #4b3b30;
  white-space: pre-wrap;
  margin: 22px 0 0;
  padding-top: 22px;
  border-top: 1px solid #eee0cd;
}
.letter-body::first-letter { font-size: 1.1em; }
.letter-sign {
  text-align: right;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: #a08e7c;
  margin-top: 18px;
}
.letter-actions { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }

.primary, .ghost {
  font-family: inherit;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  padding: 12px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s var(--ease);
}
.primary {
  border: 0;
  color: #fff8f2;
  background: linear-gradient(140deg, #c87654, var(--accent-2));
  box-shadow: 0 16px 30px -16px rgba(168, 88, 58, 0.75);
}
.primary:hover { transform: translateY(-1px); }
.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: #7a6a5c;
}
.ghost:hover { border-color: #d6bda8; color: var(--accent-2); }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 14px);
  z-index: 80;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(43, 37, 33, 0.9);
  color: #fdf6ec;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s var(--ease);
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

:focus-visible { outline: 2px solid rgba(191, 106, 73, 0.55); outline-offset: 3px; }

/* ---------------- responsive ---------------- */

@media (max-width: 1020px) {
  .step:not(:last-child)::after { width: 20px; }
  .brand, .restart { min-width: 0; }
}

@media (max-width: 880px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .topbar {
    gap: 10px;
    padding: 12px 16px 10px;
    align-items: center;
  }
  .brand { gap: 8px; min-width: 0; }
  .brand-mark { width: 24px; height: 24px; }
  .brand-text b { font-size: 16px; letter-spacing: 0.18em; white-space: nowrap; }
  .brand-text span { display: none; }
  .steps { flex: 1 1 auto; justify-content: center; }
  .steps em { display: none; }
  .step { flex: 0 0 auto; }
  .step:not(:last-child)::after { width: 18px; margin: 0 5px; }
  .restart {
    flex: 0 0 auto;
    width: 32px; height: 32px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    font-size: 0;
    justify-content: center;
    gap: 0;
  }
  .restart svg { width: 14px; height: 14px; }
  .stage {
    grid-template-columns: 1fr;
    height: auto;
    align-items: stretch;
    gap: 6px;
    padding-bottom: 20px;
  }
  .portrait { min-height: 0; padding-top: 4px; gap: 4px; }
  .portrait-frame { width: min(240px, 54vw); }
  .identity .name { font-size: 22px; }
  .identity .role { font-size: 11px; }
  .aura { width: min(360px, 100%); }
  .dialog { height: auto; min-height: 58vh; }
  .messages { max-height: 46vh; }
  .chips { display: none; }
  .disclaimer { display: none; }
  .intro h1 { font-size: clamp(30px, 8vw, 44px); }
  .intro .lede { font-size: 13.5px; }
  .intro .tiny { max-width: 21em; margin: 20px auto 0; }
}

@media (max-height: 760px) and (min-width: 881px) {
  .topbar { padding-top: 12px; padding-bottom: 10px; }
  .portrait-frame { width: min(350px, 66%); }
  .identity .role { display: none; }
  .stage { padding-bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
