:root {
  color-scheme: light;
  --app-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --chrome: rgba(0, 0, 0, 0.035);
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.9);
  --surface-muted: #f5f5f8;
  --field: rgba(0, 0, 0, 0.06);
  --hover: rgba(0, 0, 0, 0.06);
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --text: rgba(0, 0, 0, 0.92);
  --muted: rgba(0, 0, 0, 0.6);
  --faint: rgba(0, 0, 0, 0.36);
  --accent-rgb: 94 92 230;
  --accent: #5e5ce6;
  --list-active: rgb(var(--accent-rgb) / 0.16);
  --shadow: 0 14px 34px rgba(20, 24, 40, 0.08);
  --sidebar-width: 286px;
}

/* Appearance overrides. Setting attributes on :root keeps the rules cheap
   and avoids running JS to update individual elements when the user flips
   a toggle in settings. */
:root[data-hover-background="off"] {
  --hover: transparent;
}
:root[data-list-style="flush"] .persona-row {
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
}
:root[data-list-style="flush"] .persona {
  border-radius: 0;
  min-height: 66px;
}
:root[data-list-style="flush"] .persona-row.active {
  border-bottom-color: transparent;
}
:root[data-selection-style="solid"] .persona-row.active {
  background: var(--accent);
}
:root[data-selection-style="solid"] .persona-row.active .persona-name,
:root[data-selection-style="solid"] .persona-row.active .persona-preview,
:root[data-selection-style="solid"] .persona-row.active .persona-time {
  color: #fff;
}
:root[data-show-user-avatar="off"] .chat .message.user .avatar,
:root[data-show-assistant-avatar="off"] .chat .message.assistant .avatar {
  display: none !important;
}
.chat .message.user .bubble {
  background: var(--user-bubble-color, var(--accent));
  color: #fff;
}

/* Toggle widget tuned to desktop's settings-switch proportions. */
.settings-switch-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 30px;
  height: 18px;
  cursor: pointer;
}
.settings-switch-wrap input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.settings-switch-text {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  background: var(--field);
  transition: background 0.16s ease;
}
.settings-switch-text::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
  transition: transform 0.16s ease;
}
.settings-switch-wrap input:checked + .settings-switch-text {
  background: var(--accent);
}
.settings-switch-wrap input:checked + .settings-switch-text::after {
  transform: translateX(12px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --chrome: #121318;
  --surface: #1f2128;
  --surface-soft: rgba(31, 33, 40, 0.92);
  --surface-muted: #171920;
  --field: rgba(255, 255, 255, 0.08);
  --hover: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: rgba(255, 255, 255, 0.94);
  --muted: rgba(255, 255, 255, 0.66);
  --faint: rgba(255, 255, 255, 0.44);
  --accent-rgb: 124 116 255;
  --accent: #7c74ff;
  --list-active: rgb(var(--accent-rgb) / 0.22);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--chrome);
  color: var(--text);
  font: 14px/1.5 var(--app-font);
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.admin-body {
  overflow: auto;
  min-height: 100dvh;
  background: #f7f7f8;
}

.admin-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-header p {
  color: var(--muted);
  font-size: 13px;
}

.admin-header h1 {
  margin-top: 2px;
  font-size: 30px;
  line-height: 1.16;
}

.admin-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.admin-panel {
  display: grid;
  gap: 20px;
  margin-top: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 24, 40, 0.06);
}

.admin-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.admin-status-row strong,
.admin-log-panel strong {
  font-size: 15px;
}

.admin-status-row p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.admin-badge {
  flex: 0 0 auto;
  min-width: 70px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgb(var(--accent-rgb) / 0.13);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

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

.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.admin-form input,
.admin-form select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--surface-muted);
  color: var(--text);
}

.admin-form input:focus,
.admin-form select:focus {
  border-color: rgb(var(--accent-rgb) / 0.55);
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.12);
}

.admin-actions {
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
}

.admin-primary,
.admin-secondary {
  height: 42px;
  padding: 0 16px;
  border-radius: 9px;
  font-weight: 720;
}

.admin-primary {
  background: var(--accent);
  color: #fff;
}

.admin-secondary {
  background: var(--field);
  color: var(--text);
}

.admin-primary:disabled,
.admin-secondary:disabled {
  cursor: default;
  opacity: 0.55;
}

.admin-log-panel pre {
  min-height: 160px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  background: #111318;
  color: #e5e7eb;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 720px) {
  .admin-shell {
    width: min(100% - 20px, 920px);
    padding-top: 18px;
  }

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

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

  .admin-status-row,
  .admin-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

.hidden,
.hidden-file-input,
.app-shell[data-auth="signed-in"] .login-view,
.app-shell:not([data-auth="signed-in"]) .main-view {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
}

.login-view {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 12%, rgb(var(--accent-rgb) / 0.14), transparent 28%),
    var(--surface-muted);
}

.login-panel {
  display: grid;
  gap: 22px;
  width: min(440px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.brand-mark,
.rail-logo {
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #111827, #3f3dcd);
  color: #fff;
  font-weight: 760;
}

.brand-mark {
  width: 52px;
  height: 52px;
  font-size: 24px;
}

.login-brand h1 {
  font-size: 28px;
  line-height: 1.15;
}

.login-brand p,
.login-hint {
  color: var(--muted);
  font-size: 13px;
}

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

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

.login-form input:focus {
  border-color: rgb(var(--accent-rgb) / 0.58);
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.12);
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.code-row button,
.primary-action {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 720;
}

.code-row button {
  background: var(--field);
  color: var(--text);
}

.primary-action {
  background: var(--accent);
  color: #fff;
}

.main-view {
  display: grid;
  grid-template-columns: 60px var(--sidebar-width) minmax(0, 1fr);
  height: 100dvh;
  padding: 0 2px 2px 0;
  background: var(--chrome);
}

.nav-rail {
  display: grid;
  grid-template-rows: 54px 44px minmax(0, 1fr) 44px;
  justify-items: center;
  align-items: center;
  gap: 4px;
  padding: 8px 0 14px;
}

.rail-logo {
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.rail-avatar {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 430;
  overflow: hidden;
}

.rail-avatar:hover,
.rail-avatar:focus-visible {
  box-shadow: none;
}

.rail-spacer {
  width: 1px;
  min-height: 1px;
}

.rail-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

.rail-button:hover {
  background: var(--hover);
}

.rail-button.active {
  color: var(--accent);
  background: var(--list-active);
}

.rail-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-button em {
  position: absolute;
  right: 3px;
  top: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  line-height: 16px;
}

.sidebar,
.workspace {
  min-width: 0;
  min-height: 0;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 14px 0 0 14px;
}

.sidebar-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 6px;
  min-height: 66px;
  padding: 14px 10px 10px;
}

.search-box {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  height: 32px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--field);
  color: var(--faint);
}

.search-box input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 300;
}

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

.persona-list {
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 0;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  overflow: auto;
}

.persona-empty {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
}

.persona {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  margin: 0;
  padding: 9px 10px;
  border-radius: inherit;
  background: transparent;
  color: var(--text);
  text-align: left;
}

/* Hover/active live on the row wrapper so the highlight fills the full card
   rectangle symmetrically (including the gap reserved for the ⋯ menu). */
.persona-row {
  position: relative;
  display: block;
  margin: 0 7px;
  border-radius: 11px;
}
.persona-row:hover {
  background: var(--hover);
}
.persona-row.active {
  background: var(--list-active);
}

.avatar,
.profile-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  background-position: center;
  background-size: cover;
  color: var(--accent);
  font-size: 11px;
  font-weight: 760;
  overflow: hidden;
}

.avatar-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Group composite avatar (mirrors desktop's groups.css mosaic) */
.avatar.group-avatar {
  display: grid;
  gap: 1px;
  overflow: hidden;
  padding: 0;
  background: var(--surface, #fff);
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.avatar.group-avatar[data-count="1"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.avatar.group-avatar[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}
.avatar.group-avatar[data-count="3"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.avatar.group-avatar[data-count="3"] > .group-avatar-tile:nth-child(1) {
  grid-column: 1 / span 2;
}
.avatar.group-avatar[data-count="5"] {
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: 1fr 1fr;
}
.avatar.group-avatar[data-count="5"] > .group-avatar-tile:nth-child(1) { grid-column: 1 / span 3; grid-row: 1; }
.avatar.group-avatar[data-count="5"] > .group-avatar-tile:nth-child(2) { grid-column: 4 / span 3; grid-row: 1; }
.avatar.group-avatar[data-count="5"] > .group-avatar-tile:nth-child(3) { grid-column: 1 / span 2; grid-row: 2; }
.avatar.group-avatar[data-count="5"] > .group-avatar-tile:nth-child(4) { grid-column: 3 / span 2; grid-row: 2; }
.avatar.group-avatar[data-count="5"] > .group-avatar-tile:nth-child(5) { grid-column: 5 / span 2; grid-row: 2; }
.avatar.group-avatar[data-count="6"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.group-avatar-tile {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-soft, #ccc);
  overflow: hidden;
}

.utility-avatar {
  display: grid;
  place-items: center;
  background-image: none !important;
  background: rgb(var(--accent-rgb) / 0.12);
  color: var(--accent);
}

.persona-main,
.persona-side,
.persona-name,
.persona-preview,
.persona-time {
  min-width: 0;
}

.persona-main {
  display: grid;
  gap: 2px;
}

.persona-name,
.persona-preview,
.persona-time {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.persona-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 430;
}

.persona.active .persona-name {
  color: var(--accent);
}

.persona-preview {
  color: var(--muted);
  font-size: 12px;
}

.persona-side {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.persona-time {
  color: var(--faint);
  font-size: 11px;
}

.persona-unread {
  display: grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.persona-row.has-unread .persona-name {
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.group-title h1 {
  overflow: hidden;
  font-size: 17px;
  font-weight: 520;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-title p {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.session-menu-wrap {
  position: relative;
}

.session-trigger {
  display: grid;
  grid-template-columns: minmax(70px, 190px);
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
}

.session-trigger:hover {
  background: var(--hover);
}

.current-session-title {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-session-title.title-updated {
  animation: titleSwap 360ms ease;
}

@keyframes titleSwap {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.session-menu {
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  width: min(286px, calc(100vw - 24px));
  max-height: 430px;
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.08);
  backdrop-filter: blur(22px) saturate(1.08);
  transform-origin: top right;
  animation: menuPopoverIn 120ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes menuPopoverIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.session-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 6px;
  border-bottom: 1px solid var(--line);
}

.session-menu-head strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
}

.session-menu-head-icon {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  color: var(--muted);
}

.session-menu-head-icon svg {
  width: 16px;
  height: 16px;
}

.session-list {
  display: grid;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
}

.session-row:hover {
  background: var(--hover);
}

.session-row.active {
  background: var(--list-active);
}

.session-row strong,
.session-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-row strong {
  font-weight: 500;
}

.session-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.session-row em,
.session-row i {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-style: normal;
  font-size: 14px;
  font-weight: 400;
}

.session-row em:hover {
  background: var(--hover);
  color: var(--accent);
}

.sync-pill {
  height: 28px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--field);
  color: var(--muted);
  font-size: 12px;
}

.sync-pill.ready {
  color: var(--accent);
  background: rgb(var(--accent-rgb) / 0.12);
}

.narrow-back-button {
  display: none;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
}

.chat-layout {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--surface);
}

.chat {
  display: grid;
  align-content: start;
  gap: 4px;
  overflow: auto;
  padding: 14px 18px 10px;
}

.message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  width: 100%;
  min-width: 0;
  padding: 3px 6px;
}

.message.user {
  flex-direction: row-reverse;
}

.message .avatar {
  flex: 0 0 auto;
  margin-bottom: 2px;
}

.message-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  max-width: min(74%, 780px);
}

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

.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 10px 15px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.055);
  color: var(--text);
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.bubble p {
  margin: 0 0 9px;
}

.bubble p:last-child,
.bubble ul:last-child,
.bubble ol:last-child,
.bubble .message-divider:last-child,
.bubble .message-code-block:last-child {
  margin-bottom: 0;
}

.bubble h1,
.bubble h2,
.bubble h3 {
  margin: 4px 0 8px;
  color: inherit;
  font-size: 15px;
  line-height: 1.35;
}

.bubble ul,
.bubble ol {
  margin: 7px 0 10px;
  padding-left: 22px;
}

.bubble li {
  margin: 3px 0;
}

.bubble .message-divider {
  height: 1px;
  margin: 12px 2px;
  border: 0;
  background: var(--line-strong);
}

.bubble a.message-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  word-break: break-word;
}

.bubble a.message-link:hover {
  text-decoration-thickness: 2px;
}

.message.user .bubble a.message-link {
  color: #fff;
}

.bubble code.inline-code {
  position: relative;
  padding: 1px 4px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.055);
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  transition: background 120ms ease;
}

.bubble code.inline-code:hover,
.bubble code.inline-code:focus-visible {
  background: rgba(0, 0, 0, 0.085);
}

.bubble code.inline-code.copied {
  background: var(--accent);
  color: #fff;
}

.bubble code.inline-code.copied::after {
  content: "已复制";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  z-index: 3;
  transform: translateX(-50%);
  padding: 3px 7px;
  border-radius: 7px;
  background: var(--text);
  color: var(--surface);
  font-family: var(--app-font);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
}

:root[data-theme="dark"] .bubble code.inline-code {
  background: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .bubble code.inline-code:hover,
:root[data-theme="dark"] .bubble code.inline-code:focus-visible {
  background: rgba(255, 255, 255, 0.14);
}

.message-code-block {
  position: relative;
  margin: 10px 0;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.54);
}

:root[data-theme="dark"] .message-code-block {
  background: rgba(255, 255, 255, 0.06);
}

.message-code-block figcaption {
  position: absolute;
  top: 6px;
  right: 7px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.message-code-copy {
  flex: 0 0 auto;
  width: auto;
  height: 18px;
  max-width: 100%;
  padding: 0 5px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  opacity: 0.72;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.message-code-copy:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  opacity: 1;
}

.message-code-copy:focus-visible {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  opacity: 1;
  outline: none;
}

:root[data-theme="dark"] .message-code-copy:hover,
:root[data-theme="dark"] .message-code-copy:focus-visible {
  background: rgba(255, 255, 255, 0.10);
}

.message-code-copy:disabled {
  cursor: default;
  opacity: 0.8;
}

.message-code-copy.copied {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  font-size: 0;
  opacity: 1;
}

:root[data-theme="dark"] .message-code-copy.copied {
  background: rgba(255, 255, 255, 0.10);
}

.message-code-copy.copied::before {
  content: "已复制";
  font-size: 11px;
  line-height: 18px;
}

.message-code-block pre {
  margin: 0;
  max-width: 100%;
  overflow: auto;
  padding: 12px;
  color: #23252a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

:root[data-theme="dark"] .message-code-block pre {
  color: rgba(255, 255, 255, 0.88);
}

.message-code-block code {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  tab-size: 2;
}

.syntax-keyword {
  color: #c94f8d;
}

.syntax-variable {
  color: #2f8f8d;
}

.syntax-property,
.syntax-parameter {
  color: #c79424;
}

.syntax-function,
.syntax-class {
  color: #2f9f9d;
}

.syntax-string {
  color: #42a85f;
}

.syntax-number,
.syntax-literal {
  color: #986bd6;
}

.syntax-operator {
  color: #d74f5a;
}

.syntax-punctuation {
  color: #555b66;
}

.syntax-comment {
  color: #8a95a3;
  font-style: italic;
}

:root[data-theme="dark"] .syntax-keyword {
  color: #ff7ab2;
}

:root[data-theme="dark"] .syntax-variable,
:root[data-theme="dark"] .syntax-function,
:root[data-theme="dark"] .syntax-class {
  color: #65d6d4;
}

:root[data-theme="dark"] .syntax-property,
:root[data-theme="dark"] .syntax-parameter {
  color: #e6b450;
}

:root[data-theme="dark"] .syntax-string {
  color: #7ee787;
}

:root[data-theme="dark"] .syntax-number,
:root[data-theme="dark"] .syntax-literal {
  color: #c6a0ff;
}

:root[data-theme="dark"] .syntax-operator {
  color: #ff7b72;
}

:root[data-theme="dark"] .syntax-punctuation {
  color: #b8c0cc;
}

:root[data-theme="dark"] .syntax-comment {
  color: #8b949e;
}

:root[data-theme="dark"] .bubble {
  background: rgba(255, 255, 255, 0.1);
}

.message.user .bubble {
  background: #2f68d8;
  color: #fff;
}

.command-result.session-list {
  display: grid;
  gap: 6px;
  min-width: min(520px, 68vw);
  margin-top: 9px;
}

.command-session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.command-session-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.command-session-main strong,
.command-session-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-session-main strong {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.command-session-main small,
.command-session-side {
  color: var(--faint);
  font-size: 11px;
  line-height: 1.25;
}

.command-session-side {
  white-space: nowrap;
}

:root[data-theme="dark"] .command-session-row {
  background: rgba(255, 255, 255, 0.06);
}

.message-time {
  margin: 0 8px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1;
}

.typing-status {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--accent);
}

.streaming-text {
  white-space: pre-wrap;
  margin-bottom: 6px;
}

.typing-dots {
  display: inline-flex;
  gap: 2px;
}

.typing-dots i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.25;
  animation: typingDotBlink 1.4s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDotBlink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 100%;
}

.message-attachment {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  max-width: 260px;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.42);
  color: inherit;
  line-height: 1;
  text-decoration: none;
}

.message-attachment.image {
  display: block;
  width: min(360px, 58vw);
  max-width: 100%;
  height: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  cursor: zoom-in;
}

.message-attachment-thumb {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
}

.message-attachment.image .message-attachment-thumb {
  width: 100%;
  height: auto;
  max-height: 360px;
  border-radius: 8px;
  object-fit: contain;
}

.message-attachment strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  position: relative;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px 18px 12px;
  background: var(--surface-soft);
}

/* Borderless card: depth from a soft shadow, not a dividing line.
   Mirrors the desktop renderer composer card. */
.composer-card {
  display: grid;
  gap: 2px;
  padding: 8px 8px 7px 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(15, 20, 40, 0.07);
  transition: box-shadow 160ms ease;
}

.composer-card:focus-within {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 3px rgb(var(--accent-rgb) / 0.10), 0 10px 28px rgba(15, 20, 40, 0.09);
}

:root[data-theme="dark"] .composer-card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.30), 0 10px 28px rgba(0, 0, 0, 0.30);
}

:root[data-theme="dark"] .composer-card:focus-within {
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.18), 0 12px 30px rgba(0, 0, 0, 0.36);
}

/* Top row: textarea grows, send pinned top-right. */
.composer-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: start;
  gap: 8px;
  min-width: 0;
}

/* Toolbar row inside the card: + button then switchers. */
.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-top: 1px;
}

.composer-add-button {
  position: relative;
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  margin-left: -6px;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 0;
}

.composer-add-button::before,
.composer-add-button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 15px;
  height: 1.6px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.composer-add-button::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.composer-add-button:hover {
  background: var(--hover);
  color: var(--text);
}

.composer textarea {
  min-height: 32px;
  max-height: 156px;
  height: 32px;
  border: 0;
  outline: 0;
  resize: none;
  padding: 6px 0 4px;
  background: transparent;
  color: var(--text);
  overflow-y: hidden;
}

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

/* Circle-arrow send (matches the desktop arrow-up icon): accent when enabled,
   faint when disabled. Web has no Lottie player, so it stays a static SVG. */
.send-button {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-size: 0;
  transition: color 120ms ease, transform 160ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 120ms ease;
}

.send-button svg {
  width: 30px;
  height: 30px;
}

.send-button:hover {
  transform: scale(1.08);
}

.send-button:active {
  transform: scale(0.94);
}

.send-button:disabled {
  color: var(--faint);
  cursor: default;
  transform: none;
}

.composer-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.composer-dot {
  color: var(--faint);
  font-size: 12px;
  font-weight: 340;
  line-height: 26px;
  pointer-events: none;
  user-select: none;
}

.model-switcher {
  position: relative;
  display: inline-grid;
  grid-template-columns: 16px minmax(0, max-content);
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: min(280px, 42vw);
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.model-switcher:hover {
  background: var(--hover);
}

.model-switcher:focus-within {
  background: var(--field);
}

.model-avatar {
  position: relative;
  z-index: 2;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  background: rgb(var(--accent-rgb) / 0.14);
  background-size: 14px 14px;
  background-position: center;
  background-repeat: no-repeat;
  color: var(--accent);
  font-size: 10px;
  font-weight: 400;
  pointer-events: none;
}

.model-avatar img {
  display: block;
  width: 16px;
  height: 16px;
}

.model-current-label {
  position: relative;
  z-index: 2;
  min-width: 0;
  max-width: calc(min(280px, 42vw) - 36px);
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 340;
  line-height: 26px;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-switcher select {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  border-radius: 8px;
  outline: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  font-size: 12px;
  font-weight: 340;
  opacity: 0;
  box-shadow: none;
}

.effort-switcher,
.permission-switcher {
  position: relative;
  display: inline-grid;
  grid-template-columns: max-content;
  align-items: center;
  height: 26px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.effort-switcher {
  padding: 0 6px;
}

.permission-switcher {
  padding: 0 8px;
}

.effort-switcher:hover,
.permission-switcher:hover {
  background: var(--hover);
}

.effort-switcher:focus-within,
.permission-switcher:focus-within {
  background: var(--field);
}

.effort-label,
.permission-label {
  position: relative;
  z-index: 2;
  font-size: 12px;
  font-weight: 340;
  line-height: 26px;
  pointer-events: none;
  white-space: nowrap;
}

.effort-label {
  color: var(--faint);
}

.permission-label {
  color: var(--muted);
}

.permission-switcher.yolo .permission-label {
  color: #8b5cf6;
}

.permission-switcher.claude-bypass .permission-label {
  color: #b88712;
}

.effort-switcher select,
.permission-switcher select {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  outline: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  font-size: 12px;
  font-weight: 340;
  opacity: 0;
  box-shadow: none;
}

.model-switcher select:disabled,
.effort-switcher select:disabled,
.permission-switcher select:disabled {
  cursor: default;
}

.model-switch-status {
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-switch-status.online {
  color: var(--accent);
}

.composer-attachments {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  overflow-x: auto;
}

.composer-attachment {
  display: inline-grid;
  grid-template-columns: 26px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  min-width: 132px;
  height: 38px;
  padding: 3px 4px 3px 3px;
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.composer-attachment img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}

.composer-attachment span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-attachment strong,
.composer-attachment em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: normal;
  font-weight: 500;
  line-height: 1.2;
}

.composer-attachment em {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.composer-attachment button {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
}

.image-preview-overlay img {
  display: block;
  max-width: min(100%, 1280px);
  max-height: calc(100dvh - 56px);
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.42);
  cursor: default;
}

.image-preview-close {
  position: fixed;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 24px;
}

.utility-view {
  min-height: 0;
  overflow: auto;
  padding: 20px;
  background: var(--surface);
}

.utility-shell {
  display: grid;
  gap: 16px;
  max-width: 920px;
}

.profile-panel,
.utility-hero,
.bridge-panel {
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.profile-panel {
  grid-template-columns: 72px minmax(0, 1fr) auto;
}

.profile-large {
  width: 72px;
  height: 72px;
}

.profile-panel h2,
.utility-hero h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 620;
}

.profile-panel p,
.utility-hero p {
  margin-top: 4px;
  color: var(--muted);
}

.bridge-panel {
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.4fr) auto;
}

.bridge-panel h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.bridge-panel p {
  margin-top: 4px;
  color: var(--muted);
}

.bridge-panel code {
  min-width: 0;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}

.bridge-panel-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.bridge-device-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  min-width: 0;
}

.bridge-device {
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 54px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.bridge-device.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent);
}

.bridge-device strong,
.bridge-device span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bridge-device strong {
  font-size: 13px;
  font-weight: 620;
}

.bridge-device span {
  color: var(--muted);
  font-size: 11px;
}

.utility-action {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

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

.utility-grid article {
  display: grid;
  gap: 8px;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.utility-grid strong,
.timeline-list strong {
  font-weight: 560;
}

.utility-grid span,
.timeline-list p,
.timeline-list em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

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

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

.timeline-list article > span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 10020;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

/* Social panel */
.social-panel {
  display: grid;
  align-content: start;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.social-panel-inner {
  padding: 8px 0 12px;
}

.social-my-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--muted);
}

.social-my-user strong {
  color: var(--text);
}

.social-copy-btn {
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--field);
  color: var(--muted);
  font-size: 12px;
}

.social-copy-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.social-add-friend-row {
  padding: 4px 10px 4px;
}

.social-toggle-add-friend {
  width: auto;
  padding: 0 10px;
  font-size: 13px;
}

.social-add-friend-form {
  display: flex;
  gap: 6px;
  padding: 4px 10px 6px;
}

.social-add-friend-form input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.social-add-friend-form input:focus {
  border-color: rgb(var(--accent-rgb) / 0.5);
}

.social-send-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.social-add-friend-result {
  padding: 2px 14px 4px;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}

.social-section-header {
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--faint);
  text-transform: uppercase;
}

.social-subsection-header {
  padding: 2px 14px 2px;
  font-size: 11px;
  color: var(--faint);
}

.social-request-list {
  padding: 0 0 4px;
}

.social-request-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 14px;
  font-size: 13px;
}

.social-request-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.social-request-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.social-accept-btn,
.social-reject-btn,
.social-cancel-btn {
  height: 26px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
}

.social-accept-btn {
  background: var(--accent);
  color: #fff;
}

.social-reject-btn,
.social-cancel-btn {
  background: var(--field);
  color: var(--muted);
}

.social-reject-btn:hover,
.social-cancel-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.social-conversation-list {
  padding: 0 0 4px;
}

.social-empty {
  padding: 4px 14px;
  font-size: 12px;
  color: var(--faint);
}

/* Social chat layout */
.social-chat-layout {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--surface);
}

.social-chat-layout .chat {
  background: var(--surface);
}

.social-chat-empty {
  padding: 24px;
  color: var(--faint);
  font-size: 14px;
  text-align: center;
}

.social-msg-sender {
  font-size: 11px;
  color: var(--faint);
  margin: 0 4px 2px;
}

.social-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 10px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.social-composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 120px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  padding: 8px 12px;
  resize: none;
  background: var(--field);
  color: var(--text);
  font: inherit;
}

.social-composer textarea:focus {
  border-color: rgb(var(--accent-rgb) / 0.5);
  background: var(--surface);
}

@media (max-width: 760px) {
  body {
    background: var(--surface);
  }

  .main-view {
    grid-template-columns: 54px minmax(0, 1fr);
    padding: 0;
  }

  .nav-rail {
    grid-column: 1;
    grid-row: 1;
  }

  .sidebar,
  .workspace {
    grid-column: 2;
    grid-row: 1;
    border-radius: 0;
    box-shadow: none;
  }

  .main-view[data-pane="chat"] .sidebar {
    display: none;
  }

  .main-view:not([data-pane="chat"]) .workspace {
    display: none;
  }

  .narrow-back-button {
    display: grid;
    flex: 0 0 auto;
  }

  .topbar {
    min-height: 58px;
    padding: 9px 10px;
  }

  .session-trigger {
    grid-template-columns: minmax(52px, 120px);
    height: 32px;
    padding: 0 8px;
  }

  .session-menu {
    top: 38px;
    right: 0;
  }

  .group-title {
    gap: 9px;
  }

  .group-title h1 {
    font-size: 15px;
  }

  .sync-pill,
  #logoutButton {
    display: none;
  }

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

  .message-attachment.image {
    width: min(100%, 320px);
  }

  .model-switch-status {
    display: none;
  }

  .utility-view {
    padding: 12px;
  }

  .profile-panel {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .profile-large {
    width: 54px;
    height: 54px;
  }

  .profile-panel .utility-action {
    grid-column: 1 / -1;
  }

  .bridge-panel {
    grid-template-columns: 1fr;
  }

  .bridge-panel code {
    white-space: normal;
    word-break: break-all;
  }

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

/* ── create-menu (＋ dropdown in sidebar header) ─────────────────────────── */

.sidebar-tools {
  position: relative;
}

.create-menu {
  position: absolute;
  top: 52px;
  right: 10px;
  z-index: 18;
  display: grid;
  width: max-content;
  min-width: 128px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.create-menu.hidden {
  display: none;
}

.create-menu button {
  display: grid;
  grid-template-columns: 16px max-content;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
}

.create-menu button:hover:not(:disabled) {
  background: var(--hover);
}

.create-menu-icon,
.create-menu-icon svg {
  width: 16px;
  height: 16px;
}

.create-menu-label {
  color: inherit;
}

/* ── per-conversation ⋯ menu (.persona-row hover/active above) ──────────── */

.persona-more {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s ease-out, background 0.12s ease-out;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.persona-row:hover .persona-more,
.persona-more:focus-visible {
  opacity: 1;
}

.persona-more:hover {
  background: var(--hover);
  color: var(--text);
}

.conv-menu {
  position: fixed;
  z-index: 90;
  min-width: 130px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}

.conv-menu.hidden {
  display: none;
}

.conv-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.conv-menu button:hover {
  background: var(--hover);
}

.conv-menu .conv-menu-danger {
  color: #ff3b30;
}

.conv-menu .conv-menu-danger:hover {
  background: rgba(255, 59, 48, 0.12);
}

/* ── settings modal ────────────────────────────────────────────────────── */

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.32);
}

.settings-modal.hidden {
  display: none;
}

.settings-dialog {
  position: relative;
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  display: grid;
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.settings-close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.settings-close-button:hover {
  background: var(--hover);
  color: var(--text);
}

.settings-layout {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  min-height: 360px;
  max-height: calc(100vh - 80px);
}

.settings-tabs {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 18px 8px;
  border-right: 1px solid var(--line);
  background: var(--surface-muted);
}

.settings-tab {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.settings-tab:hover {
  background: var(--hover);
  color: var(--text);
}

.settings-tab.active {
  background: var(--list-active);
  color: var(--accent);
}

.settings-content {
  padding: 22px 22px 28px;
  overflow: auto;
}

.settings-panel.hidden {
  display: none;
}

.runtime-card.mobile-pairing-card {
  display: grid;
  gap: 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface);
}

.connection-row {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 16px 22px;
  background: var(--surface);
}

.connection-row:not(:last-of-type)::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 0;
  left: 22px;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}

.connection-row-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.connection-row-head strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.connection-row-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.connection-details {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.web-bot-dialog,
.web-avatar-crop-modal {
  padding: 24px;
  background: rgba(16, 20, 39, 0.24);
}

.web-avatar-crop-modal {
  z-index: 90;
}

.bot-form {
  display: grid;
  gap: 14px;
  width: min(430px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.bot-dialog-head,
.bot-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bot-dialog-head h2,
.avatar-crop-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.bot-form label,
.persona-details label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.bot-form input,
.bot-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

.bot-form textarea {
  min-height: 118px;
  resize: vertical;
}

.web-bot-runtime-fixed {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  min-height: 34px;
  padding: 4px 10px 4px 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
}

.web-bot-runtime-logo {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

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

.avatar-crop-preview {
  position: relative;
  width: 82px;
  height: 82px;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  background-repeat: no-repeat;
  box-shadow: none;
  cursor: pointer;
}

.avatar-crop-preview:hover,
.avatar-crop-preview:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.avatar-drop {
  display: grid;
  gap: 7px;
  align-content: center;
  min-height: 82px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--field);
  color: var(--muted);
}

.avatar-drop.dragging {
  border-color: var(--accent);
  background: var(--list-active);
}

.avatar-file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: max-content;
}

.avatar-file-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.avatar-drop span,
.persona-details label span,
.avatar-crop-actions span {
  color: var(--muted);
  font-size: 12px;
}

.persona-details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
}

.persona-details summary {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  list-style: none;
}

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

.persona-details summary::after {
  content: "⌄";
  float: right;
  color: var(--faint);
}

.persona-details label {
  padding: 0 12px 12px;
}

.bot-dialog-actions {
  justify-content: flex-end;
}

.avatar-crop-card {
  display: grid;
  gap: 14px;
  width: min(390px, calc(100vw - 48px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.avatar-crop-head,
.avatar-crop-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.avatar-crop-stage {
  position: relative;
  width: min(320px, calc(100vw - 96px));
  aspect-ratio: 1;
  justify-self: center;
  overflow: hidden;
  border-radius: 12px;
  background-repeat: no-repeat;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.avatar-crop-stage:active {
  cursor: grabbing;
}

.avatar-crop-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.2);
}

.avatar-crop-circle {
  position: absolute;
  inset: 22px;
  z-index: 2;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.cloud-login-grid {
  display: grid;
  gap: 8px;
}

.cloud-login-grid input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

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

.cloud-actions {
  display: flex;
  gap: 6px;
}

.primary {
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.secondary {
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.secondary:hover:not(:disabled) {
  background: var(--hover);
}

/* Settings rows mirror desktop: a single unified card per group,
   horizontal dividers between rows, no per-row borders or chunky margins.
   The first/last row in a group rounds its corresponding corners. */
.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.settings-section-label {
  margin: 16px 4px 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.2;
}

.settings-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(160px, 280px);
  align-items: center;
  gap: 18px;
  min-height: 66px;
  padding: 12px 22px;
  border: 0;
  background: var(--surface);
}

.settings-row:first-of-type,
.settings-row.settings-group-start {
  border-radius: 14px 14px 0 0;
}

.settings-row:last-of-type,
.settings-row.settings-group-end {
  border-radius: 0 0 14px 14px;
}

.settings-row.settings-group-start.settings-group-end,
.settings-row:first-of-type:last-of-type {
  border-radius: 14px;
}

.settings-row:not(:last-of-type):not(.settings-group-end)::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 0;
  left: 22px;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}

.settings-row > div:first-child {
  min-width: 0;
}

.settings-row strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
}

.settings-row p {
  margin: 2px 0 0;
  color: var(--faint);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
}

.settings-row > select,
.settings-row > input[type="color"],
.settings-row > .settings-switch-wrap {
  justify-self: end;
}

.settings-row > select {
  width: 100%;
  max-width: 170px;
  min-height: 34px;
  padding: 0 28px 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background-color: var(--field);
  color: var(--text);
  font-weight: 400;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

.settings-row > select:focus {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.12);
}

.settings-row > input[type="color"] {
  width: 36px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--field);
  cursor: pointer;
}

.settings-row select {
  min-width: 120px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background-color: var(--field);
  color: var(--text);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.bubble-sender {
  display: block;
  font-size: 0.82em;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 4px;
}

.bubble-sender + p,
.bubble-sender + ul,
.bubble-sender + ol,
.bubble-sender + pre {
  margin-top: 0;
}

.mention {
  display: inline;
  padding: 0 4px;
  border-radius: 4px;
  background: rgb(var(--accent-rgb, 94 92 230) / 0.14);
  color: rgb(var(--accent-rgb, 94 92 230));
  font-weight: 500;
  text-decoration: none;
}

.message.user .mention {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* ── narrow viewport: rail → bottom bar ──────────────────────────────────── */

@media (max-width: 640px) {
  .main-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 56px;
    padding: 0;
  }

  .nav-rail {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 56px;
    align-items: center;
    justify-items: center;
    gap: 0;
    padding: 0;
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .nav-rail .rail-logo,
  .nav-rail .rail-spacer {
    display: none;
  }

  .nav-rail .rail-button {
    width: 48px;
    height: 48px;
  }

  .sidebar,
  .workspace {
    grid-column: 1;
    grid-row: 1;
    border-radius: 0;
    box-shadow: none;
  }

  .main-view[data-pane="chat"] .sidebar {
    display: none;
  }

  .main-view:not([data-pane="chat"]) .workspace {
    display: none;
  }
}

/* ----- terminal-style trace (reasoning + tools) -----
   Mirrors src/renderer/styles/chat.css trace block styles so web shares the
   same details/summary affordance as desktop. */

.permission-banner {
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border, rgba(120, 120, 130, 0.28));
  border-left: 3px solid #e0a106;
  border-radius: 12px;
  background: color-mix(in srgb, #e0a106 8%, var(--surface, #fff));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.permission-banner .permission-head {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1f2328);
}

.permission-banner .permission-preview {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(120, 120, 130, 0.1);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow: auto;
}

.permission-banner .permission-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.permission-banner .permission-actions button {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(120, 120, 130, 0.28));
  background: var(--surface, #fff);
  color: var(--text, #1f2328);
  font-size: 13px;
  cursor: pointer;
}

.permission-banner .permission-actions button:hover {
  background: rgba(120, 120, 130, 0.12);
}

.permission-banner .permission-allow {
  border-color: #1b8e57;
  color: #1b8e57;
}

.permission-banner .permission-always {
  background: #1b8e57;
  border-color: #1b8e57;
  color: #fff;
}

.permission-banner .permission-deny {
  color: #b4493b;
}

.trace {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted, #6b7280);
  opacity: 0.78;
}

.trace-row {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.trace-anim-enter {
  animation: traceRowEnter 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: var(--trace-delay, 0ms);
}

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

.trace-row > summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 6px 2px 2px;
  list-style: none;
  user-select: none;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.trace-row > summary::-webkit-details-marker { display: none; }

.trace-row:hover > summary {
  background: rgba(15, 23, 42, 0.05);
}

.trace-chevron {
  display: inline-block;
  width: 10px;
  flex: 0 0 auto;
  color: var(--muted, #94a3b8);
  transition: transform 120ms ease;
}

.trace-row[open] > summary > .trace-chevron {
  transform: rotate(90deg);
}

.trace-glyph {
  flex: 0 0 auto;
  width: 10px;
  text-align: center;
  font-weight: 400;
}

.trace-row[data-status="run"] > summary > .trace-glyph {
  color: #6366f1;
  animation: traceGlyphPulse 1.2s ease-in-out infinite;
}

.trace-row[data-status="ok"] > summary > .trace-glyph { color: #16a34a; }
.trace-row[data-status="err"] > summary > .trace-glyph { color: #dc2626; }

@keyframes traceGlyphPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.trace-cmd {
  flex: 0 0 auto;
  color: var(--text, #1f2937);
  font-weight: 400;
}

.trace-arg {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.7;
}

.trace-row[open] > summary > .trace-arg { display: none; }

.trace-meta {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 11px;
  opacity: 0.55;
}

.trace-body {
  margin: 2px 0 6px 18px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-left: 2px solid rgba(15, 23, 42, 0.12);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--muted, #6b7280);
  opacity: 0.85;
  max-height: 240px;
  overflow: auto;
}

.trace-row[data-auto-open="true"] .trace-body { max-height: 6.8em; }
.trace-row[data-user-open="true"] .trace-body { max-height: 240px; }

@media (prefers-reduced-motion: reduce) {
  .trace-anim-enter,
  .trace-row[data-status="run"] > summary > .trace-glyph {
    animation: none;
  }
}
