/* ============================================================
   Qomni AI — Sovereign UX
   Design Language: "Deep Void" Cyberpunk-Industrial
   ============================================================ */

/* ── Reset + Base ─────────────────────────────────────────── */
:root {
  --bg: #06060a;
  --surface: #0c0c12;
  --surface2: #131320;
  --surface3: #1a1a2e;
  --border: #1e1e32;
  --border-glow: #2a2a4a;

  --text: #e4e4ef;
  --text-dim: #8888a8;
  --text-muted: #505068;

  --cyan: #00f0ff;
  --cyan-dim: rgba(0, 240, 255, 0.15);
  --cyan-glow: rgba(0, 240, 255, 0.25);
  --magenta: #ff00aa;
  --magenta-dim: rgba(255, 0, 170, 0.12);
  --magenta-glow: rgba(255, 0, 170, 0.2);
  --blue: #4d8bff;
  --blue-dim: rgba(77, 139, 255, 0.12);

  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --accent2: #a78bfa;

  --success: #00e68a;
  --error: #ff4466;
  --warning: #ffaa00;
  --info: var(--blue);

  --glow: rgba(0, 240, 255, 0.25);
  --glow2: rgba(167, 139, 250, 0.1);

  --code-bg: #08080e;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --nav-w: 56px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}

/* ── Typography: msg-bubble content ───────────────────────── */
.msg-bubble code {
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 13px;
}

.msg-bubble p code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--cyan);
}

.msg-bubble p {
  margin-bottom: 8px;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble ul,
.msg-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.msg-bubble li {
  margin-bottom: 4px;
}

.msg-bubble strong {
  color: var(--accent2);
}

.msg-bubble h1,
.msg-bubble h2,
.msg-bubble h3 {
  margin: 12px 0 6px;
  color: var(--accent2);
}

.msg-bubble img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
  border: 1px solid var(--border);
}

.msg-bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 13px;
}

.msg-bubble th,
.msg-bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.msg-bubble th {
  background: var(--surface2);
  color: var(--accent2);
  font-weight: 600;
}

.msg-bubble tr:hover td {
  background: var(--glow2);
}

.msg-bubble pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 8px 0;
  overflow-x: auto;
}

.msg-bubble pre::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  opacity: 0.6;
}

.msg-bubble pre code {
  border: none;
  padding: 0;
  background: none;
  color: var(--text);
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

.copy-btn:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-dim);
}

.msg-actions {
  float: right;
  display: flex;
  gap: 2px;
}

.msg-action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.4;
  padding: 2px;
  transition: opacity 0.15s;
}

.msg-action:hover {
  opacity: 1;
}

/* ── Nav Rail ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.nav-rail {
  width: var(--nav-w);
  min-width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 50;
  flex-shrink: 0;
}

.nav-rail-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  margin: 12px auto;
  box-shadow: 0 0 20px var(--cyan-dim);
}

.nav-rail-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  gap: 2px;
  overflow-y: auto;
}

.nav-rail-item {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  flex-shrink: 0;
}

.nav-rail-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-rail-item.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  box-shadow: inset 0 0 12px var(--cyan-dim);
}

.nav-rail-item svg {
  width: 20px;
  height: 20px;
}

/* Tooltip: slides from left */
.nav-rail-item::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--surface3);
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  border: 1px solid var(--border-glow);
}

.nav-rail-item:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.nav-rail-divider {
  width: 24px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  flex-shrink: 0;
}

.nav-rail-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 6px;
  border-top: 1px solid var(--border);
}

.nav-rail-footer .user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.nav-rail-footer .user-avatar:hover {
  box-shadow: 0 0 12px var(--glow);
}

.nav-rail-footer .btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.nav-rail-footer .btn-logout:hover {
  color: var(--error);
  background: var(--surface2);
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 12px;
}

/* ── Sessions Flyout ──────────────────────────────────────── */
.sessions-flyout {
  position: absolute;
  left: var(--nav-w);
  top: 0;
  width: 260px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 49;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
}

.sessions-flyout.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.sessions-flyout-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.sessions-flyout-header h3 {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.sessions-flyout-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  transition: all 0.15s;
}

.sessions-flyout-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.session-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.session-item.active {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.session-item .session-del {
  opacity: 0;
  color: var(--error);
  cursor: pointer;
  margin-left: auto;
  font-size: 14px;
  background: none;
  border: none;
  padding: 0 4px;
  transition: opacity 0.15s;
}

.session-item:hover .session-del {
  opacity: 0.6;
}

.session-item .session-del:hover {
  opacity: 1;
}

.session-item .session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Status Bar + SOV chips ───────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  position: relative;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 42px;
  min-height: 42px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 12, 18, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-shrink: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  display: none;
  transition: all 0.15s;
}

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

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

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  transition: background 0.3s;
  box-shadow: 0 0 6px var(--success);
}

.status-dot.offline {
  background: var(--error);
  box-shadow: 0 0 6px var(--error);
}

.sov-mini {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.sov-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2px 8px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sov-chip .sdot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sov-chip.ok .sdot {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

.sov-chip.warn .sdot {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

.sov-chip.crit .sdot {
  background: var(--error);
  box-shadow: 0 0 6px var(--error);
}

.sov-chip.ok {
  border-color: rgba(0, 240, 255, 0.2);
}

.sov-chip.warn {
  border-color: rgba(255, 170, 0, 0.2);
}

.sov-chip.crit {
  border-color: rgba(255, 68, 102, 0.2);
}

.sov-val {
  color: #e4e4f0;
  font-weight: 600;
}

.sov-label {
  color: #8888a0;
  font-size: 9px;
}

/* ── Chat Area + Messages ─────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

.msg {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 780px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.msg.user .msg-avatar {
  background: linear-gradient(135deg, #1a1a2e, #2a2a4a);
  color: var(--accent2);
}

.msg.bot .msg-avatar {
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  color: #fff;
  box-shadow: 0 0 12px var(--cyan-dim);
}

.msg-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.msg-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.msg.bot .msg-bubble {
  border-left: 3px solid var(--cyan);
  background: linear-gradient(135deg, var(--surface2), rgba(0, 240, 255, 0.03));
}

.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--surface2), var(--magenta-dim));
  border-color: rgba(255, 0, 170, 0.15);
}

.msg.streaming .msg-bubble {
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-dim), 0 0 24px rgba(0, 240, 255, 0.08);
  animation: streamGlow 2s ease-in-out infinite;
}

.msg-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  padding: 0 4px;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Welcome Screen ───────────────────────────────────────── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  gap: 12px;
  padding: 40px 20px;
}

.welcome-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
  color: #fff;
  box-shadow: 0 0 60px var(--cyan-dim), 0 0 120px rgba(255, 0, 170, 0.1);
}

.welcome h2 {
  font-size: 26px;
  background: linear-gradient(135deg, #fff, var(--cyan), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome p {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 500px;
}

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
  max-width: 500px;
  width: 100%;
}

.suggestion {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  color: var(--text-dim);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggestion:hover {
  border-color: var(--cyan);
  color: var(--text);
  background: var(--cyan-dim);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 240, 255, 0.08);
}

.sug-icon {
  font-size: 18px;
}

/* ── Input Area ───────────────────────────────────────────── */
.input-area {
  padding: 12px 20px 16px;
  flex-shrink: 0;
  background: rgba(12, 12, 18, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(30, 30, 50, 0.5);
}

.input-wrap {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 6px 6px 16px;
  transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrap:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim), 0 0 20px rgba(0, 240, 255, 0.06);
}

.input-box {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 140px;
  min-height: 36px;
  line-height: 1.5;
  padding: 6px 0;
}

.input-box::placeholder {
  color: var(--text-muted);
}

.btn-attach,
.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-attach {
  background: transparent;
  border: none;
  color: var(--text-dim);
}

.btn-attach:hover {
  color: var(--cyan);
  background: var(--cyan-dim);
}

.btn-send {
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border: none;
  color: #fff;
}

.btn-send:hover {
  transform: scale(1.08);
  box-shadow: 0 0 20px var(--cyan-dim), 0 0 40px var(--magenta-dim);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-attach svg,
.btn-send svg,
.btn-mic svg {
  width: 18px;
  height: 18px;
}

.btn-mic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  border: none;
  color: var(--text-dim);
}

.btn-mic:hover {
  color: var(--cyan);
  background: var(--cyan-dim);
}

.btn-mic.recording {
  background: var(--cyan);
  color: #fff;
  animation: pulse 1.5s infinite;
  box-shadow: 0 0 16px var(--cyan-glow);
}

input[type=file] {
  display: none;
}

.input-hint {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
  font-family: 'JetBrains Mono', monospace;
}

/* ── File handling (chips, badges, previews) ──────────────── */
.file-preview {
  display: flex;
  gap: 6px;
  padding-bottom: 8px;
  flex-wrap: wrap;
  max-width: 780px;
  margin: 0 auto;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
  animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.file-chip img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
}

.file-chip .rm {
  cursor: pointer;
  color: var(--error);
  font-weight: bold;
  margin-left: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.file-chip .rm:hover {
  opacity: 1;
}

.file-chip .processing {
  color: var(--blue);
  font-size: 10px;
  margin-left: 4px;
}

.file-chip .processed {
  color: var(--cyan);
  font-size: 12px;
}

.file-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
  font-size: 12px;
  color: var(--text-dim);
}

.file-badge svg {
  width: 16px;
  height: 16px;
  color: var(--cyan);
}

/* ── Login Overlay ────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-overlay.hidden {
  display: none;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px;
  width: 420px;
  max-width: 94vw;
  text-align: center;
  box-shadow: 0 0 80px rgba(0, 240, 255, 0.05), 0 0 160px rgba(255, 0, 170, 0.03);
}

.login-logo {
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 34px;
  color: #fff;
  margin: 0 auto 24px;
  box-shadow: 0 0 60px var(--cyan-dim), 0 0 120px var(--magenta-dim);
}

.login-box h2 {
  margin-bottom: 4px;
  font-size: 26px;
  background: linear-gradient(135deg, #fff, var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-box .sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 30px;
}

.login-field {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.login-field:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim);
}

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px var(--cyan-dim), 0 0 60px var(--magenta-dim);
}

.login-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

/* ── Slide Panels ─────────────────────────────────────────── */
.slide-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 10, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
}

.slide-backdrop.active {
  display: block;
}

.slide-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border-glow);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -4px 0 40px rgba(0, 0, 0, 0.4);
}

.slide-panel.open {
  transform: translateX(0);
}

.slide-panel.w-sm { width: 380px; }
.slide-panel.w-md { width: 520px; }
.slide-panel.w-lg { width: 700px; }
.slide-panel.w-xl { width: 940px; }

.slide-panel .panel {
  background: transparent;
  border: none;
  border-radius: 0;
  max-width: 100%;
  width: 100%;
  max-height: 100%;
  height: 100%;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

/* ── Panel internals ──────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}

.panel-header h2 {
  flex: 1;
  font-size: 16px;
  color: var(--accent2);
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all 0.15s;
}

.panel-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.panel-tabs {
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.panel-tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

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

.panel-tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.panel-section {
  display: none;
}

.panel-section.active {
  display: block;
}

/* stat-grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: var(--border-glow);
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'JetBrains Mono', monospace;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  background: linear-gradient(135deg, var(--cyan), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: 'JetBrains Mono', monospace;
}

.stat-card .sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

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

.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'JetBrains Mono', monospace;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(30, 30, 50, 0.5);
}

.data-table tr:hover td {
  background: var(--glow2);
}

/* forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  display: block;
}

.form-input,
.form-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim);
}

.form-select {
  cursor: pointer;
}

.form-select option {
  background: var(--surface2);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
}

/* badges */
.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}

.badge-admin {
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent);
}

.badge-user {
  background: rgba(0, 230, 138, 0.12);
  color: var(--success);
}

/* alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-top: 10px;
  display: none;
}

.alert.success {
  display: block;
  background: rgba(0, 230, 138, 0.08);
  color: var(--success);
  border: 1px solid rgba(0, 230, 138, 0.2);
}

.alert.error {
  display: block;
  background: rgba(255, 68, 102, 0.08);
  color: var(--error);
  border: 1px solid rgba(255, 68, 102, 0.2);
}

/* buttons */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.btn-danger {
  background: none;
  border: 1px solid var(--error);
  color: var(--error);
  padding: 5px 12px;
  font-size: 11px;
  border-radius: var(--radius-xs);
}

.btn-danger:hover {
  background: var(--error);
  color: #fff;
}

.btn-ghost {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.btn-ghost:hover {
  border-color: var(--cyan);
  color: var(--text);
  box-shadow: 0 0 8px var(--cyan-dim);
}

/* code-blocks */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  overflow-x: auto;
  line-height: 1.6;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  white-space: pre-wrap;
  position: relative;
}

.code-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  opacity: 0.5;
}

/* ── Model cards ──────────────────────────────────────────── */
.model-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.model-card:hover {
  border-color: var(--border-glow);
}

.model-card .model-info {
  flex: 1;
}

.model-card .model-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.model-card .model-detail {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.model-card .model-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.model-card .model-tags span {
  background: var(--surface3);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}

/* ── File Explorer (fe-*) ─────────────────────────────────── */
.fe-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.fe-path {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  outline: none;
  min-width: 200px;
  transition: border-color 0.15s;
}

.fe-path:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim);
}

.fe-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.fe-btn:hover {
  border-color: var(--cyan);
  color: var(--text);
  box-shadow: 0 0 8px var(--cyan-dim);
}

.fe-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.fe-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 50vh;
  overflow-y: auto;
}

.fe-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.fe-entry:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

.fe-entry.dir {
  color: var(--accent2);
}

.fe-entry .fe-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.fe-entry .fe-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
}

.fe-entry .fe-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.fe-editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fe-editor-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fe-editor-filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent2);
  flex: 1;
  font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fe-editor {
  width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text);
  font-size: 13px;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  resize: vertical;
  outline: none;
  line-height: 1.6;
  min-height: 300px;
  max-height: 60vh;
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
}

.fe-editor:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim);
}

.fe-search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 8px;
}

.fe-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
  transition: all 0.1s;
}

.fe-search-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.fe-search-item .line-num {
  color: var(--cyan);
  min-width: 40px;
  text-align: right;
}

.fe-search-item .match-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fe-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.fe-status {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
  font-family: 'JetBrains Mono', monospace;
}

.fe-modified {
  color: var(--error) !important;
}

/* ── Export buttons ────────────────────────────────────────── */
.msg-exports {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.export-btn:hover {
  border-color: var(--cyan);
  color: var(--text);
  background: var(--cyan-dim);
}

.export-btn svg {
  width: 14px;
  height: 14px;
}

/* ── PDF Preview ──────────────────────────────────────────── */
.pdf-preview {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 8px 0;
  background: var(--surface2);
}

.pdf-preview canvas {
  max-width: 100%;
  display: block;
  margin: 4px auto;
  border-radius: 4px;
}

/* ── Web Builder (wb-*) ───────────────────────────────────── */
.wb-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 120px);
  min-height: 400px;
}

.wb-sidebar {
  width: 260px;
  min-width: 220px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wb-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wb-templates {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.wb-tpl {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--surface2);
}

.wb-tpl:hover {
  border-color: var(--cyan);
  color: var(--text);
}

.wb-tpl.active {
  border-color: var(--cyan);
  background: var(--cyan-dim);
  color: var(--cyan);
}

.wb-tpl-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}

.wb-tpl-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.wb-prompt-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wb-prompt {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 60px;
  max-height: 100px;
  line-height: 1.4;
}

.wb-prompt:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim);
}

.wb-gen-btn {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.wb-gen-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px var(--cyan-dim);
}

.wb-gen-btn:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

.wb-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.wb-toolbar .fe-btn {
  padding: 4px 10px;
  font-size: 11px;
}

.wb-view-tabs {
  display: flex;
  gap: 0;
  margin-left: auto;
}

.wb-view-tab {
  padding: 4px 12px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--surface2);
  transition: all 0.1s;
}

.wb-view-tab:first-child {
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
}

.wb-view-tab:last-child {
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.wb-view-tab:not(:first-child) {
  border-left: none;
}

.wb-view-tab.active {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #fff;
}

.wb-preview {
  flex: 1;
  background: #fff;
  overflow: hidden;
}

.wb-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.wb-preview.active {
  display: block;
}

.wb-code-area {
  flex: 1;
  display: none;
  overflow: hidden;
}

.wb-code-area.active {
  display: flex;
}

.wb-code {
  width: 100%;
  height: 100%;
  background: var(--code-bg);
  border: none;
  color: var(--text);
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  padding: 12px;
  resize: none;
  outline: none;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

.wb-split {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.wb-split .wb-code-area {
  width: 50%;
  border-right: 1px solid var(--border);
}

.wb-split .wb-preview {
  width: 50%;
}

/* ── Inference Source Indicators ───────────────────────────── */
.msg.src-reflex .msg-bubble {
  border-left-color: var(--cyan);
  background: linear-gradient(135deg, var(--surface2), var(--cyan-dim));
}

.msg.src-reflex .msg-meta::before {
  content: '\26A1 Reflex';
  color: var(--cyan);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  margin-right: 4px;
}

.msg.src-reflex .reflex-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--cyan-dim);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--cyan);
  font-family: 'JetBrains Mono', monospace;
}

.msg.src-ssi .msg-bubble {
  border-left-color: var(--blue);
  background: linear-gradient(135deg, var(--surface2), var(--blue-dim));
}

.msg.src-ssi .msg-meta::before {
  content: '\2744 SSI';
  color: var(--blue);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  margin-right: 4px;
}

.msg.src-llm .msg-bubble {
  border-left-color: var(--magenta);
  background: linear-gradient(135deg, var(--surface2), var(--magenta-dim));
}

.msg.src-llm .msg-meta::before {
  content: '\1F9E0 Cascade';
  color: var(--magenta);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  margin-right: 4px;
}

.msg.src-reflex .msg-bubble {
  animation: reflexPulse 2s ease-in-out 1;
}

.msg.src-llm .msg-bubble {
  position: relative;
  overflow: hidden;
}

.msg.src-llm .msg-bubble::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--magenta-glow) 0%, transparent 60%);
  animation: cascadeFlow 3s ease-in-out 1;
  pointer-events: none;
  opacity: 0;
}

/* ── Sovereign Action Buttons ─────────────────────────────── */
.sov-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.sov-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'JetBrains Mono', monospace;
}

.sov-btn:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.sov-btn svg {
  width: 13px;
  height: 13px;
}

.sov-btn-crystal {
  border-color: rgba(0, 240, 255, 0.3);
}

.sov-btn-crystal:hover {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-dim);
}

.sov-btn-validate {
  border-color: rgba(0, 230, 138, 0.3);
}

.sov-btn-validate:hover {
  background: rgba(0, 230, 138, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.sov-btn-validate.negative {
  border-color: rgba(255, 68, 102, 0.3);
}

.sov-btn-validate.negative:hover {
  background: rgba(255, 68, 102, 0.1);
  border-color: var(--error);
  color: var(--error);
}

.sov-btn-isolate {
  border-color: rgba(255, 170, 0, 0.3);
}

.sov-btn-isolate:hover {
  background: rgba(255, 170, 0, 0.1);
  border-color: var(--warning);
  color: var(--warning);
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.1);
}

/* ── Typing indicator ─────────────────────────────────────── */
.typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: bounce 1.4s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ── Stream cursor ────────────────────────────────────────── */
.stream-cursor {
  animation: blink 0.8s infinite;
  color: var(--cyan);
  font-weight: bold;
}

/* ── Animations (@keyframes) ──────────────────────────────── */
@keyframes bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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

@keyframes sovLive {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.sov-chip.live {
  animation: sovLive 2s ease-in-out infinite;
}

@keyframes reflexPulse {
  0% {
    box-shadow: 0 0 0 0 var(--cyan-glow);
  }
  25% {
    box-shadow: 0 0 16px 4px var(--cyan-glow);
  }
  50% {
    box-shadow: 0 0 8px 2px var(--cyan-dim);
  }
  75% {
    box-shadow: 0 0 12px 3px var(--cyan-glow);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes cascadeFlow {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(0deg);
  }
  30% {
    opacity: 0.3;
  }
  60% {
    opacity: 0.15;
    transform: scale(1) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.2) rotate(360deg);
  }
}

@keyframes streamGlow {
  0%, 100% {
    box-shadow: 0 0 8px var(--cyan-dim);
  }
  50% {
    box-shadow: 0 0 20px var(--cyan-glow), 0 0 40px rgba(0, 240, 255, 0.06);
  }
}

/* ── Responsive (768px) ───────────────────────────────────── */
@media (max-width: 768px) {
  .nav-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 100%;
    height: 48px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 50;
  }

  .nav-rail-logo {
    display: none;
  }

  .nav-rail-items {
    flex-direction: row;
    justify-content: center;
    padding: 0 4px;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .nav-rail-item {
    width: 44px;
    height: 40px;
  }

  .nav-rail-item::after {
    display: none;
  }

  .nav-rail-divider {
    width: 1px;
    height: 24px;
    margin: 0 2px;
  }

  .nav-rail-footer {
    flex-direction: row;
    border-top: none;
    border-left: 1px solid var(--border);
    padding: 0 6px;
    gap: 6px;
  }

  .nav-rail-footer .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  .sessions-flyout {
    left: 0;
    bottom: 48px;
    top: auto;
    height: 50vh;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--border);
    transform: translateY(100%);
  }

  .sessions-flyout.open {
    transform: translateY(0);
  }

  .app-layout {
    flex-direction: column;
  }

  .main-content {
    padding-bottom: 48px;
  }

  .status-bar {
    padding: 0 10px;
  }

  .topbar-title {
    font-size: 12px;
  }

  .sov-mini {
    display: none !important;
  }

  .chat-area {
    padding: 10px 6px;
  }

  .msg {
    gap: 6px;
    margin-bottom: 10px;
    max-width: 100%;
  }

  .msg-bubble {
    padding: 10px 12px;
    font-size: 13px;
  }

  .msg-avatar {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }

  .input-area {
    padding: 6px 8px;
  }

  .input-wrap {
    gap: 4px;
    padding: 4px 4px 4px 12px;
  }

  .btn-send,
  .btn-mic {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  .btn-attach {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .btn-attach svg,
  .btn-send svg,
  .btn-mic svg {
    width: 16px;
    height: 16px;
  }

  .input-box {
    font-size: 14px;
    min-height: 34px;
  }

  .input-hint {
    font-size: 9px;
  }

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

  .welcome h2 {
    font-size: 20px;
  }

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

  .welcome-icon {
    width: 50px;
    height: 50px;
    font-size: 24px;
    border-radius: 14px;
  }

  .slide-panel {
    width: 100vw !important;
  }

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

  .form-row {
    flex-direction: column;
  }

  .msg-exports {
    gap: 4px;
  }

  .export-btn {
    padding: 3px 8px;
    font-size: 10px;
  }

  .file-chip {
    font-size: 11px;
    padding: 4px 8px;
  }

  .fe-toolbar {
    gap: 4px;
  }

  .fe-path {
    font-size: 11px;
    padding: 6px 8px;
    min-width: 120px;
  }

  .fe-btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  .fe-entry {
    padding: 6px 8px;
    font-size: 12px;
  }

  .fe-entry .fe-size {
    display: none;
  }

  .wb-layout {
    flex-direction: column;
    height: auto;
  }

  .wb-sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .wb-split {
    flex-direction: column;
  }

  .wb-split .wb-code-area,
  .wb-split .wb-preview {
    width: 100%;
    height: 50%;
  }

  .sov-actions {
    gap: 4px;
  }

  .sov-btn {
    padding: 2px 8px;
    font-size: 10px;
  }
}

/* ── Responsive (480px) ───────────────────────────────────── */
@media (max-width: 480px) {
  .btn-attach:nth-child(2) {
    display: none;
  }

  .msg-avatar {
    display: none;
  }

  .btn-send,
  .btn-mic {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .btn-attach {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }

  .export-btn span {
    display: none;
  }

  .topbar-title {
    font-size: 11px;
  }

  .login-box {
    padding: 28px 20px;
  }

  .login-logo {
    width: 60px;
    height: 60px;
    font-size: 28px;
    border-radius: 16px;
  }
}

/* ── SOV chips visibility by breakpoint ───────────────────── */
@media (min-width: 900px) {
  .sov-mini {
    display: flex;
  }
}

@media (max-width: 899px) {
  .sov-mini {
    display: none;
  }
}
