:root { --character-accent: #3f7cac; --character-soft: #c7e4ed; }
.character-page { --accent: var(--character-accent); --accent-strong: #285e80; --accent-soft: var(--character-soft); }
.character-hero { min-height: min(620px, calc(100dvh - 72px)); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr); align-items: center; gap: 50px; padding: 58px 0 70px; }
.character-hero h1 { font-size: clamp(48px, 6vw, 82px); }
.character-orbit { position: relative; width: min(40vw, 430px); aspect-ratio: 1; justify-self: end; display: grid; place-items: center; border: 1px dashed color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 50%; transform: rotate(-7deg); }
.character-orbit::before, .character-orbit::after { content: ''; position: absolute; inset: 12%; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 50%; }
.character-orbit::after { inset: 27%; border-style: dotted; }
.character-face { display: grid; width: 42%; aspect-ratio: 1; place-items: center; color: #fff; background: var(--ink); border: 12px solid var(--accent); border-radius: 42% 58% 51% 49%; box-shadow: 12px 13px 0 var(--accent-strong); font-size: 76px; font-weight: 900; transform: rotate(7deg); }
.spark { position: absolute; z-index: 2; padding: 10px 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--ink); border-radius: 12px; box-shadow: 4px 5px 0 var(--ink); font-size: 13px; font-weight: 850; }
.spark-a { top: 9%; left: 14%; font-size: 30px; color: var(--accent); border: 0; box-shadow: none; background: transparent; }
.spark-b { right: 4%; top: 40%; transform: rotate(9deg); }
.spark-c { bottom: 12%; left: 8%; transform: rotate(-6deg); }
.character-workbench, .character-result { margin-bottom: 80px; padding: clamp(24px, 4vw, 54px); background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); border-radius: var(--radius); box-shadow: 0 28px 70px var(--shadow); backdrop-filter: blur(14px); }
.section-intro h2 { margin: 0; font-size: clamp(34px, 5vw, 56px); letter-spacing: -.06em; }
.section-intro > p:last-child { margin: 12px 0 32px; color: var(--muted); }
.random-character { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 28px; padding: 10px 14px; color: var(--accent-strong); background: color-mix(in srgb, var(--accent-soft) 42%, transparent); border: 1px solid var(--accent); border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 850; }
.random-character:hover { color: #fff; background: var(--accent); transform: translateY(-2px); }
.character-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.character-field { display: grid; gap: 8px; }
.character-field.wide { grid-column: 1 / -1; }
.character-field span { font-size: 18px; font-weight: 850; }
.character-field small { color: var(--muted); font-size: 12px; }
.character-field input, .character-field textarea { width: 100%; padding: 14px 16px; color: var(--ink); background: color-mix(in srgb, var(--paper) 90%, transparent); border: 1px solid var(--line); border-radius: 11px; outline: 0; font-size: 15px; line-height: 1.65; }
.character-field input:focus, .character-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.character-field textarea { min-height: 86px; resize: vertical; }
.character-button { display: flex; width: 100%; min-height: 76px; align-items: center; justify-content: center; gap: 16px; margin-top: 30px; color: #fff; background: var(--accent); border: 2px solid var(--ink); border-radius: 14px; box-shadow: 0 9px 0 var(--ink); cursor: pointer; font-size: clamp(21px, 3vw, 32px); font-weight: 950; }
.character-button:hover { background: var(--accent-strong); transform: translateY(-2px); }
.character-result[hidden] { display: none; }
.character-card-head { display: flex; justify-content: space-between; gap: 30px; align-items: center; padding-bottom: 35px; border-bottom: 1px solid var(--line); }
.character-card-head h2 { font-size: clamp(44px, 7vw, 78px); }
.tagline { margin: 14px 0 0; color: var(--accent-strong); font-size: 20px; font-weight: 750; }
.avatar-placeholder { display: grid; width: 130px; aspect-ratio: 1; flex: none; place-items: center; color: #fff; background: var(--ink); border: 11px solid var(--accent); border-radius: 43% 57% 48% 52%; font-size: 46px; transform: rotate(7deg); box-shadow: 8px 9px 0 var(--accent-strong); }
.character-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 34px 0; background: var(--line); border: 1px solid var(--line); }
.character-grid article { min-height: 160px; padding: 22px; background: var(--paper); }
.character-grid article span, .image-prompt > span { color: var(--accent-strong); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.character-grid article p { margin: 12px 0 0; line-height: 1.8; }
.image-prompt { padding: 22px; background: color-mix(in srgb, var(--accent-soft) 40%, var(--paper)); border-left: 4px solid var(--accent); }
.image-prompt p { margin: 10px 0 17px; line-height: 1.8; }
.image-prompt button { padding: 8px 12px; color: var(--accent-strong); background: transparent; border: 1px solid currentColor; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 800; }
.chat-panel { margin-top: 46px; padding: 24px; background: var(--ink); border-radius: 15px; color: #fff; }
.chat-heading { display: flex; justify-content: space-between; gap: 18px; align-items: start; }
.chat-heading h3 { margin: 0; font-size: clamp(21px, 3vw, 30px); }
.chat-heading .result-kicker { color: var(--character-soft); }
.chat-status { color: #a9e1a4; font-size: 12px; white-space: nowrap; }
.chat-messages { display: grid; gap: 10px; min-height: 88px; max-height: 360px; overflow: auto; padding: 26px 0; }
.chat-message { width: fit-content; max-width: 78%; margin: 0; padding: 11px 14px; border-radius: 12px 12px 12px 3px; background: rgba(255,255,255,.12); line-height: 1.6; }
.chat-message.user { justify-self: end; color: var(--ink); background: var(--character-soft); border-radius: 12px 12px 3px 12px; }
.chat-form { display: flex; gap: 9px; }
.chat-form input { min-width: 0; flex: 1; padding: 13px 14px; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.3); border-radius: 9px; outline: 0; }
.chat-form button { padding: 0 17px; color: var(--ink); background: var(--character-soft); border: 0; border-radius: 9px; cursor: pointer; font-weight: 900; }
.character-making { background: repeating-radial-gradient(circle, transparent 0 8px, rgba(255,255,255,.1) 9px 10px), #0e2735; }
@media (max-width: 820px) { .character-hero { grid-template-columns: 1fr; padding: 48px 0; } .character-orbit { width: min(86vw, 390px); justify-self: center; } }
@media (max-width: 560px) { .site-nav { gap: 10px; } .site-nav a { font-size: 12px; } .character-fields, .character-grid { grid-template-columns: 1fr; } .character-field.wide { grid-column: auto; } .character-workbench, .character-result { padding: 20px 16px 24px; margin-bottom: 48px; } .character-card-head { align-items: start; } .avatar-placeholder { width: 80px; border-width: 7px; font-size: 28px; } .chat-panel { margin-left: -4px; margin-right: -4px; padding: 17px 14px; } }

/* Light classroom flow: one question area, then the image and chat. */
.character-page .topbar { min-height: 58px; }
.character-hero { display: none; }
.character-page main { max-width: 840px; margin: 0 auto; }
.character-workbench { margin: 10vh 0 26px; padding: 0; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
.section-intro h1 { margin: 0; font-size: clamp(38px, 7vw, 62px); }
.section-intro > p:last-child { margin: 8px 0 17px; }
.character-fields { gap: 12px; }
.character-field span { font-size: 15px; }
.character-field small { display: none; }
.character-field input, .character-field textarea { padding: 11px 13px; background: color-mix(in srgb, var(--paper) 65%, transparent); border-radius: 8px; font-size: 14px; }
.character-field textarea { min-height: 56px; }
.character-button { min-height: 54px; margin-top: 16px; border: 1px solid var(--ink); border-radius: 9px; box-shadow: none; font-size: 18px; }
.character-button:hover { box-shadow: none; }
.random-character { margin-bottom: 20px; padding: 7px 11px; font-size: 12px; }
.character-result { margin-bottom: 30px; padding: 0; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
.character-card-head { padding: 0 0 14px; border: 0; }
.character-card-head h2 { font-size: 30px; }
.tagline { margin-top: 4px; font-size: 14px; }
.character-artwork { margin-bottom: 22px; }
.character-portrait { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: #dce9eb; border-radius: 14px; }
.character-portrait[hidden] { display: none; }
.portrait-actions { display: flex; min-height: 44px; align-items: center; justify-content: flex-end; gap: 14px; padding-top: 10px; }
.portrait-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.portrait-actions button { min-height: 36px; padding: 0 14px; color: var(--accent-strong); background: transparent; border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--line)); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 850; }
.portrait-actions button:hover { color: #fff; background: var(--accent); }
.portrait-actions button:active { transform: translateY(1px); }
.portrait-actions button:disabled { cursor: wait; opacity: .55; }
.chat-panel { margin-top: 0; padding: 16px; border-radius: 11px; }
.chat-heading h3 { font-size: 18px; }
.chat-messages { min-height: 52px; padding: 15px 0; }
.chat-message { font-size: 14px; }
.chat-form input { padding: 10px 12px; font-size: 14px; }
.chat-form button { padding: 0 14px; }
.character-page footer { padding-bottom: 22px; }

/* Character reveal stage and chat thinking state. */
.is-making { overflow: hidden; }
.character-stage {
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(202, 232, 236, .24), transparent 28%),
    radial-gradient(ellipse at 50% 115%, rgba(97, 169, 194, .22), transparent 42%),
    #071f2e;
}
.character-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -4;
  opacity: .42;
  background-image: radial-gradient(circle, rgba(255,255,255,.7) 0 1px, transparent 1.4px);
  background-size: 74px 74px;
  mask-image: radial-gradient(ellipse at 50% 28%, #000, transparent 68%);
}
.character-stage::after {
  content: '';
  position: absolute;
  z-index: -3;
  right: 8%;
  bottom: -18%;
  left: 8%;
  height: 42%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(113, 185, 205, .24), rgba(7,31,46,0) 68%);
  transform: perspective(500px) rotateX(62deg);
}
.stage-curtain {
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  width: 31%;
  background:
    radial-gradient(ellipse at 92% 12%, rgba(121, 188, 211, .5), transparent 28%),
    linear-gradient(100deg, #0b2c43 0%, #225d7d 48%, #123c58 78%, #081f32 100%);
  box-shadow: inset -28px 0 50px rgba(1,13,22,.32), 16px 0 45px rgba(0,0,0,.22);
  will-change: transform;
}
.curtain-left { left: 0; clip-path: polygon(0 0, 100% 0, 79% 100%, 0 100%); transform-origin: left center; }
.curtain-right { right: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 21% 100%); transform-origin: right center; }
.stage-curtain::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(194, 226, 235, .5);
  box-shadow: 0 0 24px rgba(175, 220, 232, .42);
}
.curtain-left::after { right: 15%; transform: rotate(3.4deg); transform-origin: top; }
.curtain-right::after { left: 15%; transform: rotate(-3.4deg); transform-origin: top; }
.stage-card {
  position: relative;
  z-index: 3;
  width: min(690px, calc(100vw - 48px));
  padding: 28px 24px;
  text-align: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  will-change: transform, opacity;
}
.stage-card .stage-kicker {
  min-height: 0;
  margin: 0 0 18px;
  color: #92cada;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .13em;
}
.stage-card h2 {
  max-width: 470px;
  margin: 0 auto;
  color: #fffdf6;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.14;
  letter-spacing: -.055em;
}
.stage-cues { display: flex; width: min(220px, 62vw); justify-content: center; gap: 6px; margin: 34px auto 24px; }
.stage-cues span {
  width: 33.333%;
  height: 3px;
  background: #8cc9dc;
  border-radius: 3px;
  box-shadow: 0 0 12px rgba(140,201,220,.55);
  animation: stage-cue 1.15s ease-in-out infinite;
}
.stage-cues span:nth-child(2) { animation-delay: .16s; }
.stage-cues span:nth-child(3) { animation-delay: .32s; }
.stage-card .stage-note { min-height: 0; margin: 0; color: #adc4cc; font-size: 13px; font-weight: 600; }
.stage-fireworks { position: absolute; z-index: 1; inset: 0; pointer-events: none; }
.firework {
  --spark-color: #f4cf77;
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0;
  background: var(--spark-color);
  box-shadow:
    0 -70px 0 -2px var(--spark-color), 49px -49px 0 -2px var(--spark-color),
    70px 0 0 -2px var(--spark-color), 49px 49px 0 -2px var(--spark-color),
    0 70px 0 -2px var(--spark-color), -49px 49px 0 -2px var(--spark-color),
    -70px 0 0 -2px var(--spark-color), -49px -49px 0 -2px var(--spark-color),
    25px -31px 0 -3px #89c9dd, 31px 25px 0 -3px #89c9dd,
    -25px 31px 0 -3px #89c9dd, -31px -25px 0 -3px #89c9dd;
  animation: firework-bloom 2.4s cubic-bezier(.2,.7,.2,1) infinite;
  will-change: transform, opacity;
}
.firework-one { top: 21%; left: 23%; }
.firework-two { --spark-color: #f0a772; top: 16%; right: 23%; animation-delay: .8s; }
.firework-three { --spark-color: #a4d7dd; right: 17%; bottom: 22%; animation-delay: 1.6s; }
.character-stage.is-revealing .curtain-left { transform: translateX(-102%); transition: transform .95s cubic-bezier(.65,0,.2,1); }
.character-stage.is-revealing .curtain-right { transform: translateX(102%); transition: transform .95s cubic-bezier(.65,0,.2,1); }
.character-stage.is-revealing .stage-card { opacity: 0; transform: translateY(-10px) scale(.96); transition: opacity .42s ease .12s, transform .55s ease .12s; }

.chat-message.thinking { display: inline-flex; align-items: center; gap: 9px; color: rgba(255,255,255,.83); }
.thinking-dots { display: inline-flex; align-items: center; gap: 4px; }
.thinking-dots i { width: 5px; height: 5px; background: var(--character-soft); border-radius: 50%; animation: thinking-dot .9s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .14s; }
.thinking-dots i:nth-child(3) { animation-delay: .28s; }
.chat-form input:disabled { color: rgba(255,255,255,.55); cursor: wait; opacity: .72; }
.chat-form button:disabled { cursor: wait; opacity: .65; }

@keyframes stage-cue { 0%, 65%, 100% { opacity: .24; transform: scaleX(.65); } 35% { opacity: 1; transform: scaleX(1); } }
@keyframes firework-bloom { 0%, 8% { opacity: 0; transform: scale(.1); } 20% { opacity: 1; } 57%, 100% { opacity: 0; transform: scale(1.05); } }
@keyframes thinking-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

@media (max-width: 560px) {
  .character-page main { max-width: 100%; }
  .character-artwork { margin-right: -4px; margin-left: -4px; }
  .portrait-actions { padding-right: 4px; padding-left: 4px; }
  .stage-card { width: calc(100vw - 40px); padding: 24px 10px; }
  .stage-card h2 { font-size: 34px; }
  .stage-card .stage-note { font-size: 12px; line-height: 1.6; }
  .stage-curtain { width: 23%; }
  .firework { transform: scale(.7); }
  .firework-one { top: 17%; left: 20%; }
  .firework-two { top: 13%; right: 20%; }
  .firework-three { right: 20%; bottom: 13%; }
  .chat-form button { min-width: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-cues span, .firework, .thinking-dots i { animation: none; }
  .stage-cues span, .thinking-dots i { opacity: .8; }
  .firework { display: none; }
  .character-stage.is-revealing .stage-curtain, .character-stage.is-revealing .stage-card { transition: none; }
}
