:root {
  color-scheme: dark;
  --bg:       #020806;
  --panel:    #07120d;
  --panel2:   #0b1a12;
  --panel3:   #102619;
  --text:     #e2f3e8;
  --text-dim: #b7d3c0;
  --muted:    #6d8e79;
  --border:   #183023;
  --border-hi: #284a37;
  --accent:   #2fca68;
  --accent-hi: #54e68a;
  --accent-dim: #1d8545;
  --accent-rgb: 47, 202, 104;
  --accent-hi-rgb: 84, 230, 138;
  --accent-dim-rgb: 29, 133, 69;
  --button-bg: linear-gradient(160deg, var(--accent-hi), var(--accent));
  --button-text: #041507;
  --danger:   #ef7676;
  --warn:     #e7c85c;
  --tool-indicator-idle:  #94a3b8;
  --tool-indicator-chat:  #facc15;
  --tool-indicator-web:   #38bdf8;
  --tool-indicator-code:  #22c55e;
  --tool-indicator-image: #d946ef;
  --tool-indicator-error: #ef4444;

  /* History/sidebar theme tokens. Theme overlays can tune these without
     duplicating the shared sidebar layout rules. */
  --history-sidebar-bg: rgba(7, 18, 13, 0.88);
  --history-sidebar-border: var(--border);
  --history-sidebar-restore-bg: var(--history-sidebar-bg);

  --history-card-bg: rgba(255,255,255,0.025);
  --history-card-bg-hover: rgba(var(--accent-rgb), 0.055);
  --history-card-bg-active: rgba(var(--accent-rgb), 0.08);
  --history-card-bg-active-hover: var(--history-card-bg-active);
  --history-card-border: transparent;
  --history-card-border-hover: rgba(var(--accent-rgb), 0.28);
  --history-card-border-active: rgba(var(--accent-rgb), 0.32);
  --history-card-border-active-hover: var(--history-card-border-active);
  --history-card-shadow: none;
  --history-card-shadow-hover: none;
  --history-card-shadow-active: none;
  --history-card-shadow-active-hover: var(--history-card-shadow-active);
  --history-card-text: var(--text-dim);
  --history-card-text-active: var(--text);
  --history-card-muted: var(--muted);

  --history-delete-bg: var(--history-card-bg);
  --history-delete-bg-hover: rgba(240, 112, 112, 0.08);
  --history-delete-border: var(--history-card-border);
  --history-delete-border-hover: rgba(240, 112, 112, 0.35);
  --history-delete-color: var(--muted);
  --history-delete-color-hover: var(--danger);

  --history-archive-color: var(--warn);
  --history-archive-rgb: 231, 200, 92;
  --history-archive-bg: rgba(var(--history-archive-rgb), 0.065);
  --history-archive-bg-hover: rgba(var(--history-archive-rgb), 0.11);
  --history-archive-border: rgba(var(--history-archive-rgb), 0.24);
  --history-archive-border-hover: rgba(var(--history-archive-rgb), 0.42);
  --history-archive-text: var(--history-archive-color);

  --history-generating-bg: rgba(105, 198, 255, 0.07);
  --history-generating-border: rgba(105, 198, 255, 0.32);
  --history-generating-shadow: var(--history-card-shadow-active);
  --history-generation-badge-bg: rgba(105, 198, 255, 0.10);
  --history-generation-badge-border: rgba(105, 198, 255, 0.35);
  --history-generation-badge-text: var(--text);
  --history-generation-badge-dot: var(--accent-hi);
  --history-generation-badge-shadow: none;

  --glow:     rgba(var(--accent-rgb), 0.18);
  --glow-sm:  rgba(var(--accent-rgb), 0.09);
  --shadow:   0 1px 3px rgba(0,0,0,0.48), 0 4px 16px rgba(0,0,0,0.36);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.58), 0 1px 3px rgba(0,0,0,0.45);
  --radius:   0.9rem;
  --radius-sm: 0.55rem;
  --control-radius: 0.38rem;
  --transition: 140ms ease;

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

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

html, body { min-height: 100%; height: 100%; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(var(--accent-rgb), 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(var(--accent-dim-rgb), 0.08), transparent);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbars ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Base elements ─────────────────────────────────── */
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hi); text-decoration: underline; text-underline-offset: 3px; }

button, input, textarea, select { font: inherit; }

button {
  border: 1px solid var(--accent-dim);
  border-radius: var(--control-radius);
  background: var(--button-bg);
  color: var(--button-text);
  padding: 0.6rem 1.1rem;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: 0 1px 6px rgba(var(--accent-rgb), 0.2), inset 0 1px 0 rgba(255,255,255,0.08);
}
button:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 2px 12px rgba(var(--accent-rgb), 0.35), inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(-1px);
}
button:active:not(:disabled) { transform: translateY(0); filter: brightness(0.96); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.secondary {
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
  border-color: var(--border-hi);
  box-shadow: none;
  font-weight: 500;
}
button.secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: var(--muted);
  box-shadow: none;
  transform: none;
  filter: none;
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(240, 112, 112, 0.35);
  box-shadow: none;
  font-weight: 500;
}
button.danger:hover:not(:disabled) {
  background: rgba(240, 112, 112, 0.08);
  border-color: var(--danger);
  box-shadow: none;
  transform: none;
  filter: none;
}

input:not([type]),
input[type=text],
input[type=password],
input[type=email],
input[type=search],
input[type=url],
input[type=tel],
input[type=number],
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: rgba(12, 28, 19, 0.86);
  color: var(--text);
  color-scheme: dark;
  padding: 0.7rem 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}
input:not([type]):focus,
input[type=text]:focus,
input[type=password]:focus,
input[type=email]:focus,
input[type=search]:focus,
input[type=url]:focus,
input[type=tel]:focus,
input[type=number]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent-dim);
  background: rgba(14, 33, 22, 0.94);
  box-shadow: 0 0 0 3px var(--glow-sm);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
input:-webkit-autofill,
input:-webkit-autofill:hover {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border-color: var(--border-hi);
  box-shadow: 0 0 0 1000px rgba(12, 28, 19, 0.96) inset;
  transition: background-color 9999s ease-out 0s;
}
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 1000px rgba(14, 33, 22, 0.96) inset, 0 0 0 3px var(--glow-sm);
}
input:-moz-autofill {
  background: rgba(12, 28, 19, 0.96) !important;
  color: var(--text) !important;
  caret-color: var(--text);
  border-color: var(--border-hi);
  box-shadow: 0 0 0 1000px rgba(12, 28, 19, 0.96) inset;
}
input:-moz-autofill:focus {
  background: rgba(14, 33, 22, 0.96) !important;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 1000px rgba(14, 33, 22, 0.96) inset, 0 0 0 3px var(--glow-sm);
}
textarea { resize: vertical; line-height: 1.5; }

label { display: grid; gap: 0.4rem; color: var(--muted); font-size: 0.875rem; font-weight: 500; }

/* ── Layout helpers ─────────────────────────────────── */
.centered-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1rem;
}
.stack { display: grid; gap: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.inline-form { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.inline-form input[type=password] { width: 15rem; }
.inline-form.compact-action-form { flex-wrap: nowrap; }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.alert.error {
  color: #ffd6d6;
  border-color: rgba(180, 50, 50, 0.5);
  background: rgba(50, 12, 12, 0.7);
}
.alert.success {
  color: #d0fce0;
  border-color: rgba(40, 160, 80, 0.4);
  background: rgba(12, 50, 25, 0.7);
}

/* ── Cards ──────────────────────────────────────────── */
.login-card, .card, .composer-card {
  background: rgba(11, 24, 16, 0.85);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}
.login-card {
  width: min(100%, 26rem);
  padding: 2.25rem;
}
.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.login-card .muted { margin-bottom: 0.25rem; font-size: 0.875rem; }
.card { padding: 1.25rem; margin: 1rem 0; }

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.45rem;
  padding: 0.55rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 13, 7, 0.86);
  backdrop-filter: blur(16px) saturate(1.35);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-status-group {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  min-width: 0;
  flex: 0 0 auto;
}

.brand {
  font-weight: 850;
  font-size: 1.15rem;
  letter-spacing: -0.025em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
  color: var(--text);
}
.brand-logo {
  width: 1.65rem;
  height: 1.65rem;
  object-fit: contain;
  flex: 0 0 auto;
}
.brand-title-group {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-width: 0;
}
.brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}
.brand-tool-indicator {
  display: inline-block;
  flex: 0 0 auto;
  background: var(--tool-indicator-idle);
  transition: background-color 140ms ease, box-shadow 140ms ease, opacity 140ms ease, transform 140ms ease;
}
.brand-tool-dot {
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 999px;
  opacity: 0.92;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 0 rgba(148, 163, 184, 0);
}
.brand-tool-cursor {
  width: 0.72em;
  height: 0.14em;
  border-radius: 999px;
  transform: translateY(0.34em);
  opacity: 0.9;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 8px rgba(148, 163, 184, 0.18);
}
.brand-tool-indicator.tool-chat {
  background: var(--tool-indicator-chat);
}
.brand-tool-indicator.tool-web {
  background: var(--tool-indicator-web);
}
.brand-tool-indicator.tool-code {
  background: var(--tool-indicator-code);
}
.brand-tool-indicator.tool-image {
  background: var(--tool-indicator-image);
}
.brand-tool-indicator.tool-error {
  background: var(--tool-indicator-error);
}
.brand-tool-dot.tool-chat {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 10px rgba(250, 204, 21, 0.24);
}
.brand-tool-dot.tool-web {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 10px rgba(56, 189, 248, 0.24);
}
.brand-tool-dot.tool-code {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 10px rgba(34, 197, 94, 0.24);
}
.brand-tool-dot.tool-image {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 10px rgba(217, 70, 239, 0.24);
}
.brand-tool-dot.tool-error {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 10px rgba(239, 68, 68, 0.28);
}
.brand-tool-indicator.is-active {
  animation: brand-tool-status-pulse 1.2s ease-in-out infinite;
}
.brand-wordmark-part {
  color: inherit;
}
.brand-space-before {
  margin-left: 0.26em;
}
.brand-accent,
.brand-em {
  color: var(--accent-hi);
  text-shadow: 0 0 10px rgba(var(--accent-hi-rgb), 0.22);
}
.brand-muted,
.brand-chat {
  color: var(--text-dim);
  font-weight: 760;
  letter-spacing: -0.02em;
}
@keyframes brand-tool-status-pulse {
  0%, 100% { opacity: 0.82; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.login-brand-title .brand-wordmark {
  justify-content: center;
}
.topbar-cluster {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.topbar nav {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.topbar nav a,
.topbar-control,
.topbar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-height: 2.05rem;
  padding: 0.34rem 0.72rem;
  border: 1px solid var(--border-hi);
  border-radius: var(--control-radius);
  background: rgba(255,255,255,0.025);
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: 0.005em;
  line-height: 1;
  box-shadow: none;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.topbar nav a:hover,
.topbar-control:hover:not(:disabled),
.topbar-toggle:hover {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.055);
  border-color: rgba(var(--accent-rgb), 0.32);
  text-decoration: none;
  box-shadow: none;
  transform: none;
  filter: none;
}
.topbar form { margin: 0; }
.topbar form button.secondary,
.runner-status button.secondary.topbar-control,
.service-status button.secondary.topbar-control {
  font-size: 0.9rem;
  padding: 0.34rem 0.72rem;
  font-weight: 650;
}
.topbar-toggle {
  width: auto;
  cursor: pointer;
  user-select: none;
}
.topbar-toggle input {
  width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  accent-color: var(--accent);
}

/* ── Runner status ──────────────────────────────────── */
.runner-status,
.activity-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  flex-wrap: wrap;
}
.service-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}
.service-status .status-text,
.service-status .runner-detail {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.dot,
.status-indicator {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  display: inline-block;
  background: var(--muted);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}
.dot.online,
.status-indicator.online {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2), 0 0 8px rgba(var(--accent-rgb), 0.5);
  animation: pulse-dot 2.5s ease-in-out infinite;
}
.dot.offline,
.status-indicator.offline { background: var(--danger); box-shadow: 0 0 6px rgba(240, 112, 112, 0.4); }
.dot.unknown,
.status-indicator.unknown { background: var(--warn); }
.dot.warning,
.dot.busy,
.status-indicator.warning,
.status-indicator.busy { background: #eab308; box-shadow: 0 0 8px rgba(234, 179, 8, 0.45); }
.dot.busy,
.status-indicator.busy {
  background: #eab308;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.2), 0 0 8px rgba(234, 179, 8, 0.45);
  animation: pulse-busy-dot 1.6s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2), 0 0 8px rgba(var(--accent-rgb), 0.45); }
  50%       { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.08), 0 0 14px rgba(var(--accent-rgb), 0.6); }
}

@keyframes pulse-busy-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.2), 0 0 8px rgba(234, 179, 8, 0.45); }
  50%       { box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.08), 0 0 14px rgba(234, 179, 8, 0.6); }
}

.runner-detail {
  color: var(--muted);
  font-size: 0.82rem;
  opacity: 0.8;
}


/* ── Shared accessibility helpers ───────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Pages ──────────────────────────────────────────── */
.page { padding: 1.5rem; margin: 0 auto; }
.page.narrow { max-width: 42rem; }
.page.wide { max-width: 82rem; }
.page h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  color: var(--text);
}
.page h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
  color: var(--text-dim);
}


/* ── Shared tables and pills ─────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-hi);
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}
tbody tr:hover td { background: rgba(255,255,255,0.015); }
.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--panel3);
  border: 1px solid var(--border-hi);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: 0.25rem;
}
.pill.warn { color: #f0c850; border-color: rgba(240, 200, 80, 0.3); background: rgba(240, 200, 80, 0.08); }
.pill.admin { color: #f6d66b; border-color: rgba(240, 200, 80, 0.45); background: rgba(240, 200, 80, 0.12); }
.pill.busy { color: #f0c850; border-color: rgba(240, 200, 80, 0.35); background: rgba(240, 200, 80, 0.1); }
.pill.online { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.32); background: rgba(var(--accent-rgb), 0.08); }
.pill.muted { color: var(--muted); border-color: rgba(145, 163, 184, 0.28); background: rgba(145, 163, 184, 0.08); }

/* ── Shared tiny button variant ───────────────────────── */
.tiny {
  font-size: 0.76rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--control-radius);
}

/* ── Shared responsive topbar polish ──────────────────── */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0.55rem; padding: 0.55rem 0.85rem; }
  .topbar-cluster { order: 3; width: 100%; justify-content: space-between; }
  .topbar nav { margin-left: auto; }
  .runner-detail { display: none; }
}


/* ── Shared eyebrow label ─────────────────────────────── */
.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Shared danger button and topbar mobile cleanup ────── */
button.danger {
  border-color: rgba(255, 97, 97, 0.55);
  background: rgba(255, 97, 97, 0.15);
  color: #ffd5d5;
}
button.danger:hover:not(:disabled) {
  border-color: rgba(255, 128, 128, 0.8);
  background: rgba(255, 97, 97, 0.25);
}

/* ── Mobile/navigation cleanup ─────────────────────── */
.topbar nav:empty { display: none; }
.topbar-cluster { margin-left: auto; }
.icon-topbar-button {
  width: 2.1rem;
  min-width: 2.1rem;
  padding-inline: 0;
  font-size: 1.05rem;
}

@media (max-width: 720px) {
  body {
    font-size: 1rem;
  }
  .topbar {
    flex-wrap: nowrap;
    gap: 0.42rem;
    padding: 0.58rem 0.62rem;
    overflow-x: hidden;
  }
  .brand-status-group {
    gap: 0.26rem;
    flex: 0 0 auto;
  }
  .brand {
    font-size: 1.08rem;
    flex: 0 0 auto;
  }
  .brand-tool-dot {
    width: 0.48rem;
    height: 0.48rem;
  }
  .brand-tool-cursor {
    width: 0.66em;
    transform: translateY(0.32em);
  }
  .brand-mobile-optional,
  .brand-chat { display: none; }
  .topbar-cluster {
    order: 0;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    gap: 0.34rem;
    margin-left: auto;
  }
  .service-status {
    flex: 0 1 auto;
    min-width: auto;
    gap: 0.25rem;
    padding-inline: 0.05rem;
  }
  .service-status #runner-text,
  .runner-detail {
    display: none;
  }
  .topbar-generation-badge {
    max-width: 8.5rem;
    font-size: 0.64rem;
    padding-inline: 0.32rem;
  }
  .topbar nav {
    margin-left: 0;
    flex: 0 0 auto;
  }
  .topbar nav a,
  .topbar-control,
  .topbar-toggle {
    min-height: 2.6rem;
    padding: 0.4rem 0.72rem;
    font-size: 0.94rem;
    gap: 0.34rem;
  }
  .topbar-toggle input {
    width: 1.02rem;
    height: 1.02rem;
  }
  .icon-topbar-button {
    width: 2.65rem;
    min-width: 2.65rem;
    padding-inline: 0;
    font-size: 1.28rem;
  }
}

@media (max-width: 460px) {
  .topbar {
    gap: 0.32rem;
    padding: 0.52rem 0.5rem;
  }
  .brand {
    font-size: 1.02rem;
  }
  .topbar-cluster { gap: 0.25rem; }
  .topbar nav a,
  .topbar-control,
  .topbar-toggle {
    min-height: 2.55rem;
    padding-inline: 0.62rem;
    font-size: 0.9rem;
  }
  .icon-topbar-button {
    width: 2.6rem;
    min-width: 2.6rem;
    font-size: 1.24rem;
  }
}

@media (max-width: 370px) {
  .topbar-toggle span { display: none; }
  .brand { max-width: 5.8rem; overflow: hidden; }
}

/* Final topbar polish: keep links, toggles, and admin buttons visually identical. */
.topbar button.secondary.topbar-control {
  border-radius: var(--control-radius);
  border-color: var(--border-hi);
  background: rgba(255,255,255,0.025);
  color: var(--text-dim);
  box-shadow: none;
}
.topbar button.secondary.topbar-control:hover:not(:disabled) {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.055);
  border-color: rgba(var(--accent-rgb), 0.32);
  box-shadow: none;
  transform: none;
  filter: none;
}

