:root {
  --bg: #0b0d10;
  --bg-elev: #13171d;
  --bg-card: #181d25;
  --bg-glass: rgba(20, 24, 31, 0.86);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f5f8;
  --text-muted: #9aa4b2;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.16);
  --rose: #ef4444;
  --user-bubble: #1e293b;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.12);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.12);
  --rose: #dc2626;
  --user-bubble: #e8eef7;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Auth Overlay */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.auth-logo { width: 46px; height: 46px; border-radius: 14px; object-fit: cover; }
.auth-brand h1 { margin: 0; font-size: 18px; font-weight: 700; }
.auth-brand p { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }
.auth-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 12px 0 6px; }
.auth-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.auth-error {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  font-size: 12px;
}
.btn-primary-full {
  margin-top: 16px;
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.auth-back-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

/* Layout Shell */
.app-shell {
  display: flex;
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* Sidebar Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(4px);
  z-index: 40;
}
.sidebar-drawer {
  width: 310px;
  max-width: 86vw;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 45;
  flex-shrink: 0;
}
@media (max-width: 860px) {
  .sidebar-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-105%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar-drawer.open { transform: translateX(0); }
}
@media (min-width: 861px) {
  .mobile-only { display: none !important; }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; }
.mini-logo { width: 26px; height: 26px; border-radius: 8px; object-fit: cover; }
.sidebar-actions { display: flex; gap: 6px; }

.sidebar-search-wrap { padding: 0 12px 8px; }
.sidebar-search-wrap input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 12px 10px;
  scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.45);
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.conv-item {
  padding: 10px 11px;
  border-radius: 13px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.conv-item:hover { background: rgba(255, 255, 255, 0.04); }
.conv-item.active {
  background: var(--bg-card);
  border-color: var(--border-strong);
}
.conv-item.is-waiting { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.06); }
.conv-item-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.conv-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted);
}
.conv-badges { display: flex; align-items: center; gap: 5px; min-width: 0; }
.tag-mini {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-wait { background: var(--gold-soft); color: var(--gold); }
.tag-run { background: var(--green-soft); color: var(--green); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.footer-link {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
}
.footer-link:hover { background: var(--bg-card); color: var(--text); }

/* Main Stage */
.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--bg);
}

.top-bar {
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 20;
}
.top-left { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.top-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.alert-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--bg-card);
}

.title-stack { min-width: 0; flex: 1; cursor: pointer; }
.title-row { display: flex; align-items: center; gap: 5px; }
.active-title {
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edit-pen { font-size: 11px; color: var(--text-muted); opacity: 0.7; }
.subtitle-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.host-badge, .status-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1.5px 7px;
  border-radius: 999px;
}
.host-badge { background: rgba(255, 255, 255, 0.07); color: var(--text-muted); }
.status-badge.idle { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); }
.status-badge.running { background: var(--green-soft); color: var(--green); }
.status-badge.waiting { background: var(--gold-soft); color: var(--gold); }

.quota-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.pulse-online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}
.pulse-online.warn { background: var(--gold); }

/* Attention Banner */
.attention-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.16), rgba(59, 130, 246, 0.12));
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.attention-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Chat Feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.chat-feed > * {
  flex-shrink: 0;
}

.welcome-empty {
  margin: auto;
  text-align: center;
  max-width: 420px;
  padding: 24px 14px;
}
.welcome-orb {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 10px 28px rgba(59, 130, 246, 0.3);
}
.welcome-empty h2 { margin: 0 0 8px; font-size: 18px; }
.welcome-empty p { margin: 0 0 18px; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.quick-starters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.quick-starters button {
  padding: 9px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Messages */
.msg-user {
  align-self: flex-end;
  max-width: 88%;
  background: var(--user-bubble);
  border: 1px solid var(--border-strong);
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  font-size: 14.5px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user-media {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.msg-user-img {
  max-width: 210px;
  max-height: 210px;
  border-radius: 11px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border-strong);
}
.msg-user-file-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  text-decoration: none;
}

.msg-thinking {
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 13px;
  overflow: hidden;
}
.msg-thinking summary {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 600;
  color: #c4b5fd;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
}
.msg-thinking summary::-webkit-details-marker { display: none; }
html[data-theme="light"] .msg-thinking summary { color: #6d28d9; }
.thinking-body {
  padding: 0 12px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}

.tools-cluster {
  flex-shrink: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
}
.tools-cluster summary {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
}
.tools-cluster summary::-webkit-details-marker { display: none; }
.chev {
  display: inline-block;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}
details[open] > summary .chev {
  transform: rotate(180deg);
}
.tools-list { padding: 4px 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.process-think-item {
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.22);
  padding: 8px 10px;
}
.process-think-lbl {
  font-size: 11px;
  font-weight: 700;
  color: #c4b5fd;
  margin-bottom: 4px;
}
html[data-theme="light"] .process-think-lbl { color: #6d28d9; }
.process-think-item .thinking-body {
  padding: 0;
  max-height: 220px;
  font-size: 12px;
}
.tool-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.4;
}
.tool-name {
  flex-shrink: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
}
html[data-theme="light"] .tool-name { color: #1d4ed8; }
.tool-sum { color: var(--text-muted); word-break: break-word; }

.msg-assistant {
  font-size: 14.5px;
  line-height: 1.56;
  color: var(--text);
  word-break: break-word;
}
.msg-assistant p { margin: 0 0 8px; }
.msg-assistant p:last-child { margin-bottom: 0; }
.msg-assistant ul, .msg-assistant ol { margin: 6px 0; padding-left: 20px; }
.msg-assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
}
.msg-assistant pre {
  background: #06080b;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12px;
}
.msg-assistant a { color: #60a5fa; text-decoration: underline; }

.msg-error {
  padding: 10px 13px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.13);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 13px;
}

/* Output Files Card (Collapsed to 1 line by default) */
.files-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
}
.files-card-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
}
.files-card-summary::-webkit-details-marker { display: none; }
.files-card-title-inline {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.files-card-toggle-hint::after {
  content: 'Mở ▾';
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}
.files-card[open] .files-card-toggle-hint::after {
  content: 'Thu gọn ▴';
}
.files-card .files-grid {
  padding: 8px 12px 11px;
  border-top: 1px solid var(--border);
}
.files-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  max-width: 100%;
}
.file-chip span.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.file-chip span.fsize { font-size: 10.5px; color: var(--text-muted); }

/* Pending Interaction Card (Ask Question / Permission) */
.interact-card {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14), rgba(24, 29, 37, 0.96));
  border: 1px solid rgba(245, 158, 11, 0.55);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.interact-hdr {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 10px;
}
.q-block { margin-bottom: 12px; }
.q-text { font-size: 13.5px; font-weight: 600; line-height: 1.42; margin-bottom: 8px; }
.q-options { display: flex; flex-direction: column; gap: 7px; }
.q-opt-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  line-height: 1.38;
  cursor: pointer;
}
.q-opt-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.q-writein {
  width: 100%;
  margin-top: 7px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.interact-submit-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-approve {
  flex: 1;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--gold);
  color: #111;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}
.btn-deny {
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* Composer Dock */
.composer-dock {
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
}
.att-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 9px;
  background: var(--accent-soft);
  font-size: 11.5px;
}
.att-thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}
.att-pill button { border: 0; background: transparent; color: var(--text); cursor: pointer; font-weight: 700; }

.composer-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}
.composer-controls select {
  flex: 1;
  min-width: 125px;
  height: 30px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
}
.mini-ctrl-btn {
  width: 34px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.mini-ctrl-btn.subscribed { border-color: var(--green); background: var(--green-soft); }

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 6px 8px;
}
.attach-btn {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
#promptInput {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  max-height: 140px;
  resize: none;
  outline: none;
  padding: 6px 2px;
  font-family: inherit;
}
.send-btn, .stop-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 0;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.send-btn { background: var(--accent); color: #fff; }
.stop-btn { background: var(--rose); color: #fff; }

/* Bottom Sheet Modal (4 PCs & Account Vault) */
.sheet-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-panel {
  width: 100%;
  max-width: 720px;
  max-height: 86dvh;
  background: var(--bg-elev);
  border-top: 1px solid var(--border-strong);
  border-radius: 24px 24px 0 0;
  padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-handle { width: 38px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 0 auto 10px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.sheet-header h3 { margin: 0; font-size: 16px; }
.sheet-header p { margin: 2px 0 0; font-size: 11.5px; color: var(--text-muted); }
.sheet-hdr-btns { display: flex; gap: 6px; align-items: center; }

.nodes-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 10px;
  padding-bottom: 8px;
}
.node-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.node-card.offline { opacity: 0.72; }
.node-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.node-name { font-size: 14px; font-weight: 700; }
.node-state { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.node-state.on { background: var(--green-soft); color: var(--green); }
.node-state.off { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
.node-acct-box {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 11px;
  padding: 8px 10px;
  font-size: 12px;
}
.quota-bars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.q-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--text);
}
.vault-list { display: flex; flex-direction: column; gap: 6px; }
.vault-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
}
.vault-row.current { border-color: var(--green); }
.mini-btn {
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.mini-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mini-btn.warn { background: var(--gold-soft); border-color: rgba(245, 158, 11, 0.4); color: var(--gold); }

.empty-muted { text-align: center; padding: 24px 12px; color: var(--text-muted); font-size: 13px; }
.toast-banner {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  background: #111827;
  color: #f9fafb;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}
