:root {
  --pink-50: #fff5f8;
  --pink-100: #ffe5ef;
  --pink-200: #ffcadd;
  --pink-400: #ff91b9;
  --pink-500: #f7659d;
  --pink-600: #dc477f;
  --navy-700: #343760;
  --navy-900: #202347;
  --violet-400: #a895e7;
  --green-500: #55c98a;
  --text: #24264d;
  --text-soft: #625e73;
  --text-muted: #827d8d;
  --glass: rgba(255, 250, 252, 0.56);
  --glass-strong: rgba(255, 252, 253, 0.73);
  --glass-soft: rgba(255, 255, 255, 0.38);
  --glass-border: rgba(255, 255, 255, 0.72);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --input-bg: rgba(255, 255, 255, 0.68);
  --hover-bg: rgba(255, 255, 255, 0.7);
  --shadow: 0 22px 54px rgba(117, 72, 101, 0.16), 0 4px 14px rgba(112, 75, 95, 0.08);
  --shadow-small: 0 9px 24px rgba(120, 79, 101, 0.13);
  --focus-ring: rgba(236, 77, 140, 0.34);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --ease-soft: cubic-bezier(0.22, 0.8, 0.24, 1);
  --character-scene-scale: 0.84;
  --character-scene-x: -15px;
  --character-scene-y: -118px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --pink-50: #2c2037;
  --pink-100: #3d2844;
  --pink-200: #63415e;
  --pink-400: #f09bbf;
  --pink-500: #ec76a8;
  --pink-600: #f19abf;
  --navy-700: #c7c9e6;
  --navy-900: #f2efff;
  --text: #f4f0ff;
  --text-soft: #d4cee2;
  --text-muted: #aaa6bb;
  --glass: rgba(15, 19, 46, 0.58);
  --glass-strong: rgba(17, 21, 50, 0.72);
  --glass-soft: rgba(27, 31, 66, 0.43);
  --glass-border: rgba(193, 198, 239, 0.16);
  --glass-highlight: rgba(255, 255, 255, 0.12);
  --input-bg: rgba(8, 12, 33, 0.46);
  --hover-bg: rgba(60, 61, 101, 0.54);
  --shadow: 0 24px 64px rgba(2, 5, 24, 0.42), 0 5px 18px rgba(2, 4, 20, 0.3);
  --shadow-small: 0 10px 30px rgba(1, 3, 18, 0.32);
  --focus-ring: rgba(240, 155, 191, 0.3);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  min-width: 320px;
  background: #f7dce6;
  scroll-behavior: smooth;
  overflow: hidden;
}

html[data-theme="dark"] {
  background: #090e29;
}

body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 320px;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: transparent;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  transition: color 420ms ease, background-color 420ms ease;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

button:active {
  transform: translateY(1px) scale(0.985);
}

.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;
}

/* ---------- Layered student council room ---------- */

.room-stage,
.table-stage {
  --scene-crossfade: 760ms cubic-bezier(0.22, 0.61, 0.36, 1);
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.room-stage {
  z-index: 0;
  background: #f4dfe8;
  isolation: isolate;
}

.room-backgrounds,
.table-backgrounds,
.room-image,
.table-image {
  position: absolute;
  inset: 0;
}

.room-backgrounds,
.table-backgrounds {
  overflow: hidden;
}

.room-image,
.table-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: opacity var(--scene-crossfade);
  will-change: opacity;
}

.room-image--day,
.table-image--day { opacity: 1; }

.room-image--night,
.table-image--night { opacity: 0; }

html[data-theme="dark"] .room-image--day,
html[data-theme="dark"] .table-image--day { opacity: 0; }

html[data-theme="dark"] .room-image--night,
html[data-theme="dark"] .table-image--night { opacity: 1; }

.table-stage {
  z-index: 3;
  isolation: isolate;
}

.room-ambient,
.room-vignette,
.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.room-ambient {
  transition: opacity 780ms cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: opacity;
}

.room-ambient--day {
  opacity: 0.26;
  background:
    radial-gradient(ellipse at 43% 13%, rgba(255, 255, 255, 0.42), transparent 48%),
    linear-gradient(90deg, rgba(255, 249, 251, 0.18), transparent 52%);
  mix-blend-mode: screen;
}

.room-ambient--night {
  opacity: 0;
  background:
    radial-gradient(ellipse at 31% 10%, rgba(141, 174, 242, 0.18), transparent 35%),
    linear-gradient(180deg, rgba(25, 42, 95, 0.05), rgba(4, 8, 31, 0.17));
}

html[data-theme="dark"] .room-ambient--day { opacity: 0; }
html[data-theme="dark"] .room-ambient--night { opacity: 1; }

.room-vignette {
  z-index: 2;
  background:
    linear-gradient(90deg, rgba(255, 247, 250, 0.35) 0%, rgba(255, 247, 250, 0.13) 36%, transparent 67%),
    radial-gradient(ellipse at center, transparent 63%, rgba(78, 38, 62, 0.08) 100%);
  transition: background 620ms ease;
}

html[data-theme="dark"] .room-vignette {
  background:
    linear-gradient(90deg, rgba(5, 10, 35, 0.34) 0%, rgba(7, 12, 40, 0.12) 42%, transparent 70%),
    radial-gradient(ellipse at center, transparent 59%, rgba(2, 4, 20, 0.2) 100%);
}

/* ---------- Ambient effects ---------- */

.sakura-background,
.ambient-layer {
  --expression-speed: 1;
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.sakura-background { z-index: 1; }
.ambient-layer { z-index: 6; }

.ambient-glow {
  z-index: 3;
  top: 8%;
  right: 8%;
  bottom: auto;
  left: auto;
  width: min(44vw, 620px);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.2;
  background: radial-gradient(circle, rgba(255, 171, 205, 0.42), transparent 66%);
  filter: blur(24px);
  transform: translate3d(0, 0, 0) scale(1);
  transition: opacity 420ms ease, transform 520ms var(--ease-soft), filter 420ms ease;
}

body[data-expression="happy"] .ambient-glow {
  opacity: 0.32;
  transform: scale(1.05);
}

body[data-expression="surprised"] .ambient-glow {
  opacity: 0.39;
  transform: scale(0.92);
  filter: blur(18px);
}

body[data-expression="playful"] .ambient-glow {
  opacity: 0.34;
  transform: translate3d(12px, -7px, 0) scale(1.02);
}

body[data-expression="gentle"] .ambient-glow {
  opacity: 0.23;
  transform: scale(1.12);
  filter: blur(32px);
}

body[data-expression="happy"] .ambient-layer,
body[data-expression="happy"] .sakura-background { --expression-speed: 0.92; }
body[data-expression="surprised"] .ambient-layer,
body[data-expression="surprised"] .sakura-background { --expression-speed: 0.88; }
body[data-expression="playful"] .ambient-layer,
body[data-expression="playful"] .sakura-background { --expression-speed: 0.76; }
body[data-expression="gentle"] .ambient-layer,
body[data-expression="gentle"] .sakura-background { --expression-speed: 1.22; }

html[data-theme="dark"] .ambient-glow {
  opacity: 0.17;
  background: radial-gradient(circle, rgba(218, 120, 178, 0.32), rgba(90, 105, 183, 0.12) 42%, transparent 69%);
}

.sakura-layer {
  position: absolute;
  inset: 0;
}

.sakura-background .petal {
  opacity: calc(var(--opacity) * 0.48);
  filter: blur(0.35px);
}

.petal {
  position: absolute;
  top: -9vh;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 0.72);
  border-radius: 75% 12% 70% 38%;
  opacity: var(--opacity);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.85), rgba(255, 150, 187, 0.92) 60%, rgba(238, 98, 150, 0.72));
  box-shadow: 0 2px 7px rgba(211, 82, 134, 0.16);
  transform-origin: 70% 70%;
  animation: petal-fall calc(var(--duration) * var(--expression-speed)) linear var(--delay) infinite;
  will-change: transform, opacity;
}

.petal::after {
  content: "";
  position: absolute;
  right: 8%;
  bottom: 7%;
  width: 34%;
  height: 34%;
  border-right: 1px solid rgba(181, 75, 116, 0.2);
  border-radius: 50%;
}

html[data-theme="dark"] .petal {
  opacity: calc(var(--opacity) * 0.64);
  background: linear-gradient(145deg, rgba(255, 223, 237, 0.88), rgba(225, 123, 173, 0.72) 60%, rgba(157, 103, 178, 0.56));
  box-shadow: 0 0 8px rgba(244, 156, 199, 0.22);
}

@keyframes petal-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -7vh, 0) rotate(var(--rotation-start));
  }
  9% { opacity: var(--opacity); }
  46% {
    transform: translate3d(var(--drift), 48vh, 0) rotate(calc(var(--rotation-end) * 0.48));
  }
  78% { opacity: calc(var(--opacity) * 0.76); }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--drift) * -0.42), 114vh, 0) rotate(var(--rotation-end));
  }
}

.expression-spark {
  position: fixed;
  left: var(--spark-x);
  top: var(--spark-y);
  width: var(--spark-size);
  height: var(--spark-size);
  opacity: 0;
  border-radius: 50%;
  background: rgba(255, 213, 233, 0.95);
  box-shadow: 0 0 16px rgba(247, 101, 157, 0.52);
  animation: sparkle-burst 760ms var(--ease-soft) forwards;
}

@keyframes sparkle-burst {
  0% { opacity: 0; transform: scale(0.2) rotate(0); }
  34% { opacity: 0.92; }
  100% { opacity: 0; transform: translate3d(var(--spark-dx), var(--spark-dy), 0) scale(1.4) rotate(120deg); }
}

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

.character-stage {
  position: fixed;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.character-stage::before {
  content: "";
  position: absolute;
  right: clamp(3vw, 6vw, 110px);
  bottom: 8vh;
  width: min(42vw, 650px);
  height: 16vh;
  border-radius: 50%;
  opacity: 0.12;
  background: radial-gradient(ellipse, rgba(67, 38, 61, 0.42), transparent 68%);
  filter: blur(18px);
  transform: translate3d(0, 0, 0);
  transition: opacity 620ms ease, background-color 620ms ease;
}

.character-image {
  --character-scale: 1;
  --character-x: 0px;
  --character-y: 0px;
  position: absolute;
  right: clamp(3vw, 6vw, 110px);
  bottom: -21vh;
  width: auto;
  height: 112.5vh;
  max-width: none;
  opacity: 0;
  object-fit: contain;
  object-position: center center;
  filter: drop-shadow(0 18px 22px rgba(82, 42, 67, 0.18));
  transform:
    translate3d(
      calc(var(--character-x) + var(--character-scene-x)),
      calc(var(--character-y) + var(--character-scene-y)),
      0
    )
    scale(var(--character-scale))
    scale(var(--character-scene-scale));
  transform-origin: 55% 66%;
  transition: opacity 320ms var(--ease-soft), filter 620ms ease;
  will-change: opacity, transform;
}

.character-image[data-character="surprised"] {
  --character-scale: 1.005;
  --character-x: 7px;
  --character-y: -2px;
}

.character-image[data-character="playful"] {
  --character-scale: 0.99;
  --character-x: -8px;
  --character-y: 2px;
}

.character-image[data-character="gentle"] {
  --character-scale: 1.015;
  --character-x: 8px;
  --character-y: -3px;
}

body[data-expression="happy"] .character-image[data-character="happy"],
body[data-expression="surprised"] .character-image[data-character="surprised"],
body[data-expression="playful"] .character-image[data-character="playful"],
body[data-expression="gentle"] .character-image[data-character="gentle"] {
  opacity: 1;
}

html[data-theme="dark"] .character-image {
  filter:
    brightness(0.94)
    saturate(0.94)
    drop-shadow(-8px 7px 4px rgba(130, 163, 229, 0.15))
    drop-shadow(0 22px 28px rgba(0, 4, 28, 0.38));
}

html[data-theme="dark"] .character-stage::before {
  opacity: 0.18;
  background: radial-gradient(ellipse, rgba(1, 5, 27, 0.58), transparent 70%);
}

/* ---------- Layout and shared glass ---------- */

.page-shell {
  --shell-x: clamp(22px, 3.2vw, 58px);
  --shell-top: clamp(14px, 1.8vh, 22px);
  position: relative;
  z-index: 4;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.glass-panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.08);
  backdrop-filter: blur(22px) saturate(1.08);
  transition: background-color 430ms ease, border-color 430ms ease, box-shadow 430ms ease, color 430ms ease;
}

.glass-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}

.topbar {
  position: absolute;
  top: var(--shell-top);
  right: var(--shell-x);
  left: var(--shell-x);
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 1.4vw, 20px);
  height: 68px;
  min-height: 0;
  padding: 0 clamp(12px, 1vw, 16px);
  border-radius: 999px;
}

.brand {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-self: start;
  gap: 10px;
  width: max-content;
  min-width: 0;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.07em;
  line-height: 1;
  white-space: nowrap;
}

.brand strong { color: var(--pink-600); }

.brand-name {
  display: inline-flex;
  align-items: center;
  gap: 0.42em;
  line-height: 1;
}

.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, var(--pink-400), var(--pink-600));
  box-shadow: 0 7px 16px rgba(220, 71, 127, 0.25);
  font-size: 16px;
  line-height: 1;
}

.tabs {
  display: flex;
  height: 50px;
  align-items: center;
  justify-self: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: var(--glass-soft);
}

.tab {
  display: inline-flex;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  color: var(--text-soft);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  transition: color 220ms ease, background-color 220ms ease, box-shadow 220ms ease, transform 180ms ease;
}

.tab:hover { color: var(--pink-600); background: var(--glass-soft); }

.tab.is-active {
  color: var(--pink-600);
  background: var(--pink-100);
  box-shadow: 0 5px 15px rgba(220, 71, 127, 0.12);
}

.tab-mark {
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
}

.header-actions {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-self: end;
  justify-content: flex-end;
  gap: 9px;
}

.local-status {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text-soft);
  background: var(--glass-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.status-dot {
  display: block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-500);
  box-shadow: 0 0 0 4px rgba(85, 201, 138, 0.13);
}

.theme-toggle {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 7px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text);
  background: var(--glass-strong);
  box-shadow: var(--shadow-small);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition: color 240ms ease, background-color 320ms ease, border-color 320ms ease, transform 180ms ease, box-shadow 240ms ease;
}

.theme-toggle:hover { box-shadow: 0 12px 27px rgba(111, 74, 96, 0.16); }

.theme-toggle__icon {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, var(--violet-400), var(--pink-500));
  font-size: 15px;
  line-height: 1;
  transition: transform 420ms var(--ease-soft), background 320ms ease;
}

html[data-theme="dark"] .theme-toggle__icon {
  transform: rotate(180deg);
  background: linear-gradient(145deg, #8da8e4, #b38fda);
}

.main-content {
  position: absolute;
  z-index: 2;
  top: calc(var(--shell-top) + 80px);
  right: var(--shell-x);
  bottom: clamp(14px, 2vh, 24px);
  left: var(--shell-x);
  min-height: 0;
  overflow: hidden;
}

.view-panel {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.view-panel[hidden] { display: none; }

.view-panel.is-entering { animation: panel-enter 360ms var(--ease-soft) both; }
.view-panel.is-leaving { animation: panel-leave 180ms ease both; }

@keyframes panel-enter {
  from { opacity: 0; transform: translate3d(0, 12px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes panel-leave {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to { opacity: 0; transform: translate3d(0, -7px, 0); }
}

.page-enter { animation: page-rise 620ms var(--ease-soft) both; }
.page-enter--delay { animation-delay: 90ms; }
.page-enter--later { animation-delay: 160ms; }

@keyframes page-rise {
  from { opacity: 0; transform: translate3d(0, 18px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.content-column {
  width: min(49vw, 680px);
  height: 100%;
}

.chat-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  gap: clamp(13px, 1.8vh, 22px);
}

.eyebrow,
.card-kicker,
.summary-overline {
  margin: 0;
  color: var(--pink-600);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  font-size: 13px;
}

.hero-copy h1,
.section-heading h1 {
  max-width: 690px;
  margin: 0;
  color: var(--text);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Segoe UI", sans-serif;
  font-size: clamp(38px, min(4.25vw, 6vh), 61px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.04;
  text-wrap: balance;
}

.hero-copy h1 span,
.section-heading h1 span {
  color: var(--pink-600);
  background: linear-gradient(100deg, var(--pink-600), var(--pink-400));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.section-heading > p:last-child {
  max-width: 590px;
  margin: clamp(11px, 1.7vh, 19px) 0 0;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.72;
  text-wrap: pretty;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 11px 19px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease, transform 180ms ease, box-shadow 220ms ease;
}

.button:hover { transform: translateY(-2px); }

.button--primary {
  color: #fff;
  background: linear-gradient(105deg, var(--pink-600), var(--pink-500));
  box-shadow: 0 12px 28px rgba(220, 71, 127, 0.29);
}

.button--primary:hover { box-shadow: 0 15px 34px rgba(220, 71, 127, 0.37); }

.button--glass {
  color: var(--text);
  background: var(--glass-strong);
  border-color: var(--glass-border);
  box-shadow: var(--shadow-small);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
}

.button--glass:hover { background: var(--hover-bg); }

.button--ghost {
  color: var(--text-soft);
  background: transparent;
  border-color: var(--glass-border);
}

.button--ghost:hover { color: var(--text); background: var(--glass-soft); }

.button--danger {
  color: #fff;
  background: linear-gradient(105deg, #ca5274, #df6681);
  box-shadow: 0 10px 25px rgba(167, 56, 87, 0.24);
}

.button--small { min-height: 40px; padding: 9px 16px; font-size: 13px; }

/* ---------- Chat ---------- */

.chat-card {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin-top: 0;
  padding: clamp(16px, 2vh, 24px);
  flex-direction: column;
  border-radius: var(--radius-xl);
}

.card-heading,
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.card-heading h2,
.dialog-heading h2,
.expression-summary h2,
.confirm-dialog h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Segoe UI", sans-serif;
  font-size: 21px;
  line-height: 1.2;
}

.demo-badge,
.state-chip,
.memory-count {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--glass-soft);
  font-size: 11px;
  font-weight: 750;
}

.chat-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chat-status-badge {
  min-width: 79px;
  text-align: center;
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease;
}

.chat-status-badge[data-state="thinking"],
.chat-status-badge[data-state="talking"] {
  color: var(--pink-700);
  border-color: rgba(224, 102, 151, 0.3);
  background: var(--pink-100);
}

.chat-status-badge[data-state="error"] {
  color: #b74768;
  border-color: rgba(192, 73, 107, 0.26);
  background: rgba(255, 222, 229, 0.62);
}

.chat-clear-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-muted);
  background: var(--glass-soft);
  cursor: pointer;
  font: inherit;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.chat-clear-button:hover:not(:disabled) {
  color: var(--pink-700);
  border-color: rgba(224, 102, 151, 0.36);
  background: var(--pink-100);
  transform: translateY(-1px);
}

.chat-clear-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-height: 0;
  flex: 1;
  max-height: none;
  margin: clamp(12px, 1.6vh, 19px) -4px clamp(11px, 1.4vh, 16px) 0;
  padding: 2px 6px 2px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--pink-200) transparent;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: message-enter 270ms var(--ease-soft) both;
}

.message--user { justify-content: flex-end; }

.message--assistant .message__mark {
  color: var(--pink-700);
  background: var(--pink-100);
}

.message__mark {
  display: grid;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  color: var(--pink-600);
  background: var(--pink-100);
  font-size: 13px;
}

.message__bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 82%;
  padding: 12px 15px;
  border: 1px solid var(--glass-border);
  border-radius: 17px 17px 17px 6px;
  color: var(--text-soft);
  background: var(--glass-strong);
  font-size: 13.5px;
  line-height: 1.55;
}

.message__bubble strong { color: var(--text); font-size: 13.5px; }

.message__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message--user .message__bubble {
  border-color: rgba(225, 118, 159, 0.2);
  border-radius: 17px 17px 6px 17px;
  color: var(--text);
  background: var(--pink-100);
}

.message--error .message__bubble {
  color: var(--text-soft);
  border-color: rgba(196, 78, 111, 0.25);
  background: rgba(255, 227, 233, 0.68);
}

html[data-theme="dark"] .message--error .message__bubble {
  color: var(--text);
  border-color: rgba(245, 140, 176, 0.24);
  background: rgba(80, 29, 58, 0.48);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 34px;
  min-height: 14px;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--pink-500);
  animation: typing-dot 1.05s ease-in-out infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 120ms; }
.typing-dots i:nth-child(3) { animation-delay: 240ms; }

@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(1px); }
  30% { opacity: 1; transform: translateY(-2px); }
}

@keyframes message-enter {
  from { opacity: 0; transform: translate3d(0, 7px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 17px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--input-bg);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}

.chat-composer:focus-within { border-color: var(--pink-400); box-shadow: 0 0 0 4px var(--focus-ring); }

.chat-composer textarea {
  min-width: 0;
  min-height: 24px;
  max-height: 92px;
  flex: 1;
  padding: 7px 0;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  scrollbar-width: thin;
}

.chat-composer textarea::placeholder { color: var(--text-muted); }

.send-button,
.stop-button {
  display: grid;
  flex: 0 0 auto;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, var(--pink-400), var(--pink-600));
  box-shadow: 0 8px 18px rgba(220, 71, 127, 0.27);
  cursor: pointer;
  font-size: 17px;
  transition: transform 180ms ease, box-shadow 220ms ease;
}

.stop-button {
  color: var(--pink-700);
  border: 1px solid rgba(225, 118, 159, 0.28);
  background: var(--pink-100);
  box-shadow: none;
  font-size: 11px;
}

.send-button:hover:not(:disabled),
.stop-button:hover { transform: translateY(-1px) scale(1.04); box-shadow: 0 10px 22px rgba(220, 71, 127, 0.34); }

.send-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: none;
}

.chat-jump-button {
  position: absolute;
  left: 50%;
  bottom: 78px;
  z-index: 2;
  min-height: 31px;
  padding: 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text);
  background: var(--glass-strong);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 750;
  transform: translateX(-50%);
}

.chat-jump-button:hover { color: var(--pink-700); }

.stop-button[hidden],
.chat-jump-button[hidden] { display: none !important; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 3px 0;
  color: var(--text-muted);
  font-size: 11.5px;
}

.chat-presence {
  margin-left: auto;
  color: var(--text-soft);
  font-weight: 680;
}

/* ---------- Expressions ---------- */

.section-heading { max-width: 780px; }
.section-heading--compact { max-width: 670px; }

#panel-expression .section-heading {
  width: min(50vw, 720px);
}

#panel-expression .section-heading h1 {
  font-size: clamp(35px, min(3.45vw, 5.2vh), 50px);
}

#panel-expression .section-heading > p:last-child {
  margin-top: clamp(9px, 1.3vh, 14px);
  font-size: 14px;
  line-height: 1.58;
}

.expression-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(190px, 0.82fr);
  gap: 12px;
  align-items: stretch;
  width: min(50vw, 720px);
  max-width: none;
  margin-top: clamp(14px, 2vh, 22px);
}

.expression-card,
.expression-summary {
  border-radius: var(--radius-xl);
}

.expression-card { padding: clamp(17px, 1.7vw, 23px); }

.expression-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.expression-option {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  padding: 9px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--glass-soft);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, background-color 240ms ease, border-color 240ms ease, box-shadow 240ms ease;
}

.expression-option:hover { transform: translateY(-2px); background: var(--hover-bg); }

.expression-option.is-active {
  border-color: var(--pink-400);
  background: var(--pink-100);
  box-shadow: 0 10px 23px rgba(220, 71, 127, 0.13);
}

.expression-option__symbol {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 13px;
  color: var(--pink-600);
  background: var(--glass-strong);
  font-size: 16px;
  transition: transform 330ms var(--ease-soft), color 230ms ease;
}

.expression-option.is-active .expression-option__symbol { transform: rotate(-5deg) scale(1.06); }

.expression-option__copy { display: flex; min-width: 0; flex-direction: column; }
.expression-option__copy strong { font-size: 12.5px; }
.expression-option__copy small { margin-top: 1px; color: var(--text-muted); font-size: 10px; line-height: 1.3; }

.expression-option__check {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  background: var(--glass-soft);
  font-size: 11px;
  transition: color 220ms ease, background-color 220ms ease, transform 240ms var(--ease-soft);
}

.expression-option.is-active .expression-option__check {
  color: #fff;
  background: var(--pink-500);
  transform: scale(1.04);
}

.expression-summary {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding: 19px;
}

.expression-summary > * { position: relative; z-index: 1; }

.expression-summary h2 { margin-top: 6px; font-size: 23px; }

.expression-summary > p:not(.summary-overline) {
  margin: 8px 0 13px;
  color: var(--text-soft);
  font-size: 11.5px;
  line-height: 1.5;
}

.ambient-orbit {
  position: absolute;
  z-index: 0;
  top: -76px;
  right: -49px;
  width: 230px;
  height: 230px;
  border: 1px solid rgba(255, 145, 185, 0.18);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 174, 205, 0.24), transparent 65%);
  animation: orbit-breathe calc(5s * var(--expression-speed)) ease-in-out infinite;
}

.ambient-orbit::before,
.ambient-orbit::after {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(168, 149, 231, 0.16);
  border-radius: 50%;
}

.ambient-orbit::after { inset: 60px; }

.ambient-orbit i {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pink-400);
  box-shadow: 0 0 10px rgba(255, 145, 185, 0.48);
}

.ambient-orbit i:nth-child(1) { top: 30px; left: 74px; }
.ambient-orbit i:nth-child(2) { top: 112px; right: 24px; }
.ambient-orbit i:nth-child(3) { bottom: 33px; left: 62px; }

@keyframes orbit-breathe {
  0%, 100% { transform: rotate(0) scale(0.98); opacity: 0.72; }
  50% { transform: rotate(7deg) scale(1.04); opacity: 1; }
}

.integration-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: auto;
  padding-top: 11px;
  border-top: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}

.integration-note > span:first-child { color: var(--pink-600); font-size: 13px; }

/* Compact expression panel, based on option-1 composition. */

.expression-dock {
  position: absolute;
  z-index: 11;
  right: var(--shell-x);
  bottom: clamp(14px, 2vh, 24px);
  width: min(44vw, 650px);
  padding: clamp(13px, 1.7vh, 18px);
  border-radius: clamp(20px, 2vw, 27px);
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 240ms ease,
    transform 300ms var(--ease-soft),
    background-color 430ms ease,
    border-color 430ms ease,
    box-shadow 430ms ease;
}

body:not([data-active-tab="chat"]) .expression-dock {
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 14px, 0);
}

.expression-dock__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 11px;
}

.expression-dock__heading h2 {
  margin: 2px 0 0;
  color: var(--text);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.15;
}

.expression-dock__options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.dock-expression {
  display: flex;
  min-width: 0;
  height: clamp(65px, 8.2vh, 84px);
  padding: 8px 5px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--glass-border);
  border-radius: 15px;
  color: var(--text-soft);
  background: var(--glass-soft);
  cursor: pointer;
  transition: color 200ms ease, background-color 220ms ease, border-color 220ms ease, transform 180ms ease, box-shadow 220ms ease;
}

.dock-expression:hover {
  color: var(--pink-600);
  background: var(--hover-bg);
  transform: translateY(-2px);
}

.dock-expression.is-active {
  color: var(--pink-600);
  border-color: var(--pink-400);
  background: var(--pink-100);
  box-shadow: 0 8px 18px rgba(220, 71, 127, 0.14);
}

.dock-expression > span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: var(--glass-strong);
  font-size: 14px;
}

.dock-expression small {
  overflow: hidden;
  font-size: 10.5px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Memories ---------- */

.memory-heading {
  display: flex;
  width: min(62vw, 1040px);
  flex: 0 0 auto;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  max-width: none;
}

#panel-memories {
  display: flex;
  width: min(62vw, 1040px);
  flex-direction: column;
}

#panel-memories[hidden] { display: none; }

#panel-memories .section-heading h1 {
  font-size: clamp(35px, min(3.4vw, 5vh), 49px);
}

#panel-memories .section-heading > p:last-child {
  margin-top: clamp(9px, 1.3vh, 14px);
  font-size: 14px;
  line-height: 1.55;
}

.memories-surface {
  display: flex;
  width: 100%;
  min-height: 0;
  margin-top: clamp(13px, 2vh, 22px);
  padding: clamp(16px, 1.8vw, 24px);
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.memories-heading-row { align-items: center; }

.empty-state {
  display: flex;
  max-width: 480px;
  min-height: 0;
  margin: 18px auto 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-state[hidden] { display: none; }

.empty-state__mark {
  display: grid;
  width: 57px;
  height: 57px;
  place-items: center;
  border: 1px solid var(--glass-border);
  border-radius: 19px;
  color: var(--pink-600);
  background: var(--pink-100);
  box-shadow: var(--shadow-small);
  font-size: 25px;
  transform: rotate(-4deg);
}

.empty-state h3 { margin: 15px 0 6px; color: var(--text); font-size: 18px; }
.empty-state p { margin: 0 0 18px; color: var(--text-soft); font-size: 13.5px; line-height: 1.6; }

.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  margin-top: 22px;
  padding-right: 5px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--pink-200) transparent;
}

.memory-grid:empty { display: none; }

.memory-card {
  display: flex;
  min-height: 205px;
  flex-direction: column;
  padding: 18px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass-soft);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  animation: memory-enter 360ms var(--ease-soft) both;
  transition: transform 190ms ease, background-color 240ms ease, border-color 240ms ease, opacity 180ms ease;
}

.memory-card:hover { transform: translateY(-3px); background: var(--hover-bg); }
.memory-card.is-removing { opacity: 0; transform: translateY(7px) scale(0.97); }

@keyframes memory-enter {
  from { opacity: 0; transform: translate3d(0, 12px, 0) scale(0.985); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.memory-card__date {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--pink-600);
  font-size: 11px;
  font-weight: 750;
}

.memory-card h3 {
  margin: 11px 0 7px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
}

.memory-card__preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.55;
}

.memory-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: auto;
  padding-top: 18px;
}

.memory-action {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text-soft);
  background: var(--glass-soft);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.memory-action:hover { color: var(--pink-600); background: var(--pink-100); transform: translateY(-1px); }

.memory-action--delete {
  display: grid;
  width: 34px;
  padding: 0;
  place-items: center;
  color: var(--text-muted);
  background: transparent;
  font-size: 17px;
}

.memory-action--delete:hover { color: #c84e70; background: rgba(206, 76, 111, 0.1); }

/* ---------- Dialogs and toast ---------- */

dialog {
  color: var(--text);
}

.memory-dialog,
.confirm-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(88vh, 760px);
  max-height: min(88dvh, 760px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border-radius: var(--radius-xl);
}

.memory-dialog[open],
.confirm-dialog[open] {
  animation: dialog-open 310ms var(--ease-soft) both;
}

.memory-dialog.is-closing,
.confirm-dialog.is-closing {
  animation: dialog-close 180ms ease both;
}

.memory-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(17, 15, 36, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: backdrop-open 260ms ease both;
}

html[data-theme="dark"] .memory-dialog::backdrop,
html[data-theme="dark"] .confirm-dialog::backdrop {
  background: rgba(2, 4, 18, 0.66);
}

@keyframes dialog-open {
  from { opacity: 0; transform: translate3d(0, 14px, 0) scale(0.975); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes dialog-close {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  to { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.98); }
}

@keyframes backdrop-open {
  from { opacity: 0; }
  to { opacity: 1; }
}

.memory-dialog form { padding: clamp(22px, 4vw, 32px); }

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-soft);
  background: var(--glass-soft);
  cursor: pointer;
  font-size: 23px;
  line-height: 1;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.icon-button:hover { color: var(--pink-600); background: var(--pink-100); transform: rotate(4deg); }

.field-group { margin-top: 21px; }

.field-group label {
  display: block;
  margin: 0 0 7px 3px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.field-group input,
.field-group textarea {
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: 15px;
  outline: 0;
  color: var(--text);
  background: var(--input-bg);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 280ms ease;
}

.field-group input { height: 48px; padding: 0 15px; }
.field-group textarea { min-height: 160px; padding: 13px 15px; resize: vertical; line-height: 1.55; }

.field-group input:focus,
.field-group textarea:focus { border-color: var(--pink-400); box-shadow: 0 0 0 4px var(--focus-ring); }

.field-group input::placeholder,
.field-group textarea::placeholder { color: var(--text-muted); }

.field-group .is-invalid { border-color: #ce5275; }

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  min-height: 20px;
  margin: 5px 3px 0;
  color: var(--text-muted);
  font-size: 11px;
}

.field-error { color: #c94d71; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
}

.confirm-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 29px;
  text-align: center;
}

.confirm-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 13px;
  place-items: center;
  border-radius: 17px;
  color: #ca5274;
  background: rgba(206, 76, 111, 0.11);
  font-size: 22px;
}

.confirm-dialog p { margin: 10px auto 0; color: var(--text-soft); font-size: 13.5px; line-height: 1.55; }
.confirm-dialog .dialog-actions { justify-content: center; }

.toast {
  position: fixed;
  z-index: 60;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text);
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 10px, 0);
  font-size: 12.5px;
  font-weight: 700;
  transition: opacity 230ms ease, transform 230ms var(--ease-soft), background-color 400ms ease;
}

.toast.is-visible { opacity: 1; transform: translate3d(0, 0, 0); }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .page-shell { --shell-x: clamp(18px, 2.5vw, 32px); }
  .brand-name { font-size: 13px; }
  .local-status { display: none; }
  .content-column { width: min(52vw, 630px); }
  #panel-expression .section-heading,
  .expression-layout { width: min(53vw, 680px); }
  #panel-memories,
  .memory-heading { width: min(66vw, 900px); }
  .expression-dock { width: min(47vw, 590px); }
  .character-image { right: 0; }
  .character-stage::before { right: 0; }
  .memory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .page-shell {
    --shell-x: 16px;
    --shell-top: 12px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 8px 14px;
    height: 116px;
    padding: 9px 12px 10px;
    border-radius: 24px;
  }

  .tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .tab { flex: 1; min-width: 0; }
  .header-actions { grid-column: 2; grid-row: 1; }

  .main-content { top: 140px; bottom: 14px; }
  .view-panel { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .hero-copy h1,
  .section-heading h1 { font-size: clamp(35px, 6.8vw, 48px); }
  .content-column { width: min(58vw, 450px); }

  .chat-view {
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
  }

  #panel-chat { overflow: hidden; }
  .chat-card { height: 100%; min-height: 0; }

  #panel-expression .section-heading,
  .expression-layout { width: min(58vw, 450px); }
  .expression-layout { grid-template-columns: 1fr; }
  .expression-summary { display: none; }
  .expression-options { grid-template-columns: 1fr; }
  .expression-option { min-height: 62px; }

  #panel-memories,
  .memory-heading { width: min(64vw, 500px); }
  .memory-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .memory-heading .button { align-self: flex-start; }

  .room-vignette {
    background:
      linear-gradient(90deg, rgba(255, 247, 250, 0.4), rgba(255, 247, 250, 0.08) 75%),
      radial-gradient(ellipse at center, transparent 58%, rgba(78, 38, 62, 0.08) 100%);
  }

  html[data-theme="dark"] .room-vignette {
    background:
      linear-gradient(90deg, rgba(5, 10, 35, 0.32), rgba(7, 12, 40, 0.05) 75%),
      radial-gradient(ellipse at center, transparent 58%, rgba(2, 4, 20, 0.18) 100%);
  }

  .character-image {
    right: -18vw;
    bottom: -14.5vh;
    height: 90vh;
  }

  .character-stage::before {
    right: -14vw;
    bottom: 4vh;
    width: 52vw;
  }

  .expression-dock {
    right: 16px;
    bottom: 14px;
    width: min(48vw, 370px);
  }

  .expression-dock__heading .card-kicker,
  .expression-dock__heading .state-chip { display: none; }
  .expression-dock__heading { margin-bottom: 8px; }
  .dock-expression { height: 60px; }
  .dock-expression small { font-size: 9px; }
}

@media (max-width: 620px) {
  .page-shell {
    --shell-x: 10px;
    --shell-top: 9px;
  }

  .topbar { height: 112px; }
  .main-content { top: 130px; right: 10px; bottom: 9px; left: 10px; }

  .brand { gap: 7px; font-size: 12px; letter-spacing: 0.055em; }
  .brand-mark { width: 28px; height: 28px; font-size: 14px; }

  .theme-toggle { min-height: 40px; padding: 5px; }
  .theme-toggle__icon { width: 28px; height: 28px; }
  .theme-toggle__label { display: none; }

  .tab { min-height: 40px; padding: 8px 6px; font-size: 12.5px; }
  .tab-mark { display: none; }

  .hero-copy h1,
  .section-heading h1 { font-size: clamp(31px, 9.3vw, 42px); }
  .section-heading > p:last-child { margin-top: 10px; font-size: 13px; line-height: 1.52; }

  .button { min-height: 44px; padding: 10px 16px; }

  .content-column,
  #panel-expression .section-heading,
  .expression-layout,
  #panel-memories,
  .memory-heading { width: 100%; }

  .chat-view {
    display: grid;
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .chat-card { height: 100%; min-height: 0; border-radius: 23px; }
  .demo-badge { display: none; }
  .chat-presence { display: none; }
  .message__bubble { max-width: 88%; }

  .expression-options { grid-template-columns: 1fr; }
  .expression-option { min-height: 71px; }

  #panel-expression .section-heading h1,
  #panel-memories .section-heading h1 { font-size: clamp(30px, 8.6vw, 39px); }

  #panel-expression,
  #panel-memories { padding-bottom: 4px; }

  .memory-heading { flex-direction: row; align-items: flex-end; }
  .memory-heading .button { flex: 0 0 auto; }
  .memory-heading .button span { display: none; }
  .memories-surface { min-height: 360px; flex: 1 0 360px; }

  .memory-grid { grid-template-columns: 1fr; }
  .memory-card { min-height: 190px; }

  .memory-dialog,
  .confirm-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 23px;
  }

  .dialog-actions .button { flex: 1; }
  .toast { right: 10px; bottom: 10px; }

  .ambient-glow { top: 18%; right: -20%; width: 82vw; }

  .character-image {
    right: -7vw;
    bottom: -9.5vh;
    height: 70vh;
    opacity: 0;
  }

  .character-stage::before {
    right: -7vw;
    bottom: 2vh;
    width: 76vw;
    height: 13vh;
    opacity: 0.08;
  }

  body[data-expression="happy"] .character-image[data-character="happy"],
  body[data-expression="surprised"] .character-image[data-character="surprised"],
  body[data-expression="playful"] .character-image[data-character="playful"],
  body[data-expression="gentle"] .character-image[data-character="gentle"] { opacity: 0.5; }

  body[data-active-tab="expression"][data-expression="happy"] .character-image[data-character="happy"],
  body[data-active-tab="expression"][data-expression="surprised"] .character-image[data-character="surprised"],
  body[data-active-tab="expression"][data-expression="playful"] .character-image[data-character="playful"],
  body[data-active-tab="expression"][data-expression="gentle"] .character-image[data-character="gentle"] { opacity: 0.68; }

  html[data-theme="dark"] body[data-expression="happy"] .character-image[data-character="happy"],
  html[data-theme="dark"] body[data-expression="surprised"] .character-image[data-character="surprised"],
  html[data-theme="dark"] body[data-expression="playful"] .character-image[data-character="playful"],
  html[data-theme="dark"] body[data-expression="gentle"] .character-image[data-character="gentle"] { opacity: 0.58; }

  .expression-dock { display: none; }

  .room-vignette {
    background: linear-gradient(180deg, rgba(255, 248, 251, 0.22), rgba(255, 245, 249, 0.14));
  }

  html[data-theme="dark"] .room-vignette {
    background: linear-gradient(180deg, rgba(5, 9, 31, 0.14), rgba(3, 7, 25, 0.2));
  }
}

@media (max-width: 390px) {
  .chat-composer { padding-left: 13px; }
  .memory-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }
  .memory-heading .button { width: 100%; }
  .card-heading { gap: 10px; }
  .state-chip { display: none; }
}

@media (max-height: 820px) and (min-width: 861px) {
  .page-shell { --shell-top: 12px; }
  .topbar { height: 64px; }
  .main-content { top: 84px; bottom: 12px; }
  .hero-copy h1,
  .section-heading h1 { font-size: 41px; }
  .eyebrow { margin-bottom: 7px; }
  .button { min-height: 42px; padding-block: 9px; }
  .chat-card { height: 100%; min-height: 0; }
  .chat-log { margin-block: 10px; }
  .privacy-note { margin-top: 7px; }
  .expression-dock { bottom: 12px; padding: 11px 13px; }
  .expression-dock__heading { margin-bottom: 8px; }
  .dock-expression { height: 62px; }
  .character-image { height: 111.5vh; bottom: -21vh; }

  #panel-expression .section-heading h1,
  #panel-memories .section-heading h1 { font-size: 38px; }
  #panel-expression .section-heading > p:last-child,
  #panel-memories .section-heading > p:last-child { font-size: 12.5px; line-height: 1.45; }
  .expression-layout { margin-top: 12px; }
  .expression-card { padding: 15px; }
  .expression-options { margin-top: 11px; }
  .expression-option { min-height: 55px; }
  .memories-surface { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .sakura-layer,
  .sakura-background,
  .expression-spark { display: none; }

  .room-image,
  .table-image,
  .room-ambient { transition-duration: 160ms !important; }
}
