:root {
  color-scheme: light;

  --blue: #0284C7;
  --blue-light: #E0F2FE;
  --blue-dark: #0369A1;
  --green: #16A34A;
  --green-light: #DCFCE7;
  --orange: #E8751A;
  --orange-light: #FFEDD5;
  --purple: #8B5CF6;
  --purple-light: #EDE9FE;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --amber: #D97706;

  --bg: #F1F5F9;
  --bg-page: #F8FAFC;
  --panel: #FFFFFF;
  --border: #E2E8F0;
  --border-soft: #F1F5F9;
  --text: #0F172A;
  --text-dim: #475569;
  --text-faint: #94A3B8;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --blue-border: #BAE6FD;
  --green-border: #BBF7D0;
  --red-border: #FECACA;
  --amber-border: #FDE68A;
  --amber-bg: #FFFBEB;
  --drawer-backdrop: rgba(15, 23, 42, 0.35);
  --slider-knob: #FFFFFF;
  --scrollbar-thumb: #CBD5E1;
  --scrollbar-thumb-hover: #94A3B8;
  --focus-ring: rgba(2, 132, 199, 0.12);
  --focus-ring-soft: rgba(2, 132, 199, 0.1);
  --avatar-shadow: rgba(2, 132, 199, 0.18);

  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;

  --blue-light: #0C4A6E;
  --green-light: #14532D;
  --orange-light: #431407;
  --purple-light: #2E1065;
  --red-light: #450A0A;

  --bg: #1E293B;
  --bg-page: #0F172A;
  --panel: #1E293B;
  --border: #334155;
  --border-soft: #1A2332;
  --text: #F1F5F9;
  --text-dim: #94A3B8;
  --text-faint: #64748B;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);

  --blue-border: #0C4A6E;
  --green-border: #166534;
  --red-border: #991B1B;
  --amber-border: #92400E;
  --amber-bg: #451A03;
  --drawer-backdrop: rgba(0, 0, 0, 0.55);
  --slider-knob: #F1F5F9;
  --scrollbar-thumb: #475569;
  --scrollbar-thumb-hover: #64748B;
  --focus-ring: rgba(56, 189, 248, 0.18);
  --focus-ring-soft: rgba(56, 189, 248, 0.14);
  --avatar-shadow: rgba(56, 189, 248, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
  border: 2px solid var(--blue-light);
  box-shadow: 0 2px 8px var(--avatar-shadow);
  flex-shrink: 0;
  display: block;
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 400;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view-tabs { display: flex; gap: 4px; margin-right: 4px; }

.view-tab {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
}

.view-tab:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-light); }
.view-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.hidden { display: none !important; }

.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge-muted { color: var(--amber); border-color: var(--amber-border); background: var(--amber-bg); }
.badge.ok { color: var(--green); border-color: var(--green-border); background: var(--green-light); }
.badge.bad { color: var(--red); border-color: var(--red-border); background: var(--red-light); }
.badge-policy { color: var(--blue); border-color: var(--blue-border); background: var(--blue-light); }

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 600;
  padding: 10px 20px;
}

.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }

.btn-outline {
  width: 100%;
  background: var(--panel);
  border: 1px dashed var(--blue);
  color: var(--blue);
  font-weight: 600;
  padding: 10px;
}

.btn-outline:hover { background: var(--blue-light); }

.btn-tiny { padding: 4px 10px; font-size: 12px; color: var(--text-dim); }
.btn-icon { padding: 6px 10px; background: transparent; }
.gear { font-size: 14px; }
.theme-icon { font-size: 15px; line-height: 1; }

.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 42px;
  min-height: 42px;
  background: var(--blue);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  font-family: inherit;
}

.btn-send:hover { background: var(--blue-dark); color: #fff; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger { background: transparent; border-color: var(--red-border); color: var(--red); }
.btn-danger:hover { background: var(--red-light); border-color: var(--red); }

/* ---------- Three-column layout ---------- */
.layout {
  flex: 1;
  display: grid;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.layout-three {
  grid-template-columns: 1fr 1.1fr 0.85fr;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  flex-shrink: 0;
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
}

.panel-icon-chat { background: var(--blue-light); }
.panel-icon-audit { background: var(--green-light); }
.panel-icon-server { background: var(--blue-light); }

.panel-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.counter { font-size: 11px; color: var(--text-faint); }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--green);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  padding: 3px 8px;
  border-radius: 999px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.live-badge.active { opacity: 1; }

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.live-badge.active .live-dot {
  background: var(--green);
  animation: pulse 1.4s infinite;
}

/* ---------- Chat ---------- */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
  animation: rise 0.25s ease;
}

.msg-wrap.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-wrap.bot {
  align-self: flex-start;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
  border: 2px solid var(--blue-light);
  flex-shrink: 0;
}

.msg {
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user {
  background: var(--blue-light);
  color: var(--text);
  border: 1px solid var(--blue-border);
  border-bottom-right-radius: 4px;
}

.msg.bot {
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.bot.thinking { color: var(--text-faint); font-style: italic; }
.msg img { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; }
.msg a { color: var(--blue); }
.msg code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.empty-hint {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-faint);
  max-width: 300px;
  margin: 0 auto;
  padding: 24px 16px;
  font-size: 13px;
  line-height: 1.55;
}

.empty-hint.small { font-size: 12px; max-width: 280px; flex: 0; padding: 12px 0; }

.empty-mascot {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 0 14px;
  object-fit: cover;
  object-position: center 18%;
  display: block;
  border: 2px solid var(--blue-light);
  box-shadow: 0 2px 12px var(--avatar-shadow);
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
  flex-shrink: 0;
}

.composer textarea {
  flex: 1;
  resize: none;
  box-sizing: border-box;
  min-height: 42px;
  max-height: 140px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  overflow-y: auto;
}

.composer textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus-ring); }

/* ---------- Audit timeline ---------- */
.timeline {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 12px;
}

.event {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 10px 10px 10px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
  animation: rise 0.2s ease;
}

.event:last-child { border-bottom: none; }

.event::before {
  content: "";
  position: absolute;
  left: 58px;
  top: 28px;
  bottom: -8px;
  width: 2px;
  background: var(--border);
}

.event:last-child::before { display: none; }

.ev-time {
  color: var(--text-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding-top: 2px;
  text-align: right;
}

.ev-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.event.run .ev-marker { background: var(--blue-light); color: var(--blue); border: 2px solid var(--blue); }
.event.tool .ev-marker { background: var(--purple-light); color: var(--purple); border: 2px solid var(--purple); }
.event.ok .ev-marker { background: var(--green-light); color: var(--green); border: 2px solid var(--green); }
.event.bad .ev-marker { background: var(--red-light); color: var(--red); border: 2px solid var(--red); }
.event.warn .ev-marker { background: var(--orange-light); color: var(--orange); border: 2px solid var(--orange); }

.ev-content { min-width: 0; }

.event .ev-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}

.event .ev-tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--blue);
  font-weight: 600;
}

.event .ev-meta { color: var(--text-faint); font-size: 11px; font-weight: 400; }

.event .ev-body {
  margin-top: 5px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: auto;
  background: var(--bg);
  border-radius: 6px;
  padding: 7px 8px;
  border: 1px solid var(--border-soft);
}

.ev-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  align-self: start;
}

.ev-badge.start { background: var(--blue-light); color: var(--blue); }
.ev-badge.end { background: var(--green-light); color: var(--green); }
.ev-badge.info { background: var(--orange-light); color: var(--orange); }
.ev-badge.block { background: var(--orange-light); color: var(--orange); }
.ev-badge.err { background: var(--red-light); color: var(--red); }

.tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* ---------- SSH Registry ---------- */
.registry-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  min-height: 0;
}

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

.registry-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  position: sticky;
  top: 0;
}

.registry-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  vertical-align: middle;
}

.registry-table tr:hover td { background: var(--bg-page); cursor: pointer; }

.registry-table .col-alias {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: var(--blue);
}

.registry-table .col-host {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 4px;
}

.status-pill.online {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.status-pill.offline {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.status-pill.unknown {
  background: var(--bg);
  color: var(--text-faint);
  border: 1px solid var(--border);
}

.registry-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.registry-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
  flex-shrink: 0;
}

.registry-summary {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  text-align: center;
  display: none;
}

.registry-summary.visible { display: block; }

/* ---------- Footer status bar ---------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px;
  height: 36px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  overflow-x: auto;
}

.statusbar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 0 14px;
}

.statusbar-item strong { font-weight: 600; }

.statusbar-policy strong { color: var(--blue); }
.statusbar-audit strong { color: var(--purple); }
.statusbar-agent strong { color: var(--blue); }
.statusbar-time { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.statusbar-version { color: var(--text-faint); margin-left: auto; }

.statusbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

.statusbar-icon { font-size: 12px; opacity: 0.75; }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--drawer-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 460px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-note {
  padding: 14px 18px 0;
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

.drawer-note code, .drawer-note b { color: var(--text-dim); }

.settings-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.loading { color: var(--text-faint); text-align: center; padding: 30px; }

.group { margin-bottom: 22px; }
.group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue);
  margin-bottom: 10px;
  font-weight: 700;
}

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; }
.field .set-flag { color: var(--green); font-size: 11px; margin-left: 6px; }

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.field input:focus, .field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus-ring-soft);
}

.field.bool { display: flex; align-items: center; justify-content: space-between; }
.field.bool label { margin: 0; }

.switch { position: relative; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: 0.2s;
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: var(--slider-knob);
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: var(--shadow-sm);
}

.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.drawer-foot.inline { padding: 14px 0 0; border: none; }
.save-status { font-size: 12px; color: var(--green); }

.field .help { font-size: 11px; color: var(--text-faint); margin-top: 4px; line-height: 1.45; }
.hint-inline { color: var(--text-faint); font-weight: 400; font-size: 11px; }

.tabs { display: flex; gap: 6px; }

.tab {
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.tab:hover { color: var(--text); }
.tab.active { background: var(--bg); border-color: var(--border); color: var(--text); }

.tab-pane { display: none; }
.tab-pane.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#pane-servers.active { overflow-y: auto; }

.servers-body { padding: 14px 18px 0; }

.server-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg-page);
}

.sc-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.sc-alias { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--blue); font-weight: 700; }
.sc-meta { color: var(--text-dim); font-size: 12px; }
.sc-actions { margin-left: auto; display: flex; gap: 6px; }

.badge-auth {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg);
}

.badge-auth.key { color: var(--green); border-color: var(--green-border); background: var(--green-light); }
.badge-auth.pwd { color: var(--amber); border-color: var(--amber-border); background: var(--amber-bg); }
.badge-auth.none { color: var(--red); border-color: var(--red-border); background: var(--red-light); }

.sc-test-output {
  margin-top: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 9px;
  max-height: 170px;
  overflow: auto;
}

.sc-test-output.ok { border-color: var(--green-border); }
.sc-test-output.bad { border-color: var(--red-border); }
.servers-empty { color: var(--text-faint); font-size: 13px; padding: 8px 0 14px; }

.server-form {
  padding: 16px 18px 22px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.server-form h3 {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }
.field.narrow { max-width: 96px; }

.server-form textarea {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  resize: vertical;
  outline: none;
}

.server-form textarea:focus, .server-form input:focus { border-color: var(--blue); }

.key-upload-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.file-btn { cursor: pointer; margin: 0; display: inline-block; }
.key-file-name { font-size: 12px; color: var(--text-faint); }
.key-file-name.loaded { color: var(--green); }

/* ---------- Animations & scrollbars ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); } 70% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
::-webkit-scrollbar-track { background: transparent; }

.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

@media (max-width: 1200px) {
  .layout-three { grid-template-columns: 1fr 1fr; }
  .registry-panel { grid-column: 1 / -1; max-height: 220px; }
}

@media (max-width: 800px) {
  .layout-three { grid-template-columns: 1fr; }
  .registry-panel { max-height: none; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .status-cluster { width: 100%; }
}

/* ---------- Auth overlay (multi-user hosted demo) ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--drawer-backdrop);
  backdrop-filter: blur(4px);
  padding: 24px;
}

.auth-overlay[hidden] { display: none !important; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 28px 24px;
  text-align: center;
}

.auth-mascot { margin-bottom: 8px; }

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.auth-sub {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.45;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--blue-light);
  color: var(--blue-dark);
  border-color: var(--blue-border);
}

.auth-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}

.auth-form input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text);
}

.auth-error {
  margin: 0;
  color: var(--red);
  font-size: 0.85rem;
}

.auth-submit { width: 100%; margin-top: 4px; }

.app.auth-locked .layout,
.app.auth-locked .topbar .status-cluster > :not(#badge-conn) {
  pointer-events: none;
  filter: blur(1px);
  opacity: 0.55;
}

.btn-sm {
  font-size: 0.82rem;
  padding: 6px 10px;
}
