:root {
  --bg: #f7f2ec;
  --bg-deep: #eee7df;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: #fffdf9;
  --ink: #181716;
  --muted: #706a64;
  --line: rgba(24, 23, 22, 0.11);
  --line-strong: rgba(24, 23, 22, 0.18);
  --pink: #ec8fba;
  --pink-deep: #c94f89;
  --pink-soft: #f9d9e8;
  --yellow: #ffd36c;
  --green: #3f9f76;
  --red: #c65c61;
  --shadow: 0 26px 70px rgba(63, 48, 37, 0.13);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 211, 108, 0.26), transparent 30%),
    radial-gradient(circle at 88% 20%, rgba(236, 143, 186, 0.25), transparent 31%),
    linear-gradient(145deg, var(--bg) 0%, #fbf8f4 52%, var(--bg-deep) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, textarea, select, input { font: inherit; }
button { color: inherit; }
button, select, input[type="range"] { cursor: pointer; }
textarea { resize: vertical; }

button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(201, 79, 137, 0.28);
  outline-offset: 2px;
}

.page-glow {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .18;
  pointer-events: none;
  z-index: -1;
}
.page-glow-a { background: var(--yellow); top: -13rem; left: -12rem; }
.page-glow-b { background: var(--pink); right: -15rem; bottom: -15rem; }

.app-shell {
  width: min(1540px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  border-radius: 15px;
  background: linear-gradient(145deg, var(--pink-soft), var(--pink));
  box-shadow: 5px 5px 0 var(--ink);
  font-weight: 900;
  letter-spacing: -1px;
}
.brand strong { display: block; font-size: 1.08rem; letter-spacing: -.025em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: .76rem; }

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

.layout-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(18px);
}
.layout-option {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #6d6862;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.layout-option svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.layout-option:hover { color: var(--ink); background: rgba(0, 0, 0, .04); }
.layout-option.is-active { background: var(--ink); color: #fff; }
.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(18px);
  color: #4e4944;
  font-size: .83rem;
  font-weight: 700;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b3aea8;
  box-shadow: 0 0 0 4px rgba(179,174,168,.16);
}
.status-dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(63,159,118,.14); }
.status-dot.demo { background: #d99934; box-shadow: 0 0 0 4px rgba(217,153,52,.14); }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 4px rgba(198,92,97,.14); }

.icon-button,
.settings-button,
.mic-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.76);
  transition: transform .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
}
.icon-button { width: 42px; height: 42px; border-radius: 14px; }
.settings-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 13px;
  border-radius: 14px;
  font-size: .78rem;
  font-weight: 850;
}
.icon-button:hover, .settings-button:hover, .mic-button:hover { transform: translateY(-1px); border-color: var(--line-strong); background: #fff; }
.icon-button svg, .settings-button svg, .mic-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(450px, 1.05fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  position: relative;
  min-width: 0;
  min-height: 720px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(25px) saturate(1.08);
  overflow: hidden;
}

.avatar-panel { padding: 28px; }
.conversation-panel { display: flex; flex-direction: column; padding: 0; }

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.panel-heading h1,
.panel-heading h2,
.panel-heading h3 { margin: 0; letter-spacing: -.04em; line-height: 1.08; }
.panel-heading h1 { max-width: 560px; font-size: clamp(1.55rem, 2.25vw, 2.35rem); }
.panel-heading h2 { font-size: clamp(1.35rem, 1.8vw, 1.85rem); }
.panel-heading h3 { font-size: 1.12rem; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--pink-deep);
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .14em;
}
.mode-tag {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid rgba(201,79,137,.18);
  border-radius: 999px;
  background: var(--pink-soft);
  color: #8e3f65;
  font-size: .75rem;
  font-weight: 800;
}

.avatar-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 410px;
  padding: 22px 0 12px;
}
.avatar-halo {
  position: absolute;
  width: min(68%, 420px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,211,108,.36), rgba(236,143,186,.12) 55%, transparent 70%);
  filter: blur(8px);
  animation: haloPulse 5s ease-in-out infinite;
}
.avatar-art {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --gaze-x: 0px;
  --gaze-y: 0px;
  --speech-level: 0;
  --orb-a: #55c8f0;
  --orb-b: #8f7bf5;
  --orb-c: #f08fd0;
  --orb-base: #0b0e1e;
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 28px;
  background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--orb-base) 72%, var(--orb-a) 28%), var(--orb-base) 68%);
  box-shadow: 11px 12px 0 var(--ink), 0 28px 70px rgba(55,42,35,.18);
  overflow: hidden;
  transform-origin: 50% 85%;
  transform: perspective(900px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
  transition: transform .28s var(--ease), box-shadow .4s var(--ease);
  animation: idlePresence 7s ease-in-out infinite;
  isolation: isolate;
}
.avatar-art::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(150deg, rgba(255,255,255,.10), transparent 32%);
  z-index: 5;
}
.avatar-source-image { display: none; }

.orb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* state-tinted frame glow — the orb itself carries the real motion */
.avatar-art.talking {
  box-shadow: 11px 12px 0 var(--ink),
    0 30px 78px color-mix(in srgb, var(--orb-c) 34%, transparent),
    0 0 0 3px color-mix(in srgb, var(--orb-c) 26%, transparent);
}
.avatar-art.listening {
  box-shadow: 11px 12px 0 var(--ink),
    0 28px 72px color-mix(in srgb, var(--orb-b) 30%, transparent);
}
.avatar-art.thinking {
  box-shadow: 11px 12px 0 var(--ink),
    0 28px 72px color-mix(in srgb, var(--orb-a) 30%, transparent);
}

/* CSS-only fallback orb when WebGL is unavailable */
.orb-fallback { display: none; }
.avatar-art.orb-no-webgl .orb-fallback {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
}
.avatar-art.orb-no-webgl .orb-canvas { display: none; }
.orb-fallback-sphere {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 36% 30%, rgba(255,255,255,.55), transparent 26%),
    radial-gradient(circle at 62% 68%, color-mix(in srgb, var(--orb-b) 80%, transparent), transparent 62%),
    radial-gradient(circle at 42% 46%, color-mix(in srgb, var(--orb-a) 85%, transparent), color-mix(in srgb, var(--orb-base) 88%, var(--orb-b) 12%) 78%);
  box-shadow:
    0 0 60px color-mix(in srgb, var(--orb-a) 42%, transparent),
    inset -14px -18px 46px rgba(0,0,0,.5);
  animation: orbFallbackBreath 4.6s ease-in-out infinite;
}
.orb-fallback-mouth {
  position: absolute;
  left: 50%;
  top: 60.5%;
  width: 22%;
  height: 3px;
  border-radius: 99px;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--orb-c) 80%, white 20%);
  box-shadow: 0 0 14px var(--orb-c);
  opacity: .5;
}
.avatar-art.orb-no-webgl.talking .orb-fallback-mouth {
  animation: orbFallbackMouth .42s ease-in-out infinite alternate;
  opacity: 1;
}

/* live state chip on the orb panel */
.orb-state-chip {
  position: absolute;
  z-index: 7;
  left: 16px;
  top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(6,8,20,.5);
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,.86);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
}
.orb-state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orb-a);
  box-shadow: 0 0 10px var(--orb-a);
  transition: background .3s ease, box-shadow .3s ease;
}
.avatar-art.talking .orb-state-dot { background: var(--orb-c); box-shadow: 0 0 12px var(--orb-c); animation: orbDotPulse .5s ease-in-out infinite alternate; }
.avatar-art.listening .orb-state-dot { background: var(--orb-b); box-shadow: 0 0 12px var(--orb-b); animation: orbDotPulse 1.1s ease-in-out infinite alternate; }
.avatar-art.thinking .orb-state-dot { animation: orbDotPulse 1.6s ease-in-out infinite alternate; }

/* the uploaded source image, honored as a small specimen chip */
.source-chip {
  position: absolute;
  z-index: 7;
  left: 16px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 13px 6px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(6,8,20,.5);
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,.88);
  font-size: .74rem;
  font-weight: 700;
  max-width: 62%;
}
.source-chip img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid color-mix(in srgb, var(--orb-a) 70%, white 30%);
  box-shadow: 0 0 10px color-mix(in srgb, var(--orb-a) 55%, transparent);
}
.source-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-caption {
  min-height: 106px;
  margin-top: 5px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(140deg, rgba(255,255,255,.94), rgba(249,217,232,.46));
}

.realtime-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 0 14px;
  padding: 13px 14px;
  border: 1px solid rgba(201,79,137,.2);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(249,217,232,.58));
}
.realtime-copy, .realtime-actions { display: flex; align-items: center; gap: 10px; }
.realtime-copy { min-width: 0; }
.realtime-copy div { min-width: 0; }
.realtime-copy strong, .realtime-copy small { display: block; }
.realtime-copy strong { font-size: .86rem; }
.realtime-copy small { margin-top: 3px; color: var(--muted); font-size: .69rem; line-height: 1.35; }
.realtime-orb { flex: 0 0 auto; width: 11px; height: 11px; border-radius: 50%; background: #b7b0a9; box-shadow: 0 0 0 5px rgba(183,176,169,.14); }
.realtime-card.connecting .realtime-orb { background: #d99934; box-shadow: 0 0 0 5px rgba(217,153,52,.16); animation: orbPulse .8s ease-in-out infinite alternate; }
.realtime-card.connected .realtime-orb { background: var(--green); box-shadow: 0 0 0 5px rgba(63,159,118,.16); animation: orbPulse 1.2s ease-in-out infinite alternate; }
.realtime-card.error .realtime-orb { background: var(--red); box-shadow: 0 0 0 5px rgba(198,92,97,.14); }
.realtime-actions { flex: 0 0 auto; }
.realtime-voice-picker {
  display: inline-grid;
  grid-template-columns: auto minmax(86px, 116px);
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 4px 7px 4px 10px;
  border: 1px solid rgba(201,79,137,.24);
  border-radius: 12px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  font-size: .69rem;
  font-weight: 800;
}
.realtime-voice-picker select {
  width: 100%;
  min-width: 0;
  padding: 5px 22px 5px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
  outline: 0;
}
.realtime-voice-picker:focus-within { border-color: var(--pink-deep); box-shadow: 0 0 0 3px rgba(201,79,137,.12); }
.realtime-voice-picker:has(select:disabled) { opacity: .58; }
.realtime-button { min-width: 156px; }
.realtime-card.connected .realtime-button { background: #fff; }
.realtime-mute { min-width: 64px; }
.realtime-mute.is-muted { border-color: rgba(198,92,97,.35); background: #fff0f0; color: #8d343a; }
.caption-label {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 7px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: .65rem;
  font-weight: 900;
  letter-spacing: .1em;
}
.live-caption p { margin: 0; color: #403b37; font-size: 1.02rem; line-height: 1.58; }

.voice-controls {
  display: grid;
  grid-template-columns: auto auto minmax(155px, 1fr) minmax(150px, .9fr);
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}
.secondary-button,
.ghost-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  font-weight: 800;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.secondary-button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.82);
}
.secondary-button:hover:not(:disabled), .ghost-button:hover:not(:disabled) { transform: translateY(-1px); background: #fff; }
.secondary-button:disabled { cursor: not-allowed; opacity: .46; }
.secondary-button svg,
.primary-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.voice-select-label,
.rate-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}
.voice-select-label small { color: #9a4a70; font-size: .62rem; font-weight: 750; }
.voice-select-label select {
  width: 100%;
  min-height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.84);
  color: var(--ink);
}
.rate-control > span { display: flex; justify-content: space-between; }
.rate-control input { width: 100%; accent-color: var(--pink-deep); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.54);
}
.tab-button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 800;
}
.tab-button:hover { background: rgba(255,255,255,.7); color: var(--ink); }
.tab-button.is-active { background: var(--ink); color: #fff; box-shadow: 0 7px 18px rgba(24,23,22,.15); }

.tab-view { display: none; min-height: 0; }
.tab-view.is-active { display: flex; flex-direction: column; flex: 1; }
#chatView { padding: 24px; }
#profileView { padding: 24px; overflow: auto; }
.chat-heading { align-items: center; }
.profile-heading { margin-bottom: 18px; }
.profile-heading-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
/* A second save button sits in the heading so the pair can be applied without
   scrolling past the glossary. */
.compact-save {
  min-height: 38px;
  padding: 0 14px;
  font-size: .78rem;
  white-space: nowrap;
}
.compact-save svg { width: 16px; height: 16px; }

.switch-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; font-weight: 800; white-space: nowrap; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: #cbc5be;
  transition: .2s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.22);
  transition: .2s var(--ease);
}
.switch-label input:checked + .switch { background: var(--pink-deep); }
.switch-label input:checked + .switch::after { transform: translateX(17px); }

.chat-log {
  flex: 1;
  min-height: 310px;
  max-height: 430px;
  margin: 20px -6px 0 0;
  padding: 0 10px 12px 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  animation: messageIn .35s var(--ease) both;
}
.message-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  background: var(--pink-soft);
  font-size: .7rem;
  font-weight: 900;
}
.message-body {
  max-width: min(86%, 600px);
  padding: 13px 15px 11px;
  border: 1px solid var(--line);
  border-radius: 8px 18px 18px 18px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 20px rgba(55,42,35,.05);
}
.message-body p { margin: 0; white-space: pre-wrap; line-height: 1.58; overflow-wrap: anywhere; }
.message-meta { display: block; margin-top: 7px; color: #938b84; font-size: .67rem; }
.user-message { flex-direction: row-reverse; }
.user-message .message-avatar { background: var(--yellow); }
.user-message .message-body {
  border-radius: 18px 8px 18px 18px;
  background: var(--ink);
  color: #fff;
}
.user-message .message-meta { color: rgba(255,255,255,.58); text-align: right; }
.message.error-message .message-body { border-color: rgba(198,92,97,.32); background: #fff2f2; color: #7f3338; }
.typing-dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: #837b74; animation: dotPulse .9s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .14s; }
.typing-dots span:nth-child(3) { animation-delay: .28s; }

.prompt-chips { display: flex; gap: 7px; flex-wrap: wrap; margin: 8px 0 12px; }
.prompt-chips button {
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.68);
  color: #5e5752;
  font-size: .72rem;
  font-weight: 700;
}
.prompt-chips button:hover { border-color: rgba(201,79,137,.28); background: var(--pink-soft); color: #813b5c; }

.composer {
  padding: 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 20px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 13px 34px rgba(55,42,35,.08);
}
.composer:focus-within { border-color: rgba(201,79,137,.52); box-shadow: 0 0 0 4px rgba(201,79,137,.09), 0 13px 34px rgba(55,42,35,.08); }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: 180px;
  padding: 2px 4px 9px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.5;
}
.composer textarea::placeholder { color: #aaa29b; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.composer-left span { color: #8a827b; font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mic-button { width: 38px; height: 38px; border-radius: 12px; }
.mic-button.is-listening { border-color: var(--pink-deep); background: var(--pink-soft); color: var(--pink-deep); animation: micPulse 1.1s ease-out infinite; }
.mic-button:disabled { cursor: not-allowed; opacity: .38; }
.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border: 2px solid var(--ink);
  background: var(--pink);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  white-space: nowrap;
}
.primary-button:hover:not(:disabled) { transform: translate(-1px,-1px); box-shadow: 6px 6px 0 var(--ink); }
.primary-button:active:not(:disabled) { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }
.primary-button:disabled { cursor: wait; opacity: .58; }

.profile-grid { display: grid; gap: 16px; }
.field-block { display: grid; gap: 6px; }
.field-title { font-weight: 900; letter-spacing: -.01em; }
.field-help { color: var(--muted); font-size: .73rem; line-height: 1.45; }
.field-block textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(255,255,255,.84);
  color: var(--ink);
  line-height: 1.55;
  tab-size: 2;
}
.field-block textarea:focus { border-color: rgba(201,79,137,.5); background: #fff; }
.profile-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.ghost-button { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); background: rgba(255,255,255,.54); }
.save-state { color: var(--muted); font-size: .73rem; font-weight: 800; }
.save-state.saved { color: var(--green); }
.save-state.dirty { color: #b27620; }

/* --- 即席口譯設定 -------------------------------------------------------- */
.lang-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid rgba(201,79,137,.22);
  border-radius: 20px;
  background: linear-gradient(140deg, rgba(255,255,255,.9), rgba(249,217,232,.5));
}
.lang-slot { display: grid; gap: 7px; min-width: 0; }
.lang-slot select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}
.lang-slot select:focus { border-color: rgba(201,79,137,.5); outline: none; }
.swap-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(201,79,137,.3);
  border-radius: 999px;
  background: #fff;
  color: var(--pink-deep);
  cursor: pointer;
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.swap-button:hover { transform: rotate(180deg); background: var(--pink-soft); }
.swap-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lang-pair-hint { margin: 10px 2px 18px; color: var(--muted); font-size: .76rem; line-height: 1.5; }

.interpreter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
  margin-bottom: 16px;
}
.interpreter-grid input,
.interpreter-grid select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(255,255,255,.84);
  color: var(--ink);
}
.interpreter-grid input:focus,
.interpreter-grid select:focus { border-color: rgba(201,79,137,.5); background: #fff; outline: none; }

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.6);
  cursor: pointer;
}
.toggle-row input { margin-top: 3px; accent-color: var(--pink-deep); }
.toggle-row span { display: grid; gap: 3px; }
.toggle-row strong { font-size: .88rem; }
.toggle-row small { color: var(--muted); font-size: .72rem; line-height: 1.45; }

.prompt-preview {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.52);
}
.prompt-preview summary { cursor: pointer; font-size: .8rem; font-weight: 800; color: var(--muted); }
.prompt-preview summary:hover { color: var(--ink); }
.prompt-preview .field-help { margin: 10px 0; }
.prompt-preview textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  font-size: .82rem;
  line-height: 1.55;
}
.preview-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.caption-source {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.5;
  font-style: italic;
}
.pair-tag { font-variant-numeric: tabular-nums; }

@media (max-width: 620px) {
  .lang-pair { grid-template-columns: minmax(0, 1fr); }
  .swap-button { justify-self: center; }
  .swap-button:hover { transform: rotate(90deg); }
}

/* --- API Key 風險說明與申請教學 ------------------------------------------ */
.key-notice {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  margin: -4px 0 4px;
}
.key-risk,
.key-howto {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.66);
  padding: 12px 14px;
}
.key-risk {
  border-color: rgba(198,92,97,.34);
  background: linear-gradient(140deg, rgba(255,255,255,.9), rgba(198,92,97,.1));
}
.key-risk > summary,
.key-howto > summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: -.01em;
  list-style: none;
}
.key-risk > summary::-webkit-details-marker,
.key-howto > summary::-webkit-details-marker { display: none; }
.key-risk > summary { color: #a8474c; }
.key-howto > summary { color: var(--muted); }
.key-howto > summary:hover { color: var(--ink); }
.key-risk > summary span,
.key-howto > summary span { margin-right: 6px; }

.key-risk ul,
.key-howto ol {
  margin: 11px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 7px;
  color: #4a4340;
  font-size: .76rem;
  line-height: 1.6;
}
.key-risk li strong { color: #a8474c; }
.key-howto li strong { font-weight: 900; }
.key-howto li em { color: var(--muted); font-style: normal; }
.key-howto code,
.key-howto-foot code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(24,23,22,.07);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
}
.key-howto-foot {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: .73rem;
  line-height: 1.55;
}

.engine-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px 28px;
  margin-top: 18px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(140deg, rgba(255,255,255,.82), rgba(255,211,108,.2));
}
.engine-card dl { display: grid; gap: 8px; margin: 0; }
.engine-card dl div { display: grid; grid-template-columns: 78px minmax(0,1fr); gap: 8px; }
.engine-card dt { color: var(--muted); font-size: .73rem; font-weight: 800; }
.engine-card dd { margin: 0; font-size: .8rem; font-weight: 800; overflow-wrap: anywhere; }
.engine-card > p { grid-column: 1 / -1; margin: -4px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.55; }

.footer-note {
  display: flex;
  justify-content: center;
  gap: 9px;
  padding: 15px 0 0;
  color: #8d857e;
  font-size: .72rem;
}
.footer-link {
  color: inherit;
  font-weight: 800;
  text-decoration: none;
  border-bottom: 1px solid rgba(141,133,126,.42);
  padding-bottom: 1px;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.footer-link:hover,
.footer-link:focus-visible { color: var(--pink-deep); border-bottom-color: var(--pink-deep); }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  max-width: min(92vw, 520px);
  padding: 11px 15px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 14px;
  background: rgba(24,23,22,.92);
  color: #fff;
  box-shadow: 0 14px 40px rgba(0,0,0,.22);
  opacity: 0;
  transform: translate(-50%, 18px);
  pointer-events: none;
  transition: .25s var(--ease);
  font-size: .82rem;
}
.toast.show { opacity: 1; transform: translate(-50%,0); }

.settings-dialog {
  width: min(92vw, 690px);
  max-height: min(90vh, 820px);
  padding: 0;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 26px;
  background: rgba(255,253,249,.98);
  color: var(--ink);
  box-shadow: 0 34px 110px rgba(31,24,20,.32);
  overflow: auto;
}
.settings-dialog::backdrop { background: rgba(40,31,26,.42); backdrop-filter: blur(8px); }
.settings-form { padding: 26px; }
.settings-heading { display: flex; justify-content: space-between; gap: 20px; }
.settings-heading h2 { margin: 0; font-size: 1.65rem; letter-spacing: -.035em; }
.settings-heading p:not(.eyebrow) { max-width: 520px; margin: 8px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.dialog-close { flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 1.5rem; line-height: 1; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.settings-field { display: grid; gap: 7px; color: var(--ink); font-size: .77rem; font-weight: 850; }
.settings-field > input, .settings-field > select, .input-with-action {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}
.settings-field > input, .settings-field > select { padding: 0 12px; }
.settings-field small { color: var(--muted); font-size: .67rem; font-weight: 600; line-height: 1.45; }
.api-key-field { grid-column: 1 / -1; }
.microphone-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 46px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
}
.microphone-setting:focus-within { border-color: rgba(201,79,137,.5); box-shadow: 0 0 0 3px rgba(201,79,137,.1); }
.microphone-setting select {
  min-width: 0;
  padding: 0 10px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: .76rem;
  font-weight: 750;
}
.microphone-setting button {
  min-width: 82px;
  padding: 0 11px;
  border: 0;
  border-left: 1px solid var(--line);
  background: #f8f3ee;
  color: #625a54;
  font-size: .7rem;
  font-weight: 800;
}
.microphone-setting button:hover:not(:disabled) { background: var(--pink-soft); }
.microphone-setting select:disabled,
.microphone-setting button:disabled { cursor: not-allowed; opacity: .55; }
.input-with-action { display: flex; overflow: hidden; }
.input-with-action input { min-width: 0; flex: 1; padding: 0 12px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.input-with-action button { min-width: 64px; border: 0; border-left: 1px solid var(--line); background: #f8f3ee; color: #625a54; font-size: .72rem; font-weight: 800; }
.settings-notice { display: flex; gap: 10px; margin-top: 18px; padding: 12px 13px; border-radius: 14px; background: rgba(255,211,108,.24); color: #665124; font-size: .72rem; line-height: 1.45; }
.settings-notice strong { flex: 0 0 auto; }
.settings-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 21px; }
.danger-button { color: #9a4147; }

.avatar-settings-section {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(255,255,255,.88), rgba(249,217,232,.28));
}
.avatar-settings-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.avatar-settings-heading h3 { margin: 0; font-size: 1.15rem; letter-spacing: -.025em; }
.avatar-settings-heading p:not(.eyebrow) { margin: 5px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.avatar-save-state { flex: 0 0 auto; color: var(--muted); font-size: .67rem; font-weight: 800; }
.avatar-save-state.saved { color: var(--green); }
.avatar-save-state.dirty { color: #ad7020; }
.avatar-editor-grid { display: grid; grid-template-columns: 210px 1fr; gap: 18px; margin-top: 15px; }
.avatar-preview-column { min-width: 0; }
.avatar-preview-frame {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 48%, rgba(105, 85, 181, .26), transparent 42%),
    linear-gradient(150deg, #090b18, #161329 58%, #090b18);
  box-shadow: 5px 5px 0 var(--ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
  outline: none;
}
.avatar-preview-frame:hover,
.avatar-preview-frame:focus-visible { box-shadow: 5px 5px 0 var(--ink), 0 0 0 3px rgba(143,123,245,.28); }
.avatar-preview-frame.is-dragging { cursor: grabbing; }
.essence-preview-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.preview-orbit-line {
  position: absolute;
  inset: 14%;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  pointer-events: none;
}
.preview-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%;
  transform: translate(-50%,-50%);
  opacity: 0;
  transition: opacity .18s var(--ease);
  pointer-events: none;
}
.preview-crosshair::before,
.preview-crosshair::after { content: ""; position: absolute; background: rgba(255,255,255,.35); }
.preview-crosshair::before { left: 50%; top: -7px; width: 1px; height: 30px; }
.preview-crosshair::after { top: 50%; left: -7px; width: 30px; height: 1px; }
.avatar-preview-frame:hover .preview-crosshair,
.avatar-preview-frame:focus-visible .preview-crosshair,
.avatar-preview-frame.is-dragging .preview-crosshair { opacity: 1; }
.preview-drag-hint {
  position: absolute;
  left: 50%;
  bottom: 11px;
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(7,8,19,.62);
  color: rgba(255,255,255,.72);
  font-size: .57rem;
  font-weight: 850;
  letter-spacing: .05em;
  transform: translateX(-50%);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.preview-status-row { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-top: 11px; }
.preview-status-row span { color: #7651a8; font-size: .54rem; font-weight: 950; letter-spacing: .1em; }
.preview-status-row span i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: #65d6b1; box-shadow: 0 0 8px #65d6b1; }
.preview-status-row strong { color: var(--muted); font-size: .59rem; }
.avatar-editor-controls { display: grid; gap: 11px; min-width: 0; }
.avatar-file-button { position: relative; display: grid; }
.avatar-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.avatar-file-button span {
  display: grid;
  place-items: center;
  min-height: 43px;
  border: 1px dashed rgba(201,79,137,.5);
  border-radius: 13px;
  background: rgba(249,217,232,.45);
  color: #8b3c61;
  font-size: .76rem;
  font-weight: 850;
  cursor: pointer;
}
.avatar-file-button:hover span { border-style: solid; background: var(--pink-soft); }
.avatar-settings-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.avatar-framing-block {
  display: grid;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid rgba(31,28,48,.16);
  border-radius: 14px;
  background: rgba(255,255,255,.66);
}
.avatar-framing-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); font-size: .7rem; font-weight: 900; }
.avatar-framing-head output { color: #7651a8; font-variant-numeric: tabular-nums; }
.avatar-zoom-control { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 8px; color: var(--muted); font-size: .66rem; font-weight: 800; }
.avatar-zoom-control input { width: 100%; accent-color: #7651a8; cursor: ew-resize; }
.avatar-opacity-control { grid-template-columns: 48px 1fr 40px; }
.avatar-opacity-control output { color: #7651a8; text-align: right; font-variant-numeric: tabular-nums; }
.avatar-framing-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-framing-actions button { min-height: 34px; padding: 0 11px; font-size: .65rem; }
.avatar-framing-block small { color: var(--muted); font-size: .62rem; line-height: 1.45; }

.orb-palette-block {
  display: grid;
  gap: 7px;
  padding: 12px 14px;
  border: 1px solid rgba(132, 88, 197, .28);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(240, 232, 255, .82), rgba(255, 240, 247, .72));
}
.orb-palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.orb-palette-title { color: #7651a8; font-size: .62rem; font-weight: 950; letter-spacing: .12em; }
.orb-color-mode-toggle { font-size: .7rem; font-weight: 800; color: #6d5588; }

.orb-candidate-row { display: flex; gap: 7px; flex-wrap: wrap; min-height: 26px; }
.orb-candidate-row button {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(24,20,17,.75);
  box-shadow: 1.5px 1.5px 0 rgba(24,20,17,.4);
  cursor: pointer;
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}
.orb-candidate-row button:hover { transform: translateY(-2px) scale(1.08); box-shadow: 2px 3px 0 rgba(24,20,17,.42); }
.orb-candidate-row button:active { transform: scale(.96); }

.orb-color-inputs { display: flex; gap: 14px; flex-wrap: wrap; }
.orb-color-input {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
}
.orb-color-input input {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(24,20,17,.5);
}
.orb-color-input input:disabled { cursor: default; opacity: .55; box-shadow: none; }
.orb-color-input input::-webkit-color-swatch-wrapper { padding: 2px; }
.orb-color-input input::-webkit-color-swatch { border: none; border-radius: 50%; }
.orb-palette-block small { margin: 0; color: var(--muted); font-size: .66rem; line-height: 1.45; }
.avatar-library-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 6px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, .55);
}
.avatar-library-select-field { flex: 1 1 240px; min-width: 200px; }
.avatar-library-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Layout modes: default | focus (avatar centred) | cinema (fullscreen) ---- */

/* Focus: hide the conversation panel and centre a larger avatar. */
body[data-layout="focus"] .conversation-panel { display: none; }
body[data-layout="focus"] .workspace {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}
body[data-layout="focus"] .avatar-panel {
  width: min(100%, 760px);
}
body[data-layout="focus"] .avatar-art { width: min(100%, 620px); }

/* Cinema: nothing but the avatar frame, centred on a black background. Esc exits. */
body[data-layout="cinema"] {
  overflow: hidden;
  background: #000;
}
body[data-layout="cinema"] .page-glow { display: none; }
body[data-layout="cinema"] .app-shell {
  width: 100%;
  max-width: none;
  padding: 0;
}
body[data-layout="cinema"] .topbar,
body[data-layout="cinema"] .footer-note,
body[data-layout="cinema"] .conversation-panel,
body[data-layout="cinema"] .compact-heading,
body[data-layout="cinema"] .realtime-card,
body[data-layout="cinema"] .live-caption,
body[data-layout="cinema"] .voice-controls,
body[data-layout="cinema"] .avatar-halo { display: none; }
body[data-layout="cinema"] .workspace {
  display: block;
  height: 100vh;
  height: 100dvh;
  gap: 0;
}
body[data-layout="cinema"] .avatar-panel {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  backdrop-filter: none;
  display: flex;
  justify-content: center;
  align-items: center;
}
body[data-layout="cinema"] .avatar-zone {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
}
body[data-layout="cinema"] .avatar-art {
  width: min(92vw, 82vh);
  width: min(92vw, 82dvh);
}

/* The exit affordance for cinema. Deliberately always visible — a button that
   fades out is exactly how people get stranded here on a touch screen. The
   safe-area insets keep it clear of the Dynamic Island and the display corners. */
.cinema-exit { display: none; }
body[data-layout="cinema"] .cinema-exit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: fixed;
  z-index: 50;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  min-width: 44px;
  min-height: 44px;          /* Apple HIG minimum touch target */
  padding: 0 16px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  background: rgba(20,18,17,.55);
  color: #fff;
  font: inherit;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: -.01em;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
body[data-layout="cinema"] .cinema-exit:hover,
body[data-layout="cinema"] .cinema-exit:focus-visible {
  background: rgba(20,18,17,.78);
  border-color: rgba(255,255,255,.5);
}
.cinema-exit svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only,
.sr-only:focus:not(:focus-visible) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes haloPulse { 0%,100%{transform:scale(.96);opacity:.72} 50%{transform:scale(1.05);opacity:1} }
@keyframes idlePresence { 0%,100%{transform:perspective(900px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x)) translateY(0) scale(1)} 48%{transform:perspective(900px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x)) translateY(-2px) scale(1.002)} 52%{transform:perspective(900px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x)) translateY(-2px) scale(1.002)} }
@keyframes orbFallbackBreath { 0%,100%{transform:translate(-50%,-50%) scale(1)} 50%{transform:translate(-50%,-50%) scale(1.035)} }
@keyframes orbFallbackMouth { from{height:3px;opacity:.75} to{height:14px;opacity:1} }
@keyframes orbDotPulse { from{opacity:.55} to{opacity:1} }
@keyframes orbPulse { from{transform:scale(.82);opacity:.72} to{transform:scale(1.08);opacity:1} }
@keyframes messageIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes dotPulse { 0%,100%{opacity:.35;transform:translateY(0)} 50%{opacity:1;transform:translateY(-3px)} }
@keyframes micPulse { 0%{box-shadow:0 0 0 0 rgba(201,79,137,.25)} 100%{box-shadow:0 0 0 12px rgba(201,79,137,0)} }
@keyframes avatarProgressFlow { to { transform: translateX(24px); } }
@keyframes progressStatusPulse { 70%,100% { box-shadow: 0 0 0 7px rgba(214,139,48,0); } }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 1fr; }
  .panel { min-height: auto; }
  .avatar-panel { min-height: 720px; }
  .conversation-panel { min-height: 720px; }
  .avatar-zone { min-height: 430px; }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 1540px); padding-top: 12px; }
  .brand small { display: none; }
  .settings-button span { display: none; }
  .settings-button { width: 42px; padding: 0; justify-content: center; }
  .engine-pill { max-width: 150px; }
  #engineLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .avatar-panel, #chatView, #profileView { padding: 18px; }
  .panel { border-radius: 23px; }
  .compact-heading { display: block; }
  .mode-tag { display: inline-flex; margin-top: 12px; }
  .avatar-zone { min-height: 330px; padding-top: 18px; }
  .avatar-art { border-radius: 22px; box-shadow: 8px 9px 0 var(--ink), 0 22px 55px rgba(55,42,35,.16); }
  .voice-controls { grid-template-columns: 1fr 1fr; }
  .voice-select-label, .rate-control { grid-column: span 1; }
  .chat-heading, .profile-heading { display: block; }
  .switch-label { margin-top: 13px; }
  .chat-log { max-height: 390px; }
  .message-body { max-width: 88%; }
  .engine-card { grid-template-columns: 1fr; }
  .engine-card > p { grid-column: auto; }
  .profile-actions { align-items: stretch; flex-direction: column-reverse; }
  .footer-note { flex-wrap: wrap; text-align: center; }
  .profile-heading { display: block; }
  .profile-heading-actions { justify-content: space-between; margin-top: 12px; }
  .realtime-card { align-items: stretch; flex-direction: column; }
  .realtime-actions { justify-content: flex-end; flex-wrap: wrap; }
  .realtime-voice-picker { margin-right: auto; }
  .realtime-button { flex: 1; }
  .settings-form { padding: 21px; }
  .settings-grid { grid-template-columns: 1fr; }
  .api-key-field { grid-column: auto; }
  .settings-actions { align-items: stretch; flex-direction: column-reverse; }
  .avatar-settings-heading { display: block; }
  .avatar-save-state { display: inline-block; margin-top: 8px; }
  .avatar-editor-grid { grid-template-columns: 1fr; }
  .avatar-preview-column { width: min(68vw, 240px); margin: 0 auto; }
  .avatar-library-bar { flex-direction: column; align-items: stretch; }
  .avatar-library-actions { justify-content: flex-end; }
  .avatar-settings-actions { align-items: stretch; flex-direction: column-reverse; }
}

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