/* ============================================================
   SovereignClaw — Dark Theme Stylesheet
   ============================================================ */

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --bg-card:   #161b22;
  --bg-input:  #0d1117;
  --border:    #30363d;
  --border-hl: #484f58;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --accent-bg: rgba(88,166,255,.12);
  --success:   #3fb950;
  --error:     #f85149;
  --warning:   #d29922;
  --font:      system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono:      'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  --nav-h:     56px;
  --sidebar-w: 280px;
  --radius:    8px;
  --radius-sm: 4px;
  --shadow:    0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --transition: .15s ease;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hl); }

/* --- Navbar ------------------------------------------------ */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}
.navbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 8px;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.15rem; font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-right: 24px;
  white-space: nowrap;
}
.navbar-brand:hover { text-decoration: none; color: var(--accent); }
.navbar-logo { color: var(--accent); flex-shrink: 0; }

.navbar-links { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .92rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,.06); text-decoration: none; }
.nav-link.active { color: var(--text); background: var(--accent-bg); }

.navbar-toggle { display: none; background: none; border: none; cursor: pointer; padding: 4px; }
.navbar-toggle span {
  display: block; width: 20px; height: 2px; background: var(--muted);
  margin: 4px 0; border-radius: 1px; transition: var(--transition);
}

/* --- Layout ------------------------------------------------ */
#app {
  margin-top: var(--nav-h);
  min-height: calc(100vh - var(--nav-h));
}
.page { padding: 28px 24px; max-width: 1200px; margin: 0 auto; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-header p { color: var(--muted); margin-top: 4px; }

/* --- Cards ------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1.1rem; font-weight: 600; }
.card-header h3 { font-size: 1rem; font-weight: 600; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* --- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  font-size: .875rem; font-weight: 500; font-family: var(--font);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #4a96e8; }
.btn-danger {
  background: var(--error); color: #fff; border-color: var(--error);
}
.btn-danger:hover:not(:disabled) { background: #e04840; }
.btn-success {
  background: var(--success); color: #fff; border-color: var(--success);
}
.btn-success:hover:not(:disabled) { background: #36a046; }
.btn-outline {
  background: transparent; color: var(--muted); border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { color: var(--text); border-color: var(--border-hl); background: rgba(255,255,255,.04); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-icon {
  padding: 6px; background: transparent; border: none; color: var(--muted);
  cursor: pointer; border-radius: var(--radius-sm);
}
.btn-icon:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* --- Forms ------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: .85rem; font-weight: 500; color: var(--muted);
  margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  font-size: .9rem; font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--border-hl); }
.input-row {
  display: flex; gap: 8px; align-items: flex-end;
}
.input-row .form-input { flex: 1; }
.input-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.input-error { border-color: var(--error) !important; }

/* Password toggle wrapper */
.password-wrap {
  position: relative;
}
.password-wrap .form-input { padding-right: 40px; }
.password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .78rem; padding: 2px 4px;
}
.password-toggle:hover { color: var(--text); }

/* --- Badges ------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 10px;
}
.badge-running  { background: rgba(63,185,80,.15); color: var(--success); }
.badge-completed { background: rgba(139,148,158,.15); color: var(--muted); }
.badge-failed   { background: rgba(248,81,73,.15); color: var(--error); }
.badge-warning  { background: rgba(210,153,34,.15); color: var(--warning); }
.badge-success  { background: rgba(63,185,80,.15); color: var(--success); padding: 2px 8px; border-radius: 12px; font-size: .75rem; font-weight: 600; }

/* --- Tabs -------------------------------------------------- */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 18px;
  font-size: .9rem; font-weight: 500; font-family: var(--font);
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

/* --- Wizard Steps ------------------------------------------ */
.wizard-steps {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 32px;
}
.wizard-step {
  display: flex; align-items: center; gap: 8px;
  cursor: default;
  padding: 8px 4px;
}
.wizard-step.clickable { cursor: pointer; }
.wizard-step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 700;
  border: 2px solid var(--border);
  color: var(--muted);
  transition: all var(--transition);
}
.wizard-step.active .wizard-step-num {
  border-color: var(--accent); color: var(--accent); background: var(--accent-bg);
}
.wizard-step.completed .wizard-step-num {
  border-color: var(--success); background: var(--success); color: #fff;
}
.wizard-step-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.wizard-step.active .wizard-step-label { color: var(--text); }
.wizard-step.completed .wizard-step-label { color: var(--success); }
.wizard-sep {
  width: 40px; height: 2px; background: var(--border); margin: 0 4px;
}
.wizard-sep.completed { background: var(--success); }

.wizard-nav {
  display: flex; justify-content: space-between; margin-top: 28px; padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* --- Session Sidebar & Chat -------------------------------- */
.split-layout {
  display: flex;
  height: calc(100vh - var(--nav-h));
}
.split-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  overflow-y: auto;
  flex-shrink: 0;
}
.split-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.session-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.session-item:hover { background: rgba(255,255,255,.04); }
.session-item.active { background: var(--accent-bg); border-left: 3px solid var(--accent); }
.session-item-time { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.session-item-msg {
  font-size: .85rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.session-item-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

/* Chat bubbles */
.chat-container { max-width: 800px; margin: 0 auto; }
.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  margin-bottom: 12px;
  border-radius: 12px;
  font-size: .9rem;
  line-height: 1.6;
  word-wrap: break-word;
}
.chat-bubble.user {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  margin-right: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-bubble.system {
  margin: 8px auto;
  max-width: 90%;
  background: rgba(210,153,34,.08);
  border: 1px solid rgba(210,153,34,.2);
  color: var(--warning);
  font-size: .82rem;
  text-align: center;
}
.chat-role {
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 4px;
}
.chat-bubble.user .chat-role { color: rgba(255,255,255,.7); }

/* Tool use events */
.tool-event {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tool-event-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
  border: none; width: 100%; text-align: left;
  font-family: var(--font);
}
.tool-event-header:hover { background: rgba(255,255,255,.06); }
.tool-event-header .tool-name { color: var(--accent); font-family: var(--mono); }
.tool-event-chevron {
  margin-left: auto;
  transition: transform var(--transition);
  font-size: .7rem;
}
.tool-event.expanded .tool-event-chevron { transform: rotate(90deg); }
.tool-event-body {
  display: none;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: .78rem;
  white-space: pre-wrap;
  color: var(--muted);
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg);
}
.tool-event.expanded .tool-event-body { display: block; }

/* --- Workspace --------------------------------------------- */
.file-list { list-style: none; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  font-size: .9rem;
}
.file-item:hover { background: rgba(255,255,255,.04); }
.file-item.active { background: var(--accent-bg); }
.file-meta { font-size: .78rem; color: var(--muted); display: flex; gap: 12px; }

/* --- Logs -------------------------------------------------- */
.log-viewer {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.6;
  padding: 16px;
  height: calc(100vh - var(--nav-h) - 160px);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line { padding: 1px 0; }
.log-error { color: var(--error); }
.log-warn { color: var(--warning); }
.log-info { color: var(--text); }
.log-toolbar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
}

/* --- Table ------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.data-table .expand-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-family: var(--font); font-size: .82rem;
}
.data-table .expand-btn:hover { text-decoration: underline; }

/* --- Status cards (Dashboard) ------------------------------ */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-value.ok { color: var(--success); }
.stat-value.err { color: var(--error); }

.quick-links { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.quick-link {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), background var(--transition);
  flex: 1; min-width: 200px;
}
.quick-link:hover { border-color: var(--accent); background: var(--accent-bg); text-decoration: none; }
.quick-link-icon { font-size: 1.5rem; }
.quick-link-text { font-weight: 600; font-size: .95rem; }
.quick-link-sub { font-size: .78rem; color: var(--muted); }

/* --- Markdown rendering in chat ---------------------------- */
.chat-bubble code {
  font-family: var(--mono);
  background: rgba(0,0,0,.3);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: .84em;
}
.chat-bubble.user code { background: rgba(0,0,0,.2); }
.chat-bubble pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.5;
}
.chat-bubble pre code { background: none; padding: 0; }
.chat-bubble ul, .chat-bubble ol { padding-left: 20px; margin: 6px 0; }
.chat-bubble li { margin: 3px 0; }
.chat-bubble strong { font-weight: 700; }
.chat-bubble em { font-style: italic; }
.chat-bubble p { margin: 6px 0; }
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }

/* --- Loading Spinner --------------------------------------- */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px; color: var(--muted); font-size: .9rem;
}

/* Loading skeletons */
@keyframes skeleton-pulse {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, rgba(255,255,255,.04) 50%, var(--bg-card) 100%);
  background-size: 200px 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 4px;
}
.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}
.skeleton-text-sm { width: 40%; }
.skeleton-text-md { width: 65%; }
.skeleton-text-lg { width: 85%; }
.skeleton-card {
  height: 86px;
  border-radius: var(--radius);
}
.skeleton-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.skeleton-row .skeleton-text:last-child { margin-bottom: 0; }

/* --- Toast Notifications ----------------------------------- */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  animation: slideIn .25s ease;
  max-width: 380px;
  word-wrap: break-word;
}
.toast-success { background: #1a7f37; }
.toast-error   { background: #b62324; }
.toast-info    { background: #1a3a5c; border: 1px solid var(--accent); }
.toast.removing { animation: slideOut .2s ease forwards; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* --- Empty state ------------------------------------------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 1rem; color: var(--muted); opacity: .5; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: .5rem; }
.empty-state p { font-size: .875rem; max-width: 360px; }
.empty-state .btn { margin-top: .75rem; }

/* --- Provider card (setup wizard) -------------------------- */
.provider-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}
.provider-card.validated { border-color: var(--success); }
.provider-card.invalid { border-color: var(--error); }
.custom-provider-card { border-style: dashed; cursor: pointer; text-align: center; }
.custom-provider-card:hover { border-color: var(--accent); background: var(--accent-bg); }
.custom-provider-form { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.provider-name { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.provider-desc { font-size: .82rem; color: var(--muted); margin-bottom: 12px; }
.provider-status {
  display: flex; align-items: center; gap: 6px;
  font-size: .82rem; margin-top: 8px;
}
.provider-status .check { color: var(--success); }
.provider-status .cross { color: var(--error); }

/* --- Summary list (apply step) ----------------------------- */
.summary-list { list-style: none; }
.summary-list li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.summary-label { color: var(--muted); min-width: 160px; font-weight: 500; }
.summary-value { color: var(--text); word-break: break-all; }

/* --- Progress steps (apply) -------------------------------- */
.apply-steps { list-style: none; }
.apply-step {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: .9rem; color: var(--muted);
}
.apply-step.running { color: var(--accent); }
.apply-step.done { color: var(--success); }
.apply-step.error { color: var(--error); }
.apply-step-icon { width: 20px; text-align: center; }

/* --- Sidebar Toggle (mobile) ------------------------------- */
.sidebar-toggle { display: none; }

/* --- Responsive -------------------------------------------- */
@media (max-width: 768px) {
  .navbar-links { display: none; }
  .navbar-links.open {
    display: flex; flex-direction: column;
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .navbar-links.open .nav-link { padding: 10px 20px; }
  .navbar-toggle { display: block; margin-left: auto; }

  .split-layout { flex-direction: column; }
  .split-sidebar {
    width: 100%; min-width: 100%;
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .split-main { padding: 16px; }

  .card-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
  .wizard-sep { width: 20px; }
  .wizard-step-label { display: none; }
  .btn, .tab-btn { min-height: 44px; }
  .session-item, .file-item { min-height: 48px; }
  .nav-link { min-height: 44px; display: flex; align-items: center; }
  .sidebar-toggle { display: block; margin: 8px; }
  .split-sidebar.collapsed { display: none; }
}

/* --- Login Page ----------------------------------------------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h));
  padding: 24px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--accent);
}
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 28px;
}
.login-error {
  background: rgba(248,81,73,.1);
  border: 1px solid rgba(248,81,73,.3);
  color: var(--error);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-bottom: 16px;
}
.login-submit {
  width: 100%;
  padding: 10px 16px;
  font-size: .95rem;
  margin-top: 8px;
}

/* --- Large Button (CTA) -------------------------------------- */
.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  gap: 8px;
}

/* --- External Nav Link --------------------------------------- */
.nav-link-external {
  color: var(--accent) !important;
  font-weight: 600;
}
.nav-link-external:hover {
  background: var(--accent-bg) !important;
}

/* --- Stats Bar (Dashboard) ----------------------------------- */
.stats-bar {
  display: flex;
  gap: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stats-bar-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stats-bar-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.stats-bar-value {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
}

/* --- Export / Download UI ------------------------------------ */
.session-export-btns { display: flex; gap: 6px; }
.file-item .file-download-btn {
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.file-item:hover .file-download-btn,
.file-item:focus-within .file-download-btn { opacity: 1; }

/* --- Logout Button ------------------------------------------- */
.navbar-logout {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .82rem;
  font-family: var(--font);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.navbar-logout:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* --- Focus visible styles ------------------------------------ */
.session-item:focus-visible,
.file-item:focus-visible,
.tab-btn:focus-visible,
.nav-link:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Reconnection notice ------------------------------------- */
.sse-reconnecting {
  color: var(--warning);
  font-style: italic;
  text-align: center;
  padding: 8px 0;
}

/* Session expired modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 400px;
  text-align: center;
}
.modal-card h2 { margin-bottom: 1rem; }
.modal-card p { margin-bottom: 1.5rem; color: var(--muted); }

/* Light theme */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-card: #f6f8fa;
  --bg-input: #ffffff;
  --border: #d0d7de;
  --border-hl: #bcc3cd;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --accent-bg: rgba(9,105,218,.08);
  --success: #1a7f37;
  --error: #cf222e;
  --warning: #9a6700;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
[data-theme="light"] .navbar { background: #f6f8fa; border-bottom-color: #d0d7de; }
[data-theme="light"] .chat-bubble.user { background: rgba(9,105,218,.08); }
[data-theme="light"] .chat-bubble code { background: rgba(0,0,0,.06); }
[data-theme="light"] .tool-event-header:hover { background: rgba(0,0,0,.04); }
[data-theme="light"] pre, [data-theme="light"] .log-viewer { background: #f6f8fa; }
[data-theme="light"] .session-item:hover,
[data-theme="light"] .file-item:hover { background: rgba(0,0,0,.04); }
[data-theme="light"] .skeleton {
  background: linear-gradient(90deg, #f6f8fa 0%, #e1e4e8 50%, #f6f8fa 100%);
  background-size: 200px 100%;
}

/* Theme toggle button */
.btn-icon-theme {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  transition: background var(--transition);
}
.btn-icon-theme:hover { background: var(--accent-bg); }

/* --- Keyboard Shortcuts ------------------------------------ */
kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: .8rem;
  box-shadow: 0 1px 0 var(--border);
}
.shortcuts-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .75rem 1.5rem;
  align-items: center;
}

/* --- Syntax Highlighting ----------------------------------- */
.hl-keyword { color: var(--accent); }
.hl-string { color: var(--success); }
.hl-comment { color: var(--muted); font-style: italic; }
.hl-number { color: var(--warning); }
.hl-key { color: #d2a8ff; }

/* --- Copy Button on Code Blocks ---------------------------- */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--muted);
  opacity: 0;
  transition: opacity .2s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }

/* --- Update Banner ----------------------------------------- */
.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: .9rem;
}
.update-banner code {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .85rem;
}
.update-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* --- Chat Timestamp ---------------------------------------- */
.chat-time {
  float: right;
  font-size: .7rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 8px;
}

/* --- Onboarding Checklist ---------------------------------- */
.onboarding-card {
  margin-bottom: 1rem;
}
.onboarding-complete {
  border-color: var(--success);
}
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}
.checklist li {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.checklist li:last-child { border-bottom: none; }
.checklist-icon {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}
.checklist-done .checklist-icon { color: var(--success); }
.checklist-done span { color: var(--muted); }
.checklist li a {
  color: var(--accent);
  text-decoration: none;
}
.checklist li a:hover { text-decoration: underline; }
.badge-muted {
  background: rgba(139,148,158,.15);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
}

/* --- Help Panel -------------------------------------------- */
.help-links {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.help-link {
  display: block;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.help-link:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.help-link strong { display: block; margin-bottom: .25rem; }
.help-link span { font-size: .85rem; color: var(--muted); }

/* --- Provider Sections ------------------------------------ */
.provider-section { margin-bottom: 1.5rem; }
.provider-section-title { margin-bottom: .25rem; font-size: 1rem; }
.provider-section-desc { color: var(--muted); font-size: .85rem; margin-bottom: .75rem; }

/* Provider description in cards */
.provider-desc { color: var(--muted); font-size: .85rem; margin-bottom: .75rem; }
.provider-desc a { color: var(--accent); }

/* Model filter */
.model-filter { margin-bottom: .5rem; }
