:root {
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --bg: #0a0d14;
  --bg-elevated: #0f1219;
  --panel: #12151f;
  --panel-2: #161a26;
  --card: #1a1f2e;
  --text: #eef1f8;
  --muted: #8b95ad;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.15);
  --border: rgba(255, 255, 255, 0.07);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --danger: #f87171;
  --success: #34d399;
  --user-bubble: rgba(139, 92, 246, 0.22);
  --nav-width: 260px;
  --context-width: 320px;
  --topbar-height: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
select {
  font: inherit;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Layout */
.app {
  display: flex;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: linear-gradient(145deg, #080a10 0%, var(--bg) 40%, #0d1018 100%);
}

/* Nav rail */
.nav-rail {
  width: var(--nav-width);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  z-index: 40;
}

.nav-rail__header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--accent);
}

.title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.2;
}

.sub {
  color: var(--muted);
  font-size: 0.7rem;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-new-chat:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.nav-menu {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: left;
  width: 100%;
}

.nav-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item--active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.nav-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  overflow: hidden;
}

.nav-history__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── History search ── */
.history-search {
  padding: 0 10px 8px;
}

.history-search__input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--text, #eef1f8);
  font-size: 0.78rem;
  font-family: inherit;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.history-search__input::placeholder {
  color: var(--muted, #8b95ad);
}

.history-search__input:focus {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(255, 255, 255, 0.08);
}

.history-search__input::-webkit-search-cancel-button {
  opacity: 0.5;
  cursor: pointer;
}

/* ── History date group headers ── */
.history-group__label {
  list-style: none;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #8b95ad);
  padding: 10px 12px 3px;
  user-select: none;
}

.history-empty {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted, #8b95ad);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.history-item--active {
  background: var(--accent-soft);
}

.history-item:disabled,
.history-item--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-item:disabled:hover,
.history-item--disabled:hover {
  background: transparent;
}

.history-item__title {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item__time {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.history-row {
  position: relative;
  display: flex;
  align-items: stretch;
}

.history-row .history-item {
  flex: 1;
  min-width: 0;
  padding-right: 58px;
}

.history-item__archive,
.history-item__rename {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  font-size: 0.75rem;
  line-height: 1;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  padding: 0;
}

.history-item__archive { right: 5px; }
.history-item__rename  { right: 31px; }

.history-row:hover .history-item__archive,
.history-row:hover .history-item__rename,
.history-item__archive:focus-visible,
.history-item__rename:focus-visible {
  opacity: 1;
}

.history-item__archive:hover {
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.12);
}

.history-item__rename:hover {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

.history-item__title-input {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent, #8b5cf6);
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 0 1px;
  outline: none;
  font-family: inherit;
}

.archived-link {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.15s, background 0.15s;
}

.archived-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* ── Archive modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface, #1a1d2e);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal__close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.modal__body {
  padding: 8px 24px 20px;
  overflow-y: auto;
  flex: 1;
}

.archive-empty {
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 32px 0;
  margin: 0;
}

.archive-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.archive-item:last-child {
  border-bottom: none;
}

.archive-item__info {
  flex: 1;
  min-width: 0;
}

.archive-item__title {
  display: block;
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-item__time {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.archive-item__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.archive-item__restore {
  flex-shrink: 0;
  padding: 5px 12px;
  border: 1px solid var(--accent, #8b5cf6);
  background: transparent;
  color: var(--accent, #8b5cf6);
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.archive-item__restore:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.12);
}

.archive-item__delete {
  flex-shrink: 0;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--muted, #8b95ad);
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.archive-item__delete:hover:not(:disabled) {
  border-color: #f87171;
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

.archive-item__delete--confirm {
  border-color: #f87171;
  color: #f87171;
}

.archive-item__delete--confirm:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.16);
}

.archive-item__cancel {
  background: transparent;
  border: none;
  color: var(--muted, #8b95ad);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
  transition: color 0.15s;
}

.archive-item__cancel:hover {
  color: var(--text, #eef1f8);
}

.archive-item__confirm-label {
  font-size: 0.75rem;
  color: var(--muted, #8b95ad);
  white-space: nowrap;
}

.archive-item__restore:hover {
  background: var(--accent, #8b5cf6);
  color: #fff;
}

/* ── Profile modal ── */
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.profile-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 0;
}

.profile-row .profile-field {
  margin-bottom: 16px;
}

.profile-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted, #8b95ad);
  letter-spacing: 0.02em;
}

.profile-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text, #eef1f8);
  font-size: 0.875rem;
  font-family: inherit;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.profile-input:focus {
  border-color: rgba(139, 92, 246, 0.5);
  background: rgba(255, 255, 255, 0.08);
}

.profile-input--readonly {
  opacity: 0.55;
  cursor: default;
}

.profile-error {
  font-size: 0.8rem;
  color: #f87171;
  margin: 0 0 14px;
  padding: 8px 12px;
  background: rgba(248, 113, 113, 0.08);
  border-radius: 6px;
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.profile-btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  border: none;
}

.profile-btn--cancel {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted, #8b95ad);
}

.profile-btn--cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text, #eef1f8);
}

.profile-btn--save {
  background: var(--accent, #8b5cf6);
  color: #fff;
}

.profile-btn--save:hover:not(:disabled) {
  background: #7c3aed;
}

.profile-btn--save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-note {
  font-size: 0.775rem;
  color: var(--muted, #8b95ad);
  margin: 0 0 14px;
}

/* ── Password requirements checklist ── */
.pw-requirements[hidden] { display: none; }

.pw-requirements {
  list-style: none;
  margin: 0 0 16px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pw-req {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.775rem;
  color: var(--muted, #8b95ad);
  transition: color 0.15s;
}

.pw-req::before {
  content: '○';
  font-size: 0.7rem;
  flex-shrink: 0;
  transition: color 0.15s;
}

.pw-req--met {
  color: #4ade80;
}

.pw-req--met::before {
  content: '✓';
  color: #4ade80;
}

.pw-req--fail {
  color: #f87171;
}

.pw-req--fail::before {
  content: '✗';
  color: #f87171;
}

/* ── Ticket wizard ── */
.modal--ticket {
  max-width: 480px;
  width: 100%;
}

.ticket-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ticket-step-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted, #8b95ad);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
}

.ticket-step-intro {
  font-size: 0.875rem;
  color: var(--muted, #8b95ad);
  margin: 0 0 16px;
}

/* Category buttons — large tap targets for mobile */
.ticket-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ticket-cat-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.ticket-cat-btn:hover,
.ticket-cat-btn:focus-visible {
  background: rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.4);
  outline: none;
}

.ticket-cat-btn__label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #e2e8f0);
}

.ticket-cat-btn__sub {
  font-size: 0.75rem;
  color: var(--muted, #8b95ad);
}

/* Step 2 */
.ticket-back-btn {
  background: none;
  border: none;
  color: var(--muted, #8b95ad);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ticket-back-btn:hover { color: var(--text, #e2e8f0); }

.ticket-category-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent, #8b5cf6);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ticket-field {
  margin-bottom: 14px;
}

.ticket-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted, #8b95ad);
  margin-bottom: 5px;
}

.ticket-field input[type="text"],
.ticket-field textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text, #e2e8f0);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 9px 12px;
  box-sizing: border-box;
  resize: vertical;
  transition: border-color 0.15s;
}

.ticket-field input[type="text"]:focus,
.ticket-field textarea:focus {
  outline: none;
  border-color: rgba(139,92,246,0.5);
}

.ticket-field textarea {
  min-height: 80px;
}

/* Chip group (single-select) */
.ticket-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ticket-chip {
  padding: 7px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text, #e2e8f0);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ticket-chip:hover {
  background: rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.4);
}

.ticket-chip--selected {
  background: rgba(139,92,246,0.25);
  border-color: rgba(139,92,246,0.7);
  color: #c4b5fd;
  font-weight: 600;
}

.ticket-next-btn,
.ticket-submit-btn {
  width: 100%;
  margin-top: 6px;
  justify-content: center;
}

/* Step 3 review */
.ticket-review {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-review-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ticket-review-row__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #8b95ad);
  font-weight: 600;
}

.ticket-review-row__value {
  font-size: 0.875rem;
  color: var(--text, #e2e8f0);
  word-break: break-word;
}

.nav-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
}

.plan-widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.plan-widget__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.plan-widget__name {
  font-weight: 700;
  font-size: 0.88rem;
}

.plan-widget__label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.plan-widget__meter {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.plan-widget__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-hover), var(--accent));
  border-radius: 99px;
}

.plan-widget__stats {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
}

.nav-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  border-radius: 8px;
}

.nav-settings:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.bot-select {
  margin-left: auto;
  max-width: 110px;
  padding: 4px 6px;
  font-size: 0.72rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
}

/* Workspace */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-height);
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar__email {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
  flex-shrink: 0;
}

.connection-pill--off {
  background: rgba(139, 149, 173, 0.12);
  color: var(--muted);
}

.connection-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-link {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 6px 8px;
  border-radius: 6px;
}

.topbar-link:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.user-menu {
  position: relative;
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
  font-size: 0.78rem;
}

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 50;
}

.user-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  font-size: 0.88rem;
}

.user-menu__item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.user-menu__link {
  text-decoration: none;
  color: var(--accent);
}

/* Banner */
.banner {
  display: none;
  margin: 10px 16px 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.banner.visible {
  display: block;
}

.banner.error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.banner.info {
  background: var(--accent-soft);
  border: 1px solid rgba(139, 92, 246, 0.35);
}

/* Chat column */
.chat-column {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chatwrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 16px;
  overflow: hidden;
}

.chatwrap:not([hidden]) {
  display: flex !important;
}

.chatwrap[hidden],
.chat-placeholder[hidden] {
  display: none !important;
}

#webchat {
  flex: 1 1 auto;
  min-height: 320px;
  width: 100%;
  background: transparent;
  overflow: hidden;
}

.chat-loading {
  height: 100%;
  min-height: 200px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.chat-placeholder p {
  max-width: 420px;
  line-height: 1.6;
  margin: 0;
}

.chat-placeholder strong {
  color: var(--text);
}

.chat-disclaimer {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 8px 16px 14px;
  margin: 0;
}

.primary {
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
}

.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* Context panel */
.context-panel {
  width: var(--context-width);
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.context-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}

.context-tab {
  flex: 1;
  padding: 14px 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.context-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.context-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.context-signed-out {
  text-align: center;
  padding: 32px 12px;
  color: var(--muted);
}

.context-signed-out p {
  margin: 0 0 16px;
  line-height: 1.5;
}

.context-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.context-card--collapsible {
  padding: 0;
}

.context-card--collapsible .summary-list {
  padding: 0 14px 14px;
}

.context-card.is-collapsed .summary-list,
.summary-list[hidden] {
  display: none !important;
}

.context-card__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.context-card__toggle h3 {
  margin: 0;
}

.context-card__chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.context-card.is-collapsed .context-card__chevron {
  transform: rotate(-45deg);
}

.context-card h3 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.context-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.context-card__head h3 {
  margin: 0;
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--verified {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.identity-block {
  display: flex;
  gap: 12px;
  align-items: center;
}

.identity-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.identity-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.identity-email,
.identity-meta {
  font-size: 0.8rem;
  margin-top: 2px;
}

.summary-list,
.insights-grid {
  margin: 0;
  display: grid;
  gap: 8px;
}

.summary-list dt,
.insights-grid dt {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-list dd,
.insights-grid dd {
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 500;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-action-btn {
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.78rem;
  text-align: center;
  line-height: 1.3;
}

.quick-action-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quick-action-btn:active:not(:disabled) {
  background: rgba(139, 92, 246, 0.25);
}

.insights-intro {
  margin: 0 0 12px;
  font-size: 0.82rem;
}

/* Icons (CSS shapes) */
.icon-plus::before { content: '+'; font-weight: 700; }
.icon-search::before { content: '⌕'; }
.icon-settings::before { content: '⚙'; font-size: 0.9rem; }

.nav-item__icon::before {
  display: inline-block;
  width: 18px;
  text-align: center;
  opacity: 0.8;
}

.nav-item[data-icon='home'] .nav-item__icon::before { content: '⌂'; }
.nav-item[data-icon='book'] .nav-item__icon::before { content: '📖'; font-size: 0.75rem; }
.nav-item[data-icon='chart'] .nav-item__icon::before { content: '📊'; font-size: 0.75rem; }

/* Signup page */
.signup-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #080a10 0%, var(--bg) 40%, #0d1018 100%);
}

.signup-card {
  max-width: 440px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.signup-card h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.signup-card p {
  color: var(--muted);
  line-height: 1.5;
}

.signup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.signup-actions button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.signup-actions button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.signup-actions a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  text-align: center;
}

/* Hamburger button — hidden on desktop */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 6px;
}
.hamburger:hover { background: rgba(255,255,255,0.06); }
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* Sidebar overlay */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
}
.nav-overlay--visible {
  display: block;
}

/* Responsive */
@media (max-width: 1199px) {
  .context-panel {
    display: none;
  }
}

@media (max-width: 899px) {
  .hamburger {
    display: flex;
  }

  .nav-rail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .nav-rail--open {
    transform: translateX(0);
  }

  .topbar-link {
    display: none;
  }

  /* Give topbar breathing room so hamburger + email fit */
  .topbar__left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .topbar__email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
  }

  /* Wider chat input area on mobile */
  .chat-input-bar {
    padding: 8px 10px;
  }
}
