:root {
  color-scheme: dark;
  --bg: #090b0e;
  --panel: #101318;
  --panel-raised: #171b21;
  --panel-soft: #1d222a;
  --line: #292f38;
  --line-strong: #39414d;
  --text: #f4f5f7;
  --muted: #9da6b3;
  --faint: #68717d;
  --accent: #86efac;
  --accent-strong: #4ade80;
  --accent-ink: #092313;
  --blue: #80bfff;
  --danger: #fb7185;
  --warning: #fbbf24;
  --radius: 18px;
  --shadow: 0 20px 70px rgb(0 0 0 / 34%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}

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

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

button {
  border: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

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

.simulator-shell {
  min-height: 100vh;
}

.sim-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgb(9 11 14 / 92%);
  backdrop-filter: blur(18px);
}

.brand-link {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-link > span:last-child {
  display: grid;
  gap: 2px;
}

.brand-link strong {
  font-size: 16px;
  font-weight: 680;
  letter-spacing: 0.01em;
}

.brand-link small {
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #3b4a40;
  border-radius: 12px;
  background: #16231b;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 20px;
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.resolution-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.resolution-switch button {
  min-width: 54px;
  padding: 7px 12px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.resolution-switch button.active {
  background: var(--panel-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.server-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.server-pill i,
.screen-state i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.server-pill.online i,
.screen-state.online i {
  background: var(--accent-strong);
  box-shadow: 0 0 9px rgb(74 222 128 / 70%);
}

.server-pill.offline i,
.screen-state.error i {
  background: var(--danger);
}

.server-pill.checking i {
  animation: pulse 1.2s infinite;
  background: var(--warning);
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease,
    transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button.connect,
.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button.connect.connected {
  border-color: #3f4853;
  background: var(--panel-soft);
  color: var(--text);
}

.button.ghost {
  border-color: var(--line-strong);
  background: var(--panel-soft);
  color: var(--text);
}

.button.danger {
  border-color: rgb(251 113 133 / 35%);
  background: rgb(251 113 133 / 10%);
  color: #fda4af;
}

.button.full {
  width: 100%;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.sim-layout {
  display: grid;
  min-height: calc(100vh - 84px);
  grid-template-columns: 230px minmax(430px, 1fr) minmax(390px, 430px);
}

@media (min-width: 981px) {
  .simulator-shell {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .sim-layout {
    height: calc(100vh - 84px);
    height: calc(100dvh - 84px);
    min-height: 0;
  }

  .role-panel,
  .stage-panel {
    min-height: 0;
    overflow-y: auto;
  }

  .conversation-panel {
    height: 100%;
    overflow: hidden;
  }
}

.role-panel,
.conversation-panel {
  min-width: 0;
  background: var(--panel);
}

.role-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line);
}

.panel-heading,
.dock-heading,
.section-heading,
.modal-heading,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
  font-weight: 690;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 18px;
}

.role-list {
  display: grid;
  gap: 8px;
  overflow: auto;
}

.role-card {
  display: grid;
  width: 100%;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.role-card:hover {
  background: var(--panel-raised);
}

.role-card.active {
  border-color: #405348;
  background: #17221b;
}

.role-thumb {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #090b0e;
  color: var(--faint);
  font-family: Georgia, serif;
  font-size: 19px;
}

.role-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.role-card-text {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.role-card-text strong,
.role-card-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-card-text strong {
  font-size: 14px;
}

.role-card-text span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.role-summary {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d1014;
}

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

.role-summary strong {
  margin-bottom: 3px;
  font-size: 15px;
}

.role-summary span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.role-summary > p:last-child {
  display: -webkit-box;
  overflow: hidden;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.resource-link {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  margin-top: auto;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
}

.resource-link span {
  font-size: 13px;
  font-weight: 700;
}

.resource-link small {
  grid-column: 1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.resource-link b {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--faint);
}

.stage-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: clamp(24px, 4vh, 46px) clamp(20px, 4vw, 58px) 26px;
  background: #0b0e12;
}

.device-frame {
  position: relative;
  width: min(56vh, 540px, 100%);
  aspect-ratio: 1;
  padding: clamp(11px, 1.6vw, 18px);
  border: 1px solid #353b44;
  border-radius: 50%;
  background: #161a1f;
  box-shadow: 0 34px 90px rgb(0 0 0 / 48%), inset 0 0 0 5px #0d1013;
}

.device-frame::before {
  position: absolute;
  z-index: 2;
  top: 8%;
  left: 20%;
  width: 35%;
  height: 4%;
  border-radius: 50%;
  background: rgb(255 255 255 / 5%);
  content: "";
  filter: blur(7px);
  transform: rotate(-16deg);
}

.device-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid #050607;
  border-radius: 50%;
  background: #030405;
}

.device-screen > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screen-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 22%;
  color: var(--muted);
  text-align: center;
}

.screen-empty span {
  margin-bottom: 10px;
  color: var(--line-strong);
  font-size: 52px;
}

.screen-empty p {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.5;
}

.screen-vignette {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 50px rgb(0 0 0 / 62%);
  pointer-events: none;
}

.screen-topline {
  position: absolute;
  z-index: 3;
  top: 11%;
  right: 16%;
  left: 16%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgb(255 255 255 / 72%);
  font-size: clamp(9px, 1vw, 11px);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 5px #000;
}

.screen-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.device-frame.connected .screen-state i {
  background: var(--accent-strong);
  box-shadow: 0 0 9px rgb(74 222 128 / 80%);
}

.device-frame.recording .screen-state i {
  animation: pulse 0.7s infinite;
  background: var(--danger);
  box-shadow: 0 0 9px rgb(251 113 133 / 80%);
}

.device-frame.speaking .screen-state i {
  animation: pulse 0.9s infinite;
  background: var(--blue);
  box-shadow: 0 0 9px rgb(128 191 255 / 80%);
}

.subtitle {
  position: absolute;
  z-index: 3;
  right: 13%;
  bottom: 13%;
  left: 13%;
  max-height: 4.7em;
  overflow: hidden;
  padding: 9px 13px;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 12px;
  background: rgb(6 8 10 / 70%);
  color: #fff;
  font-size: clamp(11px, 1.15vw, 14px);
  line-height: 1.55;
  text-align: center;
  text-shadow: 0 1px 4px #000;
  backdrop-filter: blur(8px);
}

.voice-wave {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: 24%;
  left: 0;
  display: flex;
  height: 28px;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.voice-wave i {
  width: 3px;
  height: 8px;
  border-radius: 4px;
  background: var(--accent);
  animation: wave 0.8s ease-in-out infinite alternate;
}

.voice-wave i:nth-child(2),
.voice-wave i:nth-child(4) {
  animation-delay: -0.3s;
}

.voice-wave i:nth-child(3) {
  animation-delay: -0.55s;
}

.device-frame.speaking .voice-wave i {
  background: var(--blue);
}

.frame-label {
  position: absolute;
  bottom: -26px;
  left: 50%;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.13em;
  white-space: nowrap;
  transform: translateX(-50%);
}

.expression-dock {
  width: min(680px, 100%);
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.dock-heading {
  margin-bottom: 12px;
}

.dock-heading h2 {
  font-size: 15px;
}

.dock-heading > span {
  color: var(--muted);
  font-size: 11px;
}

.expression-list {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: thin;
}

.expression-chip {
  position: relative;
  display: grid;
  min-width: 76px;
  grid-template-rows: 58px auto;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: pointer;
}

.expression-chip:hover,
.expression-chip.active {
  border-color: #52665a;
  color: var(--text);
}

.expression-chip.active {
  background: #17221b;
  box-shadow: inset 0 -2px var(--accent-strong);
}

.expression-chip img {
  width: 100%;
  height: 58px;
  border-radius: 8px;
  background: #080a0c;
  object-fit: cover;
}

.expression-chip span {
  overflow: hidden;
  padding: 0 2px 2px;
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.conversation-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 11px 16px 0;
  border-bottom: 1px solid var(--line);
}

.conversation-tabs button {
  position: relative;
  padding: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.conversation-tabs button.active {
  color: var(--text);
}

.conversation-tabs button.active::after {
  position: absolute;
  right: 22%;
  bottom: -1px;
  left: 22%;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  content: "";
}

.conversation-view,
.settings-view {
  min-height: 0;
  flex: 1;
}

.conversation-view {
  display: flex;
  overflow: hidden;
  flex-direction: column;
}

.chat-header {
  padding: 20px 20px 14px;
}

.chat-header h2 {
  margin-bottom: 4px;
}

.chat-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.message-list {
  display: flex;
  min-height: 0;
  flex: 1 1 0;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  padding: 8px 20px 22px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.message-list::-webkit-scrollbar {
  width: 8px;
}

.message-list::-webkit-scrollbar-track {
  background: transparent;
}

.message-list::-webkit-scrollbar-thumb {
  border: 2px solid var(--panel);
  border-radius: 8px;
  background: var(--line-strong);
}

.message-list::-webkit-scrollbar-thumb:hover {
  background: var(--faint);
}

.welcome-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d1014;
}

.welcome-card > span {
  color: var(--accent);
}

.welcome-card strong {
  font-size: 13px;
}

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

.message {
  display: grid;
  max-width: 88%;
  gap: 4px;
}

.message.user {
  align-self: flex-end;
  justify-items: end;
}

.message.assistant,
.message.system {
  align-self: flex-start;
}

.message-bubble {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  background: var(--panel-raised);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user .message-bubble {
  border-color: #42614e;
  border-radius: 14px 14px 4px;
  background: #193021;
}

.message.system .message-bubble {
  border-style: dashed;
  color: var(--muted);
  font-size: 12px;
}

.message-meta {
  color: var(--faint);
  font-size: 10px;
}

.composer {
  display: grid;
  gap: 10px;
  margin: 0 16px;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: #0c0f13;
}

.composer:focus-within {
  border-color: #4c6455;
}

.composer textarea {
  width: 100%;
  min-height: 50px;
  max-height: 150px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mic-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.mic-button.recording {
  background: rgb(251 113 133 / 14%);
  color: #fda4af;
}

.mic-icon {
  position: relative;
  width: 10px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.mic-icon::after {
  position: absolute;
  right: -5px;
  bottom: -5px;
  left: -5px;
  height: 7px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  content: "";
}

.send-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-size: 20px;
  font-weight: 800;
}

.mic-button:disabled,
.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.composer-note {
  margin: 8px 19px 14px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.45;
}

.settings-view {
  overflow: hidden;
}

.settings-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 18px 18px 34px;
}

.settings-section {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #0d1014;
}

.section-heading {
  margin-bottom: 15px;
}

.section-heading > span {
  color: var(--muted);
  font-size: 11px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field > span,
.check-field {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

.help-control {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.help-tip {
  display: inline-grid;
  width: 18px;
  height: 18px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  outline: 0;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: help;
  font: 700 11px/1 system-ui, sans-serif;
}

.help-tip:hover,
.help-tip:focus-visible {
  border-color: #678273;
  color: var(--text);
}

.help-popover {
  position: absolute;
  z-index: 20;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(260px, calc(100vw - 44px));
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  visibility: hidden;
  background: #191e23;
  box-shadow: 0 12px 30px rgb(0 0 0 / 38%);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.55;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

.help-control:hover .help-popover,
.help-control:focus-within .help-popover {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  background: #090c0f;
  color: var(--text);
  font-size: 13px;
}

.field input,
.field select {
  min-height: 40px;
  padding: 0 11px;
}

.field textarea {
  padding: 10px 11px;
  line-height: 1.55;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #5b7765;
}

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

.range-control {
  display: grid;
  min-height: 40px;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #090c0f;
}

.range-control input[type="range"] {
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent-strong);
}

.range-control output {
  overflow: hidden;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-performance-note {
  margin-bottom: 0;
}

@media (max-width: 520px) {
  .voice-tuning-grid {
    grid-template-columns: 1fr;
  }
}

.prompt-field textarea {
  min-height: 230px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.field-help {
  margin: -2px 0 14px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.55;
}

.field-help code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.voice-field-help {
  margin-top: -7px;
  margin-bottom: 12px;
}

.base-prompt-section {
  margin-bottom: 0;
}

.base-prompt-section .prompt-field textarea {
  min-height: clamp(380px, 58vh, 680px);
}

.scope-note {
  margin-bottom: 14px;
  padding: 12px 13px;
  border: 1px solid #405348;
  border-radius: 11px;
  background: #111d16;
}

.scope-note strong {
  color: var(--accent);
  font-size: 12px;
}

.scope-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.knowledge-settings-section {
  margin-bottom: 14px;
}

.knowledge-scope-note span {
  color: var(--text);
}

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

.knowledge-actions .button {
  min-width: 0;
}

.knowledge-compact-list {
  max-height: 360px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
}

.knowledge-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.knowledge-row.disabled {
  opacity: 0.58;
}

.knowledge-row-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.knowledge-row-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.knowledge-row-title strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-state {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid rgb(118 211 155 / 30%);
  border-radius: 6px;
  background: rgb(118 211 155 / 7%);
  color: var(--success);
  font-size: 9px;
  font-weight: 700;
}

.knowledge-state.off {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--faint);
}

.knowledge-row-meta {
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-row-actions {
  display: flex;
  gap: 5px;
}

.knowledge-empty,
.knowledge-unavailable {
  margin: 0;
  padding: 18px 4px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
}

.knowledge-unavailable {
  color: var(--muted);
}

.knowledge-test-form {
  margin-top: 14px;
}

.knowledge-test-form .field {
  margin-bottom: 0;
}

.knowledge-search-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 7px;
}

.knowledge-search-control .icon-button {
  width: 40px;
  height: 40px;
  border-color: #53665a;
  color: var(--accent);
}

.knowledge-test-results {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.knowledge-result {
  padding: 9px 10px;
  border-left: 2px solid #53665a;
  background: var(--panel);
}

.knowledge-result strong,
.knowledge-result p {
  overflow-wrap: anywhere;
}

.knowledge-result strong {
  color: var(--accent);
  font-size: 10px;
}

.knowledge-result p {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.knowledge-dialog-scope {
  margin: -4px 0 15px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.knowledge-text-modal .field textarea {
  min-height: min(330px, 42vh);
}

.knowledge-file-picker {
  display: grid;
  min-height: 138px;
  place-items: center;
  align-content: center;
  gap: 7px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-align: center;
}

.knowledge-file-picker:hover,
.knowledge-file-picker:focus-within {
  border-color: #5b7765;
  background: #141a17;
}

.knowledge-file-picker > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--accent);
  font-size: 19px;
}

.knowledge-file-picker strong {
  font-size: 12px;
}

.knowledge-file-picker small {
  max-width: 100%;
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .knowledge-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .knowledge-row-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.template-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -3px 1px 13px;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

.template-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
}

.server-file-picker {
  display: grid;
  width: 100%;
  min-height: 64px;
  grid-template-columns: 34px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.server-file-picker:hover {
  border-color: #53665a;
  background: #141a17;
}

.server-file-picker > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.server-file-picker strong,
.server-file-picker small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-file-picker strong {
  font-size: 12px;
}

.server-file-picker small {
  color: var(--faint);
  font-size: 10px;
}

.server-file-picker-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--accent);
  font-size: 18px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.check-field input {
  accent-color: var(--accent-strong);
}

.managed-expression-list {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.managed-expression {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}

.managed-expression img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #07090b;
  object-fit: cover;
}

.managed-expression-info {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.managed-expression-info strong,
.managed-expression-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.managed-expression-info strong {
  font-size: 12px;
}

.managed-expression-info span {
  color: var(--faint);
  font-size: 10px;
}

.managed-expression-actions {
  display: flex;
  gap: 5px;
}

.mini-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}

.mini-button:hover {
  color: var(--text);
}

.mini-button.danger:hover {
  border-color: rgb(251 113 133 / 50%);
  color: #fda4af;
}

.modal {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--panel-raised);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal.compact {
  width: min(420px, calc(100vw - 28px));
}

.modal.file-picker-modal {
  width: min(700px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
}

.modal::backdrop {
  background: rgb(0 0 0 / 68%);
  backdrop-filter: blur(4px);
}

.modal form,
.file-picker-shell {
  padding: 20px;
}

.file-picker-shell {
  display: flex;
  min-height: min(610px, calc(100vh - 30px));
  min-height: min(610px, calc(100dvh - 30px));
  flex-direction: column;
}

.file-search-field {
  margin-bottom: 12px;
}

.file-search-field input {
  padding-left: 14px;
}

.file-picker-toolbar {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.file-breadcrumbs {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.file-breadcrumbs::-webkit-scrollbar {
  display: none;
}

.file-breadcrumbs button {
  flex: 0 0 auto;
  padding: 5px 7px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.file-breadcrumbs button:hover,
.file-breadcrumbs button:last-child {
  background: var(--panel-soft);
  color: var(--text);
}

.file-breadcrumbs i {
  color: var(--faint);
  font-style: normal;
  font-size: 10px;
}

.server-file-list {
  display: grid;
  min-height: 280px;
  flex: 1;
  align-content: start;
  gap: 5px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1014;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.server-file-row {
  display: grid;
  width: 100%;
  min-height: 52px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.server-file-row:hover {
  background: var(--panel-raised);
}

.server-file-row.selected {
  border-color: #506957;
  background: #142219;
}

.server-file-kind {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
}

.server-file-row.directory .server-file-kind {
  color: var(--warning);
}

.server-file-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.server-file-copy strong,
.server-file-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-file-copy strong {
  font-size: 12px;
}

.server-file-copy span,
.server-file-meta {
  color: var(--faint);
  font-size: 10px;
}

.server-file-meta {
  white-space: nowrap;
}

.file-picker-empty {
  align-self: center;
  margin: auto;
  color: var(--faint);
  font-size: 12px;
}

.file-picker-footer {
  display: flex;
  min-height: 48px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  color: var(--faint);
  font-size: 10px;
}

.file-picker-footer .modal-actions {
  flex: 0 0 auto;
  margin-top: 0;
}

.modal-heading {
  margin-bottom: 18px;
}

.modal-copy {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.form-error {
  margin: 8px 0 0;
  color: #fda4af;
  font-size: 12px;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #171b21;
  color: var(--text);
  box-shadow: 0 12px 36px rgb(0 0 0 / 38%);
  font-size: 12px;
  line-height: 1.5;
}

.toast.error {
  border-color: rgb(251 113 133 / 55%);
}

.toast.success {
  border-color: rgb(74 222 128 / 45%);
}

.empty-list {
  padding: 18px 10px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

@keyframes wave {
  from {
    height: 6px;
  }
  to {
    height: 24px;
  }
}

@media (max-width: 1180px) {
  .sim-layout {
    grid-template-columns: 200px minmax(390px, 1fr) 370px;
  }

  .stage-panel {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (max-width: 980px) {
  .sim-layout {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .conversation-panel {
    grid-column: 1 / -1;
    height: 680px;
    min-height: 0;
    overflow: hidden;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .device-frame {
    width: min(62vw, 520px);
  }
}

@media (max-width: 680px) {
  .sim-topbar {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .top-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .top-controls .connect {
    margin-left: auto;
  }

  .sim-layout {
    display: block;
  }

  .role-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .role-list {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .role-summary,
  .resource-link {
    display: none;
  }

  .stage-panel {
    min-height: auto;
    padding: 32px 14px 20px;
  }

  .device-frame {
    width: min(88vw, 500px);
  }

  .expression-dock {
    margin-top: 18px;
  }

  .conversation-panel {
    height: 720px;
    min-height: 0;
  }

  .conversation-tabs {
    padding-right: 8px;
    padding-left: 8px;
  }

  .conversation-tabs button {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 12px;
  }

  .settings-scroll {
    padding-right: 12px;
    padding-left: 12px;
  }

  .template-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

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

  .file-picker-shell {
    min-height: calc(100vh - 30px);
    min-height: calc(100dvh - 30px);
    padding: 15px;
  }

  .server-file-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .server-file-meta {
    display: none;
  }

  .file-picker-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .file-picker-footer .modal-actions {
    justify-content: stretch;
  }

  .file-picker-footer .button {
    flex: 1;
  }
}

/* Once a phone has connected, turn the page into a focused conversation
   surface: animation on top, messages and controls below. The class is only
   applied by JavaScript while the mobile media query matches. */
body.mobile-conversation-mode {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
  }

body.mobile-conversation-mode .simulator-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

body.mobile-conversation-mode .sim-topbar {
    position: fixed;
    z-index: 100;
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    display: block;
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

body.mobile-conversation-mode .sim-topbar > .brand-link,
body.mobile-conversation-mode .page-mode-switch,
body.mobile-conversation-mode .resolution-switch,
body.mobile-conversation-mode .server-pill {
    display: none !important;
  }

body.mobile-conversation-mode .top-controls {
    display: block;
    width: auto;
  }

body.mobile-conversation-mode .top-controls .connect {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid rgb(255 255 255 / 22%);
    border-radius: 50%;
    background: rgb(10 13 16 / 78%);
    color: transparent;
    font-size: 0;
    box-shadow: 0 6px 24px rgb(0 0 0 / 38%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

body.mobile-conversation-mode .top-controls .connect::before {
    color: var(--text);
    content: "×";
    font-size: 25px;
    font-weight: 400;
    line-height: 1;
  }

body.mobile-conversation-mode .sim-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    flex-direction: column;
  }

body.mobile-conversation-mode .role-panel,
body.mobile-conversation-mode .expression-dock,
body.mobile-conversation-mode .conversation-tabs,
body.mobile-conversation-mode .settings-view,
body.mobile-conversation-mode .frame-label,
body.mobile-conversation-mode .composer-note,
body.mobile-conversation-mode .welcome-card {
    display: none !important;
  }

body.mobile-conversation-mode .stage-panel {
    min-height: 0;
    flex: 0 0 auto;
    gap: 0;
    padding: calc(8px + env(safe-area-inset-top)) 8px 10px;
  }

body.mobile-conversation-mode .device-frame {
    width: min(76vw, 38dvh, 340px);
  }

body.mobile-conversation-mode .conversation-panel {
    display: flex;
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    border-top: 1px solid var(--line);
  }

body.mobile-conversation-mode .conversation-view {
    display: flex !important;
    min-height: 0;
    overflow: hidden;
  }

body.mobile-conversation-mode .chat-header {
    padding: 10px 14px 8px;
  }

body.mobile-conversation-mode .chat-header h2 {
    font-size: 15px;
  }

body.mobile-conversation-mode .chat-header p {
    font-size: 11px;
  }

body.mobile-conversation-mode .message-list {
    min-height: 0;
    gap: 8px;
    padding: 4px 12px 10px;
  }

body.mobile-conversation-mode .composer {
    margin: 0 10px calc(9px + env(safe-area-inset-bottom));
    padding: 9px;
  }

body.mobile-conversation-mode .composer textarea {
    min-height: 40px;
    max-height: 88px;
    resize: none;
}

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

/* Group ready and missing animations, with transitions visible first. */
.expression-list { display: block; max-height: 350px; overflow-y: auto; overflow-x: hidden; }
.animation-group + .animation-group { margin-top: 14px; }
.animation-group h3 { margin: 0 0 8px; font-size: 12px; color: var(--text); }
.animation-track { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 5px; scrollbar-width: thin; }
.animation-track .expression-chip { flex: 0 0 94px; grid-template-rows: 58px auto auto; }
.animation-track .missing-animation { opacity: .55; cursor: default; }
.animation-placeholder { display: grid; place-items: center; font-size: 25px !important; height: 58px; background: #101411; border-radius: 8px; }
.animation-badge { font-size: 10px; color: var(--accent-strong); white-space: nowrap; }
.missing-animation .animation-badge { color: var(--muted); }

.emotion-policy-choices { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 12px 0; }
.emotion-policy-choices label { display: inline-flex; align-items: center; gap: 5px; }

/* Native Live2D and original device animation stay visible together. */
.sim-layout { grid-template-columns: 180px minmax(520px, 1fr) minmax(310px, 350px); }
.stage-panel { padding: 24px 22px; gap: 16px; }
.stage-heading { width:100%; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.stage-heading h2 { font-size:17px; margin:3px 0 0; letter-spacing:-.02em; }
.stage-heading .eyebrow { margin-bottom:5px; }
.stage-actions {display:flex;align-items:center;gap:10px;}
.live2d-visibility {display:flex;align-items:center;gap:6px;min-height:32px;font-size:11px;color:var(--muted);white-space:nowrap;cursor:pointer;}
.live2d-visibility input {margin:0;accent-color:var(--accent);}
.live2d-unavailable {display:inline-flex;align-items:center;min-height:32px;padding:0 10px;border:1px solid var(--line);border-radius:10px;color:var(--muted);font-size:11px;white-space:nowrap;}
.live2d-visibility[hidden],.live2d-unavailable[hidden],.sync-badge[hidden],.live2d-card[hidden] {display:none;}
.dual-preview.single-preview {grid-template-columns:minmax(0,1fr);}
.dual-preview.single-preview .device-frame {width:min(100%,calc(var(--preview-height) - 28px),360px);}
.sync-badge { display:flex; align-items:center; gap:6px; padding:6px 9px; border:1px solid #294333; border-radius:20px; color:#a3dfb6; font-size:10px; white-space:nowrap; }
.sync-badge i { width:5px; height:5px; background:#86efac; border-radius:50%; }
.dual-preview { --preview-height:clamp(235px,39vh,360px); display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; gap:14px; }
.preview-card { min-width:0; border:1px solid var(--line); border-radius:18px; overflow:hidden; background:var(--panel); display:flex; flex-direction:column; }
.preview-heading { padding:14px 15px 11px; display:flex; align-items:center; justify-content:space-between; gap:8px; }
.preview-heading>div { display:flex; align-items:baseline; gap:7px; }
.preview-heading h3 { margin:0; font-size:14px; letter-spacing:.02em; }
.preview-heading span { font-size:10px; color:var(--muted); }
.preview-heading .preview-tag { font-size:9px; background:#1c222b; border:1px solid #2e3642; padding:4px 6px; border-radius:5px; white-space:nowrap; }
.native-viewport,.mjp-viewport { position:relative; width:100%; height:var(--preview-height); flex:0 0 auto; }
.native-viewport { background:radial-gradient(ellipse at 50% 28%,#fffaf3,#e7e0d9); overflow:hidden; }
#live2dStage { position:relative; width:100%; height:100%; }
#live2dStage canvas { display:block; position:absolute; inset:0; width:100%; height:100%; }
#live2dStage .live2d-effects-canvas { pointer-events:none; }
.native-empty { position:absolute; inset:0; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:10px; padding:24px; background:#eae5df; color:#625e5c; text-align:center; }
.native-empty[hidden],#live2dRetry[hidden] { display:none; }
.native-empty>span { font-size:28px; color:#a69789; }
.native-empty strong { font-size:13px; font-weight:500; }
.native-empty p { font-size:11px; line-height:1.65; margin:0; color:#82766f; }
.native-activity { position:absolute; top:12px; left:12px; border:1px solid #ffffff50; background:#ffffff90; color:#64594f; border-radius:14px; padding:4px 8px; font-size:10px; pointer-events:none; }
.mjp-viewport { display:grid; place-items:center; padding:15px; background:radial-gradient(ellipse at center,#1c222a,#0b0f14); }
.mjp-viewport .device-frame { width:min(100%,calc(var(--preview-height) - 28px),360px); padding:clamp(7px,1vw,14px); flex-shrink:0; box-shadow:0 14px 35px #0008,inset 0 0 0 3px #0d1013; }
.native-controls,.mjp-note { min-height:43px; display:flex; justify-content:center; align-items:center; gap:10px; padding:8px 10px; font-size:10px; color:var(--muted); }
.native-controls { flex-wrap:wrap; }
.native-controls label { display:flex; align-items:center; gap:4px; white-space:nowrap; }
.native-controls input { margin:0; width:12px; height:12px; accent-color:var(--accent); }
.native-controls a { color:var(--muted); font-size:10px; white-space:nowrap; }
.native-controls a[hidden] { display:none; }
.preview-match { min-height:46px; display:flex; align-items:flex-start; gap:7px; padding:12px 14px; border-top:1px solid var(--line); font-size:11px; line-height:1.6; color:#a2dfb6; }
.preview-match i { width:5px; height:5px; margin-top:6px; flex:0 0 auto; border-radius:50%; background:currentColor; }
.preview-match[data-kind="fallback"],.preview-match[data-kind="counterpart"] { color:#d1b17c; }
.preview-match[data-kind="missing"] { color:var(--faint); }
.selection-summary { display:flex; align-items:center; gap:10px; width:100%; padding:10px 2px 1px; }
.selection-summary>span { font-size:24px; width:37px; height:37px; display:grid; place-items:center; border:1px solid var(--line); border-radius:11px; background:var(--panel); }
.selection-summary>div { display:flex; flex-direction:column; gap:3px; }
.selection-summary small { color:var(--faint); font-size:9px; }
.selection-summary strong { font-size:12px; font-weight:500; }
.selection-summary p { margin:0 0 0 auto; max-width:65%; color:var(--muted); font-size:10px; line-height:1.6; text-align:right; }
.expression-dock { width:100%; margin-top:0; border-radius:15px; padding:14px; }
.animation-track .expression-chip { flex-basis:87px; grid-template-rows:44px auto auto; padding:6px; }
.animation-placeholder,.expression-chip img { height:44px; }
.animation-availability { display:flex; gap:3px; justify-content:center; font-size:8px; white-space:nowrap; }
.animation-availability span { padding:2px 4px; border-radius:4px; font-size:8px; color:var(--faint); background:#22252b; }
.animation-availability .available { background:#1a2b22; color:#8ddeaa; }
.animation-track .missing-animation { opacity:.4; }
@media (min-width:1600px) { .sim-layout { grid-template-columns:210px minmax(660px,1fr) 380px; } .stage-panel { padding:26px 30px; } .dual-preview {gap:20px;} }
@media (max-width:1100px) and (min-width:681px) {
  .simulator-shell { height:auto; overflow:visible; }
  .sim-layout { height:auto; grid-template-columns:160px minmax(0,1fr); }
  .stage-panel { overflow:visible; padding:20px; }
  .conversation-panel { grid-column:2; height:600px; border-top:1px solid var(--line); }
  .role-panel {grid-row:1 / 3;}
  .dual-preview {--preview-height:320px;}
}
@media (max-width:680px) {
  .stage-panel {padding:18px 12px; gap:12px;}
  .stage-heading {flex-wrap:wrap;gap:6px;}
  .stage-actions .sync-badge {display:none;}
  .stage-heading h2 {font-size:15px;}
  .dual-preview {gap:8px;}
  .preview-card {border-radius:12px;}
  .preview-heading {padding:10px 9px;}
  .preview-heading>div {display:block;}
  .preview-heading h3 {font-size:13px; margin-bottom:2px;}
  .preview-heading .preview-tag {font-size:8px; padding:3px 4px;}
  .dual-preview {--preview-height:clamp(200px,55vw,320px);}
  .mjp-viewport {padding:5px;}
  .mjp-viewport .device-frame {width:100%; padding:6px;}
  .native-controls,.mjp-note {min-height:58px; padding:7px 5px; gap:6px; font-size:9px;}
  .native-controls label {gap:2px; font-size:9px;}
  .preview-match {padding:8px; min-height:53px; font-size:10px;}
  .native-activity {top:7px;left:7px;font-size:9px;padding:3px 6px;}
  .native-empty {padding:12px;gap:6px;}
  .native-empty strong {font-size:11px;}
  .native-empty p {font-size:10px;}
  .selection-summary p {max-width:59%;font-size:9px;}
  .mjp-viewport .subtitle {font-size:9px;padding:5px;bottom:13%;}
  .mjp-viewport .screen-topline {font-size:7px;}
  .mjp-viewport .screen-empty {padding:15%;}
  .mjp-viewport .screen-empty p {font-size:10px;}
  .expression-dock {margin-top:0;padding:12px;}
}
body.mobile-conversation-mode .stage-heading,body.mobile-conversation-mode .selection-summary,
body.mobile-conversation-mode .native-controls,body.mobile-conversation-mode .mjp-note {display:none;}
body.mobile-conversation-mode .stage-panel {padding-top:calc(55px + env(safe-area-inset-top));}
body.mobile-conversation-mode .dual-preview {--preview-height:min(23dvh,210px);}
body.mobile-conversation-mode .preview-heading {padding:6px 9px;}
body.mobile-conversation-mode .preview-heading>div {display:flex;}
body.mobile-conversation-mode .preview-heading>div>span {display:none;}
body.mobile-conversation-mode .preview-match {min-height:28px;padding:5px 8px;font-size:9px;}
body.mobile-conversation-mode .mjp-viewport .device-frame {width:min(100%,21dvh);}
body.mobile-conversation-mode .stage-heading.has-role {display:flex;position:fixed;top:calc(10px + env(safe-area-inset-top));left:12px;width:auto;max-width:calc(100% - 130px);z-index:100;}
body.mobile-conversation-mode .stage-heading>div:first-child,body.mobile-conversation-mode .stage-actions .sync-badge {display:none;}
body.mobile-conversation-mode .live2d-visibility {min-height:40px;padding:0 10px;border:1px solid var(--line);border-radius:10px;background:var(--panel);}
body.mobile-conversation-mode .live2d-unavailable {min-height:40px;background:var(--panel);}

/* Keep the paired preview in view while browsing one animation category. */
.animation-tabs {display:flex;gap:5px;flex-wrap:wrap;margin:0 0 10px;}
.animation-tabs button {padding:5px 9px;border:1px solid transparent;border-radius:6px;background:#191e25;color:var(--muted);font-size:10px;cursor:pointer;}
.animation-tabs button.active {background:#1b2e22;border-color:#355340;color:#b4efc7;}
.expression-list {max-height:none;overflow:visible;}
.animation-group[hidden] {display:none;}
.animation-group + .animation-group {margin-top:0;}
.animation-group h3 {display:none;}
@media (min-width:681px) {
  .stage-panel {gap:12px;padding:18px 22px;}
  .stage-heading {min-height:28px;}
  .stage-heading .eyebrow {display:none;}
  .stage-heading h2 {font-size:14px;}
  .dual-preview {--preview-height:clamp(210px,calc(100dvh - 510px),380px);}
  .preview-heading {padding:10px 13px;}
  .native-controls,.mjp-note {min-height:34px;padding:7px 8px;}
  .preview-match {min-height:35px;padding:8px 12px;font-size:10px;}
  .selection-summary {padding:0;}
  .selection-summary>span {height:30px;width:30px;font-size:19px;}
  .selection-summary small {font-size:8px;}
  .expression-dock {padding:11px 12px;}
  .dock-heading {margin-bottom:8px;}
  .dock-heading .eyebrow {display:none;}
  .dock-heading h2 {font-size:12px;}
  .animation-tabs {margin-bottom:7px;}
}
