:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #eef5f0;
  --ink: #1d2821;
  --muted: #68766d;
  --line: #dce5df;
  --brand: #247a59;
  --brand-dark: #1b5f45;
  --gold: #f0ad39;
  --danger: #b85252;
  --shadow: 0 14px 34px rgba(26, 43, 33, .10);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  --bg: #121813;
  --surface: #1d261f;
  --surface-soft: #25342b;
  --ink: #edf5ee;
  --muted: #a9b8ae;
  --line: #334239;
  --shadow: 0 20px 56px rgba(0, 0, 0, .28);
}

[data-font="large"] {
  font-size: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

input,
select,
textarea {
  color: var(--ink);
}

.app-shell {
  height: 100vh;
  min-height: 640px;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  background: var(--bg);
}

.side {
  min-width: 0;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

[data-theme="dark"] .side {
  background: rgba(29, 38, 31, .82);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.side-close {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  margin-left: auto;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(25, 158, 174, .20);
}

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

.brand strong,
.account-card strong {
  display: block;
  font-size: 16px;
  line-height: 1.15;
}

.brand span,
.account-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.primary-button,
.send-button,
.danger-button,
.ghost-button,
.tool-button {
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  white-space: nowrap;
}

.prompt-line .tool-button {
  min-height: 34px;
  width: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  background: transparent;
  border-color: transparent;
}

.attach-wrap {
  position: relative;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: inline-flex;
}

.attach-wrap .tool-button {
  width: 34px;
  height: 34px;
  pointer-events: none;
}

.file-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 34px;
  height: 34px;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.attach-wrap:focus-within .tool-button,
.attach-wrap:hover .tool-button {
  background: var(--surface-soft);
  border-color: var(--line);
}

[data-voice-recording="true"] #voiceBtn {
  background: #fff1f1;
  border-color: rgba(184, 82, 82, .35);
  color: var(--danger);
  font-size: 14px;
}

.primary-button,
.send-button {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

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

.ghost-button,
.tool-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  background: #fff1f1;
  color: var(--danger);
  border: 1px solid rgba(184, 82, 82, .25);
}

.icon {
  font-size: 18px;
  line-height: 1;
}

.search-box {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.chat-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.chat-item {
  width: 100%;
  min-height: 56px;
  text-align: left;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 9px 10px;
  display: grid;
  gap: 4px;
}

.chat-item:hover,
.chat-item.active {
  background: var(--surface-soft);
}

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

.chat-item strong {
  font-size: 13px;
}

.chat-item span {
  color: var(--muted);
  font-size: 12px;
}

.account-card {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.account-settings {
  min-height: 34px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.avatar-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  padding: 0;
  background: var(--surface-soft);
}

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

.workspace {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 70px minmax(0, 1fr) auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(220, 229, 223, .78);
  background: var(--bg);
}

[data-theme="dark"] .topbar {
  background: rgba(18, 24, 19, .76);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #0b73f6;
  background: transparent;
  font-size: 22px;
  font-weight: 900;
}

.admin-only {
  display: none;
}

[data-admin="true"] .admin-only {
  display: inline-flex;
}

.mobile-menu {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.side-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 34;
  background: rgba(18, 24, 19, .34);
}

.messages {
  overflow: auto;
  padding: 28px min(5vw, 56px);
}

.welcome {
  max-width: 760px;
  min-height: 100%;
  margin: 0 auto;
  display: grid;
  align-content: center;
  gap: 18px;
}

.welcome h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.16;
  letter-spacing: 0;
}

.welcome p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 15px;
  max-width: 680px;
}

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

.quick-card {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 13px;
  text-align: left;
  display: grid;
  gap: 8px;
}

[data-theme="dark"] .quick-card {
  background: rgba(29, 38, 31, .88);
}

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

.quick-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.thread {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #334238;
  color: #fff;
  font-weight: 900;
}

.message.assistant .avatar {
  background: var(--brand);
}

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

.message-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 6px;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
  padding: 14px 16px;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 28px rgba(26, 43, 33, .07);
}

[data-theme="dark"] .bubble {
  background: rgba(29, 38, 31, .9);
}

.message.user .bubble {
  background: #26372d;
  border-color: #26372d;
  color: #fff;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.action-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #0b73f6;
  background: #edf5ff;
  font-size: 18px;
}

.action-icon.active {
  color: #fff;
  background: var(--brand);
}

.quick-tools {
  max-width: 920px;
  margin: 0 min(5vw, 56px) 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.quick-tools button {
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  white-space: nowrap;
  font-weight: 700;
  font-size: 13px;
}

.composer {
  margin: 0 min(5vw, 56px) 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(26, 43, 33, .08);
  padding: 6px 8px;
}

[data-theme="dark"] .composer {
  background: rgba(29, 38, 31, .94);
}

.prompt-line {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer textarea {
  width: 100%;
  min-height: 30px;
  max-height: 92px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 5px 7px;
  line-height: 1.45;
}

.call-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  color: #fff;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, .18), transparent 28%),
    linear-gradient(145deg, #5b4b35, #111916 58%, #68716e);
  overflow: hidden;
}

.call-modal.open {
  display: block;
}

body.call-open {
  overflow: hidden;
}

.call-video {
  position: absolute;
  z-index: 4;
  top: max(84px, calc(env(safe-area-inset-top) + 68px));
  right: 18px;
  left: auto;
  width: 116px;
  height: 164px;
  object-fit: cover;
  display: none;
  border: 2px solid rgba(255, 255, 255, .82);
  border-radius: 18px;
  opacity: 1;
  background: #161b18;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .30);
}

.ai-remote-card {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: rgba(24, 48, 40, .86);
  box-shadow: none;
}

.ai-remote-video,
.ai-avatar-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ai-remote-video {
  display: none;
  object-fit: contain;
  background: #15241f;
}

.ai-remote-video.connected {
  display: block;
}

.ai-avatar-fallback {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  background:
    linear-gradient(145deg, #071c35, #123f61 52%, #1b7c82);
}

.ai-avatar-fallback.hidden {
  display: none;
}

.avatar-aura {
  position: absolute;
  width: min(62vw, 360px);
  aspect-ratio: 1.22;
  border: 1px solid rgba(116, 235, 255, .62);
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 14px rgba(91, 220, 255, .07), 0 0 70px rgba(55, 205, 255, .36);
  animation: avatar-pulse 2.8s ease-in-out infinite;
}

.avatar-logo-wrap {
  position: relative;
  z-index: 1;
  width: min(47vw, 260px);
  aspect-ratio: .92;
  overflow: hidden;
  border: 1px solid rgba(133, 241, 255, .85);
  border-radius: 34px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .96), rgba(202, 249, 255, .90));
  box-shadow: 0 0 0 7px rgba(107, 222, 255, .10), 0 22px 70px rgba(0, 0, 0, .32);
  animation: avatar-float 3.4s ease-in-out infinite;
}

.avatar-logo-wrap::before,
.avatar-logo-wrap::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(20, 175, 211, .26);
  border-radius: 25px;
  pointer-events: none;
}

.avatar-logo-wrap::after {
  inset: auto 20px 12px;
  height: 3px;
  border: 0;
  background: linear-gradient(90deg, transparent, #42d9ff, transparent);
  box-shadow: 0 0 15px #42d9ff;
}

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

.ai-avatar-fallback strong,
.ai-avatar-fallback > span {
  position: relative;
  z-index: 1;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .35);
}

.ai-avatar-fallback strong { font-size: 24px; letter-spacing: 0; }
.ai-avatar-fallback > span { color: rgba(225, 249, 255, .82); font-size: 14px; }

@keyframes avatar-pulse {
  50% { transform: scale(1.08); opacity: .72; }
}

@keyframes avatar-float {
  50% { transform: translateY(-7px); }
}

.ai-remote-label {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  color: #fff;
  font-size: 11px;
  text-align: center;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .7);
}

body.video-call-open.local-video-ready .call-video {
  display: block;
}

.call-wake {
  position: relative;
  z-index: 2;
  display: block;
  min-width: 148px;
  height: 42px;
  margin: 14px auto 0;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 21px;
  color: #fff;
  background: rgba(20, 83, 65, .72);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
  font-size: 14px;
  font-weight: 800;
}

.call-wake.active {
  background: rgba(255, 255, 255, .88);
  color: #145541;
}

.call-dim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, .18), rgba(0, 0, 0, .06) 45%, rgba(0, 0, 0, .38));
  pointer-events: none;
}

.call-top {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px 44px 44px 44px;
  gap: 12px;
  align-items: center;
  padding: max(28px, env(safe-area-inset-top)) 22px 0;
}

.call-top button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  font-size: 22px;
  font-weight: 900;
}

.call-top strong,
.call-top span {
  display: block;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .30);
}

.call-top strong {
  font-size: 18px;
}

.call-top span {
  margin-top: 4px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
}

.call-prompt {
  position: relative;
  z-index: 2;
  margin: 38px 24px 0;
  height: 58px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  padding: 0 22px;
  color: rgba(255, 255, 255, .72);
  background: rgba(202, 178, 136, .62);
  font-size: 20px;
  font-weight: 800;
}

.call-center-status {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 190px;
  display: grid;
  justify-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, .90);
  text-align: center;
  font-size: 18px;
}

.call-center-status span {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin: 0 3px;
  border-radius: 50%;
  background: #fff;
}

.call-center-status p {
  margin: 0;
}

.call-controls {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 36px));
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 26px;
}

.round-call {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #111;
  background: rgba(255, 255, 255, .94);
  font-size: 36px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}

.round-call.muted {
  background: rgba(210, 216, 222, .78);
}

.round-call.active {
  color: #fff;
  background: #0b9cff;
  outline: 3px solid rgba(255, 255, 255, .8);
}

.round-call.end {
  color: #f20f0f;
  background: rgba(200, 208, 216, .80);
  font-size: 56px;
}

.call-foot {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: max(20px, env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, .58);
  font-size: 14px;
}

.call-live-sheet {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  padding: 26px;
  background: rgba(0, 0, 0, .38);
  backdrop-filter: blur(12px);
}

.call-live-sheet.open {
  display: grid;
}

.live-close {
  position: absolute;
  z-index: 2;
  top: max(20px, env(safe-area-inset-top));
  right: 20px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .18);
  font-size: 30px;
  line-height: 1;
}

.live-close:active {
  transform: scale(.94);
}

.call-live-sheet > p {
  position: absolute;
  top: 24%;
  width: min(86vw, 520px);
  margin: 0;
  color: rgba(255, 255, 255, .92);
  line-height: 1.6;
  text-align: center;
  font-weight: 700;
}

.live-card {
  width: min(82vw, 430px);
  border-radius: 28px;
  background: rgba(100, 100, 100, .56);
  border: 1px solid rgba(255, 255, 255, .22);
  overflow: hidden;
  text-align: center;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .35);
}

.live-card strong,
.live-start,
.live-row {
  min-height: 62px;
}

.live-card strong {
  display: grid;
  place-items: center;
  font-size: 18px;
}

.live-row,
.live-start {
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  background: transparent;
}

.live-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  text-align: left;
}

.live-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--brand);
  font-weight: 900;
}

.composer-row {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-row select {
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 10px;
  max-width: 150px;
}

.model-select {
  max-width: 132px;
}

.send-button {
  margin-left: auto;
  min-width: 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  font-size: 17px;
  display: none;
}

.send-button:disabled {
  opacity: .55;
  cursor: wait;
}

[data-has-input="true"] .send-button {
  display: inline-flex;
}

.read-button {
  min-width: 82px;
}

.ai-orb {
  position: fixed;
  right: 26px;
  top: 50%;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .30) 28%, transparent 29%),
    linear-gradient(145deg, #1f8a63, #35b6a2 55%, #f0ad39);
  color: #fff;
  box-shadow: 0 16px 34px rgba(36, 122, 89, .30);
  z-index: 20;
  touch-action: none;
  user-select: none;
  overflow: hidden;
  padding: 0;
  display: grid;
  place-items: center;
}

.ai-orb::before {
  content: "";
  position: absolute;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .38);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .12),
    0 0 20px rgba(255, 255, 255, .18);
}

.ai-orb::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 15px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    -28px 23px 0 rgba(255, 255, 255, .70),
    12px 27px 0 rgba(255, 255, 255, .56);
}

.ai-orb span {
  position: relative;
  z-index: 1;
  width: 38px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, .44);
  border-radius: 10px;
  background: rgba(255, 255, 255, .18);
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .20);
  backdrop-filter: blur(6px);
}

.assistant-panel {
  position: fixed;
  right: 28px;
  top: calc(50% + 82px);
  width: min(320px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  display: none;
  z-index: 22;
}

.assistant-panel.open {
  display: block;
}

.assistant-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.assistant-panel header button,
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-soft);
}

.assistant-suggestions {
  display: grid;
  gap: 8px;
}

.assistant-suggestions button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  text-align: left;
  padding: 9px 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 24, 19, .36);
  backdrop-filter: blur(6px);
  display: none;
  z-index: 40;
}

.modal-backdrop.open {
  display: block;
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100vh - 44px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  z-index: 45;
  transition: .18s ease;
}

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

.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

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

.user-settings-modal {
  width: min(520px, calc(100vw - 18px));
  background: #f6f6f6;
  border: 0;
  border-radius: 28px;
  padding: 26px 18px 24px;
}

.user-settings-modal header {
  justify-content: center;
  margin-bottom: 22px;
}

.user-settings-modal .modal-close {
  position: absolute;
  right: 22px;
  top: 22px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  font-size: 28px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .08);
}

.settings-section {
  margin: 0 0 18px;
}

.settings-section > p {
  margin: 0 0 8px 18px;
  color: #9b9b9b;
  font-size: 14px;
}

.settings-card,
.settings-single {
  border-radius: 22px;
  background: #fff;
  overflow: hidden;
}

.settings-card {
  display: grid;
}

.settings-row,
.settings-single {
  min-height: 58px;
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.settings-row + .settings-row {
  border-top: 1px solid #ededed;
}

.settings-row strong,
.settings-single strong {
  font-size: 16px;
  font-weight: 800;
}

.settings-row span:not(.settings-icon) {
  color: #9b9b9b;
  font-size: 14px;
}

.settings-icon {
  font-size: 20px;
  color: #111;
}

.settings-row em,
.settings-single em {
  color: #bbb;
  font-style: normal;
  font-size: 26px;
}

.settings-single {
  margin-top: 18px;
  grid-template-columns: 34px minmax(0, 1fr) 20px;
}

.update-modal {
  width: min(440px, calc(100vw - 28px));
  border-radius: 24px;
  padding: 24px;
}

.update-modal header {
  margin-bottom: 20px;
}

.update-version-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.update-version-line strong {
  color: var(--brand);
  font-size: 20px;
}

.update-arrow {
  color: #a9b5ae;
  font-size: 20px;
}

.update-published,
.update-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.update-notes {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--ink);
  line-height: 1.6;
}

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

.logout-setting {
  margin-top: 28px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  min-height: 36px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-soft);
}

.tab.active {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.form {
  display: none;
  gap: 12px;
}

.form.active {
  display: grid;
}

.form label,
.settings-grid label,
.user-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.form input,
.settings-grid input,
.settings-grid select,
.user-row input,
.user-row select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
  outline: 0;
}

.avatar-preview {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.avatar-preview img {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--surface-soft);
}

.settings-grid {
  display: grid;
  gap: 12px;
}

.settings-title {
  font-weight: 900;
  color: var(--ink);
  padding-top: 4px;
}

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

.model-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

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

.model-item span {
  color: var(--muted);
  font-size: 12px;
}

.admin-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.user-table {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: 132px minmax(120px, 1fr) minmax(160px, 1.4fr) 120px minmax(130px, 1fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.user-main {
  min-width: 0;
  align-self: center;
}

.user-main strong,
.user-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-main span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  background: #26372d;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
  }

  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 310px);
    z-index: 35;
    transform: translateX(-102%);
    transition: .2s ease;
    box-shadow: var(--shadow);
  }

  .side.open {
    transform: translateX(0);
  }

  .side-close {
    display: grid;
    place-items: center;
  }

  [data-side-open="true"] .side-scrim {
    display: block;
  }

  .workspace {
    min-height: 100vh;
    height: 100vh;
    grid-template-rows: 76px minmax(0, 1fr) auto auto;
    background: #fff;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 18;
    padding: max(10px, env(safe-area-inset-top)) 12px 8px;
    border-bottom: 0;
    background: rgba(255, 255, 255, .96);
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .mobile-menu {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    font-size: 28px;
  }

  .topbar > div:nth-child(2) {
    text-align: center;
    min-width: 0;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar p {
    margin-top: 2px;
    font-size: 12px;
  }

  .top-actions {
    gap: 2px;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .top-actions .admin-only {
    display: none;
  }

  .call-button {
    width: 38px;
    height: 38px;
    font-size: 21px;
  }

  .ghost-button {
    padding: 0 10px;
  }

  .messages {
    padding: 18px 14px 190px;
  }

  .thread {
    gap: 16px;
  }

  .message {
    display: flex;
    gap: 0;
  }

  .message .avatar,
  .message-meta {
    display: none;
  }

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

  .message.assistant {
    justify-content: flex-start;
  }

  .message-body {
    max-width: 86%;
  }

  .bubble {
    border: 0;
    border-radius: 18px;
    box-shadow: none;
    background: #f4f4f4;
    color: #111;
    font-size: 17px;
    line-height: 1.72;
    padding: 14px 16px;
  }

  .message.user .bubble {
    background: #0b9cff;
    color: #fff;
    border-radius: 18px;
  }

  .message-actions {
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, .06);
  }

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

  .quick-tools {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 92px;
    z-index: 16;
    max-width: none;
    margin: 0;
    padding: 0 14px 10px;
    background: linear-gradient(180deg, rgba(255,255,255,0), #fff 30%);
  }

  .quick-tools button {
    min-height: 42px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  }

  .composer {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 17;
    margin: 0;
    border: 0;
    border-radius: 22px;
    padding: 10px 12px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, .14);
  }

  .composer textarea {
    min-height: 42px;
    font-size: 17px;
  }

  .send-button {
    flex: 0 0 34px;
    margin-left: auto;
  }

  .ai-orb {
    width: 52px;
    height: 52px;
    right: 16px;
  }

  .ai-orb span {
    width: 30px;
    height: 24px;
    border-radius: 8px;
    font-size: 15px;
  }

  .ai-orb::after {
    right: 12px;
    top: 12px;
    width: 5px;
    height: 5px;
    box-shadow:
      -21px 18px 0 rgba(255, 255, 255, .70),
      9px 21px 0 rgba(255, 255, 255, .56);
  }

  .wide-modal {
    width: calc(100vw - 20px);
  }

  .user-settings-modal {
    width: 100vw;
    max-height: 92vh;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    transform: translateY(6%);
    border-radius: 30px 30px 0 0;
    padding: 28px 18px max(24px, env(safe-area-inset-bottom));
  }

  .user-settings-modal.open {
    transform: translateY(0);
  }

  .user-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .user-row .primary-button {
    width: 100%;
  }
}
