:root {
  color-scheme: light;
  --purple: #68415f;
  --purple-2: #806479;
  --purple-soft: #f0e9ee;
  --purple-pale: #faf7f9;
  --ink: #283236;
  --muted: #667178;
  --faint: #8f999d;
  --line: rgba(55, 77, 83, 0.13);
  --line-soft: rgba(255, 255, 255, 0.82);
  --surface: rgba(255, 255, 255, 0.74);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --mint: #dcece8;
  --mint-ink: #467267;
  --peach: #f3e9df;
  --lab-blue: #dcecf0;
  --lab-blue-ink: #3f6c78;
  --shadow: 0 24px 70px rgba(42, 61, 66, 0.1);
  --shadow-soft: 0 12px 34px rgba(42, 61, 66, 0.065);
  --radius-xl: 36px;
  --radius-lg: 28px;
  --radius-md: 20px;
  --font-sans: Inter, ui-rounded, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  background: #eef2f1;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 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;
}

.overline {
  margin-bottom: 5px;
  color: var(--purple-2);
  font-size: 0.7rem;
  font-weight: 790;
  letter-spacing: 0.18em;
}

.ambient {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(4px);
}

.ambient-one {
  top: -28vh;
  right: -13vw;
  width: 58vw;
  height: 58vw;
  background: radial-gradient(circle, rgba(151, 195, 204, 0.3), rgba(225, 239, 240, 0.08) 62%, transparent 72%);
}

.ambient-two {
  bottom: -46vh;
  left: -17vw;
  width: 56vw;
  height: 56vw;
  background: radial-gradient(circle, rgba(229, 218, 207, 0.58), rgba(239, 234, 232, 0.05) 62%, transparent 73%);
}

body[data-page="visitor"]::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 11.8%, rgba(75, 101, 108, 0.035) 11.9% 12%, transparent 12.1% 87.8%, rgba(75, 101, 108, 0.035) 87.9% 88%, transparent 88.1%),
    linear-gradient(rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
}

.presentation-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-height: 660px;
  overflow: hidden;
  padding: clamp(15px, 1.8vw, 32px);
  padding-top: clamp(12px, 1.35vw, 22px);
}

.visitor-topbar,
.studio-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.visitor-topbar {
  min-height: 62px;
  padding: 0 6px clamp(10px, 1.3vh, 17px);
}

.visitor-brand,
.studio-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 15px;
}

.visitor-brand {
  gap: 13px;
}

.visitor-brand h1,
.studio-brand h1 {
  margin-bottom: 3px;
  font-size: clamp(1.34rem, 1.7vw, 2rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.visitor-brand h1 {
  margin-bottom: 2px;
  font-size: clamp(1.15rem, 1.45vw, 1.68rem);
}

.visitor-brand .overline {
  margin-bottom: 4px;
  font-size: 0.62rem;
}

.visitor-brand > div > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(0.74rem, 0.9vw, 1rem);
}

.visitor-brand > div > p[hidden] {
  display: none !important;
}

.brand-emblem {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border: 1px solid rgba(113, 26, 95, 0.16);
  border-radius: 17px;
  background: linear-gradient(145deg, #8d4a7f, #6e285f);
  box-shadow: 0 12px 28px rgba(113, 26, 95, 0.18), inset 0 1px rgba(255, 255, 255, 0.34);
}

.visitor-brand .brand-logo {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-emblem.large {
  width: 66px;
  height: 66px;
  border-radius: 23px;
}

.brand-emblem i {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
}

.brand-emblem i:nth-child(1) {
  transform: translate(-8px, -5px);
}

.brand-emblem i:nth-child(2) {
  transform: translate(8px, -5px);
}

.brand-emblem i:nth-child(3) {
  transform: translate(0, 9px);
}

.brand-emblem::before,
.brand-emblem::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 1px;
  background: rgba(255, 255, 255, 0.72);
}

.brand-emblem::before {
  transform: rotate(28deg);
}

.brand-emblem::after {
  transform: rotate(-28deg);
}

.visitor-actions,
.studio-actions,
.speech-controls,
.heading-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.visitor-actions {
  gap: 7px;
}

.mode-pill,
.character-state,
.save-indicator,
.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: #5f4e60;
  background: rgba(255, 255, 255, 0.67);
  box-shadow: var(--shadow-soft), inset 0 1px rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  font-size: 0.79rem;
  font-weight: 710;
}

.mode-pill i,
.character-state i,
.save-indicator i,
.chat-footer i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #7eb29f;
  box-shadow: 0 0 0 4px rgba(126, 178, 159, 0.12);
}

.mode-pill {
  color: #4d6870;
  background: rgba(247, 251, 250, 0.78);
}

.visitor-actions .mode-pill {
  min-height: 33px;
  padding-inline: 12px;
  font-size: 0.72rem;
}

.round-button,
.soft-button,
.primary-action,
.send-button,
.nav-item,
.profile-option,
.toggle {
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.round-button:active,
.soft-button:active,
.primary-action:active,
.send-button:active,
.nav-item:active,
.profile-option:active {
  transform: translateY(1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(113, 26, 95, 0.17);
  outline-offset: 2px;
}

.round-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-color: rgba(113, 26, 95, 0.1);
  border-radius: 15px;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.92), 0 8px 20px rgba(75, 46, 72, 0.06);
  font-size: 1.1rem;
}

.visitor-actions .round-button {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  font-size: 0.96rem;
}

.settings-button {
  color: #5d4859;
}

.visitor-grid {
  display: grid;
  grid-template-columns: minmax(390px, 1fr) minmax(520px, 1fr);
  min-height: 0;
  gap: clamp(16px, 1.75vw, 30px);
}

.character-panel,
.chat-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(24px);
}

.character-panel {
  position: relative;
  display: grid;
  align-self: center;
  grid-template-rows: auto minmax(0, 1fr);
  height: clamp(680px, 88vh, 1080px);
  max-height: 100%;
  gap: 8px;
  padding: 10px;
  border-color: rgba(199, 211, 212, 0.9);
  border-radius: clamp(31px, 3vw, 44px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(209, 221, 222, 0.94) 46%, rgba(244, 248, 247, 0.96) 74%),
    #dde6e5;
  box-shadow:
    0 26px 60px rgba(45, 65, 69, 0.13),
    inset 0 1px rgba(255, 255, 255, 0.98),
    inset 0 -1px rgba(74, 95, 99, 0.12);
  backdrop-filter: none;
}

.character-panel::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 4px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(77, 102, 107, 0.05);
}

.lab-window-console {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 0 22px;
  border: 1px solid rgba(91, 118, 123, 0.1);
  border-radius: 18px 18px 11px 11px;
  color: #60777c;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(228, 236, 235, 0.68));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.95), 0 3px 8px rgba(54, 76, 80, 0.05);
}

.lab-window-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  white-space: nowrap;
}

.lab-window-code i {
  width: 14px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6b4263, #9ab8b8);
  box-shadow: 0 0 0 3px rgba(106, 67, 98, 0.06);
}

.lab-window-bolt {
  position: absolute;
  z-index: 8;
  width: 8px;
  height: 8px;
  pointer-events: none;
  border: 1px solid rgba(70, 91, 95, 0.2);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #ffffff 0 18%, #aebdbd 20% 46%, #6d8285 48% 58%, #dce5e4 61% 100%);
  box-shadow: 0 1px 2px rgba(42, 59, 62, 0.22);
}

.bolt-top-left,
.bolt-top-right {
  top: 24px;
}

.bolt-bottom-left,
.bolt-bottom-right {
  bottom: 19px;
}

.bolt-top-left,
.bolt-bottom-left {
  left: 14px;
}

.bolt-top-right,
.bolt-bottom-right {
  right: 14px;
}

.character-stage {
  position: relative;
  z-index: 2;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(96, 121, 125, 0.24);
  border-radius: clamp(24px, 2.3vw, 34px);
  background:
    linear-gradient(180deg, rgba(246, 251, 250, 0.08), rgba(209, 224, 221, 0.07)),
    url("./assets/lab-stage-bg-v1.png") center / cover no-repeat,
    #dce7e5;
  box-shadow:
    inset 0 0 0 7px rgba(235, 241, 240, 0.42),
    inset 0 18px 28px rgba(41, 58, 62, 0.16),
    inset 0 -10px 20px rgba(255, 255, 255, 0.18),
    0 5px 11px rgba(46, 64, 68, 0.11);
}

.character-panel.has-stage-composite .character-stage {
  background: linear-gradient(180deg, #aebbc7 0%, #c4cdd3 64%, #d8d8d4 100%);
}

.character-stage::before {
  content: "";
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.2) 0 9%, rgba(255, 255, 255, 0.035) 18% 62%, transparent 71%),
    linear-gradient(180deg, rgba(26, 49, 54, 0.08), transparent 7% 90%, rgba(255, 255, 255, 0.12));
  box-shadow: inset 0 0 0 6px rgba(245, 249, 248, 0.14);
}

.character-stage::after {
  content: "";
  position: absolute;
  z-index: 5;
  top: 8%;
  right: -7%;
  width: 24%;
  height: 82%;
  pointer-events: none;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.13), transparent);
  filter: blur(1px);
  transform: rotate(7deg);
}

.stage-orbit {
  position: absolute;
  left: 50%;
  top: 48%;
  border: 1px solid rgba(64, 111, 122, 0.14);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-14deg);
}

.character-panel:not(.has-stage-composite) .stage-orbit,
.character-panel:not(.has-stage-composite) .stage-dot {
  opacity: 0;
}

.orbit-a {
  width: 74%;
  aspect-ratio: 1.65;
}

.orbit-b {
  width: 58%;
  aspect-ratio: 0.92;
  transform: translate(-50%, -50%) rotate(24deg);
}

.stage-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(82, 125, 136, 0.62);
  box-shadow: 0 0 0 8px rgba(82, 125, 136, 0.06);
}

.dot-a {
  top: 24%;
  right: 14%;
}

.dot-b {
  bottom: 22%;
  left: 13%;
  background: rgba(91, 150, 128, 0.55);
  box-shadow: 0 0 0 8px rgba(91, 150, 128, 0.06);
}

.dot-c {
  top: 15%;
  left: 22%;
  width: 6px;
  height: 6px;
  background: rgba(218, 160, 110, 0.62);
}

.character-art {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(78%, 560px);
  height: 92%;
  transform: translateX(-50%);
}

.character-art {
  z-index: 3;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 20px 30px rgba(42, 68, 75, 0.12));
}

.live2d-mount,
.animated-character-mount {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
}

.live2d-mount canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.animated-character-mount {
  isolation: isolate;
}

.animated-character-media {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(68%, 480px);
  height: 84%;
  object-fit: contain;
  object-position: center bottom;
  opacity: 0;
  transform: translateX(-50%);
  transform-origin: center 82%;
  filter: drop-shadow(0 20px 30px rgba(42, 68, 75, 0.12));
}

.animated-character-media.is-visible {
  opacity: 1;
}

.animated-character-media.is-stage-composite {
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
  object-fit: contain;
  object-position: center bottom;
  background: linear-gradient(180deg, #aebbc7 0%, #c4cdd3 64%, #d8d8d4 100%);
  filter: saturate(0.92) contrast(0.98);
}

.animated-character-media[data-motion="breathe"]:not(.is-stage-composite) {
  animation: pet-breathe 5.8s ease-in-out infinite;
}

.animated-character-media[data-motion="fumble"]:not(.is-stage-composite) {
  animation: pet-hand-fumble 8.8s ease-in-out infinite;
}

.animated-character-media[data-motion="listen"]:not(.is-stage-composite) {
  animation: pet-listen 3.2s ease-in-out infinite;
}

.animated-character-media[data-motion="search"]:not(.is-stage-composite) {
  animation: pet-search 2.8s ease-in-out infinite;
}

.animated-character-media[data-motion="explain"]:not(.is-stage-composite) {
  animation: pet-explain 3.6s ease-in-out infinite;
}

.animated-character-media[data-motion="float"]:not(.is-stage-composite) {
  animation: gentle-float 3.6s ease-in-out infinite;
}

.animated-character-media.is-stage-composite[data-motion="fumble"] {
  animation: pet-stage-fumble 8.8s ease-in-out infinite;
}

.animated-character-media.is-stage-composite:not([data-motion="still"]):not([data-motion="fumble"]) {
  animation: pet-stage-breathe 5.8s ease-in-out infinite;
}

@keyframes pet-breathe {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50% { transform: translateX(-50%) translateY(-0.7%) scale(1.008); }
}

@keyframes pet-hand-fumble {
  0%, 22%, 48%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg); }
  25% { transform: translateX(-50%) translateY(0.7%) rotate(0.8deg); }
  28% { transform: translateX(-50%) translateY(-1.5%) rotate(-0.9deg); }
  31% { transform: translateX(-50%) translateY(-0.3%) rotate(0.55deg); }
  35% { transform: translateX(-50%) translateY(-1%) rotate(-0.35deg); }
  41% { transform: translateX(-50%) translateY(0) rotate(0.15deg); }
}

@keyframes pet-listen {
  0%, 100% { transform: translateX(-50%) rotate(0deg) translateY(0); }
  50% { transform: translateX(-50%) rotate(-0.7deg) translateY(-0.5%); }
}

@keyframes pet-search {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  38% { transform: translateX(-50%) rotate(0.8deg) translateY(-0.4%); }
  72% { transform: translateX(-50%) rotate(-0.45deg); }
}

@keyframes pet-explain {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg); }
  40% { transform: translateX(-50%) translateY(-0.7%) rotate(0.35deg); }
  68% { transform: translateX(-50%) translateY(-0.25%) rotate(-0.25deg); }
}

@keyframes pet-stage-breathe {
  0%, 100% { filter: saturate(0.92) contrast(0.98) brightness(1); }
  50% { filter: saturate(0.96) contrast(0.99) brightness(1.015); }
}

@keyframes pet-stage-fumble {
  0%, 22%, 48%, 100% { filter: saturate(0.92) contrast(0.98) brightness(1); }
  27% { filter: saturate(0.98) contrast(1) brightness(1.035); }
  32% { filter: saturate(0.9) contrast(0.98) brightness(0.99); }
  38% { filter: saturate(0.96) contrast(0.99) brightness(1.02); }
}

.character-art.character-card-art {
  bottom: 6%;
  width: min(74%, 510px);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: clamp(28px, 3.2vw, 46px);
  object-fit: cover;
  object-position: center;
  box-shadow:
    0 24px 55px rgba(38, 76, 86, 0.16),
    0 0 0 9px rgba(255, 255, 255, 0.18),
    inset 0 1px rgba(255, 255, 255, 0.8);
  filter: saturate(0.84) contrast(0.97);
}

.character-art.character-full-stage-art {
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
  object-fit: cover;
  object-position: center 36%;
  filter: saturate(0.92) contrast(0.98);
}

.character-panel.has-stage-composite .stage-orbit,
.character-panel.has-stage-composite .stage-dot {
  display: none;
}

/* The real first frame remains visible until the video is actually playing. */
.portrait-placeholder {
  z-index: 2; inset: 0; width: 100%; height: 100%; transform: none;
  object-fit: contain; object-position: center bottom;
  background: #bcc7ce;
}

.voice-wave {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 6%;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(10px);
}

.voice-wave i {
  width: 3px;
  height: 8px;
  border-radius: 999px;
  background: var(--purple-2);
}

.character-panel[data-state="thinking"] .stage-orbit {
  animation: orbit-breathe 2.2s ease-in-out infinite;
}

.character-panel[data-state="thinking"] .character-art,
.character-panel[data-state="thinking"] .live2d-mount {
  animation: gentle-float 2.4s ease-in-out infinite;
}

.character-panel.has-stage-composite[data-state="thinking"] .character-full-stage-art {
  animation: stage-breathe 2.4s ease-in-out infinite;
}

.character-panel[data-state="speaking"] .voice-wave {
  opacity: 1;
  transform: translate(-50%, 0);
}

.character-panel[data-state="speaking"] .voice-wave i {
  animation: voice-bar 720ms ease-in-out infinite alternate;
}

.character-panel[data-state="speaking"] .voice-wave i:nth-child(2),
.character-panel[data-state="speaking"] .voice-wave i:nth-child(4) {
  animation-delay: -280ms;
}

.character-panel[data-state="speaking"] .voice-wave i:nth-child(3) {
  animation-delay: -480ms;
}

.ai-disclaimer {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #77878a;
  font-size: clamp(0.56rem, 0.64vw, 0.66rem);
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
}

.ai-disclaimer i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7eb29f;
  box-shadow: 0 0 0 4px rgba(126, 178, 159, 0.11);
}

.character-state {
  flex: 0 0 auto;
  min-height: 26px;
  padding-inline: 9px;
  border-color: rgba(82, 113, 116, 0.08);
  background: rgba(250, 253, 252, 0.7);
  box-shadow: none;
  font-size: 0.61rem;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: clamp(15px, 1.45vw, 24px);
  padding-bottom: clamp(18px, 1.65vw, 28px);
  background: rgba(253, 253, 251, 0.86);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  padding: 2px 1px 11px;
  border-bottom: 1px solid var(--line);
}

.chat-title {
  display: grid;
  align-content: center;
  align-self: center;
}

.chat-header h2 {
  margin-bottom: 0;
  font-size: clamp(0.98rem, 1.16vw, 1.28rem);
  line-height: 1.22;
  letter-spacing: -0.03em;
}

.chat-header .overline {
  margin-bottom: 4px;
  color: #59757c;
  font-size: 0.55rem;
}

.chat-tools {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.chat-tool-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.chat-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(62, 91, 98, 0.1);
  border-radius: 10px;
  color: #637176;
  background: rgba(255, 255, 255, 0.68);
  cursor: pointer;
  font-size: 0.59rem;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.chat-tool:hover {
  border-color: rgba(70, 103, 111, 0.2);
  background: white;
}

.soft-button {
  min-height: 36px;
  padding: 0 13px;
  border-color: rgba(95, 70, 95, 0.11);
  border-radius: 13px;
  color: #69596a;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 7px 18px rgba(69, 45, 67, 0.045), inset 0 1px rgba(255, 255, 255, 0.88);
  font-size: 0.75rem;
  font-weight: 710;
}

.soft-button:hover:not(:disabled) {
  border-color: rgba(113, 26, 95, 0.21);
  background: #fff;
}

.soft-button:disabled {
  cursor: default;
  opacity: 0.46;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: clamp(9px, 1.1vh, 14px) 3px 9px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(66, 104, 113, 0.18) transparent;
}

.message-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 14px;
  animation: message-in 260ms ease-out both;
}

.assistant-row {
  width: 100%;
}

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

.message-stack {
  display: grid;
  max-width: min(84%, 720px);
}

.assistant-row .message-stack {
  width: 100%;
  max-width: 100%;
  justify-items: start;
}

.user-row .message-stack {
  max-width: min(72%, 680px);
  justify-items: end;
}

.message-bubble {
  max-width: 100%;
  padding: clamp(12px, 1vw, 16px) clamp(14px, 1.25vw, 20px);
  border: 1px solid var(--line);
  border-radius: 8px 22px 22px 22px;
  color: #3e333f;
  font-size: clamp(0.88rem, 1.02vw, 1.08rem);
  line-height: 1.66;
  white-space: pre-wrap;
}

.assistant-bubble {
  width: 100%;
  padding: clamp(11px, 0.9vw, 14px) clamp(12px, 1vw, 16px);
  border: 1px solid rgba(71, 101, 107, 0.08);
  border-radius: 12px;
  background: rgba(249, 251, 250, 0.7);
  box-shadow: none;
}

.assistant-bubble.has-hidden-actions {
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.assistant-bubble.has-hidden-actions:hover,
.assistant-row.is-action-open .assistant-bubble {
  color: #334e55;
  border-color: rgba(71, 101, 107, 0.14);
  background: rgba(243, 248, 247, 0.94);
  box-shadow: none;
}

.assistant-bubble.has-hidden-actions:focus-visible {
  outline: 2px solid rgba(78, 111, 118, 0.17);
  outline-offset: 4px;
}

.user-bubble {
  border-color: rgba(63, 105, 115, 0.13);
  border-radius: 20px 8px 20px 20px;
  color: #3e5a61;
  background: #e7f0f1;
}

.message-actions {
  display: flex;
  gap: 6px;
  min-height: 25px;
  margin-top: 5px;
}

.assistant-actions {
  padding-left: 2px;
  justify-content: flex-start;
}

.assistant-row .assistant-actions {
  min-height: 0;
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: max-height 160ms ease, margin-top 160ms ease, opacity 130ms ease, transform 160ms ease, visibility 0s linear 160ms;
}

.assistant-row.is-action-open .assistant-actions {
  min-height: 27px;
  max-height: 27px;
  margin-top: 5px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

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

.message-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 25px;
  padding: 0 7px;
  border: 0;
  border-radius: 8px;
  color: #7d898c;
  background: transparent;
  cursor: pointer;
  font-size: 0.61rem;
  font-weight: 680;
}

.message-action.icon-only {
  display: grid;
  width: 27px;
  min-width: 27px;
  height: 27px;
  min-height: 27px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(71, 101, 107, 0.08);
  border-radius: 9px;
  background: rgba(249, 251, 250, 0.7);
}

.message-action:hover,
.message-action.is-playing {
  color: #486f78;
  background: rgba(225, 237, 238, 0.7);
}

.topic-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: #94a0a2;
  font-size: 0.62rem;
  font-weight: 680;
}

.topic-divider::before,
.topic-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(67, 92, 99, 0.1);
}

.display-note {
  display: grid;
  min-height: 100%;
  place-items: center;
  color: #93a0a2;
  font-size: 0.7rem;
}

.thinking-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 78px;
  min-height: 50px;
}

.thinking-bubble i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple-2);
  animation: typing-dot 900ms ease-in-out infinite;
}

.thinking-bubble i:nth-child(2) {
  animation-delay: 130ms;
}

.thinking-bubble i:nth-child(3) {
  animation-delay: 260ms;
}

.quick-prompts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 5px 2px 10px;
  scrollbar-width: none;
}

.quick-prompts::-webkit-scrollbar {
  display: none;
}

.quick-prompt {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(72, 104, 111, 0.1);
  border-radius: 999px;
  color: #5e6d70;
  background: rgba(243, 247, 246, 0.88);
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 680;
  transition: background 150ms ease, transform 150ms ease;
}

.quick-prompt:hover {
  background: #e3eef0;
}

.question-composer {
  position: relative;
  display: grid;
  gap: 0;
  padding: 4px;
  border: 1px solid rgba(62, 96, 104, 0.13);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 13px 34px rgba(43, 67, 73, 0.07), inset 0 1px rgba(255, 255, 255, 0.9);
}

.question-field {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
}

.question-field textarea {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 88px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 8px 88px 8px 11px;
  color: var(--ink);
  background: transparent;
  font-size: clamp(0.87rem, 0.97vw, 1.02rem);
  line-height: 28px;
}

.composer-actions {
  position: absolute;
  right: 2px;
  top: 50%;
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  transform: translateY(-50%);
}

.composer-icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(67, 95, 102, 0.1);
  border-radius: 12px;
  color: #64787d;
  background: rgba(242, 247, 246, 0.9);
  line-height: 0;
  cursor: pointer;
  transition: transform 150ms ease, color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.composer-icon-button:hover:not(:disabled) {
  color: #456d76;
  background: #edf5f4;
}

.composer-icon-button:active:not(:disabled) {
  transform: translateY(1px);
}

.composer-icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.send-icon-button {
  border-color: transparent;
  color: white;
  background: linear-gradient(145deg, #607f82, #60405a);
  box-shadow: 0 8px 18px rgba(63, 83, 84, 0.16), inset 0 1px rgba(255, 255, 255, 0.22);
}

.send-icon-button:hover:not(:disabled) {
  color: white;
  background: linear-gradient(145deg, #56777b, #57384f);
}

.composer-icon-button.is-listening {
  color: #a8524c;
  background: #fbebe8;
  box-shadow: 0 0 0 5px rgba(180, 82, 73, 0.08);
  animation: listening-pulse 1.2s ease-in-out infinite;
}

.composer-status {
  display: none;
  order: -1;
  min-height: 0;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid rgba(73, 103, 108, 0.08);
  border-radius: 8px;
  color: #7a898d;
  background: rgba(250, 252, 251, 0.94);
  box-shadow: 0 5px 14px rgba(48, 68, 72, 0.06);
  font-size: 0.75rem;
  line-height: 1.35;
  opacity: 0;
  transition: opacity 150ms ease;
}

.composer-status.is-visible {
  display: block;
  opacity: 1;
}

.ui-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  color: currentColor;
}

.icon-play::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 9px;
  height: 9px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.message-action.is-playing .icon-play::before {
  top: 3px;
  left: 3px;
  width: 3px;
  height: 9px;
  clip-path: none;
  box-shadow: 6px 0 currentColor;
}

.regenerate-icon {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  object-position: 50% 50%;
  opacity: 0.9;
  pointer-events: none;
  user-select: none;
}

.mic-icon {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
  object-position: 50% 50%;
  pointer-events: none;
  user-select: none;
}

.composer-icon-button.is-listening .mic-icon {
  filter: sepia(0.45) saturate(1.7) hue-rotate(315deg) brightness(0.9);
}

.icon-plane::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: currentColor;
  clip-path: polygon(0 41%, 100% 0, 70% 100%, 49% 59%, 20% 70%);
}

.icon-topic::before,
.icon-topic::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 7px;
  border: 1.4px solid currentColor;
  border-radius: 3px;
}

.icon-topic::before {
  left: 1px;
  top: 2px;
}

.icon-topic::after {
  right: 1px;
  bottom: 1px;
  background: rgba(255, 255, 255, 0.7);
}

.icon-clear::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 7px;
  height: 9px;
  border: 1.4px solid currentColor;
  border-top: 0;
  border-radius: 1px 1px 3px 3px;
}

.icon-clear::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 2px;
  width: 9px;
  height: 1.4px;
  background: currentColor;
  box-shadow: 3px -2px 0 -0.2px currentColor;
}

.icon-gear {
  width: 16px;
  height: 16px;
  background: currentColor;
  clip-path: polygon(
    42% 0, 58% 0, 63% 14%, 75% 8%, 87% 20%, 81% 32%, 100% 42%, 100% 58%, 84% 63%,
    92% 76%, 80% 88%, 66% 82%, 58% 100%, 42% 100%, 37% 84%, 24% 91%, 12% 79%, 18% 65%,
    0 58%, 0 42%, 16% 37%, 8% 24%, 20% 12%, 34% 18%
  );
}

.icon-gear::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
}

.question-field textarea::placeholder {
  color: #ad9eac;
}

.send-button,
.primary-action {
  color: white;
  background: linear-gradient(145deg, #607f82, #60405a);
  box-shadow: 0 12px 24px rgba(62, 77, 78, 0.17), inset 0 1px rgba(255, 255, 255, 0.22);
  font-weight: 760;
}

.send-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 142px;
  border-radius: 18px;
  font-size: 0.88rem;
}

.send-button i {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.16);
  font-style: normal;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.62;
  box-shadow: none;
}

/* Settings studio */

body[data-page="settings"] {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: #edf2f1;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% 6%, rgba(151, 195, 204, 0.24), transparent 31%),
    radial-gradient(circle at 10% 90%, rgba(229, 218, 207, 0.42), transparent 34%),
    linear-gradient(180deg, #f8faf9, #edf2f1);
}

.login-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(400px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 28px 80px rgba(42, 61, 66, 0.11), inset 0 1px rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(24px);
}

.login-card .brand-emblem {
  margin-bottom: 18px;
}

.login-card h1 {
  margin-bottom: 22px;
  font-size: 1.55rem;
  letter-spacing: -0.045em;
}

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

.text-link {
  display: inline-block;
  margin-top: 22px;
  color: var(--purple-2);
  font-size: 0.83rem;
  font-weight: 700;
}

.studio-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}

.studio-topbar {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1540px;
  min-height: 68px;
  margin: 0 auto;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft), inset 0 1px rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(22px);
}

.studio-brand h1 {
  margin-bottom: 0;
  font-size: 0.98rem;
}

.studio-brand .overline {
  margin-bottom: 2px;
  font-size: 0.58rem;
}

.save-indicator {
  min-height: 32px;
  box-shadow: none;
  background: rgba(246, 250, 248, 0.82);
  font-size: 0.7rem;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.studio-layout {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: 1540px;
  margin: 0 auto;
  gap: 16px;
}

.studio-layout > *,
.field-stack,
.field-stack input,
.field-stack select,
.field-stack textarea {
  min-width: 0;
}

.studio-sidebar {
  position: static;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow-soft), inset 0 1px rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
}

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

.nav-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px 6px 7px;
  border-radius: 16px;
  text-align: left;
  background: transparent;
}

.nav-item i {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.68);
  font-size: 0.56rem;
  font-style: normal;
  font-weight: 780;
}

.nav-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 710;
}

.nav-item.is-active {
  border-color: rgba(74, 111, 118, 0.12);
  background: rgba(220, 236, 240, 0.72);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.76);
}

.nav-item.is-active i {
  color: white;
  background: #607f82;
}

.nav-item.is-active span {
  color: #3f646c;
}

.sidebar-note {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(74, 111, 118, 0.09);
  border-radius: 18px;
  background: rgba(242, 247, 246, 0.78);
}

.sidebar-note p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.55;
}

.tiny-orbit {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(74, 111, 118, 0.28);
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(74, 111, 118, 0.06);
}

.studio-content {
  height: 100%;
  min-height: 0;
  min-width: 0;
}

.studio-section {
  display: none;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(18px, 1.7vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-soft), inset 0 1px rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(22px);
}

.studio-section.is-active {
  display: block;
  animation: section-in 240ms ease-out both;
}

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

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.28rem, 1.6vw, 1.72rem);
  letter-spacing: -0.05em;
}

.section-heading > div > p:last-child {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.profile-option {
  position: relative;
  min-height: 184px;
  overflow: hidden;
  padding: 17px;
  border-color: rgba(92, 64, 91, 0.1);
  border-radius: 23px;
  text-align: left;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 26px rgba(42, 61, 66, 0.05), inset 0 1px rgba(255, 255, 255, 0.84);
}

.profile-option::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -42px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(95, 127, 130, 0.045);
}

.profile-option .profile-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  color: #52747a;
  background: rgba(220, 236, 240, 0.82);
  font-size: 0.62rem;
  font-weight: 790;
}

.profile-option > strong {
  display: block;
  margin-top: 14px;
  font-size: 0.9rem;
}

.profile-details {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  margin-top: 13px;
}

.profile-detail {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  font-size: 0.66rem;
  line-height: 1.45;
}

.profile-detail b {
  color: var(--faint);
  font-weight: 720;
}

.profile-detail span {
  color: var(--muted);
}

.profile-option.is-active {
  border-color: rgba(74, 111, 118, 0.24);
  background: linear-gradient(145deg, rgba(241, 247, 247, 0.96), rgba(224, 238, 239, 0.86));
  box-shadow: 0 16px 34px rgba(42, 76, 82, 0.09), inset 0 1px rgba(255, 255, 255, 0.9);
}

.profile-option.is-active::before {
  content: "当前使用";
  position: absolute;
  top: 14px;
  right: 14px;
  color: #52747a;
  font-size: 0.62rem;
  font-weight: 760;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.soft-card {
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 23px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 28px rgba(42, 61, 66, 0.055), inset 0 1px rgba(255, 255, 255, 0.9);
}

.status-card {
  min-height: 120px;
  padding: 18px;
}

.status-card > span {
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 720;
}

.status-card strong {
  display: block;
  margin-top: 15px;
  color: #455d63;
  font-size: 1.75rem;
  line-height: 1;
}

.status-card strong.small-value {
  font-size: 1.02rem;
  line-height: 1.25;
}

.status-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 15px;
}

.status-split > div + div {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.status-split strong {
  margin-top: 0;
}

.status-split p {
  margin-top: 6px;
}

.status-card p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.accent-card {
  background: linear-gradient(145deg, rgba(229, 240, 242, 0.9), rgba(255, 255, 255, 0.74));
}

.primary-action {
  min-height: 43px;
  padding: 0 20px;
  border-radius: 15px;
}

.primary-action.compact {
  min-height: 38px;
  padding-inline: 16px;
  white-space: nowrap;
  font-size: 0.77rem;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

.form-card {
  padding: 18px;
}

.form-card + .form-card,
.form-grid + .form-card {
  margin-top: 14px;
}

.form-grid .form-card + .form-card {
  margin-top: 0;
}

.form-card h3,
.import-card h3 {
  margin-bottom: 14px;
  font-size: 0.9rem;
}

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

.field-stack {
  display: grid;
  gap: 7px;
}

.field-stack.full {
  grid-column: 1 / -1;
}

.field-stack > span {
  color: #756575;
  font-size: 0.7rem;
  font-weight: 710;
}

.field-stack input,
.field-stack textarea,
.field-stack select,
.knowledge-toolbar input,
.knowledge-toolbar select,
.search-field {
  width: 100%;
  border: 1px solid rgba(62, 96, 104, 0.13);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.84);
}

.field-stack input,
.field-stack select,
.knowledge-toolbar input,
.knowledge-toolbar select {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.78rem;
}

.field-stack textarea {
  min-height: 96px;
  resize: vertical;
  padding: 11px 12px;
  font-size: 0.78rem;
  line-height: 1.55;
}

.field-stack input:focus,
.field-stack textarea:focus,
.field-stack select:focus,
.knowledge-toolbar input:focus,
.knowledge-toolbar select:focus {
  border-color: rgba(74, 111, 118, 0.34);
  background: white;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.card-title-row h3 {
  margin-bottom: 5px;
}

.card-title-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.card-title-row > span {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--purple-2);
  background: var(--purple-soft);
  font-size: 0.64rem;
  font-weight: 720;
}

.character-render-card {
  align-content: start;
}

.renderer-fields {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.renderer-fields[hidden] {
  display: none;
}

.renderer-fields p {
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.5;
}

.character-animation-workbench[hidden] {
  display: none;
}

.animation-workbench-heading {
  align-items: center;
}

.animation-workbench-heading h3 {
  margin: 0;
}

.animation-workbench-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 2fr);
  gap: 14px;
  align-items: start;
}

.animation-preview-panel {
  display: grid;
  grid-template-rows: auto auto;
  gap: 9px;
  width: min(100%, 230px);
  min-width: 0;
  justify-self: center;
  align-self: start;
}

.animation-preview-stage {
  position: relative;
  width: 100%;
  min-height: 0;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid rgba(72, 108, 114, 0.12);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(220, 235, 233, 0.2)),
    url("./assets/lab-stage-bg-v1.png") center / cover;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.9);
}

.animation-preview-stage > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.animation-preview-panel > strong {
  color: #61777b;
  font-size: 0.72rem;
  text-align: center;
}

.animation-preview-media {
  max-width: 100%;
}

.character-animation-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.animation-state-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(72, 108, 114, 0.1);
  border-radius: 18px;
  background: rgba(247, 250, 249, 0.68);
}

.animation-state-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.animation-state-card > header strong {
  color: #50686d;
  font-size: 0.73rem;
}

.animation-action-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  scrollbar-width: thin;
}

.animation-state-empty {
  min-height: 70px;
  display: grid;
  place-items: center;
  color: #96a4a6;
  font-size: 0.68rem;
}

.animation-action-row {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(72, 108, 114, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.animation-action-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.animation-action-row input,
.animation-action-row select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid rgba(62, 96, 104, 0.12);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.69rem;
}

.animation-action-name {
  font-weight: 720;
}

.animation-action-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px auto;
  gap: 6px;
}

.soft-button.tiny {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: 0.66rem;
  white-space: nowrap;
}

.upload-animation-button {
  min-width: 68px;
}

.prompt-workbench {
  display: grid;
  gap: 13px;
}

.prompt-workbench h3 {
  margin-bottom: 0;
}

.compact-prompt textarea {
  min-height: 76px;
}

.profile-editors {
  display: grid;
  gap: 8px;
}

.profile-editor {
  border: 1px solid rgba(62, 96, 104, 0.1);
  border-radius: 17px;
  background: rgba(247, 249, 249, 0.78);
  overflow: hidden;
}

.profile-editor summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 0 15px;
  cursor: pointer;
  list-style: none;
}

.profile-editor summary::-webkit-details-marker {
  display: none;
}

.profile-editor summary::after {
  content: "+";
  flex: 0 0 auto;
  color: #6f8589;
  font-size: 1rem;
  font-weight: 500;
}

.profile-editor[open] summary::after {
  content: "−";
}

.profile-editor summary strong {
  color: var(--ink);
  font-size: 0.78rem;
}

.profile-editor summary span {
  margin-left: auto;
  color: var(--faint);
  font-size: 0.64rem;
}

.profile-editor-body {
  padding: 0 15px 15px;
}

.profile-editor textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid rgba(62, 96, 104, 0.1);
  border-radius: 12px;
  padding: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  font-size: 0.72rem;
  line-height: 1.6;
}

.profile-editor button {
  width: 100%;
  margin-top: 8px;
}

.helper-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.55;
}

code {
  padding: 2px 5px;
  border-radius: 6px;
  color: #6a3c60;
  background: var(--purple-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}

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

.toggle-row strong {
  font-size: 0.79rem;
}

.toggle-row span {
  margin-top: 3px;
  color: var(--faint);
  font-size: 0.65rem;
}

.toggle {
  position: relative;
  flex: 0 0 auto;
  width: 43px;
  height: 25px;
  border-radius: 999px;
  background: #ddd5dd;
}

.toggle i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 8px rgba(46, 31, 45, 0.18);
  transition: transform 180ms ease;
}

.toggle.is-on {
  background: var(--purple-2);
}

.toggle.is-on i {
  transform: translateX(18px);
}

.range-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 13px;
}

.provider-stack {
  gap: 14px;
}

.provider-workbench {
  container-name: provider-card;
  container-type: inline-size;
}

.provider-saved-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(62, 96, 104, 0.1);
  border-radius: 16px;
  background: rgba(242, 247, 247, 0.68);
}

.inline-actions,
.workbench-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.provider-profile-actions {
  padding-bottom: 1px;
}

.workbench-actions {
  margin-top: 11px;
}

.provider-action-status {
  min-height: 0;
  margin-top: 8px;
}

.provider-action-status:empty {
  display: none;
}

.provider-stack > .form-card {
  padding: 16px;
}

.provider-core-grid {
  grid-template-columns: 0.8fr 1.25fr 1.2fr;
  gap: 10px;
}

.provider-model-results {
  grid-column: span 2;
}

@container provider-card (max-width: 900px) {
  .provider-core-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container provider-card (max-width: 580px) {
  .provider-saved-row,
  .provider-core-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .provider-model-results {
    grid-column: auto;
  }
}

.speech-provider-card {
  container-name: speech-card;
  container-type: inline-size;
}

.speech-essentials {
  display: grid;
  grid-template-areas: "key voice fetch" "speed autoplay actions";
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) max-content;
  align-items: end;
  gap: 10px;
}

.speech-key-field {
  grid-area: key;
}

.speech-voice-field {
  grid-area: voice;
}

.speech-speed-field { grid-area: speed; }
.speech-speed-field output { float: right; font-variant-numeric: tabular-nums; }
.speech-speed-field input { height: 40px; padding: 0; }
#minimaxVoiceDescription:empty { display: none; }
.speech-key-field input, .speech-voice-field select { height: 40px; }


#fetchMiniMaxVoicesButton {
  grid-area: fetch;
  white-space: nowrap;
}

.speech-essentials > button {
  min-height: 40px;
}

.compact-toggle {
  grid-area: autoplay;
  min-height: 40px;
  min-width: 118px;
  padding: 0 10px;
  border: 1px solid rgba(62, 96, 104, 0.1);
  border-radius: 13px;
  background: rgba(247, 250, 249, 0.72);
}

.compact-toggle strong {
  font-size: 0.72rem;
  white-space: nowrap;
}

.speech-actions {
  grid-area: actions;
  margin: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

@container speech-card (max-width: 1120px) {
  .speech-essentials {
    grid-template-areas:
      "key voice fetch"
      "speed autoplay actions";
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) max-content;
  }
}

@container speech-card (max-width: 720px) {
  .speech-essentials {
    grid-template-areas:
      "key key"
      "voice fetch"
      "speed speed"
      "autoplay actions";
    grid-template-columns: minmax(0, 1fr) max-content;
  }
}

@container speech-card (max-width: 470px) {
  .speech-essentials {
    grid-template-areas:
      "key"
      "voice"
      "fetch"
      "speed"
      "autoplay"
      "actions";
    grid-template-columns: minmax(0, 1fr);
  }

  #fetchMiniMaxVoicesButton,
  .speech-actions {
    width: 100%;
  }

  .speech-actions > button {
    flex: 1 1 0;
  }
}

input[type="range"] {
  accent-color: var(--purple-2);
}

.full-width {
  width: 100%;
  margin-top: 14px;
}

.knowledge-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  flex: 1 1 auto;
  align-items: stretch;
}

#knowledgeSection.is-active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 14px;
}

#knowledgeSection .section-heading {
  flex: 0 0 auto;
  margin-bottom: 12px;
}

#knowledgeSection .section-heading h2 {
  font-size: 1.16rem;
}

.knowledge-control-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 3px;
}

.import-card {
  flex: 0 0 auto;
  padding: 13px;
}

.import-card h3 {
  margin-bottom: 10px;
  font-size: 0.84rem;
}

.field-stack small {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.plain-file-upload {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid rgba(74, 111, 118, 0.14);
  border-radius: 13px;
  color: #5b7378;
  background: rgba(239, 246, 246, 0.84);
  font-size: 0.72rem;
  font-weight: 720;
  cursor: pointer;
}

.plain-file-upload input {
  display: none;
}

.import-destination {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 680;
}

.import-destination select {
  min-width: 0;
  min-height: 32px;
  padding: 0 28px 0 9px;
  border: 1px solid rgba(62, 96, 104, 0.12);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.68rem;
}

.import-card .form-status {
  margin-top: 8px;
}

.import-card .form-status:empty {
  display: none;
}

.knowledge-index-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
}

.knowledge-index-card .search-field {
  min-height: 36px;
  margin-bottom: 11px;
  padding: 0 9px;
}

.knowledge-index-card .search-field span {
  font-size: 0.78rem;
}

.knowledge-index-card .search-field input {
  min-height: 32px;
  font-size: 0.72rem;
}

.knowledge-index-section > strong {
  display: block;
  margin-bottom: 7px;
  color: #746575;
  font-size: 0.7rem;
}

.knowledge-category-filters,
.knowledge-tag-filters {
  display: grid;
  gap: 7px;
}

.knowledge-filter-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(62, 96, 104, 0.1);
  border-radius: 11px;
  color: var(--muted);
  text-align: left;
  background: rgba(250, 252, 251, 0.7);
  font-size: 0.74rem;
}

.knowledge-filter-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-filter-button b {
  color: var(--faint);
  font-size: 0.58rem;
}

.knowledge-filter-button.is-active {
  border-color: rgba(72, 108, 114, 0.16);
  color: #486c72;
  background: rgba(220, 236, 240, 0.82);
}

.knowledge-filter-all {
  margin-bottom: 1px;
}

.knowledge-tag-filters {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 112px;
  overflow-y: auto;
  align-content: flex-start;
  margin-top: 12px;
  padding-right: 4px;
  padding-top: 11px;
  border-top: 1px solid rgba(62, 96, 104, 0.08);
  scrollbar-gutter: stable;
}

.knowledge-tag-button {
  min-height: 25px;
  padding: 0 8px;
  border: 1px solid rgba(62, 96, 104, 0.1);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(245, 242, 245, 0.88);
  font-size: 0.62rem;
}

.knowledge-tag-button.is-active {
  border-color: rgba(72, 108, 114, 0.16);
  color: #496f74;
  background: rgba(220, 236, 240, 0.86);
}

.knowledge-toolbar-filters {
  display: grid;
  flex: 0 1 419px;
  grid-template-columns: minmax(136px, 170px) minmax(94px, 110px) minmax(104px, 125px);
  gap: 7px;
}

.knowledge-toolbar-filters select {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid rgba(62, 96, 104, 0.12);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.76);
  font-size: 0.66rem;
}

.knowledge-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  container-name: knowledge-main;
  container-type: inline-size;
}

.knowledge-pane-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  padding: 3px 2px;
}

.knowledge-pane-header .heading-actions {
  flex: 0 0 auto;
  gap: 7px;
  margin-left: auto;
}

.knowledge-result-count {
  margin-right: 2px;
  color: var(--faint);
  font-size: 0.62rem;
  white-space: nowrap;
}

.knowledge-pane-header .soft-button,
.knowledge-pane-header .primary-action {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 11px;
  font-size: 0.62rem;
}

@container knowledge-main (max-width: 570px) {
  .knowledge-pane-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .knowledge-toolbar-filters {
    flex: 1 1 100%;
  }
}

@container knowledge-main (max-width: 460px) {
  .knowledge-toolbar-filters {
    grid-template-columns: 1fr;
  }
}

.search-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
}

.search-field span {
  color: var(--faint);
  font-size: 1rem;
}

.search-field input {
  min-height: 38px;
  border: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
}

.knowledge-list {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  gap: 8px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: transparent;
  box-shadow: none;
}

.knowledge-group {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 21px;
  background: rgba(244, 248, 247, 0.56);
  box-shadow: 0 8px 24px rgba(42, 61, 66, 0.035);
}

.knowledge-group > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(62, 96, 104, 0.08);
}

.knowledge-group > header h3 {
  margin-bottom: 2px;
  font-size: 0.78rem;
}

.knowledge-group > header p {
  color: var(--muted);
  font-size: 0.56rem;
  line-height: 1.45;
}

.knowledge-group-count {
  flex: 0 0 auto;
  color: #55767a;
  font-size: 0.62rem;
  font-weight: 720;
}

.knowledge-group-items {
  display: grid;
  gap: 1px;
}

.knowledge-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 17px;
  border: 1px solid rgba(255, 255, 255, 0.87);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 7px 18px rgba(42, 61, 66, 0.04), inset 0 1px rgba(255, 255, 255, 0.88);
}

.knowledge-item-body {
  min-width: 0;
}

.knowledge-item h3 {
  margin-bottom: 6px;
  font-size: 0.82rem;
}

.knowledge-item p {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.item-meta,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.meta-chip,
.status-chip {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #f3eff2;
  font-size: 0.56rem;
  font-weight: 700;
}

.type-chip {
  color: #536f75;
  background: rgba(220, 236, 240, 0.72);
}

.asset-chip {
  color: #6b5b70;
  background: rgba(235, 229, 237, 0.78);
}

.chunk-chip {
  color: #527276;
  background: rgba(231, 241, 240, 0.88);
}

.status-chip.published {
  color: var(--mint-ink);
  background: var(--mint);
}

.status-chip.disabled {
  color: #8a6b5c;
  background: var(--peach);
}

.item-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.58rem;
}

.item-actions button.is-active {
  color: #486d72;
  background: rgba(220, 236, 240, 0.84);
}

.knowledge-chunk-panel {
  grid-column: 1 / -1;
  min-width: 0;
  padding-top: 13px;
  border-top: 1px solid rgba(62, 96, 104, 0.09);
  color: var(--muted);
  font-size: 0.66rem;
}

.knowledge-chunk-list {
  display: grid;
  gap: 8px;
}

.knowledge-chunk-row {
  display: grid;
  gap: 6px;
}

.knowledge-chunk-row > span {
  color: #6f6470;
  font-size: 0.62rem;
  font-weight: 720;
}

.knowledge-chunk-row textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid rgba(62, 96, 104, 0.12);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(252, 253, 252, 0.9);
  font-size: 0.68rem;
  line-height: 1.65;
}

.knowledge-chunk-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.empty-state {
  padding: 42px 20px;
  border: 1px dashed rgba(97, 72, 96, 0.15);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.4);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(39, 53, 57, 0.24);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(900px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 30px 100px rgba(49, 32, 48, 0.22), inset 0 1px rgba(255, 255, 255, 0.95);
}

.modal-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 17px;
  border-bottom: 1px solid var(--line);
}

.modal-card h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
}

.modal-form {
  padding: 22px 24px 24px;
}

.modal-form footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

#knowledgeBody {
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, "PingFang SC", monospace;
  line-height: 1.7;
}

.knowledge-assets-editor {
  grid-column: 1 / -1;
  padding: 13px;
  border: 1px solid rgba(62, 96, 104, 0.1);
  border-radius: 16px;
  background: rgba(241, 247, 247, 0.62);
}

.asset-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.asset-editor-heading strong,
.asset-editor-heading span {
  display: block;
}

.asset-editor-heading strong {
  color: #6f5f70;
  font-size: 0.72rem;
}

.asset-editor-heading span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.62rem;
}

.knowledge-asset-rows {
  display: grid;
  gap: 8px;
}

.knowledge-asset-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1.25fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 720px) {
  .knowledge-asset-row {
    grid-template-columns: 1fr;
  }

  .asset-remove {
    justify-self: end;
  }
}

.knowledge-asset-row input,
.knowledge-asset-row select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(62, 96, 104, 0.13);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.7rem;
}

.asset-remove {
  min-height: 38px;
  white-space: nowrap;
}

.form-status {
  min-height: 19px;
  margin: 0;
  color: var(--purple-2);
  font-size: 0.7rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  z-index: 150;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 17px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  color: #563e50;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 52px rgba(42, 61, 66, 0.15);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 170ms ease, transform 170ms ease;
  font-size: 0.76rem;
  backdrop-filter: blur(14px);
}

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

@keyframes gentle-float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-8px); }
}

@keyframes stage-breathe {
  0%, 100% { transform: scale(1); filter: saturate(0.92) contrast(0.98); }
  50% { transform: scale(1.008); filter: saturate(0.96) contrast(0.99); }
}

@keyframes listening-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(180, 82, 73, 0.06); }
  50% { box-shadow: 0 0 0 8px rgba(180, 82, 73, 0.11); }
}

@keyframes orbit-breathe {
  0%, 100% { opacity: 0.52; }
  50% { opacity: 1; }
}

@keyframes voice-bar {
  from { height: 7px; }
  to { height: 20px; }
}

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

@keyframes typing-dot {
  0%, 100% { opacity: 0.34; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

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

@media (max-aspect-ratio: 4 / 3) and (min-width: 900px) {
  .visitor-grid {
    grid-template-columns: minmax(350px, 0.95fr) minmax(480px, 1.05fr);
  }

  .character-art {
    width: min(90%, 560px);
  }

  .character-art.character-card-art {
    width: min(82%, 500px);
  }

  .character-art.character-full-stage-art {
    width: 100%;
    height: 100%;
  }

  .message-stack .message-bubble {
    max-width: 100%;
  }
}

@media (max-height: 760px) and (min-width: 900px) {
  .presentation-shell {
    min-height: 620px;
    padding-block: 11px;
  }

  .visitor-topbar {
    min-height: 54px;
    padding-bottom: 9px;
  }

  .portrait-note {
    bottom: 15%;
  }

  .chat-panel {
    padding: 16px;
    padding-bottom: 19px;
  }

  .messages {
    padding-block: 8px;
  }
}

@media (max-width: 980px) {
  body[data-page="settings"] {
    height: auto;
    overflow: auto;
  }

  .studio-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .studio-topbar {
    margin-bottom: 14px;
  }

  .presentation-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .visitor-grid {
    grid-template-columns: 1fr;
  }

  .character-panel {
    align-self: stretch;
    height: min(78vh, 760px);
    max-height: none;
    min-height: 620px;
  }

  .chat-panel {
    min-height: 720px;
  }

  .studio-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .studio-sidebar {
    position: static;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .studio-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar-note,
  .sidebar-intro {
    display: none;
  }

  .profile-grid,
  .overview-grid,
  .profile-editors {
    grid-template-columns: 1fr;
  }

  .knowledge-layout {
    grid-template-columns: 1fr;
  }

  .studio-content,
  .studio-section {
    height: auto;
    overflow: visible;
  }

  #knowledgeSection.is-active {
    display: block;
    overflow: visible;
  }

  .knowledge-control-column,
  .knowledge-index-card,
  .knowledge-main,
  .knowledge-list {
    min-height: auto;
    overflow: visible;
  }

  .provider-core-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .provider-model-results {
    grid-column: auto;
  }
}

@media (min-width: 860px) and (max-width: 980px) {
  body[data-page="visitor"] .presentation-shell {
    height: 100vh;
    min-height: 660px;
    overflow: hidden;
  }

  body[data-page="visitor"] .visitor-grid {
    grid-template-columns: minmax(330px, 0.9fr) minmax(460px, 1.1fr);
  }

  body[data-page="visitor"] .character-panel {
    align-self: center;
    height: clamp(620px, 88vh, 760px);
    min-height: 0;
    max-height: 100%;
  }

  body[data-page="visitor"] .chat-panel {
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .visitor-topbar,
  .studio-topbar,
  .section-heading,
  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-title { align-self: stretch; }

  .provider-saved-row {
    grid-template-columns: 1fr;
  }

  .provider-core-grid {
    grid-template-columns: 1fr;
  }

  .speech-actions {
    width: 100%;
    margin-left: 0;
  }

  .visitor-actions,
  .studio-actions,
  .chat-tools {
    width: 100%;
  }

  .chat-tools {
    justify-items: start;
  }

  .ai-disclaimer {
    white-space: normal;
  }

  .presentation-shell {
    padding: 12px;
  }

  .character-panel,
  .chat-panel {
    border-radius: 27px;
  }

  .question-composer {
    grid-template-columns: 1fr;
  }

  .send-button {
    min-height: 50px;
  }

  .form-grid.two-columns,
  .field-grid,
  .range-grid {
    grid-template-columns: 1fr;
  }

  .field-stack.full {
    grid-column: auto;
  }

  .studio-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .knowledge-toolbar {
    grid-template-columns: 1fr;
  }

  .knowledge-item {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 30px 24px;
  }
}

@media (max-width: 1180px) {
  .animation-workbench-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .character-animation-editor {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .animation-workbench-layout {
    grid-template-columns: 1fr;
  }

  .animation-preview-panel {
    grid-template-rows: auto auto;
    width: min(100%, 230px);
  }
}

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

/* Voice conversation: the transcript owns the space, controls remain in reach. */
.call-entry { color: var(--mint-ink); background: var(--mint); }
.chat-tool-buttons { flex-wrap: wrap; }
.chat-panel.is-call-mode { grid-template-rows: auto minmax(0, 1fr); background: #fcfafb; }
.is-call-mode > .messages, .is-call-mode > .quick-prompts,
.is-call-mode > .question-composer, .is-call-mode .chat-tool-buttons,
.is-call-mode .chat-title { display: none; }
.is-call-mode .chat-header { justify-content: flex-end; border: 0; padding-bottom: 0; }
.call-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; gap: 0; padding: 24px 8px 0; }
.call-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 12px 24px; border-bottom: 1px solid var(--line); }
.call-eyebrow { margin: 0 0 12px; font-size: 13px; color: var(--purple); font-weight: 600; letter-spacing: .06em; }
.call-heading h2 { margin: 0; font-size: clamp(24px,2.3vw,34px); line-height: 1.3; letter-spacing: -.04em; }
.call-signal { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 5px; width: 64px; height: 64px; background: #e7eeeb; border-radius: 22px; color: #467267; }
.call-signal i { width: 4px; height: 12px; background: currentColor; border-radius: 3px; }
.call-signal i:nth-child(2), .call-signal i:nth-child(4) { height: 24px; }
.call-signal i:nth-child(3) { height: 34px; }
[data-phase="speaking"] .call-signal i { animation: call-signal 900ms ease-in-out infinite alternate; }
[data-phase="speaking"] .call-signal i:nth-child(even) { animation-delay: -500ms; }
.call-panel[data-input="live"] .call-signal i { animation: none; transition: height 80ms linear; }
.call-panel[data-input="processing"] .call-signal { color: var(--purple); background: #f0eaf2; }
.call-panel[data-input="processing"] .call-signal i { animation: call-signal 1400ms ease-in-out infinite alternate; }
.call-panel[data-input="processing"] .call-signal i:nth-child(even) { animation-delay: -700ms; }
[data-phase="muted"] .call-signal { color: #858089; background: #eeeaee; }
@keyframes call-signal { to { transform: scaleY(.45); } }
.call-hint { margin: 12px 12px 0; color: #934d53; font-size: 14px; }
.call-conversation { grid-row: 3; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 28px 12px; }
.call-question { margin: 0 0 32px auto; padding: 16px 20px; width: fit-content; max-width: 90%; background: #edf1ef; border-radius: 22px 22px 6px 22px; }
.call-question > span { color: #536e65; font-size: 12px; font-weight: 600; }
.call-question p { margin: 6px 0 0; line-height: 1.65; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.call-speaker { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; font-size: 13px; color: var(--purple); font-weight: 600; }
.call-caption { font-size: clamp(19px,1.7vw,25px); line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; color: #34343a; padding-bottom: 16px; }
.call-rest { display: flex; gap: 7px; padding: 16px 0; }
.call-rest i { height: 7px; width: 7px; border-radius: 50%; background: #b6a1b0; }
.call-controls { grid-row: 4; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 20px 8px 4px; border-top: 1px solid var(--line); }
.call-control { flex: 1; max-width: 230px; min-height: 60px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid #dcd4da; border-radius: 20px; padding: 14px 16px; background: white; color: #564452; font-size: 15px; font-weight: 600; cursor: pointer; }
.call-control svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.call-end { color: white; background: #89516a; border-color: #89516a; box-shadow: 0 6px 16px #89516a20; }
.call-control:hover { filter: brightness(.94); }
.call-control:focus-visible, .call-entry:focus-visible, .call-conversation:focus-visible { outline: 3px solid var(--mint-ink); outline-offset: 3px; }
.call-control:disabled { opacity: .55; cursor: default; }
@media (max-width: 700px) {
  body.has-voice-call .chat-panel { padding: 16px; }
  .call-panel { padding: 16px 0 0; }
  .call-heading { padding: 0 0 18px; }
  .call-heading h2 { font-size: 23px; }
  .call-eyebrow { margin-bottom: 8px; }
  .call-signal { width: 52px; height: 52px; border-radius: 18px; }
  .call-conversation { padding: 20px 0; }
  .call-question { margin-bottom: 24px; }
  .call-caption { font-size: 19px; }
  .call-controls { position: sticky; bottom: 0; padding: 14px 0 0; gap: 10px; background: #fcfafb; }
  .call-control { min-height: 54px; padding: 12px 8px; font-size: 14px; border-radius: 18px; }
}

@media (min-width: 860px) {
  body.has-voice-call .presentation-shell { height: 100dvh; min-height: 0; }
  body.has-voice-call .visitor-grid { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
  body.has-voice-call .chat-panel { height: 100%; min-height: 0; }
}
@media (max-width: 859px) {
  body[data-page="visitor"] .character-panel { display: none; }
  body[data-page="visitor"] .presentation-shell { height: 100dvh; min-height: 0; overflow: hidden; }
  body[data-page="visitor"] .visitor-grid { grid-template-columns: minmax(0, 1fr); }
  body[data-page="visitor"] .chat-panel { height: 100%; min-height: 0; }
}

/* One shared desktop row; telephone and dictation have separate targets. */
body[data-page="visitor"] .presentation-shell { height: 100dvh; min-height: 0; overflow: hidden; }
body[data-page="visitor"] .visitor-grid { min-height: 0; grid-template-rows: minmax(0, 1fr); }
body[data-page="visitor"] .chat-panel { height: 100%; min-height: 0; }
@media (min-width: 860px) {
  body[data-page="visitor"] .presentation-shell { container-type: inline-size; }
  body[data-page="visitor"] .visitor-grid {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    /* Cap the shared row by the portrait video's width, rather than stretching
       its letterbox across a tall preview. The 16px remainder accounts for chrome. */
    height: min(100%, calc((100cqw - clamp(16px, 1.75vw, 30px)) * .425 * 16 / 9 + 16px));
    align-self: start;
  }
  body[data-page="visitor"] .character-panel { align-self: stretch; height: 100%; max-height: none; min-height: 0; }
}
.question-composer { padding: 8px; border-radius: 22px; }
.question-field { display: grid; grid-template-rows: auto auto; gap: 4px; }
.question-field textarea { padding: 8px 10px; height: 44px; min-height: 44px; }
.composer-actions { position: static; transform: none; justify-content: flex-end; gap: 8px; width: 100%; }
.composer-icon-button { height: 44px; width: 44px; flex-shrink: 0; }
.composer-actions .call-entry { height: 44px; width: 44px; min-width: 44px; margin-right: auto; justify-content: center; gap: 0; padding: 0; border-radius: 14px; }
.call-entry svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.call-controls .call-end { flex: 0 1 200px; min-height: 56px; }
.call-panel[data-phase="starting"] .call-signal { display: none; }
.call-panel[data-phase="starting"] .call-conversation { visibility: hidden; }
.call-entry-error { margin: 0 2px 8px; padding: 8px 10px; background: #f5e9ec; color: #7a394d; border-radius: 10px; font-size: 13px; }

/* Keep the shared filing line inside the viewport without covering the composer. */
body[data-page="visitor"] {
  height: 100dvh; min-height: 0; overflow: hidden;
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body[data-page="visitor"] .presentation-shell { width: 100%; height: 100%; min-height: 0; }
body.has-voice-call .visitor-grid { height: 100%; }
body.has-voice-call .visitor-topbar { gap: 12px; }
@media (max-height: 600px) {
  body.has-voice-call .call-heading { padding-bottom: 8px; }
  body.has-voice-call .call-panel { padding-top: 8px; }
  body.has-voice-call .call-eyebrow { margin-bottom: 4px; }
  body.has-voice-call .call-conversation { padding-block: 12px; }
  body.has-voice-call .call-controls { padding-top: 8px; }
}
.icp-footer { min-height: 40px; padding: 6px 12px; text-align: center; color: #8a8f98; font-size: 11px; line-height: 1.5; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 4px; }
.icp-footer a { color: inherit; text-decoration: none; }
.icp-footer a:hover { text-decoration: underline; }

/* Compact reading emphasis within the existing conversation surface. */
.assistant-bubble { white-space: normal; overflow-wrap: anywhere; }
.assistant-bubble p { margin: 0 0 0.75em; }
.assistant-bubble > :last-child { margin-bottom: 0; }
.assistant-bubble h1, .assistant-bubble h2, .assistant-bubble h3,
.assistant-bubble h4, .assistant-bubble h5, .assistant-bubble h6 {
  font-size: 1.12em; line-height: 1.5; margin: 0.8em 0 0.35em; color: var(--ink);
}
.assistant-bubble > :first-child { margin-top: 0; }
.assistant-bubble strong { color: #365c62; font-weight: 750; }
.assistant-bubble ul, .assistant-bubble ol { margin: 0.4em 0 0.75em; padding-left: 1.4em; }
.assistant-bubble pre { white-space: pre-wrap; }

.pwa-notice {
  flex: 1 0 100%; min-width: 0; min-height: 52px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: 8px; padding: 4px 5px 4px 12px;
  border: 1px solid var(--line); border-radius: 15px;
  background: var(--surface-strong); color: var(--ink); box-shadow: var(--shadow-soft);
  font-size: 14px; line-height: 1.4;
}
.visitor-topbar:has(.pwa-notice:not([hidden])) { flex-wrap: wrap; }
.pwa-notice > span:first-child { min-width: 0; font-weight: 650; }
.pwa-actions { display: inline-flex; align-items: center; gap: 2px; }
.pwa-notice button { min-width: 52px; min-height: 44px; padding: 0 8px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer; }
#pwaUpdate { color: var(--purple); background: var(--purple-soft); }
.pwa-notice button:focus-visible { outline: 2px solid var(--purple); outline-offset: -2px; }
@media (max-width: 680px) { .pwa-notice { flex: 0 0 auto; width: 100%; } }

@media (max-height: 500px) and (orientation: landscape) {
  body.has-voice-call .visitor-topbar { min-height: 48px; padding-bottom: 8px; }
  body.has-voice-call .brand-logo { width: 36px; height: 36px; }
  body.has-voice-call .visitor-brand .overline,
  body.has-voice-call .call-eyebrow,
  body.has-voice-call .call-speaker { display: none; }
  body.has-voice-call .call-heading h2 { font-size: 20px; }
  body.has-voice-call .call-signal { width: 36px; height: 36px; border-radius: 12px; }
  body.has-voice-call .call-conversation { padding-block: 8px; }
  body.has-voice-call .call-caption { font-size: 18px; line-height: 1.6; }
  body.has-voice-call .call-controls .call-end { min-height: 44px; padding-block: 8px; }
}

/* Phone chrome: tighter header rhythm and light surfaces without the desktop haze. */
@media (max-width: 680px) {
  body[data-page="visitor"] {
    --surface-strong: #ffffff;
    --shadow: 0 12px 36px rgba(89, 73, 104, 0.055);
    --shadow-soft: 0 6px 18px rgba(89, 73, 104, 0.04);
    background: #fcfbff;
  }
  body[data-page="visitor"] .visitor-topbar { gap: 8px; padding-bottom: 12px; }
  body[data-page="visitor"] .ambient { opacity: 0.22; }
  body[data-page="visitor"]::before { opacity: 0.3; }
  body[data-page="visitor"] .chat-panel { background: #fff; }
  body[data-page="visitor"] .assistant-bubble { background: #fafcfb; }
  body[data-page="visitor"] .question-composer { background: #fff; box-shadow: 0 6px 20px rgba(89, 73, 104, 0.045); }
}
