:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --line: #d9dee7;
  --text: #15171c;
  --muted: #626a78;
  --accent: #176b87;
  --accent-strong: #0f4c61;
  --bot: #5f4b8b;
  --shadow: 0 18px 48px rgba(24, 32, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.13);
}

.shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  width: 100%;
  min-height: calc(100vh - 72px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

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

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

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.brand p,
.eyebrow,
.empty-state p,
.panel label,
#activeUserLabel {
  color: var(--muted);
}

.brand p {
  margin: 8px 0 0;
}

.sidebar-title {
  padding: 4px 4px 0;
}

.sidebar-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.sidebar-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.status {
  min-width: 74px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #e9edf2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.status.online {
  background: #dff3e8;
  color: #17633a;
}

.panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(24, 32, 44, 0.05);
}

.identity {
  position: relative;
}

.account-toggle {
  display: grid;
  grid-template-columns: 28px minmax(0, auto);
  gap: 8px;
  align-items: center;
  min-height: 40px;
  max-width: 220px;
  padding: 6px 10px 6px 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.account-toggle span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(320px, calc(100vw - 28px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.tab.active {
  border-color: var(--accent);
  background: #e9f6fa;
  color: var(--accent-strong);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form button,
.full-width {
  width: 100%;
  min-height: 40px;
}

.hidden {
  display: none !important;
}

.account-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #e9f6fa;
  color: var(--accent-strong);
  font-weight: 900;
}

.avatar.small {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

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

.account-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.auth-message {
  margin-top: 8px;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.auth-message.error {
  color: #a33a32;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.section-title button,
.inline-form button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.section-action {
  margin-top: 10px;
}

.panel input {
  min-height: 38px;
  padding: 0 11px;
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.list.compact {
  max-height: 160px;
  overflow: auto;
}

.list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.list-item.active {
  border-color: rgba(23, 107, 135, 0.55);
  background: #edf7fa;
}

.list-item strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.bot-token {
  overflow-wrap: anywhere;
}

.check-list {
  display: grid;
  gap: 6px;
  max-height: 150px;
  margin-top: 10px;
  overflow: auto;
}

.check-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.check-item input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.check-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.chat-header h2,
.eyebrow {
  margin: 0;
}

.chat-header h2 {
  margin-top: 4px;
  font-size: 22px;
  letter-spacing: 0;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 22px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.78)),
    repeating-linear-gradient(135deg, #eef1f5 0, #eef1f5 1px, #ffffff 1px, #ffffff 14px);
}

.message {
  max-width: min(720px, 82%);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(24, 32, 44, 0.06);
}

.message.mine {
  align-self: flex-end;
  border-color: rgba(23, 107, 135, 0.28);
  background: #e9f6fa;
}

.message.bot {
  border-color: rgba(95, 75, 139, 0.25);
  background: #f4f0fb;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer textarea {
  min-height: 46px;
  max-height: 150px;
  padding: 12px;
  resize: vertical;
}

.composer button {
  min-height: 46px;
}

.empty-state {
  align-self: center;
  max-width: 360px;
  margin: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  text-align: center;
  box-shadow: var(--shadow);
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.empty-state p {
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .topbar-actions {
    flex-shrink: 0;
  }

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

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

  .chat {
    min-height: 68vh;
  }

  .message {
    max-width: 94%;
  }
}
