:root {
  --bg: #0f1117;
  --sidebar: #171922;
  --panel: #1f222e;
  --panel-hover: #2a2e3d;
  --field: #191c26;
  --composer: #232326;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: #303442;
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

body.dev-open .app-shell {
  grid-template-columns: 280px minmax(0, 1fr) 330px;
}

.sidebar,
.developer-panel {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  height: 100dvh;
  min-height: 100dvh;
  padding: 18px 20px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.developer-panel {
  display: none;
  border-left: 1px solid var(--border);
  border-right: 0;
  overflow-y: auto;
}

body.dev-open .developer-panel {
  display: block;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  background: #101217;
  border: 1px solid var(--border);
  border-radius: 12px;
  object-fit: cover;
}

.brand-title {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1;
}

.account-line,
.discord-profile,
.model-label,
.model-block span,
.status,
.chat-meta,
.message-role,
.reflection,
.welcome-subtitle,
.field-row span,
.dev-section h3,
.section-head {
  color: var(--muted);
}

.account-line {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discord-profile {
  align-items: center;
  display: flex;
  gap: 10px;
  min-height: 38px;
  padding: 0 2px;
}

.discord-avatar {
  align-items: center;
  background: var(--panel);
  background-position: center;
  background-size: cover;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 750;
  height: 34px;
  justify-content: center;
  width: 34px;
}

body:not(.discord-connected) .discord-profile {
  color: var(--muted);
}

body:not(.discord-connected) .account-line {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.account-actions [data-action="logout"],
.model-block {
  display: none;
}

body.discord-connected .account-actions [data-action="login"],
body:not(.discord-connected) .settings-buttons [data-action="logout"] {
  display: none;
}

body:not(.discord-connected) .settings-buttons {
  grid-template-columns: 1fr;
}

.account-actions {
  display: grid;
  gap: 8px;
}

.button,
.icon-button,
.send-button,
.chat-item {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 34px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.button:disabled,
.icon-button:disabled,
.send-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.button svg,
.icon-button svg,
.send-button svg {
  height: 17px;
  width: 17px;
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
  font-weight: 650;
}

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

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

.button-soft:hover,
.button-ghost:hover,
.tiny:hover,
.icon-button:hover,
.chat-item:hover {
  background: var(--panel-hover);
  border-color: #44495c;
}

.button-ghost,
.tiny,
.mode-button {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.new-chat {
  min-height: 40px;
  width: 100%;
}

.section-head {
  align-items: center;
  display: flex;
  font-size: 14px;
  font-weight: 650;
  justify-content: space-between;
  margin-top: 6px;
}

.compact {
  height: 28px;
  width: 28px;
}

.chat-list {
  display: grid;
  gap: 8px;
  min-height: 120px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
}

.chat-item {
  background: var(--panel);
  border-color: transparent;
  color: var(--text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 60px;
  padding: 8px 10px 8px 14px;
  text-align: left;
  width: 100%;
}

.chat-item.active {
  background: var(--accent);
  border-color: var(--accent-hover);
}

.chat-title {
  display: block;
  font-weight: 650;
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-meta {
  display: block;
  font-size: 12px;
  margin-top: 5px;
}

.chat-actions {
  display: inline-flex;
  gap: 4px;
  min-width: 86px;
}

.chat-actions .icon-button {
  height: 26px;
  width: 26px;
}

.sidebar-bottom {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.settings-popover {
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  bottom: 78px;
  box-shadow: var(--shadow);
  display: none;
  left: 20px;
  padding: 14px;
  position: fixed;
  width: 320px;
  z-index: 30;
}

body.settings-open .settings-popover {
  display: block;
}

body.settings-management-open .settings-popover {
  width: min(460px, calc(100vw - 24px));
}

.settings-titlebar {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  margin-bottom: 14px;
}

.settings-titlebar svg {
  color: var(--text);
  height: 22px;
  width: 22px;
}

.settings-titlebar strong {
  font-size: 15px;
}

.settings-back {
  display: none;
}

body.settings-management-open .settings-back {
  display: inline-flex;
}

body.settings-management-open .settings-icon,
body.settings-management-open .settings-main-page,
.settings-management-page {
  display: none;
}

body.settings-management-open .settings-management-page {
  display: grid;
}

.settings-close {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.settings-main-page,
.settings-management-page {
  gap: 14px;
}

.settings-account {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  gap: 10px;
  padding: 12px 14px 10px;
}

.settings-eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings-profile {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 46px;
}

.settings-avatar {
  align-items: center;
  background: var(--panel);
  background-position: center;
  background-size: cover;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: 15px;
  font-weight: 750;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.settings-name {
  color: var(--text);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-buttons {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.settings-mini-button {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  min-height: 30px;
}

.settings-mini-button:hover {
  background: var(--panel-hover);
}

.settings-mini-button.danger {
  background: #522d34;
  border-color: #6f3840;
  color: #ff8b8b;
}

.settings-dev-row {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 66px;
  margin-top: 14px;
  min-height: 50px;
  padding: 10px 14px 10px 16px;
}

.settings-dev-row.is-hidden {
  display: none;
}

.settings-manage-row {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 82px;
  min-height: 58px;
  padding: 10px 12px 10px 16px;
}

.settings-manage-row.is-hidden {
  display: none;
}

.settings-manage-row strong,
.management-head strong {
  display: block;
  font-size: 14px;
}

.settings-manage-row small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

.settings-switch {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  height: 28px;
}

body.dev-open .settings-switch {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #fafaff;
}

.settings-tabs {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  padding: 4px;
}

.settings-tab {
  background: var(--accent);
  border-radius: 8px;
  color: #ffffff;
  cursor: default;
  font-weight: 700;
  min-height: 32px;
}

.management-head {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 34px;
  min-height: 58px;
  padding: 10px 12px 10px 14px;
}

.members-list {
  display: grid;
  gap: 8px;
  max-height: min(360px, calc(100dvh - 270px));
  overflow-y: auto;
  padding-right: 2px;
}

.member-card {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  padding: 9px 10px;
}

.member-card.is-restricted {
  border-color: #6f3840;
}

.member-summary {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 42px minmax(0, 1fr) 30px auto;
  min-height: 46px;
}

.member-avatar {
  align-items: center;
  background: var(--panel);
  background-position: center;
  background-size: cover;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 750;
  height: 42px;
  justify-content: center;
  overflow: hidden;
  width: 42px;
}

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

.member-name {
  display: block;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-meta {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-menu-button {
  background: transparent;
  color: var(--muted);
}

.member-menu-button.active {
  background: var(--panel-hover);
  border-color: #44495c;
  color: var(--text);
}

.member-menu-button:disabled {
  background: transparent;
  border-color: var(--border);
  color: #686b78;
  cursor: not-allowed;
  opacity: 0.55;
}

.member-badge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  padding: 5px 8px;
  white-space: nowrap;
}

.member-badge.is-helper {
  color: #86efac;
}

.member-badge.is-admin {
  color: #facc15;
}

.member-badge.is-moderator {
  color: #93c5fd;
}

.member-badge.is-developer {
  color: #c4b5fd;
}

.member-card.is-restricted .member-badge {
  background: #522d34;
  border-color: #6f3840;
  color: #ff8b8b;
}

.member-management {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
  padding-top: 10px;
}

.member-management-section {
  display: grid;
  gap: 8px;
}

.member-management-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.member-role-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.member-action-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  min-height: 28px;
  padding: 0 6px;
}

.member-action-chip.active,
.member-action-chip:hover {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.member-action-chip:disabled {
  background: var(--field);
  border-color: var(--border);
  color: #686b78;
  cursor: not-allowed;
  opacity: 0.62;
}

.member-action-chip:disabled:hover {
  background: var(--field);
  color: #686b78;
}

.member-management-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.danger-inline {
  border-color: #6f3840;
  color: #ff8b8b;
}

.member-chats {
  display: grid;
  gap: 7px;
}

.member-chat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.member-chat summary {
  cursor: pointer;
  display: grid;
  gap: 3px;
  list-style: none;
  padding: 9px 10px;
}

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

.member-chat summary span {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-chat summary small {
  color: var(--muted);
  font-size: 11px;
}

.member-chat-messages {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
}

.member-chat-messages p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.member-chat-messages strong {
  color: var(--text);
}

.members-empty {
  background: var(--field);
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.model-block {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 8px;
  gap: 5px;
  padding: 12px;
}

.model-block strong {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-block span {
  font-size: 12px;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto auto;
  height: 100dvh;
  min-height: 100dvh;
  min-width: 0;
  overflow: hidden;
  padding: 18px 24px 20px;
}

.chat-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 10px;
  max-width: 940px;
  width: 100%;
}

.chat-header h1,
.developer-panel h2 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0;
}

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

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.send-button {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
  height: 38px;
  width: 38px;
}

.messages {
  margin: 0 auto;
  max-width: 940px;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 8px 24px;
  scroll-behavior: smooth;
  width: 100%;
}

.welcome {
  display: grid;
  justify-items: center;
  margin-top: 58px;
  text-align: center;
}

.welcome-logo {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  height: 70px;
  margin-bottom: 18px;
  object-fit: cover;
  width: 70px;
}

.welcome h2 {
  font-size: 28px;
  margin: 0;
}

.welcome-subtitle {
  margin: 8px 0 34px;
}

.suggestions {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(180px, 330px));
  justify-content: center;
  width: 100%;
}

.suggestion {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  min-height: 58px;
  padding: 12px 16px;
  text-align: left;
}

.suggestion:hover {
  background: var(--panel-hover);
}

.message {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.message.user {
  justify-items: end;
}

.message.assistant {
  justify-items: start;
}

.reflection {
  font-size: 13px;
  margin-left: 48px;
}

.bubble-wrap {
  align-items: start;
  display: flex;
  gap: 10px;
  max-width: min(760px, calc(100% - 24px));
}

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

.avatar {
  align-items: center;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 750;
  height: 30px;
  justify-content: center;
  margin-top: 9px;
  width: 30px;
}

.avatar.has-image {
  background: var(--panel);
  overflow: hidden;
}

.avatar img {
  border-radius: inherit;
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.message.user .avatar {
  background: var(--accent-hover);
  border-color: #a78bfa;
}

.message.user .avatar.has-image {
  background: var(--panel);
}

.bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  min-width: 240px;
  padding: 12px 18px 16px;
}

.message.user .bubble {
  background: var(--accent);
  border-color: var(--accent-hover);
}

.message-role {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.message.user .message-role {
  color: #f5f0ff;
}

.message-text {
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-actions {
  display: flex;
  gap: 12px;
  margin-left: 48px;
}

.message-actions .icon-button {
  background: transparent;
  height: 30px;
  width: 30px;
}

.message-actions .good.active {
  color: var(--success);
}

.message-actions .bad.active {
  color: var(--danger);
}

.typing {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  min-height: 24px;
}

.typing span {
  animation: pulse 1s infinite ease-in-out;
  background: var(--muted);
  border-radius: 50%;
  height: 6px;
  width: 6px;
}

.typing span:nth-child(2) {
  animation-delay: 140ms;
}

.typing span:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  align-items: center;
  background: var(--composer);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: grid;
  gap: 10px;
  grid-template-columns: 38px minmax(80px, 1fr) auto 38px 46px;
  margin: 0 auto;
  max-width: 940px;
  min-height: 58px;
  padding: 7px 10px 7px 12px;
  width: 100%;
}

.composer textarea {
  background: transparent;
  border: 0;
  color: var(--text);
  max-height: 160px;
  min-height: 24px;
  outline: none;
  resize: none;
  width: 100%;
}

.composer textarea::placeholder {
  color: #777987;
}

.composer-tool {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.mode-button {
  height: 36px;
  min-width: 98px;
  padding: 0 10px;
  white-space: nowrap;
}

.mode-button:disabled {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.72;
}

.mode-button:disabled:hover {
  background: transparent;
  border-color: var(--border);
}

.send-button {
  background: #f4f4f5;
  border-color: #f4f4f5;
  color: #141416;
  height: 44px;
  width: 44px;
}

.send-button:hover {
  background: #ffffff;
}

.underbar {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(80px, 1fr) auto auto;
  margin: 10px auto 0;
  max-width: 940px;
  width: 100%;
}

.tiny {
  min-height: 30px;
  padding: 0 12px;
}

.status {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.developer-panel h2 {
  margin-bottom: 18px;
}

.dev-section {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.dev-section h3 {
  font-size: 13px;
  margin: 0 0 2px;
}

.full {
  width: 100%;
}

.split-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.field-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 90px;
}

.field-row input,
.dev-section textarea {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  min-height: 28px;
  outline: none;
  padding: 5px 8px;
}

.dev-section textarea {
  line-height: 1.4;
  resize: vertical;
  width: 100%;
}

.checks {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.checks label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 7px;
}

.toast {
  background: #111318;
  border: 1px solid var(--border);
  border-radius: 8px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: var(--text);
  left: 50%;
  max-width: min(420px, calc(100vw - 28px));
  padding: 11px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 20;
}

::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}

::-webkit-scrollbar-track {
  background: #16181f;
}

::-webkit-scrollbar-thumb {
  background: #4c505e;
  border: 3px solid #16181f;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #62687a;
}

@media (max-width: 1120px) {
  body.dev-open .app-shell,
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  body.dev-open .developer-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 820px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body.dev-open .app-shell,
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .sidebar,
  .chat-panel,
  .developer-panel {
    height: auto;
    min-height: 0;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    gap: 10px;
    max-height: 38dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 14px;
  }

  .brand {
    min-height: 36px;
  }

  .brand-mark {
    border-radius: 10px;
    height: 36px;
    width: 36px;
  }

  .brand-title {
    font-size: 22px;
  }

  .discord-profile {
    min-height: 32px;
  }

  .discord-avatar {
    height: 30px;
    width: 30px;
  }

  .account-actions .button {
    min-height: 34px;
  }

  .new-chat {
    min-height: 38px;
  }

  .section-head {
    font-size: 12px;
    margin-top: 0;
  }

  .chat-list {
    display: flex;
    gap: 8px;
    max-height: 60px;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 2px 4px 0;
  }

  .chat-item {
    flex: 0 0 min(250px, 72vw);
    min-height: 52px;
    padding: 7px 9px 7px 12px;
  }

  .chat-title {
    max-width: none;
  }

  .chat-meta {
    display: none;
  }

  .chat-actions {
    min-width: auto;
  }

  .chat-actions .icon-button {
    height: 28px;
    width: 28px;
  }

  .sidebar-bottom {
    gap: 8px;
    margin-top: 0;
  }

  .settings-popover {
    bottom: max(72px, env(safe-area-inset-bottom));
    left: 12px;
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    right: 12px;
    width: auto;
  }

  body.settings-management-open .settings-popover {
    width: auto;
  }

  .members-list {
    max-height: min(300px, calc(100dvh - 300px));
  }

  .chat-panel {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    min-height: 0;
    padding: 12px 14px max(10px, env(safe-area-inset-bottom));
  }

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

  .chat-header h1 {
    font-size: 20px;
  }

  .chat-header p {
    font-size: 12px;
  }

  .messages {
    padding: 10px 0 12px;
  }

  .welcome {
    margin-top: 26px;
  }

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

  .composer {
    border-radius: 14px;
    grid-template-columns: 36px minmax(0, 1fr) 42px;
    min-height: 56px;
    padding: 6px 8px;
  }

  .mode-button,
  .composer-tool[data-action="mic"] {
    display: none;
  }

  .underbar {
    grid-template-columns: minmax(0, 1fr) 38px 38px 38px;
    margin-top: 8px;
  }

  .status {
    grid-column: auto;
    order: -1;
  }

  .underbar .tiny {
    min-height: 38px;
    padding: 0;
  }

  .underbar .tiny span {
    display: none;
  }
}

@media (max-width: 520px) {
  .sidebar {
    gap: 8px;
    max-height: 34dvh;
    padding: 10px 12px;
  }

  .chat-panel {
    padding: 10px 10px max(8px, env(safe-area-inset-bottom));
  }

  .messages {
    padding: 8px 0 10px;
  }

  .bubble-wrap {
    gap: 8px;
    max-width: 100%;
  }

  .avatar {
    height: 28px;
    width: 28px;
  }

  .bubble {
    border-radius: 14px;
    max-width: calc(100vw - 84px);
    min-width: 0;
    padding: 10px 14px 12px;
  }

  .message.user .bubble {
    max-width: calc(100vw - 92px);
  }

  .message-actions,
  .reflection {
    margin-left: 36px;
  }

  .header-actions {
    display: none;
  }

  .composer textarea {
    font-size: 16px;
  }

  .send-button {
    border-radius: 12px;
    height: 42px;
    width: 42px;
  }

  .member-summary {
    grid-template-columns: 38px minmax(0, 1fr) 30px auto;
  }

  .member-avatar {
    height: 38px;
    width: 38px;
  }

  .member-role-grid,
  .member-management-actions {
    grid-template-columns: 1fr;
  }

  .split-actions,
  .checks {
    grid-template-columns: 1fr;
  }
}
