@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #151e27;
  --surface: #090a17;
  --surface-hover: #101444;
  --surface-light: #1a2332;
  --accent: #b5daff;
  --accent-hover: #d0e7ff;
  --accent-dim: rgba(181, 218, 255, 0.15);
  --accent-border: rgba(181, 218, 255, 0.2);
  --text: #e2e2e2;
  --text-muted: rgba(181, 218, 255, 0.5);
  --text-dim: rgba(181, 218, 255, 0.3);
  --border: rgba(181, 218, 255, 0.12);
  --border-accent: rgba(181, 218, 255, 0.25);
  --destructive: #df5f79;
  --green: #86efac;
  --green-bg: rgba(134, 239, 172, 0.12);
  --blue: #93c5fd;
  --purple: #c4b5fd;
  /* Colorblind-friendly sync state palette.
     Blue and orange are reliably distinguishable across protanopia,
     deuteranopia, and tritanopia — they sit far apart on the color
     wheel and differ significantly in luminance. Pairing them with
     icons (see .sidebar-sync-icon) ensures state is never conveyed
     by color alone. */
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --blue-strong: #3b82f6;
  --blue-strong-bg: rgba(59, 130, 246, 0.12);
  --offline: #6b7280;
  --offline-bg: rgba(107, 114, 128, 0.12);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --font: "Roboto Mono", "Courier New", monospace;
  --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-bg: #000d19;
  --sidebar-w: 220px;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.3); }

.layout {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  /* No overflow here — the .nav-section children handle their own
     scrolling via flex: 1; overflow-y: auto, which lets the sync
     indicator stay pinned to the bottom at all times. */
}

.sidebar-logo {
  padding: 0 12px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

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

.sidebar .input {
  background: var(--sidebar-bg);
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  transition: all var(--transition);
  user-select: none;
}

.nav-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.6;
  flex-shrink: 0;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 20px 4px;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

/* Colorblind-friendly: blue for healthy (instead of green which is hard
   to distinguish from red/amber for protanopic/deuteranopic users). The
   accompanying health-text is the primary indicator; this is a cue. */
.health-dot.ok { background: var(--blue-strong); box-shadow: 0 0 6px rgba(59, 130, 246, 0.4); }
.health-dot.err { background: var(--destructive); box-shadow: 0 0 6px rgba(223, 95, 121, 0.4); }

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

/* ─── Sidebar Sync Indicator ─── */
#sidebar-sync-indicator {
  padding: 18px 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  transition: opacity 0.2s ease;
  /* Pin the sync indicator to the bottom of the sidebar. The footer
     sits directly below it in the DOM (inserted by app.js via
     `insertBefore(footer)`), so this pushes both the indicator and
     the footer down together with zero gap between them. */
  margin-top: auto;
}

#sidebar-sync-indicator.is-loading {
  opacity: 0.65;
}

.sidebar-sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.sidebar-sync-row-text {
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.sidebar-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* State classes for the sync dot. Color is one signal; the
   .sidebar-sync-icon next to the dot is the primary indicator so we
   never depend on color alone. */
.sidebar-sync-dot.is-blue {
  background: var(--blue-strong);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}

.sidebar-sync-dot.is-amber {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.sidebar-sync-dot.is-offline {
  background: var(--offline);
  box-shadow: none;
}

.sidebar-sync-dot.is-error {
  background: var(--destructive);
  box-shadow: 0 0 6px rgba(223, 95, 121, 0.4);
}

/* State icon shown to the left of each row's dot. This is the primary
   accessibility signal — the color of the dot is a redundant cue. */
.sidebar-sync-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border-radius: 3px;
  flex-shrink: 0;
  font-family: var(--font);
  transition: color 0.2s ease, background 0.2s ease;
  user-select: none;
}

.sidebar-sync-icon.is-synced {
  color: var(--blue-strong);
  background: var(--blue-strong-bg);
}

.sidebar-sync-icon.is-syncing {
  color: var(--amber);
  background: var(--amber-bg);
  animation: sync-icon-spin 1.2s linear infinite;
}

.sidebar-sync-icon.is-offline {
  color: var(--offline);
  background: var(--offline-bg);
}

.sidebar-sync-icon.is-error {
  color: var(--destructive);
  background: rgba(223, 95, 121, 0.12);
}

.sidebar-sync-icon.is-idle {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
}

@keyframes sync-icon-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Progress bar */
.sidebar-sync-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-sync-progress-track {
  position: relative;
  width: 100%;
  height: 6px;
  background: var(--surface-light);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.sidebar-sync-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--text-dim);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
  box-shadow: 0 0 0 transparent;
}

/* Pending state: orange with diagonal stripes. The striped pattern
   is the primary accessibility signal — it reads as "in progress"
   even when the color is hard to distinguish or the bar is at low
   percentage (where color fill alone would be a tiny sliver). */
.sidebar-sync-progress-fill.is-pending {
  background: var(--amber);
  background-image: repeating-linear-gradient(
    45deg,
    var(--amber) 0,
    var(--amber) 8px,
    rgba(255, 255, 255, 0.22) 8px,
    rgba(255, 255, 255, 0.22) 16px
  );
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

/* Done state: solid blue. The accompanying "All synced" text + ✓
   icon (set in JS) are the primary signal; the bar's solid color
   reinforces it. */
.sidebar-sync-progress-fill.is-done {
  background: var(--blue-strong);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

/* Indeterminate shimmer while loading */
#sidebar-sync-indicator.is-loading .sidebar-sync-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.18) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: sync-shimmer 1.2s linear infinite;
  pointer-events: none;
}

@keyframes sync-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.sidebar-sync-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.sidebar-sync-progress-pct {
  font-weight: 600;
  color: var(--text);
}

.sidebar-sync-progress-counts {
  transition: color 0.3s ease, background 0.3s ease;
  padding: 1px 4px;
  border-radius: 3px;
}

.sidebar-sync-progress-counts.pulse-update {
  animation: sync-pulse 0.9s ease-out;
}

@keyframes sync-pulse {
  0% {
    background: rgba(181, 218, 255, 0.25);
    color: var(--accent);
  }
  100% {
    background: transparent;
    color: var(--text-muted);
  }
}

/* Footer row: "Updated Xs ago" + Refresh button */
.sidebar-sync-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-sync-updated {
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

.sidebar-sync-updated.is-stale {
  color: var(--amber);
}

.sidebar-sync-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px !important;
  padding: 3px 8px !important;
  line-height: 1;
}

.sidebar-sync-refresh-icon {
  display: inline-block;
  transition: transform 0.2s ease;
}

.sidebar-sync-refresh-btn:hover .sidebar-sync-refresh-icon {
  transform: rotate(-30deg);
}

.sidebar-sync-refresh-btn.is-loading .sidebar-sync-refresh-icon {
  animation: spin 0.7s linear infinite;
}

.sidebar-sync-refresh-btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

/* ─── Main ─── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.tab-header {
  margin-bottom: 24px;
}

.tab-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

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

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

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

.card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color var(--transition);
}

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

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge-green { background: var(--green-bg); color: var(--green); }

.badge-accent { background: var(--accent-dim); color: var(--accent); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  outline: none;
  white-space: nowrap;
}

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

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

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

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Inputs ─── */
.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.input:focus { border-color: var(--accent); }

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

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b5daff' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ─── Table ─── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(181, 218, 255, 0.03); }

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-dim); }

.mono { font-family: var(--font); font-size: 11px; color: var(--text-muted); }
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Chat ─── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
}

.chat-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chat-controls .input { max-width: 250px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  max-width: 85%;
  font-size: 13px;
  line-height: 1.6;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--surface);
  border-bottom-right-radius: 2px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
  white-space: pre-wrap;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chat-input-bar .input { flex: 1; }

/* ─── Peer Card / Representation ─── */
.representation-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

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

.peer-card-item {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
}

/* ─── Conclusion Colors ─── */
.conclusion-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.conclusion-type .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conclusion-type.explicit .dot { background: var(--green); }
.conclusion-type.deductive .dot { background: var(--blue); }
.conclusion-type.inductive .dot { background: var(--purple); }

/* ─── Search Bar ─── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar .input { flex: 1; }

/* ─── Loading ─── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 0;
  color: var(--text-muted);
  font-size: 12px;
}

/* ─── Empty State ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 300px;
}

/* ─── Expand Row ─── */
.expand-content {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 16px;
}

/* ─── Inline Code ─── */
code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-size: 11px;
  color: var(--accent);
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

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

.modal h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-body label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.btn-danger:hover { opacity: 0.9; }

/* ─── Workspace Select ─── */
#workspace-select {
  font-size: 12px;
  padding: 6px 28px 6px 8px;
}

/* ─── Accordion ─── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.accordion-header:hover {
  background: var(--surface-hover);
}

.accordion-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.accordion-header .chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.accordion.open .accordion-header .chevron {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.accordion.open .accordion-body {
  max-height: 2000px;
}

.accordion-content {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Settings ─── */
.settings-sticky-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  z-index: 10;
}

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

.settings-field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.settings-field input,
.settings-field select {
  font-size: 12px;
}

.settings-masked {
  position: relative;
}

.settings-masked input[type="password"] {
  padding-right: 40px;
}

.settings-mask-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
}

.settings-mask-toggle:hover {
  color: var(--text);
}

.settings-dirty-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  display: inline-block;
  margin-left: 6px;
}

/* ─── Utility ─── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.font-medium { font-weight: 500; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── Typing Indicator ─── */
.chat-msg.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  min-width: 60px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ─── Toast Notifications ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.toast-exit {
  animation: toastOut 0.2s ease forwards;
}

.toast-info { border-color: var(--accent); }
.toast-success { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--destructive); color: var(--destructive); }
.toast-warning { border-color: #f59e0b; color: #f59e0b; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

/* ─── Delete Button (inline on cards/rows) ─── */
.btn-delete-inline {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  opacity: 0;
}

.card:hover .btn-delete-inline,
tr:hover .btn-delete-inline {
  opacity: 1;
}

.btn-delete-inline:hover {
  color: var(--destructive);
  background: rgba(223, 95, 121, 0.12);
}

/* ─── Load More Button ─── */
.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.btn-load-more {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-load-more:hover {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--border-accent);
}

.btn-load-more:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Comparison Container ─── */
.comparison-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.comparison-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comparison-pane-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.comparison-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

/* ─── Peer soft-deleted ─── */
.peer-soft-deleted {
  opacity: 0.35;
  pointer-events: none;
}

/* ─── Auth Section ─── */
.auth-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.auth-name {
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ─── Workspace Merge ─── */
.merge-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: #f59e0b;
  line-height: 1.5;
}

.merge-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 600px) {
  .merge-fields {
    grid-template-columns: 1fr;
  }
}

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

.merge-strategy-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.merge-strategy-option:hover {
  background: var(--accent-dim);
}

.merge-strategy-option input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.merge-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.merge-preview-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.merge-preview-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.merge-preview-stats {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.merge-stat {
  font-size: 12px;
  color: var(--text);
}

.merge-stat-label {
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 4px;
}

.merge-preview-conflicts {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.merge-conflict-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.merge-conflict-list code {
  font-size: 11px;
}

.merge-preview-section-group {
  border-top: 1px solid var(--border);
}

.merge-preview-group-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  padding: 8px 14px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.merge-preview-section {
  padding: 6px 14px;
}

.merge-preview-section-title {
  font-size: 12px;
  font-weight: 600;
}

.merge-preview-id-list {
  font-size: 12px;
  line-height: 1.6;
  margin-top: 2px;
}

.merge-preview-id-list code {
  font-size: 11px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
}

.merge-preview-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 5%, transparent);
}

.merge-preview-note strong {
  color: var(--text);
}

/* ─── Credentials Section ─── */
.credentials-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.credentials-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.credentials-row input[data-cred-field="username"],
.credentials-row select[data-cred-field="role"] {
  font-size: 12px;
}

.credentials-row input[data-cred-field="username"] {
  flex: 2;
}

.credentials-row select[data-cred-field="role"] {
  flex: 1;
  max-width: 130px;
}

.credentials-row input[data-cred-field="password"] {
  flex: 2;
  font-size: 12px;
}

/* ─── Search Highlight ─── */
.search-highlight {
  background: rgba(245, 158, 11, 0.3);
  color: var(--text);
  border-radius: 2px;
  padding: 0 2px;
}

/* ─── Status Dots ─── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  flex-shrink: 0;
}

.status-dot-green {
  background: var(--green);
  box-shadow: 0 0 6px rgba(134, 239, 172, 0.4);
}

.status-dot-gray {
  background: var(--text-dim);
}

/* ─── Sync Status Grid ─── */
.sync-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sync-status-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}

.sync-status-item:hover {
  border-color: var(--border-accent);
}

.sync-status-item .sync-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sync-status-item .sync-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.sync-status-item.sync-full-width {
  grid-column: 1 / -1;
}

.sync-pending-0 {
  color: var(--green);
  font-weight: 600;
}

.sync-pending-active {
  color: #f59e0b;
  font-weight: 600;
}

@media (max-width: 600px) {
  .sync-status-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Trash Modal ─── */
.trash-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trash-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  transition: border-color var(--transition);
}

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

.trash-item-content {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

.trash-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.trash-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.btn-restore {
  background: transparent;
  color: var(--green);
  border: 1px solid rgba(134, 239, 172, 0.25);
}

.btn-restore:hover {
  background: var(--green-bg);
  border-color: rgba(134, 239, 172, 0.4);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--destructive);
  border: 1px solid rgba(223, 95, 121, 0.25);
}

.btn-danger-ghost:hover {
  background: rgba(223, 95, 121, 0.12);
  border-color: rgba(223, 95, 121, 0.4);
}
