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

:root {
  --bg: #0a0a0f;
  --bg-raised: #111118;
  --surface: #16161f;
  --surface-hover: #1c1c28;
  --surface-active: #222230;
  --accent: #6c5ce7;
  --accent-light: #a78bfa;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.12);
  --cyan: #06b6d4;
  --text: #e4e4eb;
  --text-secondary: #9494a8;
  --text-muted: #5e5e72;
  --border: #1e1e2c;
  --border-light: #2a2a3c;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --sidebar-w: 220px;
  --topbar-h: 64px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* ─── Layout ─── */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ─── Sidebar ─── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition), opacity var(--transition);
  overflow: hidden;
}

.sidebar-collapsed #sidebar {
  width: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.3px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.sidebar-nav {
  flex: 1;
  padding: 4px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent-light); }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-pill svg { width: 14px; height: 14px; }

/* ─── Main ─── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Topbar ─── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-left h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

#sidebar-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

#sidebar-toggle:hover { background: var(--surface); color: var(--text); }
#sidebar-toggle svg { width: 18px; height: 18px; }

#btn-add {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  box-shadow: 0 2px 12px rgba(108, 92, 231, 0.25);
}

#btn-add:hover { background: #5b4bd4; box-shadow: 0 4px 20px rgba(108, 92, 231, 0.35); }
#btn-add svg { width: 16px; height: 16px; }

/* ─── Stats Row ─── */
#stats-row {
  display: flex;
  gap: 14px;
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  flex: 1;
  min-width: 0;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon-total { background: var(--accent-glow); color: var(--accent-light); }
.stat-icon-online { background: var(--green-dim); color: var(--green); }
.stat-icon-offline { background: var(--red-dim); color: var(--red); }

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2px;
}

/* ─── Bot Grid ─── */
#bot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  align-content: flex-start;
}

.bot-card {
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.bot-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.bot-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.bot-card:hover::before { opacity: 1; }

.bot-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-glow);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bot-avatar svg { width: 17px; height: 17px; }

.bot-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-online    { background: var(--green-dim); color: var(--green); }
.status-connecting { background: var(--orange-dim); color: var(--orange); }
.status-offline   { background: var(--red-dim); color: var(--red); }
.status-kicked    { background: var(--red-dim); color: var(--red); }
.status-error     { background: var(--red-dim); color: var(--red); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.bot-name {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.bot-server {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.bot-server svg { width: 11px; height: 11px; }

.bot-stats {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.bot-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.bot-stat svg { width: 12px; height: 12px; }
.bot-stat .heart-icon { color: var(--red); }
.bot-stat .food-icon { color: var(--orange); }

.bot-card-arrow {
  position: absolute;
  right: 16px;
  bottom: 16px;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: all var(--transition);
}

.bot-card-arrow svg { width: 16px; height: 16px; }
.bot-card:hover .bot-card-arrow { opacity: 1; transform: translateX(0); }

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

.empty-icon {
  width: 80px;
  height: 80px;
  color: var(--text-muted);
  margin-bottom: 20px;
  opacity: 0.4;
}

.empty-icon svg { width: 100%; height: 100%; }

#empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

#empty-state p {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 280px;
}

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

#modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 92%;
  max-width: 440px;
  animation: slideUp 0.2s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.modal-header svg {
  width: 24px;
  height: 24px;
  color: var(--accent-light);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-grow { flex: 1; }
.form-port { width: 110px; flex-shrink: 0; }

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group label svg { width: 14px; height: 14px; }

.form-group textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  resize: vertical;
  min-height: 60px;
}

.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea::placeholder { color: var(--text-muted); }

.form-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder { color: var(--text-muted); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn-cancel {
  flex: 1;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-cancel:hover { background: var(--surface-hover); color: var(--text); }

.btn-primary {
  flex: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover { background: #5b4bd4; }
.btn-primary svg { width: 16px; height: 16px; }

/* ─── Console Panel ─── */
#console-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

#console-panel.hidden { display: none; }

.console-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-raised);
}

.btn-back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-back:hover { background: var(--surface-hover); color: var(--text); }
.btn-back svg { width: 18px; height: 18px; }

.console-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.console-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-glow);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.console-avatar svg { width: 20px; height: 20px; }

#console-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-right: 8px;
}

#console-status {
  font-size: 0.65rem;
  vertical-align: middle;
}

.console-actions {
  display: flex;
  gap: 6px;
}

.console-actions button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.console-actions button svg { width: 18px; height: 18px; }

#btn-dc { color: var(--orange); }
#btn-dc:hover { background: var(--orange-dim); }
#btn-rm { color: var(--red); }
#btn-rm:hover { background: var(--red-dim); }

/* ─── Console Logs ─── */
#console-logs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
}

#console-logs::-webkit-scrollbar { width: 6px; }
#console-logs::-webkit-scrollbar-track { background: transparent; }
#console-logs::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.log-entry {
  padding: 3px 0;
  word-break: break-word;
  display: flex;
  gap: 10px;
}

.log-time {
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
  font-size: 0.75rem;
  min-width: 70px;
}

.log-msg { flex: 1; }

.log-chat .log-msg { color: #fff; }
.log-system .log-msg { color: var(--text-secondary); }
.log-info .log-msg { color: var(--cyan); }
.log-success .log-msg { color: var(--green); }
.log-warn .log-msg { color: var(--orange); }
.log-error .log-msg { color: var(--red); }

/* ─── Chat Input ─── */
#chat-form {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-raised);
}

.chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 4px 0 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 12px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}

#chat-input::placeholder { color: var(--text-muted); }

#chat-form button[type="submit"] {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
}

#chat-form button[type="submit"]:hover { background: #5b4bd4; }
#chat-form button[type="submit"] svg { width: 16px; height: 16px; }

/* ─── Inventory Panel (Bedrock Style) ─── */
#inv-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#inv-overlay.hidden { display: none; }

#inv-panel {
  background: #c6c6c6;
  border: 4px solid;
  border-color: #fff #555 #555 #fff;
  padding: 8px;
  max-width: 352px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  image-rendering: pixelated;
  box-shadow: 0 0 0 2px #000, 0 16px 48px rgba(0,0,0,0.7);
}

#inv-panel::-webkit-scrollbar { width: 6px; }
#inv-panel::-webkit-scrollbar-track { background: #c6c6c6; }
#inv-panel::-webkit-scrollbar-thumb { background: #888; border-radius: 0; }

.inv-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #404040;
  font-family: 'Inter', sans-serif;
}

.inv-section-header svg {
  width: 14px;
  height: 14px;
  color: #666;
}

.inv-close-btn {
  margin-left: auto;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #c6c6c6;
  border: 2px solid;
  border-color: #fff #555 #555 #fff;
  color: #404040;
  cursor: pointer;
  transition: background 0.1s;
}

.inv-close-btn:hover { background: #aaa; }
.inv-close-btn svg { width: 10px; height: 10px; }

/* Slot Grid */
.inv-grid {
  display: grid;
  gap: 2px;
}

.inv-grid-9 {
  grid-template-columns: repeat(9, 36px);
  justify-content: center;
}

#inv-container-slots {
  grid-template-columns: repeat(9, 36px);
  justify-content: center;
}

#inv-container {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 2px solid #aaa;
}

#inv-container.hidden { display: none; }

/* Armor Row */
.inv-armor-row {
  display: flex;
  gap: 2px;
  margin-bottom: 4px;
  justify-content: center;
}

.armor-slot { position: relative; }

.armor-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  color: #aaa;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

/* Individual Slot — Minecraft Bedrock style */
.inv-slot {
  width: 36px;
  height: 36px;
  background: #8b8b8b;
  border: 2px solid;
  border-color: #373737 #fff #fff #373737;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: none;
}

.inv-slot:hover {
  background: #aaa;
  outline: 2px solid #fff;
  outline-offset: -2px;
  z-index: 2;
}

.inv-slot.selected {
  background: #6a6aff;
  border-color: #3030aa #c0c0ff #c0c0ff #3030aa;
}

.inv-slot.drag-over {
  background: #6aaa6a;
}

/* Item inside slot */
.inv-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.inv-item-img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  pointer-events: none;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.3));
}

/* Fallback text when no texture */
.inv-item-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1;
  text-shadow: 1px 1px 0 #000;
  word-break: break-all;
  overflow: hidden;
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}

.inv-item-count {
  position: absolute;
  bottom: 0;
  right: 1px;
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f, 1px 1px 0 #3f3f3f;
  line-height: 1;
  z-index: 3;
  font-family: 'Inter', sans-serif;
}

/* Item name tooltip */
.inv-slot .inv-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #100010;
  border: 2px solid #2d0a5f;
  color: #fff;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 30;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  font-family: 'Inter', sans-serif;
}

.inv-slot:hover .inv-tooltip { display: block; }

/* Separator between main inv and hotbar */
.inv-separator {
  height: 6px;
  margin: 2px 0;
}

/* Drop Zone */
#inv-drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  padding: 8px;
  background: #8b8b8b;
  border: 2px solid;
  border-color: #373737 #fff #fff #373737;
  color: #404040;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

#inv-drop-zone svg { width: 16px; height: 16px; }

#inv-drop-zone:hover {
  background: #aa5555;
  color: #fff;
}

#inv-drop-zone.hidden { display: none; }

/* Inventory button in header */
#btn-inv { color: var(--accent-light); }
#btn-inv:hover { background: var(--accent-glow); }

/* Offhand slot */
.inv-offhand-row {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  justify-content: center;
  align-items: center;
}

.inv-offhand-label {
  font-size: 0.65rem;
  color: #666;
  font-weight: 600;
  margin-right: 4px;
}

/* ─── Topbar Actions ─── */
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  color: #fff;
}

.btn-action svg { width: 14px; height: 14px; }

.btn-green {
  background: var(--green);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}
.btn-green:hover { background: #1aaf54; }

.btn-red {
  background: var(--red);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}
.btn-red:hover { background: #dc3030; }

/* ─── Bot Card Actions ─── */
.bot-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.bot-card-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.bot-card-btn svg { width: 12px; height: 12px; }

.bot-card-btn.btn-start {
  background: var(--green-dim);
  color: var(--green);
}
.bot-card-btn.btn-start:hover {
  background: var(--green);
  color: #fff;
}

.bot-card-btn.btn-stop {
  background: var(--red-dim);
  color: var(--red);
}
.bot-card-btn.btn-stop:hover {
  background: var(--red);
  color: #fff;
}

/* ─── Console Start/QJ buttons ─── */
.btn-console-start { color: var(--green); }
.btn-console-start:hover { background: var(--green-dim); }

.btn-console-qj { color: var(--cyan); }
.btn-console-qj:hover { background: rgba(6, 182, 212, 0.12); }

/* ─── Scan Button ─── */
.btn-console-scan { color: var(--orange); }
.btn-console-scan:hover { background: var(--orange-dim); }

/* ─── Scan Panel ─── */
#scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 160;
  animation: fadeIn 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

#scan-overlay.hidden { display: none; }

#scan-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 92%;
  max-width: 400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}

.scan-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 600;
  flex-shrink: 0;
}

.scan-header svg {
  width: 18px;
  height: 18px;
  color: var(--orange);
  flex-shrink: 0;
}

.scan-header span {
  flex: 1;
}

.scan-rescan-btn,
.scan-close-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.scan-rescan-btn:hover { background: var(--surface-hover); color: var(--orange); }
.scan-close-btn:hover { background: var(--surface-hover); color: var(--red); }
.scan-rescan-btn svg,
.scan-close-btn svg { width: 14px; height: 14px; }

#scan-list {
  overflow-y: auto;
  max-height: 60vh;
  padding: 4px 0;
}

#scan-list::-webkit-scrollbar { width: 5px; }
#scan-list::-webkit-scrollbar-track { background: transparent; }
#scan-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.scan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.scan-item:last-child { border-bottom: none; }

.scan-item:hover { background: var(--surface-hover); }
.scan-item:active { background: var(--surface-active); }

.scan-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.scan-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text);
}

.scan-item-pos {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.scan-item-dist {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--orange);
  padding: 3px 8px;
  background: var(--orange-dim);
  border-radius: 12px;
  flex-shrink: 0;
}

.scan-loading,
.scan-empty {
  padding: 32px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.scan-loading {
  color: var(--orange);
}

/* ─── Player section hide ─── */
#inv-player-section.hidden { display: none; }

/* ─── Tablet ─── */
@media (max-width: 1024px) {
  #sidebar { display: none; }
  #sidebar-toggle { display: none; }
  .bot-card { width: calc(33.333% - 8px); }
  .topbar-actions .btn-action span { }
}

/* ─── Mobile ─── */
@media (max-width: 768px) {
  body { overflow: auto; }

  #app { flex-direction: column; height: auto; min-height: 100vh; }
  #sidebar { display: none; }
  #sidebar-toggle { display: none; }
  #main { overflow: auto; min-height: 100vh; }

  /* Topbar */
  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-left h2 { font-size: 1rem; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .btn-action { padding: 7px 10px; font-size: 0.75rem; }
  .btn-action svg { width: 12px; height: 12px; }
  #btn-add { padding: 7px 14px; font-size: 0.8rem; }

  /* Stats */
  #stats-row { padding: 12px 14px 0; gap: 8px; }
  .stat-card { padding: 10px 12px; gap: 8px; }
  .stat-icon { width: 32px; height: 32px; border-radius: 8px; }
  .stat-icon svg { width: 16px; height: 16px; }
  .stat-value { font-size: 1.1rem; }
  .stat-label { font-size: 0.68rem; }

  /* Bot grid */
  #bot-grid { padding: 12px 14px; gap: 8px; }
  .bot-card { width: calc(50% - 4px); padding: 12px; }
  .bot-card-header { margin-bottom: 8px; }
  .bot-avatar { width: 28px; height: 28px; border-radius: 6px; }
  .bot-avatar svg { width: 14px; height: 14px; }
  .bot-status { font-size: 0.6rem; padding: 3px 8px; }
  .bot-name { font-size: 0.82rem; }
  .bot-server { font-size: 0.68rem; }
  .bot-stats { gap: 8px; margin-top: 8px; padding-top: 8px; }
  .bot-stat { font-size: 0.68rem; }
  .bot-card-arrow { display: none; }
  .bot-card:hover { transform: none; }

  /* Console */
  #console-panel {
    position: fixed;
    inset: 0;
  }
  .console-header {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .console-title-group { min-width: 0; flex: 1; }
  #console-title { font-size: 0.85rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #console-status { font-size: 0.6rem; }
  .console-avatar { width: 30px; height: 30px; flex-shrink: 0; }
  .console-avatar svg { width: 16px; height: 16px; }
  .console-actions { gap: 4px; flex-shrink: 0; }
  .console-actions button { width: 32px; height: 32px; }
  .console-actions button svg { width: 15px; height: 15px; }
  .btn-back { width: 32px; height: 32px; flex-shrink: 0; }
  .btn-back svg { width: 16px; height: 16px; }
  #console-logs { padding: 10px 12px; font-size: 0.72rem; line-height: 1.6; }
  .log-time { font-size: 0.65rem; min-width: 58px; }
  #chat-form { padding: 10px 12px; }
  .chat-input-wrap { border-radius: var(--radius-sm); }
  #chat-input { padding: 10px 8px; font-size: 0.82rem; }
  #chat-form button[type="submit"] { width: 34px; height: 34px; }

  /* Modal */
  .modal { padding: 20px; width: 96%; max-width: none; }
  .modal-header { margin-bottom: 16px; }
  .modal-header h2 { font-size: 1rem; }
  .form-row { flex-direction: column; gap: 0; }
  .form-port { width: 100%; }
  .form-group input, .form-group select { padding: 10px 12px; font-size: 0.85rem; }
  .form-group textarea { font-size: 0.78rem; }
  .modal-actions { margin-top: 16px; }
  .btn-cancel, .btn-primary { padding: 10px; font-size: 0.85rem; }

  /* Scan */
  #scan-panel { max-width: none; width: 96%; }
  .scan-header { padding: 12px 14px; font-size: 0.82rem; }
  .scan-item { padding: 10px 14px; }
  .scan-item-name { font-size: 0.8rem; }

  /* Inventory */
  #inv-panel {
    padding: 6px;
    max-width: none;
    width: 100%;
    max-height: 95vh;
    border-width: 3px;
  }
  .inv-slot {
    width: 32px;
    height: 32px;
  }
  .inv-grid-9 { grid-template-columns: repeat(9, 32px); }
  #inv-container-slots { grid-template-columns: repeat(9, 32px); }
  .inv-item-img { width: 24px; height: 24px; }
  .inv-item-icon { width: 24px; height: 24px; font-size: 0.45rem; }
  .inv-item-count { font-size: 0.58rem; }
  .inv-section-header { font-size: 0.68rem; padding: 3px 2px 4px; }
  .inv-section-header svg { width: 12px; height: 12px; }
  .inv-close-btn { width: 20px; height: 20px; }
  .inv-close-btn svg { width: 8px; height: 8px; }
  .inv-offhand-label { font-size: 0.6rem; }
  #inv-drop-zone { padding: 6px; font-size: 0.65rem; }
  .inv-tooltip { font-size: 0.65rem; padding: 3px 6px; }
}

/* ─── Small phones ─── */
@media (max-width: 380px) {
  .topbar-left h2 { display: none; }
  .btn-action span { display: none; }
  .btn-action { padding: 8px; }
  #btn-add { padding: 8px 10px; font-size: 0.75rem; }
  .bot-card { width: 100%; }
  .stat-card { flex-direction: column; text-align: center; gap: 4px; padding: 8px; }
  #stats-row { gap: 6px; }
  .inv-slot { width: 28px; height: 28px; }
  .inv-grid-9 { grid-template-columns: repeat(9, 28px); }
  #inv-container-slots { grid-template-columns: repeat(9, 28px); }
  .inv-item-img { width: 20px; height: 20px; }
  .inv-item-icon { width: 20px; height: 20px; font-size: 0.4rem; }
  .inv-item-count { font-size: 0.5rem; }
}

/* ─── Landscape phones ─── */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { min-height: 48px; padding: 6px 12px; }
  #stats-row { padding: 8px 12px 0; }
  .stat-card { padding: 6px 10px; }
  .stat-icon { width: 28px; height: 28px; }
  .stat-value { font-size: 1rem; }
  #bot-grid { padding: 8px 12px; }
  .console-header { padding: 6px 10px; }
  #console-logs { padding: 8px 10px; }
  #chat-form { padding: 6px 10px; }
  #inv-panel { max-height: 98vh; }
}

/* ─── Touch improvements ─── */
@media (hover: none) and (pointer: coarse) {
  .bot-card:hover { transform: none; box-shadow: none; }
  .bot-card:hover::before { opacity: 0; }
  .bot-card:active { background: var(--surface-active); }
  .bot-card:active::before { opacity: 1; }
  .inv-slot:hover { outline: none; background: #8b8b8b; }
  .inv-slot:active { background: #aaa; outline: 2px solid #fff; outline-offset: -2px; }
  .bot-card-arrow { display: none; }
  .inv-slot .inv-tooltip { display: none !important; }
}

/* ─── Large screens ─── */
@media (min-width: 1400px) {
  .bot-card { width: 240px; }
  #console-logs { font-size: 0.85rem; }
  .stat-value { font-size: 1.6rem; }
}
