:root {
  --bg: #f5f7fb;
  --bg-subtle: #edf4f8;
  --surface: #ffffff;
  --surface-tint: #fbfdff;
  --surface-glass: rgba(255, 255, 255, 0.78);
  --sidebar: rgba(255, 255, 255, 0.9);
  --sidebar-elevated: #f4f8fb;
  --sidebar-border: rgba(196, 210, 226, 0.7);
  --sidebar-text: #122033;
  --sidebar-muted: #66768b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --accent: #0f9f8f;
  --accent-soft: rgba(15, 159, 143, 0.12);
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.13);
  --text: #111827;
  --text-secondary: #42526a;
  --text-muted: #6b778c;
  --border: rgba(210, 220, 232, 0.92);
  --border-strong: #bac8d8;
  --user-bubble: #2563eb;
  --assistant-bubble: rgba(255, 255, 255, 0.92);
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 16px 42px rgba(18, 32, 51, 0.1);
  --shadow-lg: 0 26px 82px rgba(18, 32, 51, 0.14);
  --radius: 8px;
  --radius-lg: 12px;
  --font: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --chat-max: 820px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  position: relative;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 251, 255, 0.86)),
    var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  box-shadow: 12px 0 40px rgba(18, 32, 51, 0.05);
  backdrop-filter: blur(18px);
  z-index: 40;
}

.sidebar-top {
  padding: 22px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.brand-icon img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-text h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
}

.brand-text p {
  font-size: 11px;
  color: #6b7a90;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f4f8ff);
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.08);
  transition: background 0.3s ease-out, border-color 0.3s ease-out, box-shadow 0.3s ease-out, transform 0.3s ease-out;
}

.btn-new-chat:hover {
  background: linear-gradient(180deg, #ffffff, #eef5ff);
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.13);
  transform: translateY(-1px);
}

.sidebar-section {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7a889b;
  margin-bottom: 10px;
}

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

.section-header .section-label {
  margin-bottom: 0;
}

.btn-refresh-history {
  background: transparent;
  border: none;
  color: #7a889b;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.btn-refresh-history:hover {
  color: var(--accent, #2563eb);
  background: rgba(37, 99, 235, 0.08);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(226, 232, 240, 0.7);
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease-out;
  user-select: none;
}

.history-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  transform: translateX(2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.history-item.active {
  background: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.history-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #3b82f6;
}

.history-main {
  flex: 1;
  min-width: 0;
  margin-right: 8px;
}

.history-title {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.history-time {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 3px;
}

.history-del-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s;
}

.history-item:hover .history-del-btn,
.history-item.active .history-del-btn {
  opacity: 1;
}

.history-del-btn:hover {
  color: #ef4444;
  background: #fee2e2;
}

.history-empty {
  font-size: 12px;
  color: #94a3b8;
  padding: 16px 8px;
  text-align: center;
  line-height: 1.6;
}

.suggestion-btn:focus-visible,
.btn-new-chat:focus-visible,
.btn-menu:focus-visible,
.btn-send:focus-visible,
.btn-retry:focus-visible,
.welcome-card-btn:focus-visible,
.access-field button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.sidebar-capabilities {
  flex: 0;
  padding-top: 0;
}

.capability-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.capability-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--sidebar-muted);
}

.capability-icon {
  font-size: 11px;
  color: var(--primary);
  opacity: 0.9;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
}

.env-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--sidebar-muted);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(210, 220, 232, 0.8);
}

.env-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 6px rgba(217, 119, 6, 0.5);
}

.sidebar-backdrop {
  display: none;
}

/* ── Chat panel ── */
.chat-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(18, 32, 51, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(18, 32, 51, 0.035) 1px, transparent 1px),
    linear-gradient(145deg, #ffffff 0%, #f5f9ff 46%, #f3fbf8 100%);
  background-size: 28px 28px, 28px 28px, auto;
  background-position: center top;
}

.chat-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.18) 42%, rgba(255, 255, 255, 0.48)),
    linear-gradient(120deg, rgba(37, 99, 235, 0.08), transparent 34%, rgba(15, 159, 143, 0.08));
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(18, 32, 51, 0.04);
  flex-shrink: 0;
}

.btn-menu {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  place-items: center;
  transition: border-color 0.3s ease-out, color 0.3s ease-out, transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.btn-menu:hover {
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(18, 32, 51, 0.08);
  transform: translateY(-1px);
}

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

.header-main h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
}

.header-main p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.model-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(237, 244, 248, 0.88);
  border: 1px solid var(--border);
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.status.thinking .status-dot {
  background: var(--warning);
  animation: pulse 1.2s infinite;
}

.status.error .status-dot {
  background: var(--error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ── Messages ── */
.messages-wrap {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  width: 100%;
  will-change: scroll-position;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.messages-wrap::-webkit-scrollbar,
.sidebar-section::-webkit-scrollbar {
  width: 10px;
}

.messages-wrap::-webkit-scrollbar-thumb,
.sidebar-section::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.32);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.messages-wrap::-webkit-scrollbar-thumb:hover,
.sidebar-section::-webkit-scrollbar-thumb:hover {
  background-color: rgba(100, 116, 139, 0.38);
}

.messages {
  max-width: calc(var(--chat-max) + 56px);
  width: 100%;
  margin: 0 auto;
  padding: 36px 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100%;
  box-sizing: border-box;
}

.app:not(.chat-started) .messages-wrap {
  flex: 1 1 0%;
  min-height: 0;
}

.app:not(.chat-started) .messages {
  min-height: 100%;
  padding-top: 36px;
  padding-bottom: 20px;
}

/* Welcome */
.welcome {
  margin: auto auto;
  width: 100%;
  max-width: var(--chat-max);
  padding: 0;
}

.ge-home {
  max-width: 840px;
  perspective: 1200px;
}

.welcome-hero,
.ge-hero {
  margin-bottom: 18px;
}

.ge-hero {
  text-align: center;
}

.welcome-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.welcome-logo img {
  display: block;
  width: 100%;
  height: 100%;
}

.ge-copy {
  position: relative;
  z-index: 1;
}

.ge-agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  padding: 7px 13px 7px 8px;
  border: 1px solid rgba(190, 206, 224, 0.78);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  color: #3f4d63;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(18, 32, 51, 0.08);
}

.ge-agent-badge img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.welcome-hero h3,
.ge-copy h3 {
  font-size: 54px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.04;
  margin-bottom: 16px;
  color: #0f172a;
}

.welcome-desc {
  font-size: 16px;
  line-height: 1.72;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto;
}

.ge-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 620px;
  margin: 26px auto 22px;
}

.ge-metrics div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid rgba(190, 206, 224, 0.78);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 12px 28px rgba(18, 32, 51, 0.05);
  backdrop-filter: blur(12px);
}

.ge-metrics strong {
  font-size: 14px;
  line-height: 1;
  color: var(--text);
}

.ge-metrics span {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.welcome-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 auto 16px;
  max-width: 840px;
}

.welcome-card-btn {
  position: relative;
  text-align: left;
  min-height: 126px;
  padding: 16px;
  border: 1px solid rgba(190, 206, 224, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(249, 252, 255, 0.72));
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.3s ease-out, box-shadow 0.3s ease-out, transform 0.3s ease-out, background 0.3s ease-out;
  box-shadow: 0 10px 28px rgba(18, 32, 51, 0.06);
  overflow: hidden;
  will-change: transform;
  animation: cardRise 0.5s ease-out both;
}

.welcome-card-btn > * {
  position: relative;
  z-index: 1;
}

.welcome-card-btn:nth-child(2) { animation-delay: 0.08s; }
.welcome-card-btn:nth-child(3) { animation-delay: 0.16s; }
.welcome-card-btn:nth-child(4) { animation-delay: 0.24s; }

.welcome-card-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent 42%, rgba(15, 159, 143, 0.08));
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.welcome-card-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 18px 42px rgba(37, 99, 235, 0.13);
  transform: translateY(-4px) rotateX(1deg);
  background: #ffffff;
}

.welcome-card-btn:hover::before {
  opacity: 1;
}

.welcome-card-btn::after {
  content: "→";
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 16px;
  z-index: 1;
  transition: color 0.3s ease-out, transform 0.3s ease-out;
}

.welcome-card-btn:hover::after {
  color: var(--primary);
  transform: translateX(3px);
}

.welcome-card-btn .card-icon {
  width: 30px;
  height: 30px;
  margin-bottom: 12px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.welcome-card-btn[data-tone="teal"] .card-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.welcome-card-btn[data-tone="gold"] .card-icon {
  background: var(--gold-soft);
  color: var(--gold);
}

.welcome-card-btn[data-tone="slate"] .card-icon {
  background: rgba(71, 85, 105, 0.12);
  color: #475569;
}

.welcome-card-btn .card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.welcome-card-btn .card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.welcome-foot {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.app:not(.chat-started) .composer {
  padding-top: 8px;
  padding-bottom: 34px;
}

.app:not(.chat-started) .composer-box {
  max-width: 760px;
}

.app:not(.chat-started) .composer-inner {
  min-height: 60px;
  border-radius: 999px;
  padding: 10px 10px 10px 24px;
  border-color: #c9d8ea;
  box-shadow: 0 22px 58px rgba(18, 32, 51, 0.14);
}

/* Messages */
.message {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: var(--chat-max);
  margin: 0 auto;
  animation: fadeIn 0.34s ease-out;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.18);
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, #2563eb, #0d9488);
  color: #fff;
  box-shadow: 0 10px 18px rgba(13, 148, 136, 0.16);
}

.message-body {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 44px);
}

.message.user .message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-content {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.75;
  font-size: 14px;
  word-break: break-word;
  box-shadow: 0 10px 28px rgba(18, 32, 51, 0.05);
}

.message.user .message-content {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
  max-width: 85%;
}

.message.assistant .message-content {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(10px);
}

.message-content p { margin-bottom: 0.65em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 0.5em 0 0.5em 1.25em; }

.message-content h1, .message-content h2,
.message-content h3, .message-content h4 {
  margin: 1em 0 0.45em;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.message-content h3 { font-size: 15px; }
.message-content h4 { font-size: 14px; }

.message-content table {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.message-content th, .message-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.message-content th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.message-content tr:nth-child(even) td { background: #fafbfc; }

.message-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.message-content blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--primary);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.message-content code {
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: "SF Mono", "Fira Code", monospace;
}

.message-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.message-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 0 2px;
}

.citations {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.citations h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.citation-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--primary);
  padding: 4px 0;
  line-height: 1.45;
}

.citation-item::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 7px;
  flex-shrink: 0;
}

.retrieval-hint {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.retrieval-hint::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.retrieval-query {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-text { color: var(--error); }

.btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.3s ease-out, border-color 0.3s ease-out, box-shadow 0.3s ease-out, transform 0.3s ease-out;
}

.btn-retry::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2'/%3E%3C/svg%3E") center / contain no-repeat;
}

.btn-retry:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.btn-retry:active {
  transform: scale(0.97);
}

/* ── Composer ── */
.composer {
  flex-shrink: 0;
  padding: 12px 24px 20px;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, rgba(247, 251, 255, 0) 0%, rgba(247, 251, 255, 0.72) 38%, rgba(247, 251, 255, 0.94) 100%);
  position: relative;
  z-index: 10;
}

.composer-box {
  width: 100%;
  max-width: var(--chat-max);
}

.composer-inner {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 10px 10px 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transition: border-color 0.3s ease-out, box-shadow 0.3s ease-out, background 0.3s ease-out;
}

.composer-inner:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow);
  background: rgba(255, 255, 255, 0.95);
}

.composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  max-height: 160px;
  outline: none;
  color: var(--text);
  padding: 4px 0;
}

.composer textarea::placeholder { color: #94a3b8; }

.btn-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.2);
  transition: filter 0.3s ease-out, transform 0.3s ease-out, box-shadow 0.3s ease-out;
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  filter: saturate(1.08) brightness(1.02);
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.24);
}

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

.composer-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  text-align: center;
  line-height: 1.5;
}

/* ── User pill & Status ── */
.btn-login-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-login-trigger:hover {
  background: var(--primary, #2563eb);
  color: #fff;
}

.btn-login-trigger[hidden] {
  display: none;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.user-pill[hidden] {
  display: none;
}

.user-pill .user-avatar {
  font-size: 13px;
}

.user-pill .user-name {
  color: var(--text);
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-pill .btn-logout {
  background: transparent;
  border: none;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.user-pill .btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

/* ── Access gate ── */
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(18, 32, 51, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(18, 32, 51, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(247, 251, 255, 0.94)),
    rgba(248, 250, 252, 0.92);
  background-size: 30px 30px, 30px 30px, auto, auto;
  backdrop-filter: blur(14px);
}

.access-gate[hidden] {
  display: none;
}

.access-panel {
  width: min(440px, 100%);
  padding: 32px 28px 24px;
  border: 1px solid rgba(219, 230, 243, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(24px);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(37, 99, 235, 0.06);
}

.access-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #1d4ed8;
  margin-bottom: 16px;
}

.access-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
}

.access-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.access-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
  flex-shrink: 0;
}

.access-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.access-panel h2 {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.access-subtitle {
  color: #64748b !important;
  font-size: 12px !important;
  line-height: 1.45 !important;
  margin: 0 !important;
}

.access-features {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
}

.access-feat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
}

.access-feat-item .feat-icon {
  font-size: 14px;
}

.access-inputs {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.access-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.access-label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.access-input-group input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.access-input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-access-submit {
  width: 100%;
  height: 44px;
  margin-top: 4px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.18);
  transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-access-submit:hover:not(:disabled) {
  filter: saturate(1.08) brightness(1.02);
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.23);
}

.btn-access-submit:active:not(:disabled) {
  transform: scale(0.98);
}

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

.access-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.access-tip {
  font-size: 11px !important;
  color: #059669 !important;
  margin: 0 !important;
  font-weight: 500;
}

.access-admin-hint {
  font-size: 11px !important;
  color: #94a3b8 !important;
  margin: 0 !important;
}

.access-field {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.access-field input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.3s ease-out, box-shadow 0.3s ease-out;
}

.access-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.access-field button {
  height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.18);
  transition: filter 0.3s ease-out, transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.access-field button:hover:not(:disabled) {
  filter: saturate(1.08) brightness(1.02);
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.23);
}

.access-field button:active:not(:disabled) {
  transform: scale(0.98);
}

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

.access-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--error) !important;
  font-size: 13px !important;
}

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

@keyframes cardRise {
  from { opacity: 0; transform: translateY(14px) rotateX(-2deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

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

/* ── Responsive ── */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 100%;
    height: 100vh;
    height: 100dvh;
  }

  .chat-panel {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 286px;
    transform: translateX(-100%);
    transition: transform 0.3s ease-out;
  }

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

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 30;
    backdrop-filter: blur(2px);
  }

  .sidebar-backdrop[hidden] { display: none; }

  .btn-menu { display: grid; }

  .model-badge { display: none; }

  .app:not(.chat-started) .messages-wrap {
    flex: 1 1 auto;
    min-height: 0;
  }

  .app:not(.chat-started) .messages {
    padding-top: 34px;
    padding-bottom: 18px;
  }

  .welcome-cards {
    grid-template-columns: 1fr 1fr;
    max-width: 640px;
  }

  .welcome-hero h3,
  .ge-copy h3 {
    font-size: 38px;
  }

  .ge-metrics {
    grid-template-columns: 1fr;
    max-width: 420px;
  }

  .chat-header { padding: 12px 16px; }
  .messages { padding: 16px; }
  .composer {
    padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 560px) {
  .chat-header {
    gap: 12px;
  }

  .header-main h2 {
    font-size: 15px;
    line-height: 1.3;
  }

  .header-main p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .status {
    padding: 6px 10px;
  }

  .ge-agent-badge {
    margin-bottom: 16px;
  }

  .welcome-hero h3,
  .ge-copy h3 {
    font-size: 31px;
  }

  .app:not(.chat-started) .messages {
    padding-top: 32px;
  }

  .welcome-desc {
    font-size: 14px;
    line-height: 1.65;
  }

  .ge-metrics {
    gap: 7px;
    margin: 22px auto 18px;
  }

  .ge-metrics div {
    min-height: 44px;
    padding: 9px 13px;
  }

  .welcome-cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .welcome-card-btn {
    min-height: 104px;
    padding: 14px 15px;
  }

  .welcome-card-btn .card-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 10px;
  }

  .welcome-foot,
  .composer-note {
    display: none;
  }

  .app:not(.chat-started) .composer-inner {
    min-height: 54px;
    border-radius: 12px;
    padding-left: 16px;
  }

  .access-panel {
    padding: 22px;
  }

  .access-field {
    flex-direction: column;
  }

  .access-field button {
    width: 100%;
  }
}
