:root {
  --bg: #f5f7fb;
  --bg-soft: #eef2fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #111827;
  --text-soft: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e6e9f0;
  --line-strong: #d0d5dd;
  --accent: #2f5cff;
  --accent-strong: #1d45d8;
  --accent-soft: #eef3ff;
  --accent-softer: #f5f8ff;
  --success: #12b76a;
  --success-soft: #e9f9f1;
  --warning: #f79009;
  --warning-soft: #fff7e8;
  --danger: #f04438;
  --danger-soft: #fef0ef;
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 28px 80px rgba(16, 24, 40, 0.18);
  --sidebar-w: 288px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

svg {
  display: block;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none !important;
}

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

.small {
  font-size: 13px;
}

.danger-text {
  color: var(--danger) !important;
}

.dot-sep {
  margin: 0 8px;
  color: var(--muted-2);
}

/* ---------- Boot ---------- */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, var(--bg) 68%);
}

.boot-logo {
  width: 64px;
  height: 64px;
  color: var(--accent);
  animation: breathe 1.8s ease-in-out infinite;
}

.boot-logo svg {
  width: 100%;
  height: 100%;
}

.boot-text {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.02em;
}

/* ---------- Auth ---------- */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(460px, 0.95fr);
  background: var(--surface);
}

.auth-aside {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 64px clamp(40px, 7vw, 96px);
  color: #fff;
  background:
    radial-gradient(circle at 18% 12%, rgba(120, 150, 255, 0.5), transparent 42%),
    radial-gradient(circle at 82% 82%, rgba(58, 208, 255, 0.25), transparent 45%),
    linear-gradient(140deg, #1c3ea8 0%, #274ed4 45%, #16327f 100%);
}

.auth-aside::before,
.auth-aside::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

.auth-aside::before {
  width: 540px;
  height: 540px;
  right: -220px;
  top: -180px;
}

.auth-aside::after {
  width: 380px;
  height: 380px;
  left: -160px;
  bottom: -160px;
}

.auth-aside-inner {
  position: relative;
  z-index: 1;
  max-width: 520px;
  padding-top: 8vh;
}

.brand-mark {
  display: inline-flex;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  overflow: hidden;
  flex: none;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-mark.large {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  color: var(--accent);
  background: #fff;
  box-shadow: 0 16px 40px rgba(8, 20, 60, 0.24);
}

.auth-aside h1 {
  margin-top: 34px;
  font-size: clamp(38px, 4vw, 54px);
  line-height: 1.16;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-aside p {
  margin-top: 20px;
  max-width: 430px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 16px;
  line-height: 1.8;
}

.auth-points {
  margin-top: 38px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-points li {
  position: relative;
  padding-left: 30px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
}

.auth-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.75);
}

.auth-aside-foot {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.58);
  font-size: 13px;
}

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px clamp(28px, 5vw, 72px);
  background:
    radial-gradient(circle at 80% 10%, #f1f5ff 0%, transparent 40%),
    var(--surface);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  animation: fadeUp 0.45s ease both;
}

.auth-mobile-brand {
  display: none;
}

.auth-card-head h2 {
  font-size: 30px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card-head p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.18s ease;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
}

.field em {
  font-style: normal;
  font-weight: 400;
  color: var(--muted-2);
  margin-left: 4px;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  padding: 11px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted-2);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 92, 255, 0.12);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-error {
  min-height: 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.form-error:empty {
  display: none;
}

.auth-note,
.privacy-note,
.auth-disclaimer {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.privacy-note {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.auth-disclaimer {
  margin-top: 6px;
  color: var(--muted-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, #3c68ff, #2f5cff);
  color: #fff;
  box-shadow: 0 8px 20px rgba(47, 92, 255, 0.24);
}

.btn.primary:hover {
  background: linear-gradient(180deg, #2f5cff, #2149d8);
  color: #fff;
}

.btn.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-soft);
}

.btn.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-softer);
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn.block {
  width: 100%;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: all 0.18s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn.subtle {
  font-size: 15px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 500;
}

.text-btn:hover {
  color: var(--text);
  text-decoration: none;
}

.text-btn.danger {
  color: var(--danger);
}

/* ---------- Status screen ---------- */
.status-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 15%, #eef3ff 0%, transparent 50%),
    var(--bg);
}

.status-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 44px 40px;
  text-align: center;
  animation: fadeUp 0.4s ease both;
}

.status-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: var(--accent-soft);
  font-size: 28px;
}

.status-card h2 {
  font-size: 24px;
  font-weight: 700;
}

.status-card p {
  margin-top: 12px;
  color: var(--muted);
}

.status-actions {
  margin-top: 26px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.status-foot {
  margin-top: 20px;
  font-size: 12px;
  color: var(--muted-2);
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 16px 14px 14px;
  min-height: 0;
  z-index: 30;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 14px;
}

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

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

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text small {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 1px;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--accent-softer);
  color: var(--accent-strong);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.18s ease;
}

.new-chat:hover {
  border-color: #c7d5ff;
  background: var(--accent-soft);
}

.new-chat-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(47, 92, 255, 0.12);
  font-size: 16px;
  line-height: 1;
}

.kb-badge {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.12);
  animation: dotPulse 2.4s ease-in-out infinite;
  flex: none;
}

.history-head {
  margin-top: 20px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.history-filters {
  display: flex;
  gap: 4px;
  padding: 8px 4px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.history-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 2px 12px;
  margin: 0 -2px;
}

.history-group-label {
  padding: 12px 8px 6px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.history-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 28px 9px 9px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.16s ease;
}

.history-item:hover {
  background: var(--surface-2);
}

.history-item.active {
  background: var(--accent-soft);
}

.history-icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  margin-top: 1px;
}

.history-item.active .history-icon {
  background: #fff;
}

.history-text {
  min-width: 0;
  flex: 1;
}

.history-title {
  font-size: 13px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted-2);
}

.history-delete {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted-2);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  opacity: 0;
  transition: all 0.16s ease;
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.history-empty {
  padding: 24px 10px;
  text-align: center;
  color: var(--muted-2);
  font-size: 12px;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  flex: none;
}

.quota-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-softer);
  border: 1px solid #e1e9ff;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.quota-ring {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 1px #fff;
  background: var(--accent);
  flex: none;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px 8px;
}

.user-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 2px;
  color: var(--muted);
  font-size: 12px;
}

.user-avatar,
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4b74ff, #2447c9);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.avatar.large {
  width: 46px;
  height: 46px;
  font-size: 18px;
}

.role-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 600;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 80% -10%, #eef3ff 0%, transparent 36%),
    var(--bg);
}

.topbar {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(230, 233, 240, 0.85);
  background: rgba(245, 247, 251, 0.86);
  backdrop-filter: blur(14px);
  z-index: 10;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s ease;
  white-space: nowrap;
}

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

.mode-tab.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.mode-ico {
  font-size: 14px;
  line-height: 1;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.mock-badge {
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--warning-soft);
  border: 1px solid #fde3b8;
  color: #b54708;
  font-size: 11px;
  font-weight: 600;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.chat-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 28px 20px;
}

/* ---------- Welcome ---------- */
.welcome {
  padding: 5vh 0 28px;
  text-align: center;
  animation: fadeUp 0.45s ease both;
}

.welcome-orb {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background:
    radial-gradient(circle at 30% 20%, #ffffff, transparent 55%),
    linear-gradient(145deg, #dce6ff, #b9ccff);
  color: var(--accent-strong);
  font-size: 30px;
  box-shadow: 0 14px 34px rgba(47, 92, 255, 0.16);
}

.welcome h1 {
  font-size: 32px;
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.welcome p {
  margin: 10px auto 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 14px;
}

.suggestions {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}

.suggestion {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
  transition: all 0.18s ease;
}

.suggestion:hover {
  border-color: #c9d6ff;
  background: #fff;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
  transform: translateY(-1px);
}

.suggestion .s-ico {
  width: 26px;
  height: 26px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
}

/* ---------- Messages ---------- */
.messages {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-bottom: 12px;
}

.msg {
  display: flex;
  gap: 12px;
  animation: fadeUp 0.25s ease both;
}

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

.msg-avatar {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.msg.user .msg-avatar {
  order: 2;
  background: linear-gradient(135deg, #4b74ff, #2447c9);
  color: #fff;
}

.msg-body {
  min-width: 0;
  max-width: min(100%, 760px);
}

.msg.user .msg-body {
  max-width: min(78%, 640px);
}

.msg-name {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.msg.user .msg-name {
  text-align: right;
}

.msg.user .bubble {
  padding: 11px 15px;
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(180deg, #3c68ff, #2f5cff);
  color: #fff;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 8px 20px rgba(47, 92, 255, 0.18);
}

.assistant-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.assistant-card.streaming {
  border-color: #d7e2ff;
}

.md {
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.78;
  word-break: break-word;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 1.1em 0 0.5em;
  color: var(--text);
  line-height: 1.4;
  font-weight: 700;
}

.md h1 {
  font-size: 20px;
}

.md h2 {
  font-size: 18px;
}

.md h3 {
  font-size: 16px;
}

.md p {
  margin: 0.6em 0;
}

.md ul,
.md ol {
  margin: 0.6em 0;
  padding-left: 1.4em;
}

.md ul {
  list-style: disc;
}

.md ol {
  list-style: decimal;
}

.md li {
  margin: 0.28em 0;
}

.md strong {
  color: var(--text);
}

.md blockquote {
  margin: 0.8em 0;
  padding: 8px 14px;
  border-left: 3px solid #b9ccff;
  background: var(--accent-softer);
  border-radius: 0 8px 8px 0;
  color: var(--text-soft);
}

.md code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

.md pre {
  margin: 0.8em 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #101828;
  color: #e6e9f0;
  overflow-x: auto;
}

.md pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.9em 0;
  font-size: 13px;
}

.md th,
.md td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.md th {
  background: var(--surface-2);
  font-weight: 600;
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.2em 0;
}

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md .citation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin: 0 2px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: 1px;
  cursor: pointer;
  transition: background 0.16s ease;
}

.md .citation:hover {
  background: #dce6ff;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  min-height: 24px;
}

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

.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: blink 1.2s infinite ease-in-out;
}

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

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

.stream-status {
  margin-top: 10px;
  color: var(--muted-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.msg-action {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg-action:hover {
  background: var(--surface-2);
  color: var(--text);
}

.msg-action.primary {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.msg-action.primary:hover {
  background: #e2ebff;
}

.error-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid #fbd5d2;
  color: #b42318;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.error-note.warning {
  background: var(--warning-soft);
  border-color: #fde3b8;
  color: #b54708;
}

.notice {
  margin: 10px 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--warning-soft);
  border: 1px solid #fde3b8;
  color: #b54708;
  font-size: 12.5px;
}

/* ---------- Search results ---------- */
.search-summary {
  margin-bottom: 14px;
}

.policy-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.policy-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  padding: 14px 16px 13px;
  transition: all 0.18s ease;
}

.policy-card:hover {
  border-color: #c9d6ff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.06);
}

.policy-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.policy-index {
  width: 24px;
  height: 24px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.policy-title {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.5;
}

.status-pill {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.status-pill.valid {
  background: var(--success-soft);
  border-color: #c7f0da;
  color: #067647;
}

.status-pill.abolished {
  background: var(--danger-soft);
  border-color: #fbd5d2;
  color: #b42318;
}

.status-pill.updated {
  background: var(--warning-soft);
  border-color: #fde3b8;
  color: #b54708;
}

.policy-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 12px;
}

.policy-meta span {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}

.policy-meta b {
  color: var(--muted-2);
  font-weight: 500;
}

.policy-relevance {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.65;
}

.policy-quote {
  margin-top: 9px;
  padding: 8px 12px;
  border-left: 3px solid #d7e2ff;
  background: var(--accent-softer);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.policy-quote::before {
  content: "原文摘录";
  display: block;
  margin-bottom: 2px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.empty-result {
  padding: 22px 16px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-2);
}

/* ---------- References ---------- */
.refs-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.refs-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.refs-title .count {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
}

.refs-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-soft);
}

.ref-num {
  width: 18px;
  height: 18px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

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

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

.ref-desc {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.refs-more {
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  padding: 2px 0;
}

/* ---------- Composer ---------- */
.composer-area {
  flex: none;
  padding: 8px 24px 16px;
  background: linear-gradient(180deg, rgba(245, 247, 251, 0) 0%, var(--bg) 38%);
}

.composer-inner {
  max-width: 920px;
  margin: 0 auto;
}

.context-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--warning-soft);
  border: 1px solid #fde3b8;
  color: #b54708;
  font-size: 12px;
}

.context-label {
  flex: none;
  font-weight: 700;
}

.context-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}

.context-clear {
  flex: none;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.composer {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(16, 24, 40, 0.09);
  padding: 12px 14px 9px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer:focus-within {
  border-color: #b9ccff;
  box-shadow: 0 12px 34px rgba(47, 92, 255, 0.13), 0 0 0 4px rgba(47, 92, 255, 0.07);
}

.composer textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.65;
  max-height: 180px;
  min-height: 28px;
  padding: 0 2px;
  color: var(--text);
}

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

.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.char-count {
  color: var(--muted-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.composer-status {
  flex: 1;
  color: var(--accent-strong);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #3c68ff, #2f5cff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(47, 92, 255, 0.28);
  transition: all 0.18s ease;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(47, 92, 255, 0.34);
}

.send-btn:disabled {
  background: #c7d1e6;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.composer-hint {
  margin-top: 8px;
  text-align: center;
  color: var(--muted-2);
  font-size: 11px;
}

/* ---------- Modal / drawer / toast ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.42);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.18s ease both;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: min(86vh, 760px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.22s ease both;
}

.modal-card.narrow {
  max-width: 440px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}

.modal-head h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
}

.usage-card {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.usage-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
}

.usage-bar {
  margin: 9px 0 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.usage-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4b74ff, #2f5cff);
  transition: width 0.3s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  width: min(430px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s ease both;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h3 {
  font-size: 17px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-ref {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.drawer-ref h4 {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 4px;
}

.drawer-ref .sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.drawer-ref p {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

.drawer-ref a {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(16, 24, 40, 0.36);
  backdrop-filter: blur(2px);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  z-index: 120;
  padding: 10px 16px;
  border-radius: 11px;
  background: #101828;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.22s ease;
  max-width: min(90vw, 520px);
  pointer-events: none;
}

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

.toast.error {
  background: #b42318;
}

.toast.success {
  background: #067647;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(16, 24, 40, 0.4);
}

/* ---------- Admin ---------- */
.admin-shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.admin-sidebar {
  width: 232px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.admin-brand strong {
  font-size: 14px;
}

.admin-brand small {
  display: block;
  color: var(--muted-2);
  font-size: 11px;
}

.admin-nav {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.admin-nav button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
}

.admin-nav button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.admin-nav button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.admin-nav .nav-count {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 10px;
}

.admin-sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 48px) 56px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.admin-topbar h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.admin-topbar .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.admin-topbar .spacer {
  flex: 1;
}

.admin-section {
  animation: fadeUp 0.2s ease both;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  color: var(--muted);
  font-size: 12px;
}

.stat-card .value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stat-card .hint {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 11px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  font-size: 15px;
  font-weight: 700;
}

.panel-head .spacer {
  flex: 1;
}

.panel-body {
  padding: 16px 18px;
}

.panel-body.flush {
  padding: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.input-sm {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--surface);
  outline: none;
}

.input-sm:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 92, 255, 0.1);
}

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: 0;
}

table.data tr:hover td {
  background: #fbfcff;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge.green {
  background: var(--success-soft);
  border-color: #c7f0da;
  color: #067647;
}

.badge.orange {
  background: var(--warning-soft);
  border-color: #fde3b8;
  color: #b54708;
}

.badge.red {
  background: var(--danger-soft);
  border-color: #fbd5d2;
  color: #b42318;
}

.badge.blue {
  background: var(--accent-soft);
  border-color: #d7e2ff;
  color: var(--accent-strong);
}

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

.row-actions .btn {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 7px;
}

.quota-input {
  width: 76px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 5px 7px;
  font-size: 12px;
  text-align: center;
}

.empty-state {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state .big {
  font-size: 30px;
  margin-bottom: 8px;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 180px;
  padding: 10px 4px 0;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 46px;
  min-height: 4px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #6f92ff, #2f5cff);
  transition: height 0.3s ease;
}

.bar-label {
  color: var(--muted-2);
  font-size: 10px;
  white-space: nowrap;
}

.bar-value {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.ima-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.ima-status .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}

.ima-status.ok .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.12);
}

.ima-status.bad .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(240, 68, 56, 0.12);
}

.ima-status .ima-main {
  flex: 1;
  min-width: 0;
}

.ima-status .ima-title {
  font-weight: 600;
  font-size: 14px;
}

.ima-status .ima-desc {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px 14px;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  color: var(--text-soft);
  word-break: break-all;
}

.progress-card {
  padding: 16px;
  border-radius: 12px;
  background: var(--accent-softer);
  border: 1px solid #e1e9ff;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

.progress-line {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: #dbe5ff;
  overflow: hidden;
}

.progress-line span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: indeterminate 1.2s ease-in-out infinite;
}

.temp-password {
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.06em;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  text-align: center;
  user-select: all;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    display: none;
  }

  .auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 14px;
  }

  .auth-mobile-brand svg {
    width: 34px;
    height: 34px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }

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

  .history-delete {
    opacity: 1;
  }

  .topbar {
    padding: 0 12px;
    gap: 8px;
    height: 58px;
  }

  .mode-tabs {
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
  }

  .mode-tabs::-webkit-scrollbar {
    display: none;
  }

  .mode-tab {
    padding: 6px 9px;
  }

  .topbar-right .kb-pill {
    display: none;
  }

  .topbar-right .mock-badge {
    display: none !important;
  }

  .chat-inner {
    padding: 22px 16px 12px;
  }

  .composer-area {
    padding: 6px 12px 12px;
  }

  .welcome {
    padding-top: 3vh;
  }

  .welcome h1 {
    font-size: 27px;
  }

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

  .msg-body {
    max-width: calc(100% - 44px);
  }

  .msg.user .msg-body {
    max-width: 86%;
  }

  .admin-shell {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  .admin-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 2px;
  }

  .admin-nav button {
    white-space: nowrap;
    padding: 8px 10px;
  }

  .admin-sidebar-foot {
    display: none;
  }

  .admin-main {
    padding: 18px 14px 40px;
  }

  .admin-topbar h1 {
    font-size: 20px;
  }
}

@media (max-width: 640px) {
  .auth-main {
    padding: 28px 18px 40px;
    align-items: flex-start;
  }

  .auth-card-head h2 {
    font-size: 25px;
  }

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

  .status-card {
    padding: 32px 22px;
  }

  .chat-inner {
    padding: 16px 12px 8px;
  }

  .welcome-orb {
    width: 54px;
    height: 54px;
    border-radius: 17px;
    font-size: 25px;
  }

  .welcome h1 {
    font-size: 23px;
  }

  .welcome p {
    font-size: 13px;
  }

  .assistant-card {
    padding: 14px 14px;
  }

  .msg {
    gap: 8px;
  }

  .msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  .msg-name {
    display: none;
  }

  .composer-hint {
    display: none;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    animation: slideUp 0.22s ease both;
  }

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

  .stat-card {
    padding: 12px;
  }

  .stat-card .value {
    font-size: 23px;
  }

  .admin-topbar {
    flex-wrap: wrap;
    margin-bottom: 16px;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .kv dt {
    margin-top: 8px;
  }
}

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(24px);
    opacity: 0.4;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes dotPulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.12);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(18, 183, 106, 0.06);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

@keyframes indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

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