:root {
  color-scheme: light;
  --color-primary: #2563eb;
  --color-primary-dark: #1749b1;
  --color-primary-soft: #eaf1ff;
  --color-accent: #e85d3f;
  --color-accent-soft: #fff0eb;
  --color-success: #17845a;
  --color-success-soft: #e8f7f0;
  --color-warning: #9a5a0a;
  --color-warning-soft: #fff6df;
  --color-danger: #c9363e;
  --color-danger-soft: #fff0f1;
  --color-ink: #172033;
  --color-muted: #5e6a7e;
  --color-subtle: #8792a5;
  --color-line: #dbe1ea;
  --color-line-strong: #c5cdda;
  --color-surface: #ffffff;
  --color-background: #f5f7fa;
  --color-sidebar: #eef2f6;
  --shadow-low: 0 2px 8px rgb(23 32 51 / 0.06);
  --shadow-medium: 0 12px 32px rgb(23 32 51 / 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --focus-ring: 0 0 0 3px rgb(37 99 235 / 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--color-background);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--color-ink);
  background: var(--color-background);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
a,
select,
label[for],
.toggle-row {
  touch-action: manipulation;
}

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

button {
  border: 0;
}

button:not(:disabled),
a,
select,
.toggle-row {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--color-primary-dark);
  border-radius: var(--radius-sm);
  transform: translateY(-150%);
  transition: transform 180ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--color-primary-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  color: var(--color-ink);
  font-size: 15px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: white;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  font-size: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-page {
  overflow-x: hidden;
  color: #f7fbff;
  background: #07131f;
}

.login-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 34vw);
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

.login-scene,
.login-atmosphere {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.login-scene {
  z-index: -2;
  object-fit: cover;
  object-position: 48% center;
}

.login-atmosphere {
  z-index: -1;
  background:
    linear-gradient(90deg, rgb(2 10 19 / 0.34) 0%, rgb(3 12 23 / 0.08) 48%, rgb(3 10 19 / 0.6) 68%, rgb(3 10 19 / 0.82) 100%),
    linear-gradient(0deg, rgb(3 10 18 / 0.78) 0%, transparent 48%);
}

.login-header {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 20px clamp(24px, 4vw, 64px);
  pointer-events: none;
}

.login-brand {
  color: #f7fbff;
  text-shadow: 0 2px 20px rgb(0 0 0 / 0.4);
}

.login-brand .brand-mark {
  color: #061421;
  background: #73e3ed;
  box-shadow: 0 0 28px rgb(115 227 237 / 0.28);
}

.origin-signal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: calc(34vw + 12px);
  color: rgb(229 246 250 / 0.82);
  font-size: 11px;
  font-weight: 700;
}

.origin-signal svg {
  width: 15px;
  height: 15px;
  color: #73e3ed;
}

.login-companion {
  --body-tilt: 0deg;
  --eye-left-rotate: 0deg;
  --eye-right-rotate: 0deg;
  --eye-scale-x: 1;
  --eye-scale-y: 1;
  --look-x: 0px;
  --look-y: 0px;
  position: absolute;
  z-index: 2;
  top: clamp(104px, 16vh, 150px);
  right: calc(34vw - 28px);
  width: clamp(188px, 16vw, 242px);
  aspect-ratio: 1;
  pointer-events: none;
  filter: drop-shadow(0 24px 28px rgb(0 5 12 / 0.38));
}

.login-companion-float {
  width: 100%;
  height: 100%;
  animation: login-companion-float 5.4s ease-in-out infinite;
}

.login-companion-character {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotate(var(--body-tilt));
  transform-origin: 50% 44%;
  transition: transform 240ms ease-out;
}

.login-companion img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-companion-visor {
  position: absolute;
  top: 26.1%;
  left: 35.5%;
  width: 36.5%;
  height: 16.2%;
  overflow: hidden;
  background: #07111c;
  border: 1px solid rgb(174 222 231 / 0.55);
  border-radius: 48% 48% 46% 46% / 55% 55% 48% 48%;
  box-shadow: inset 0 4px 12px rgb(0 0 0 / 0.72), 0 0 7px rgb(145 237 243 / 0.18);
  transform: rotate(1deg);
}

.login-companion-visor::after {
  position: absolute;
  inset: 8% 12% auto;
  height: 28%;
  background: rgb(255 255 255 / 0.08);
  border-radius: 50%;
  content: "";
  filter: blur(2px);
}

.login-companion-eye {
  position: absolute;
  z-index: 1;
  top: 53%;
  width: 15%;
  height: 42%;
  background: #7df4ff;
  border-radius: 50%;
  box-shadow: 0 0 7px #4ee8fa, 0 0 15px rgb(78 232 250 / 0.72);
  transform: translate3d(calc(-50% + var(--look-x)), calc(-50% + var(--look-y)), 0) rotate(var(--eye-rotate)) scale(var(--eye-scale-x), var(--eye-scale-y));
  transition: transform 160ms ease-out, border-radius 180ms ease-out, background-color 180ms ease-out;
}

.login-companion-eye-left {
  --eye-rotate: var(--eye-left-rotate);
  left: 31%;
}

.login-companion-eye-right {
  --eye-rotate: var(--eye-right-rotate);
  left: 69%;
}

.login-companion.is-blinking {
  --eye-scale-y: 0.08;
}

.login-companion[data-expression="attentive"] {
  --eye-scale-x: 1.08;
  --eye-scale-y: 1.08;
}

.login-companion[data-expression="curious"] {
  --eye-left-rotate: -7deg;
  --eye-right-rotate: -7deg;
}

.login-companion[data-expression="curious"] .login-companion-eye-left {
  --eye-scale-x: 0.82;
  --eye-scale-y: 1.08;
}

.login-companion[data-expression="curious"] .login-companion-eye-right {
  --eye-scale-x: 1.14;
  --eye-scale-y: 0.84;
}

.login-companion[data-expression="concerned"] {
  --eye-left-rotate: 16deg;
  --eye-right-rotate: -16deg;
  --eye-scale-x: 1.14;
  --eye-scale-y: 0.38;
}

.login-companion[data-expression="excited"] {
  --eye-scale-x: 1.16;
  --eye-scale-y: 1.16;
}

.login-companion[data-expression="excited"] .login-companion-eye {
  background: #b5fbff;
}

@keyframes login-companion-float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -8px, 0); }
}

.login-story {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100dvh;
  max-width: 760px;
  padding: 120px clamp(24px, 4vw, 64px) clamp(48px, 8vh, 88px);
}

.mission-code {
  margin: 0 0 14px;
  color: #91edf3;
  font-size: 11px;
  font-weight: 800;
}

.login-story h2 {
  max-width: 690px;
  margin: 0;
  color: white;
  font-size: clamp(34px, 4.3vw, 66px);
  line-height: 1.04;
  text-wrap: balance;
  text-shadow: 0 3px 30px rgb(0 0 0 / 0.5);
}

.login-story > p:last-child {
  max-width: 610px;
  margin: 20px 0 0;
  color: rgb(235 246 250 / 0.86);
  font-size: clamp(16px, 1.3vw, 19px);
  line-height: 1.65;
  text-shadow: 0 2px 16px rgb(0 0 0 / 0.56);
}

.login-content {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 104px clamp(32px, 4vw, 64px) 56px;
  background: rgb(4 13 24 / 0.82);
  border-left: 1px solid rgb(160 218 229 / 0.18);
  box-shadow: -24px 0 70px rgb(0 0 0 / 0.18);
  backdrop-filter: blur(14px);
}

.login-form-wrap {
  width: min(100%, 400px);
}

.login-heading {
  margin-bottom: 36px;
}

.login-heading .eyebrow {
  margin-bottom: 12px;
  color: #91edf3;
}

.login-heading h1 {
  margin: 0;
  color: white;
  font-size: clamp(38px, 4vw, 54px);
  line-height: 1.04;
}

.login-heading > p:last-child {
  margin: 16px 0 0;
  color: rgb(216 232 238 / 0.72);
}

.login-form {
  display: grid;
  gap: 20px;
}

.login-form .field-group label {
  color: rgb(238 248 251 / 0.9);
  font-size: 12px;
}

.login-form .field-group input {
  min-height: 50px;
  color: white;
  background: rgb(245 251 253 / 0.08);
  border-color: rgb(169 222 232 / 0.24);
}

.login-form .field-group input:hover {
  border-color: rgb(145 237 243 / 0.46);
}

.login-form .field-group input:focus {
  border-color: #91edf3;
  box-shadow: 0 0 0 3px rgb(115 227 237 / 0.18);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 54px;
}

.password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: rgb(213 235 240 / 0.7);
  background: transparent;
  border-radius: var(--radius-sm);
}

.password-toggle:hover {
  color: #91edf3;
  background: rgb(145 237 243 / 0.09);
}

.password-toggle svg {
  width: 19px;
  height: 19px;
}

.login-error {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  color: #ffd9dc;
  background: rgb(172 37 50 / 0.26);
  border: 1px solid rgb(255 147 157 / 0.38);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 650;
}

.login-error[hidden] {
  display: none;
}

.login-error svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.login-form .primary-button.login-submit {
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  color: #04141c;
  background: #7de6ee;
  box-shadow: 0 14px 36px rgb(30 180 194 / 0.18);
}

.login-form .primary-button.login-submit:hover {
  background: #a0f1f5;
}

.login-form .primary-button.login-submit:focus-visible {
  outline-color: #c9f8fa;
}

.login-submit.is-loading svg {
  animation: login-pulse 900ms ease-in-out infinite alternate;
}

.login-session-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 24px 0 0;
  color: rgb(191 216 224 / 0.58);
  font-size: 12px;
}

.login-session-note svg {
  width: 15px;
  height: 15px;
}

@keyframes login-pulse {
  to { opacity: 0.35; }
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: 100dvh;
}

.companion-panel {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 24px;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-line);
}

.portrait-stage {
  position: relative;
  width: min(100%, 272px);
  aspect-ratio: 1;
  margin: clamp(32px, 7vh, 72px) auto 24px;
  overflow: hidden;
  background: #e4e9ef;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-medium);
  transition: border-color 220ms ease-out, box-shadow 220ms ease-out;
}

.portrait-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-stage[data-emotion="surpris"] {
  border-color: #d39422;
  box-shadow: 0 12px 32px rgb(211 148 34 / 0.18);
}

.portrait-stage[data-emotion="pensif"] {
  border-color: #61759d;
}

.portrait-stage[data-emotion="triste"] {
  border-color: #7386a7;
  filter: saturate(0.82);
}

.portrait-stage[data-emotion="amuse"] {
  border-color: var(--color-accent);
  box-shadow: 0 12px 32px rgb(232 93 63 / 0.18);
}

.status-dot {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  width: 14px;
  height: 14px;
  background: var(--color-success);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgb(23 132 90 / 0.16);
}

.companion-identity {
  text-align: center;
}

.companion-identity h1 {
  margin: 0;
  font-size: clamp(28px, 4vh, 38px);
  line-height: 1.15;
}

.emotion-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--color-muted);
  font-size: 14px;
}

.online-indicator {
  display: inline-block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  background: var(--color-success);
  border-radius: 50%;
}

.dot-separator {
  width: 3px;
  height: 3px;
  background: var(--color-subtle);
  border-radius: 50%;
}

.memory-preview {
  margin-top: auto;
  padding-top: 36px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-heading h2 {
  margin: 0;
  font-size: 14px;
}

.count-badge,
.nav-count {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  place-items: center;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.memory-preview-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.memory-preview-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  color: var(--color-muted);
  font-size: 13px;
}

.memory-preview-item svg {
  width: 18px;
  height: 18px;
  color: var(--color-primary);
}

.memory-preview-item span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-preview-empty {
  margin: 12px 0 0;
  color: var(--color-muted);
  font-size: 13px;
}

.learning-preview {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-line);
}

.learning-course-label {
  margin: 10px 0 0;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.5;
}

.learning-action {
  width: 100%;
  margin-top: 12px;
}

.learning-action[hidden] {
  display: none;
}

.secondary-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  margin-top: 24px;
  color: var(--color-ink);
  background: rgb(255 255 255 / 0.72);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.secondary-link:hover {
  background: white;
  border-color: #aeb9c9;
}

.secondary-link svg {
  width: 18px;
  height: 18px;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto auto;
  height: 100dvh;
  min-width: 0;
  background: var(--color-surface);
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 18px clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--color-line);
}

.conversation-header h2 {
  margin: 0;
  font-size: 20px;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  transition: color 180ms ease-out, background-color 180ms ease-out, border-color 180ms ease-out;
}

.icon-button:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-color: #aebee6;
}

.icon-button[aria-pressed="true"] {
  color: white;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  min-height: 0;
  margin: 0 auto;
  padding: 36px clamp(20px, 5vw, 64px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  max-width: min(82%, 680px);
  animation: message-in 220ms ease-out both;
}

.message-row.user {
  grid-template-columns: minmax(0, 1fr);
  align-self: flex-end;
}

.message-avatar {
  width: 38px;
  height: 38px;
  overflow: hidden;
  background: var(--color-sidebar);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}

.message-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-content {
  min-width: 0;
}

.message-author {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 5px;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 650;
}

.message-author .emotion-chip {
  color: var(--color-primary-dark);
  font-weight: 600;
}

.message-speak-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -12px -8px -10px auto;
  padding: 0;
  color: var(--color-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}

.message-speak-button svg {
  width: 17px;
  height: 17px;
}

.message-speak-button:hover:not(:disabled),
.message-speak-button.speaking {
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.message-speak-button:disabled {
  cursor: wait;
}

.message-speak-button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 1px;
}

.message-bubble {
  margin: 0;
  padding: 13px 16px;
  color: var(--color-ink);
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-row.user .message-bubble {
  color: white;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.message-speaker-context {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin: 0 0 5px;
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 700;
}

.message-speaker-context svg {
  width: 14px;
  height: 14px;
}

.welcome-message {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  max-width: 620px;
  margin: auto;
  padding: 8px 0;
}

.welcome-message img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}

.welcome-message h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.welcome-message p {
  margin: 0;
  color: var(--color-muted);
}

.typing-indicator {
  width: 68px;
  margin: 0 auto 10px clamp(20px, 8vw, 104px);
  padding: 11px 14px;
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
}

.typing-indicator span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  background: var(--color-subtle);
  border-radius: 50%;
  animation: typing 900ms infinite ease-in-out;
}

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

.quiz-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(calc(100% - 40px), 820px);
  margin: 0 auto 10px;
}

.quiz-actions[hidden] {
  display: none;
}

.quiz-option-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 46px;
  padding: 8px 12px;
  color: var(--color-ink);
  background: var(--color-background);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: color 180ms ease-out, background-color 180ms ease-out, border-color 180ms ease-out;
}

.quiz-option-button:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.quiz-option-button span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--color-primary-dark);
  background: white;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 750;
}

.quiz-option-button b {
  font-size: 12px;
  font-weight: 650;
}

.voice-session-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: center;
  width: min(calc(100% - 40px), 820px);
  margin: 0 auto 10px;
  padding: 10px 12px;
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  transition: background-color 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out;
}

.voice-session-bar[data-state="listening"] {
  background: #f3f7ff;
  border-color: #aebee6;
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.08);
}

.voice-session-bar[data-state="speaking"] {
  background: #fff7ed;
  border-color: #fdba74;
}

.voice-session-bar[data-state="processing"] {
  border-color: var(--color-primary);
}

.voice-session-indicator {
  width: 11px;
  height: 11px;
  background: var(--color-subtle);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--color-line-strong);
}

.voice-session-bar[data-state="listening"] .voice-session-indicator {
  background: var(--color-primary);
  animation: listen-pulse 1.2s ease-in-out infinite;
}

.voice-session-bar[data-state="speaking"] .voice-session-indicator {
  background: var(--color-accent);
}

.voice-session-copy strong,
.voice-session-copy span {
  display: block;
}

.voice-session-copy strong {
  color: var(--color-ink);
  font-size: 13px;
}

.voice-session-copy span {
  margin-top: 2px;
  color: var(--color-muted);
  font-size: 12px;
}

.voice-session-actions {
  display: flex;
  gap: 8px;
}

.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  transition: color 180ms ease-out, background-color 180ms ease-out, border-color 180ms ease-out;
}

.secondary-button {
  color: var(--color-primary-dark);
  background: white;
  border: 1px solid var(--color-line-strong);
}

.secondary-button:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.secondary-button svg,
.danger-button svg {
  width: 18px;
  height: 18px;
}

.hands-free-button[aria-pressed="true"] {
  color: white;
  background: var(--color-danger);
}

.hands-free-button[aria-pressed="true"]:hover {
  background: #a3262e;
}

.voice-partial {
  grid-column: 2 / -1;
  margin: -3px 0 2px;
  color: var(--color-primary-dark);
  font-size: 13px;
  font-style: italic;
}

.voice-partial[hidden] {
  display: none;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  width: min(calc(100% - 40px), 820px);
  margin: 0 auto;
  padding: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-low);
  transition: border-color 180ms ease-out, box-shadow 180ms ease-out;
}

.composer:focus-within {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

.composer textarea {
  width: 100%;
  max-height: 132px;
  min-height: 44px;
  padding: 10px 4px;
  resize: none;
  overflow-y: auto;
  background: transparent;
  border: 0;
  outline: 0;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--color-subtle);
}

.composer .icon-button {
  width: 44px;
  height: 44px;
  border-color: transparent;
}

.microphone-button.listening {
  color: white;
  background: var(--color-accent);
  border-color: var(--color-accent);
  animation: listen-pulse 1.2s ease-in-out infinite;
}

.send-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: white;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  transition: background-color 180ms ease-out;
}

.send-button:hover {
  background: var(--color-primary-dark);
}

.send-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.composer-status {
  min-height: 42px;
  margin: 0;
  padding: 9px 20px 12px;
  color: var(--color-subtle);
  font-size: 12px;
  text-align: center;
}

.voice-match-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  background: var(--color-surface);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-medium);
}

.voice-match-dialog::backdrop {
  background: rgb(15 23 42 / 0.58);
  backdrop-filter: blur(3px);
}

.voice-match-dialog[open] {
  animation: message-in 220ms ease-out both;
}

.voice-match-panel {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.voice-match-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.voice-match-header h2 {
  margin: 3px 0 0;
  font-size: 24px;
}

.voice-match-state {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
}

.voice-match-state-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-radius: var(--radius-sm);
}

.voice-match-state-icon svg {
  width: 22px;
  height: 22px;
}

.voice-match-state strong,
.voice-match-state p {
  display: block;
  margin: 0;
}

.voice-match-state p {
  margin-top: 3px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.5;
}

.voice-match-enrollment {
  padding: 18px;
  background: #f3f7ff;
  border: 1px solid #aebee6;
  border-radius: var(--radius-md);
}

.voice-match-enrollment[hidden] {
  display: none;
}

.voice-match-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.voice-match-progress span {
  height: 5px;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background-color 180ms ease-out;
}

.voice-match-progress span.complete,
.voice-match-progress span.active {
  background: var(--color-primary);
}

.voice-match-instruction {
  margin: 16px 0 5px;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
}

.voice-match-enrollment blockquote {
  margin: 0;
  color: var(--color-ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
}

.voice-match-live-text {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--color-primary-dark);
  font-size: 12px;
}

.consent-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--color-ink);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}

.consent-row input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--color-primary);
}

.voice-match-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 60px;
}

.voice-match-toggle-row strong,
.voice-match-toggle-row small {
  display: block;
}

.voice-match-toggle-row small {
  max-width: 440px;
  margin-top: 4px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.45;
}

.switch-control input:disabled + span {
  cursor: not-allowed;
  opacity: 0.48;
}

.voice-match-warning {
  margin: 0;
  padding: 12px 14px;
  color: #7c2d12;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.55;
}

.voice-match-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.voice-match-actions [hidden] {
  display: none;
}

.danger-button {
  color: var(--color-danger);
  background: white;
  border: 1px solid #e7b8bb;
}

.danger-button:hover {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  color: white;
  background: var(--color-ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-medium);
  animation: toast-in 220ms ease-out both;
}

.toast.error {
  background: var(--color-danger);
}

.toast svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

/* Administration */
.admin-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100dvh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 24px 18px;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-line);
}

.admin-sidebar .brand-lockup {
  padding: 0 6px;
}

.admin-robot-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 28px 6px 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-line-strong);
}

.admin-robot-summary img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
}

.admin-robot-summary div {
  min-width: 0;
}

.admin-robot-summary strong,
.admin-robot-summary span {
  display: block;
}

.admin-robot-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
  white-space: nowrap;
}

.admin-robot-summary span {
  margin-top: 3px;
  color: var(--color-muted);
  font-size: 11px;
}

.admin-robot-summary .online-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 4px 0 0;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  transition: color 180ms ease-out, background-color 180ms ease-out;
}

.nav-item:hover {
  color: var(--color-ink);
  background: rgb(255 255 255 / 0.6);
}

.nav-item.active {
  color: var(--color-primary-dark);
  background: white;
  border-color: var(--color-line);
  box-shadow: var(--shadow-low);
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.nav-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
}

.admin-chat-link {
  margin-top: auto;
}

.admin-main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 72px) 72px;
}

.admin-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 104px;
  padding: 20px 0;
  background: rgb(245 247 250 / 0.96);
  border-bottom: 1px solid var(--color-line);
}

.admin-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.2;
}

.save-state {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  color: var(--color-success);
  background: var(--color-success-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 650;
}

.save-state.saving {
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.save-state.error {
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

.save-state svg {
  width: 17px;
  height: 17px;
}

.admin-section {
  padding-top: 40px;
}

.admin-section[hidden] {
  display: none;
}

.section-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.section-intro h2,
.danger-zone h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.section-intro p,
.danger-zone p {
  max-width: 650px;
  margin: 0;
  color: var(--color-muted);
  font-size: 14px;
}

.settings-form {
  display: grid;
  gap: 22px;
  padding: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-low);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.field-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-group label {
  color: var(--color-ink);
  font-size: 13px;
  font-weight: 700;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  outline: 0;
  transition: border-color 180ms ease-out, box-shadow 180ms ease-out;
}

.field-group textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

.field-group input[readonly] {
  color: var(--color-muted);
  background: var(--color-background);
}

.field-hint {
  color: var(--color-subtle);
  font-size: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.primary-button,
.danger-ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  transition: color 180ms ease-out, background-color 180ms ease-out, border-color 180ms ease-out;
}

.primary-button {
  color: white;
  background: var(--color-primary);
}

.primary-button:hover {
  background: var(--color-primary-dark);
}

.primary-button svg,
.danger-ghost-button svg {
  width: 18px;
  height: 18px;
}

.danger-ghost-button {
  color: var(--color-danger);
  background: white;
  border: 1px solid #e7b8bb;
}

.danger-ghost-button:hover {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
}

.section-divider {
  height: 1px;
  margin: 40px 0;
  background: var(--color-line);
}

.adaptive-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 62px;
  padding: 4px 0;
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 14px;
}

.toggle-row small {
  margin-top: 3px;
  color: var(--color-muted);
  font-size: 12px;
}

.switch-control {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-control span {
  position: absolute;
  inset: 0;
  background: #aab4c3;
  border-radius: 999px;
  transition: background-color 180ms ease-out;
}

.switch-control span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  content: "";
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(23 32 51 / 0.3);
  transition: transform 180ms ease-out;
}

.switch-control input:checked + span {
  background: var(--color-primary);
}

.switch-control input:checked + span::after {
  transform: translateX(20px);
}

.switch-control input:focus-visible + span {
  box-shadow: var(--focus-ring);
}

.emotion-strip {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-top: 4px;
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 700;
}

.emotion-strip > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.emotion-tag,
.category-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--color-muted);
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 650;
}

.inline-memory-form {
  display: grid;
  grid-template-columns: 150px minmax(150px, 0.7fr) minmax(240px, 1.3fr) 46px;
  gap: 12px;
  align-items: end;
  margin-bottom: 24px;
  padding: 20px;
  background: white;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
}

.add-memory-button {
  color: white;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.add-memory-button:hover {
  color: white;
  background: var(--color-primary-dark);
}

.memory-table-wrap {
  overflow: hidden;
  background: white;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-low);
}

.memory-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.memory-table th,
.memory-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-line);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.memory-table th {
  color: var(--color-muted);
  background: var(--color-background);
  font-size: 12px;
  font-weight: 750;
}

.memory-table td {
  font-size: 13px;
}

.memory-table th:nth-child(1) { width: 130px; }
.memory-table th:nth-child(2) { width: 170px; }
.memory-table th:nth-child(4) { width: 100px; }
.memory-table th:nth-child(5) { width: 64px; }

.memory-table tr:last-child td {
  border-bottom: 0;
}

.memory-delete-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--color-muted);
  background: transparent;
  border-radius: var(--radius-sm);
}

.memory-delete-button:hover {
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

.memory-delete-button svg {
  width: 17px;
  height: 17px;
}

.confidence-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.confidence-meter span:first-child {
  width: 36px;
  height: 5px;
  overflow: hidden;
  background: var(--color-line);
  border-radius: 999px;
}

.confidence-meter i {
  display: block;
  height: 100%;
  background: var(--color-success);
}

.empty-table {
  display: grid;
  justify-items: center;
  padding: 56px 20px;
  color: var(--color-muted);
  text-align: center;
}

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

.empty-table svg {
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  color: var(--color-primary);
}

.empty-table strong {
  color: var(--color-ink);
}

.empty-table span {
  margin-top: 4px;
  font-size: 13px;
}

.status-list {
  background: white;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-low);
}

.status-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 78px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-line);
}

.status-row:last-child {
  border-bottom: 0;
}

.status-icon {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-radius: var(--radius-sm);
}

.status-icon.success {
  color: var(--color-success);
  background: var(--color-success-soft);
}

.status-icon.pending {
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.status-icon svg {
  width: 20px;
  height: 20px;
}

.status-row strong,
.status-row div > span {
  display: block;
}

.status-row strong {
  font-size: 14px;
}

.status-row div > span {
  margin-top: 2px;
  color: var(--color-muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill.success {
  color: var(--color-success);
  background: var(--color-success-soft);
}

.status-pill.pending {
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.field-group textarea[readonly] {
  color: var(--color-muted);
  background: var(--color-background);
}

.optional-label {
  color: var(--color-subtle);
  font-size: 11px;
  font-weight: 600;
}

.catalog-notice {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 24px;
  padding: 16px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border: 1px solid #c7d3ed;
  border-radius: var(--radius-md);
}

.catalog-notice > svg {
  width: 22px;
  height: 22px;
  margin: 1px auto 0;
}

.catalog-notice strong,
.catalog-notice span {
  display: block;
}

.catalog-notice strong {
  font-size: 13px;
}

.catalog-notice span {
  margin-top: 3px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.55;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 20px;
  align-items: start;
}

.species-card {
  gap: 18px;
}

.species-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-line);
}

.species-card-heading h3,
.species-card-heading span {
  margin: 0;
}

.species-card-heading h3 {
  font-size: 17px;
}

.species-card-heading span {
  display: block;
  margin-top: 4px;
  color: var(--color-subtle);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.species-card-heading > svg {
  width: 22px;
  height: 22px;
  color: var(--color-primary);
}

.voice-settings-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
  margin: 0;
  padding: 18px;
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}

.voice-settings-panel legend {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 0 6px;
  color: var(--color-ink);
  font-size: 13px;
  font-weight: 750;
}

.voice-settings-panel legend svg,
.voice-provider-status svg,
.voice-preview-button svg {
  width: 18px;
  height: 18px;
}

.voice-settings-panel legend svg,
.voice-provider-status.ready {
  color: var(--color-primary);
}

.voice-provider-status {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 650;
}

.voice-toggle-row {
  min-height: 56px;
  margin: 0;
  padding: 0;
}

.voice-range-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.voice-range-field {
  min-width: 0;
}

.voice-range-field label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 650;
}

.voice-range-field output {
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.voice-range-field input[type="range"] {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.voice-preview-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--color-primary-dark);
  background: white;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.voice-preview-button:hover:not(:disabled) {
  color: var(--color-primary);
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.voice-preview-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.voice-preview-button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.academy-knowledge-notice {
  margin-bottom: 20px;
}

.academy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 20px;
}

.academy-card {
  display: grid;
  gap: 20px;
  align-content: start;
  padding: 22px;
  background: white;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-low);
}

.academy-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.academy-card h3 {
  margin: 0;
  font-size: 16px;
}

.academy-card p {
  margin: 5px 0 0;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.55;
}

.course-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.course-list li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--color-muted);
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.course-list li.acquired {
  color: var(--color-ink);
  background: var(--color-primary-soft);
}

.course-list svg {
  width: 17px;
  height: 17px;
}

.course-list li.acquired svg {
  color: var(--color-success);
}

.course-list b {
  color: var(--color-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.academy-action {
  width: 100%;
}

.academy-action.unlocked {
  color: var(--color-success);
  background: var(--color-success-soft);
}

.academy-action:disabled,
.robot-index-button:disabled {
  cursor: default;
}

.knowledge-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding-top: 18px;
  border-top: 1px solid var(--color-line);
}

.knowledge-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.document-drop-zone {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 82px;
  padding: 14px;
  color: var(--color-muted);
  background: var(--color-background);
  border: 1px dashed var(--color-line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 180ms ease-out, background-color 180ms ease-out, border-color 180ms ease-out;
}

.document-drop-zone:hover,
.document-drop-zone:focus-visible,
.document-drop-zone.dragging {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.document-drop-zone:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.document-drop-zone > svg {
  width: 24px;
  height: 24px;
  margin: auto;
}

.document-drop-zone strong,
.document-drop-zone span {
  display: block;
}

.document-drop-zone strong {
  color: currentcolor;
  font-size: 12px;
}

.document-drop-zone span {
  margin-top: 3px;
  font-size: 11px;
}

.knowledge-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.knowledge-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--color-primary-dark);
  background: white;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.knowledge-button:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.knowledge-button:focus-within {
  box-shadow: var(--focus-ring);
}

.upload-status {
  min-height: 16px;
  color: var(--color-muted);
  font-size: 11px;
}

.academy-documents {
  min-width: 0;
  max-height: 280px;
  overflow: auto;
}

.document-tree {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.document-folder > div,
.document-file {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-height: 34px;
  padding: 7px 8px;
  background: var(--color-background);
  border-radius: 8px;
}

.document-folder > div > svg,
.document-file > svg {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--color-primary);
}

.document-folder > .document-tree {
  margin: 6px 0 0 15px;
  padding-left: 10px;
  border-left: 1px solid var(--color-line);
}

.document-folder strong,
.document-file strong,
.document-file span {
  display: block;
  min-width: 0;
}

.document-folder strong,
.document-file strong {
  font-size: 11px;
  overflow-wrap: anywhere;
}

.document-file span {
  margin-top: 3px;
  color: var(--color-subtle);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.document-empty {
  margin: 0;
  padding: 10px 0 0;
  color: var(--color-subtle);
  font-size: 11px;
}

.client-index {
  display: grid;
  gap: 12px;
}

.client-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 1.45fr);
  gap: 20px;
  align-items: start;
  padding: 18px;
  background: white;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-low);
}

.client-card > div:first-child strong,
.client-card > div:first-child span {
  display: block;
}

.client-card > div:first-child strong {
  font-size: 14px;
}

.client-card > div:first-child span {
  margin-top: 4px;
  color: var(--color-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.client-robots {
  display: grid;
  gap: 8px;
}

.robot-index-button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 8px 12px;
  color: var(--color-muted);
  background: var(--color-background);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: color 180ms ease-out, border-color 180ms ease-out, background-color 180ms ease-out;
}

.robot-index-button:hover:not(:disabled),
.robot-index-button.active {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.robot-index-button svg {
  width: 17px;
  height: 17px;
}

.robot-index-button span {
  font-size: 13px;
  font-weight: 700;
}

.robot-index-button small {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.diagnostic-output {
  max-height: 420px;
  margin: 0;
  padding: 20px;
  overflow: auto;
  color: #dbe7f5;
  background: #172033;
  border: 1px solid #2b3852;
  border-radius: var(--radius-md);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes listen-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgb(232 93 63 / 0.25); }
  50% { box-shadow: 0 0 0 7px rgb(232 93 63 / 0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-height: 800px) and (min-width: 861px) {
  .portrait-stage {
    width: min(100%, 210px);
    margin: 18px auto 14px;
  }

  .companion-identity h1 {
    font-size: 28px;
  }

  .memory-preview {
    padding-top: 20px;
  }

  .learning-preview {
    margin-top: 16px;
    padding-top: 16px;
  }
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 42dvh) minmax(0, auto);
    overflow: visible;
  }

  .login-scene {
    height: 46dvh;
    min-height: 330px;
    object-position: 38% center;
  }

  .login-atmosphere {
    height: 46dvh;
    min-height: 330px;
    background: linear-gradient(0deg, rgb(4 13 24 / 0.94) 0%, rgb(3 10 19 / 0.12) 58%);
  }

  .login-header {
    min-height: 72px;
    padding: 12px 24px;
  }

  .origin-signal {
    margin-right: 0;
  }

  .login-companion {
    top: 82px;
    right: 18px;
    width: 146px;
  }

  .login-story {
    grid-row: 1;
    min-height: 0;
    padding: 96px 24px 32px;
  }

  .login-story h2 {
    font-size: clamp(30px, 7vw, 46px);
  }

  .login-story > p:last-child {
    max-width: 560px;
    margin-top: 12px;
    font-size: 15px;
  }

  .login-content {
    grid-row: 2;
    min-height: 58dvh;
    place-items: start center;
    padding: 46px 24px 52px;
    background: #07131f;
    border-top: 1px solid rgb(160 218 229 / 0.18);
    border-left: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .companion-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    min-height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--color-line);
  }

  .companion-panel .brand-lockup,
  .memory-preview,
  .learning-preview {
    display: none;
  }

  .portrait-stage {
    width: 52px;
    height: 52px;
    margin: 0;
    box-shadow: none;
  }

  .portrait-stage .status-dot {
    top: 3px;
    right: 3px;
    width: 11px;
    height: 11px;
    border-width: 2px;
  }

  .companion-identity {
    text-align: left;
  }

  .companion-identity .eyebrow {
    display: none;
  }

  .companion-identity h1 {
    font-size: 18px;
  }

  .emotion-line {
    justify-content: flex-start;
    margin-top: 3px;
    font-size: 12px;
  }

  .secondary-link {
    width: 46px;
    height: 46px;
    min-height: 46px;
    margin: 0;
    padding: 0;
    font-size: 0;
  }

  .conversation-panel {
    height: calc(100dvh - 77px);
  }

  .conversation-header {
    min-height: 72px;
    padding: 12px 16px;
  }

  .messages {
    padding: 24px 16px;
  }

  .message-row {
    max-width: 92%;
  }

  .voice-session-bar,
  .composer {
    width: calc(100% - 24px);
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--color-line);
  }

  .admin-sidebar .brand-lockup {
    display: none;
  }

  .admin-robot-summary {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .admin-robot-summary img {
    width: 44px;
    height: 44px;
  }

  .admin-robot-summary div {
    display: none;
  }

  .admin-nav {
    display: flex;
    min-width: 0;
    gap: 4px;
    overflow-x: auto;
  }

  .nav-item {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 10px;
  }

  .nav-item svg {
    width: 18px;
  }

  .admin-chat-link {
    width: 44px;
    height: 44px;
  }

  .admin-main {
    padding: 0 20px 56px;
  }

  .admin-header {
    min-height: 86px;
  }

  .inline-memory-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-memory-form .wide-field {
    grid-column: 1 / -1;
  }

  .inline-memory-form .add-memory-button {
    grid-column: 2;
    justify-self: end;
  }

  .memory-table-wrap {
    overflow-x: auto;
  }

  .memory-table {
    min-width: 720px;
  }
}

@media (max-width: 560px) {
  .login-shell {
    grid-template-rows: minmax(320px, 46dvh) auto;
  }

  .login-scene,
  .login-atmosphere {
    height: 50dvh;
    min-height: 360px;
  }

  .login-header {
    padding-inline: 16px;
  }

  .origin-signal {
    font-size: 10px;
  }

  .login-companion {
    top: 84px;
    right: 8px;
    width: 124px;
  }

  .login-story {
    padding: 94px 16px 28px;
  }

  .login-story h2 {
    font-size: 30px;
  }

  .login-story > p:last-child {
    display: none;
  }

  .login-content {
    min-height: 54dvh;
    padding: 36px 20px 44px;
  }

  .login-heading {
    margin-bottom: 26px;
  }

  .login-heading h1 {
    font-size: 38px;
  }

  .conversation-header h2 {
    font-size: 18px;
  }

  .message-row {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 9px;
    max-width: 96%;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
  }

  .welcome-message {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .welcome-message img {
    width: 44px;
    height: 44px;
  }

  .composer {
    gap: 4px;
    padding: 6px;
  }

  .voice-session-bar {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 10px;
  }

  .voice-session-actions,
  .voice-partial {
    grid-column: 1 / -1;
  }

  .voice-session-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .voice-session-actions button {
    padding-inline: 10px;
  }

  .voice-match-panel {
    gap: 16px;
    padding: 18px;
  }

  .voice-match-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .voice-match-actions button {
    width: 100%;
  }

  .quiz-actions {
    grid-template-columns: 1fr;
  }

  .composer .icon-button,
  .send-button {
    width: 44px;
  }

  .admin-main {
    padding-inline: 16px;
  }

  .admin-header {
    align-items: flex-start;
  }

  .admin-header h1 {
    font-size: 22px;
  }

  .save-state {
    width: 38px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .section-intro,
  .danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .inline-memory-form {
    grid-template-columns: 1fr;
  }

  .inline-memory-form .wide-field,
  .inline-memory-form .add-memory-button {
    grid-column: 1;
  }

  .settings-form {
    padding: 18px;
  }

  .voice-settings-panel {
    padding: 16px;
  }

  .voice-range-grid {
    grid-template-columns: 1fr;
  }

  .client-card {
    grid-template-columns: 1fr;
  }

  .robot-index-button {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .robot-index-button small {
    grid-column: 2;
  }

  .form-actions .primary-button,
  .danger-zone .danger-ghost-button,
  .section-intro .danger-ghost-button {
    width: 100%;
  }

  .emotion-strip {
    flex-direction: column;
  }

  .status-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .status-row .status-pill {
    grid-column: 2;
    justify-self: start;
  }
}

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

  .login-companion-float {
    animation: none !important;
  }
}
