/* MIT AI Console — OpenFang-inspired design system */

[data-theme="light"],
:root {
  --bg: #f5f4f2;
  --bg-primary: #edeceb;
  --bg-elevated: #f8f7f6;
  --surface: #ffffff;
  --surface2: #f0eeec;
  --surface3: #e8e6e3;
  --border: #d5d2cf;
  --border-light: #c8c4c0;
  --border-subtle: #e0deda;
  --border-strong: #b0aca8;
  --text: #1a1817;
  --text-secondary: #3d3935;
  --text-dim: #6b6560;
  --text-muted: #9a958f;
  --text-on-accent: #ffffff;
  --accent: #ff5c00;
  --accent-light: #ff7a2e;
  --accent-dim: #e05200;
  --accent-glow: rgba(255, 92, 0, 0.1);
  --accent-subtle: rgba(255, 92, 0, 0.05);
  --success: #22c55e;
  --success-dim: #16a34a;
  --error: #ef4444;
  --error-dim: #dc2626;
  --warning: #f59e0b;
  --warning-dim: #d97706;
  --info: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --sidebar-width: 240px;
  --sidebar-collapsed: 56px;
  --header-height: 56px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.05);
  --shadow-accent: 0 4px 16px rgba(255, 92, 0, 0.12);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s var(--ease-smooth);
  --transition-normal: 0.25s var(--ease-smooth);
}

[data-theme="dark"] {
  --bg: #080706;
  --bg-primary: #0f0e0e;
  --bg-elevated: #161413;
  --surface: #242221;
  --surface2: #2f2d2c;
  --surface3: #1a1817;
  --border: #363230;
  --border-light: #4a4644;
  --border-subtle: #2d2a28;
  --border-strong: #4a4644;
  --text: #ffffff;
  --text-secondary: #d1d1d1;
  --text-dim: #9fa0a0;
  --text-muted: #6b6663;
  --text-on-accent: #ffffff;
  --accent: #ff5c00;
  --accent-light: #ff7a2e;
  --accent-dim: #e05200;
  --accent-glow: rgba(255, 92, 0, 0.15);
  --accent-subtle: rgba(255, 92, 0, 0.08);
  --success: #4ade80;
  --success-dim: #22c55e;
  --error: #ef4444;
  --error-dim: #b91c1c;
  --warning: #f59e0b;
  --warning-dim: #d97706;
  --info: #3b82f6;
  --ok: #4ade80;
  --warn: #f59e0b;
  --err: #ef4444;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.3);
  --shadow-accent: 0 4px 16px rgba(255, 92, 0, 0.2);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

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

html { scroll-behavior: smooth; height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a { color: var(--accent-light); text-decoration: none; }
code, pre, .hash, .stat-value, .conn-badge, .version, .card .value {
  font-family: var(--font-mono);
}
code { font-size: 0.86em; }

.muted { color: var(--text-dim); }
.sm { font-size: 0.8rem; }
.error { color: var(--error); }
.ok { color: var(--success); }
.block { width: 100%; }
.hidden, [hidden] { display: none !important; }

h1, h2, h3, .card .value, .page-header h2 { letter-spacing: -0.02em; }
.nav-section-title, .nav-group, .badge, th, .card .label { letter-spacing: 0.04em; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

::selection { background: var(--accent); color: var(--text-on-accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardEntry {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.animate-entry { animation: cardEntry 0.35s var(--ease-spring) both; }
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }

.brand-mark { width: 32px; height: 32px; flex-shrink: 0; display: block; }
.brand-mark.sm { width: 28px; height: 28px; }
.logo-mark {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800; letter-spacing: 0.04em;
  font-family: var(--font-mono);
}
.logo-mark.sm { width: 28px; height: 28px; font-size: 0.62rem; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: auto;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(255, 92, 0, 0.12), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg), var(--shadow-inset);
  animation: slideUp 0.35s var(--ease-smooth);
}
.login-brand { display: flex; gap: 0.9rem; align-items: center; margin-bottom: 1.4rem; }
.login-brand h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 3px;
  font-family: var(--font-mono);
}
.login-brand p { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 12px; }
.login-hint { margin-top: 0.8rem; font-size: 0.8rem; }
.alt-login { margin-top: 1rem; color: var(--text-dim); }
.alt-login summary { cursor: pointer; font-size: 13px; }

label { display: grid; gap: 0.35rem; font-size: 11px; font-weight: 600; color: var(--text-dim); margin-bottom: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { min-height: 120px; resize: vertical; width: 100%; }
textarea.short { min-height: 72px; }

/* Buttons */
.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.btn:hover { filter: none; background: var(--surface3); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--text-on-accent);
  box-shadow: var(--shadow-xs), var(--shadow-inset);
}
.btn.primary:hover { background: var(--accent-dim); box-shadow: var(--shadow-sm), var(--shadow-accent); }
.btn.ghost { background: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border-light); }
.btn.danger { background: var(--error); border-color: transparent; color: #fff; }
.btn.danger:hover { background: var(--error-dim); }
.btn.ok { background: var(--success); border-color: transparent; color: #000; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* App chrome */
.app,
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width var(--transition-normal);
  z-index: 100;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-header-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-group,
.sidebar.collapsed #session-meta { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-status { justify-content: center; padding: 8px 0; }
.sidebar.collapsed .conn-badge { display: none; }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-header,
.sidebar-brand {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  min-height: 60px;
  gap: 10px;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-header h1,
.sidebar-brand h1,
.sidebar-brand strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 3px;
  font-family: var(--font-mono);
}
.sidebar-brand span,
.version {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 1px;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}

.sidebar-status {
  font-size: 11px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.sidebar-status.offline { color: var(--error); }
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.conn-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-left: auto;
}
.conn-badge.http { background: var(--warning); color: #000; }
.conn-badge.ws { background: var(--success); color: #000; }

.sidebar-nav,
nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }
.nav-section { margin-bottom: 4px; }
.nav-section-title,
.nav-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 12px 12px 6px 3px;
  font-weight: 600;
}

.nav-item,
nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: all var(--transition-fast);
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
  font-weight: 500;
}
.nav-item:hover,
nav a:hover {
  background: var(--surface2);
  color: var(--text);
  transform: translateX(2px);
}
.nav-item.active,
nav a.active {
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm), 0 2px 8px rgba(255, 92, 0, 0.2);
}
.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-foot {
  padding: 10px 12px;
  display: grid;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
}
.sidebar-foot .btn { justify-content: flex-start; }
.sidebar.collapsed .sidebar-foot .btn { justify-content: center; padding: 8px; }

.sidebar-toggle {
  padding: 10px 16px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  text-align: center;
  font-size: 16px;
  color: var(--text-muted);
  transition: color var(--transition-fast), transform var(--transition-fast);
  width: 100%;
}
.sidebar-toggle:hover { color: var(--text); }

.main,
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

.topbar,
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  min-height: var(--header-height);
  flex-shrink: 0;
}
.topbar h2,
.page-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.topbar p,
.page-header p { margin: 0.15rem 0 0; font-size: 12px; }
.topbar-actions { display: flex; gap: 0.55rem; align-items: center; flex-wrap: wrap; }

.page,
.page-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 14px;
  animation: fadeIn 0.2s var(--ease-smooth);
}

.page > *,
.page-body > * {
  flex: 0 0 auto;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-content: start;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  box-shadow: var(--shadow-xs), var(--shadow-inset);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.grid > .card,
.stat-card-lg {
  transition: transform 0.3s var(--ease-spring), box-shadow var(--transition-fast), border-color var(--transition-fast);
  overflow: hidden;
}
.grid > .card:hover,
.stat-card-lg:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-light);
}
.stat-card-lg::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.stat-card-lg:hover::after { opacity: 1; }
.card .label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}
.card .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.card h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; }
.card.error { border-color: var(--error); color: var(--error); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 0;
  padding: 0;
  margin: 0;
}
.section-head h3 { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.3; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.card .table-wrap {
  border: none;
  background: transparent;
  border-radius: 0;
  margin: 8px -16px -16px;
}
.card.table-wrap {
  padding: 0;
  overflow: hidden;
}
.card.table-wrap:hover { transform: none; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 10px 14px; vertical-align: top; }
th {
  background: var(--surface3);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.2;
}
.pill.ok { background: rgba(74, 222, 128, 0.12); color: var(--success); }
.pill.warn { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.pill.err { background: rgba(239, 68, 68, 0.12); color: var(--error); }

.bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: inherit;
}
.bar.warn > span { background: var(--warning); }
.bar.err > span { background: var(--error); }

.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; }
.filters label { margin-bottom: 0; }
.filters input, .filters select { min-width: 140px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.span-2 { grid-column: span 2; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(640px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s var(--ease-smooth);
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.modal-head, .modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
  gap: 0.6rem;
}
.modal-head { border-bottom: 1px solid var(--border); }
.modal-foot { border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { padding: 1rem; max-height: 70vh; overflow: auto; }
.modal-head h3 { margin: 0; font-size: 15px; }
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); }

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
  z-index: 250;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.9rem;
  min-width: 240px;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.25s var(--ease-smooth);
  font-size: 13px;
}
.toast.err { border-left-color: var(--error); }
.toast.ok { border-left-color: var(--success); }

.chat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 240px;
  padding: 0.9rem;
  white-space: pre-wrap;
  line-height: 1.5;
  font-family: var(--font-mono);
  font-size: 12px;
}
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; align-content: start; align-items: start; }
.group-card h4 { margin: 0 0 0.5rem; font-size: 13px; }
.member {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-family: var(--font-mono);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
  animation: pulse 1.8s infinite;
}

.feed { display: grid; gap: 6px; }
.feed-item {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  font-size: 13px;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.feed-item.clickable { cursor: pointer; }
.feed > .feed-item.clickable:hover,
.feed > .feed-item:hover { border-color: var(--accent); transform: translateX(2px); }
.hash { font-size: 0.75rem; word-break: break-all; }
.layers { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.5rem; }
.layer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  background: var(--bg-elevated);
}

.theme-switcher {
  display: inline-flex;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.theme-opt {
  cursor: pointer;
  padding: 5px 9px;
  font-size: 13px;
  background: none;
  border: none;
  color: var(--text-muted);
  transition: all 0.2s;
  line-height: 1;
}
.theme-opt:hover { color: var(--text); background: var(--surface2); }
.theme-opt.active { color: var(--accent); background: var(--accent-glow); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}
.mobile-menu-btn {
  display: none !important;
  position: fixed !important;
  top: 12px;
  left: 16px;
  z-index: 98;
  padding: 6px 10px !important;
}

@media (min-width: 1400px) {
  .grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 1024px) {
  .page, .page-body { padding: 16px; }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex !important; }
  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width) !important;
    transition: left var(--transition-normal);
  }
  .sidebar.mobile-open { left: 0; }
  .sidebar.mobile-open + .sidebar-overlay { display: block; }
  .page-header > :first-child { margin-left: 44px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .feed-item { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .page-header { gap: 8px; padding: 12px 16px; flex-wrap: wrap; }
  .page, .page-body { padding: 12px; }
}

@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .nav-item { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
