/* ── Arcane palette ────────────────────────────────── */
:root {
  --bg-deep:     #080412;
  --bg-panel:    #110820;
  --bg-card:     #180d2e;
  --border:      #3b1a5c;
  --border-glow: #7c3aed;
  --text:        #c8b0e0;
  --text-dim:    #6b4a8a;
  --text-bright: #ede0ff;
  --green:       #00e87a;
  --green-dim:   #00704a;
  --amber:       #ffb800;
  --amber-dim:   #7a5800;
  --red:         #ff4455;
  --red-dim:     #7a1a22;
  --blue:        #ff7a2a;   /* orange replaces blue as the primary accent */
  --orange:      #ff7a2a;
  --purple:      #a855f7;
  --font:        'JetBrains Mono', 'Courier New', monospace;
  --header-h:    52px;

  /* ── Aliases for templates that use semantic names ── */
  --bg-primary:    var(--bg-deep);
  --bg-secondary:  var(--bg-panel);
  --bg-tertiary:   var(--bg-card);
  --text-primary:  var(--text-bright);
  --text-secondary: var(--text);
  --text-muted:    var(--text-dim);
  --accent:        var(--orange);
  --accent-dim:    #b35500;
  --success:       var(--green);
  --warning:       var(--amber);
  --danger:        var(--red);
  --info:          var(--purple);

  /* ── Radius & spacing tokens ── */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  /* ── Glass effect ── */
  --glass-bg:    rgba(17, 8, 32, 0.72);
  --glass-blur:  16px;
  --glass-border: rgba(124, 58, 237, 0.18);

  /* Bootstrap dark-mode overrides */
  --bs-body-bg:            var(--bg-deep);
  --bs-body-color:         var(--text);
  --bs-body-font-family:   var(--font);
  --bs-body-font-size:     13px;
  --bs-card-bg:            var(--bg-panel);
  --bs-card-border-color:  var(--border);
  --bs-card-cap-bg:        var(--bg-card);
  --bs-card-cap-color:     var(--text-dim);
  --bs-border-color:       var(--border);
  --bs-form-control-bg:    var(--bg-deep);
  --bs-form-control-color: var(--text-bright);
}

/* ── Reset & base ─────────────────────────────────── */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--bg-deep);
  background-image: url('/static/bg.svg');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  color: var(--text);
  font-size: 13px;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--purple); }
a:hover { color: var(--orange); }

/* Smooth page transitions */
.mc-main { animation: fadeUp 0.3s ease-out; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ─────────────────────────────────────── */
.mc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(17, 8, 32, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.mc-header-left { display: flex; align-items: baseline; gap: 0; }
.mc-header-right { display: flex; align-items: center; gap: 16px; }
.mc-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.15em;
  text-shadow: 0 0 18px rgba(168, 85, 247, 0.55), 0 0 40px rgba(168, 85, 247, 0.25);
  text-decoration: none;
}
.mc-title:hover { color: var(--text-bright); text-decoration: none; }
.mc-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  margin-left: 16px;
}
.mc-time {
  font-size: 14px;
  color: var(--orange);
  letter-spacing: 0.1em;
  text-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}
.mc-test-link {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 3px 8px;
  transition: border-color 0.15s, color 0.15s;
  touch-action: manipulation;
}
.mc-test-link:hover { border-color: var(--purple); color: var(--purple); }

/* ── Named link colors ───────────────────────────── */
.mc-link-thinking { color: #c084fc; }
.mc-link-bugs { color: #ff6b6b; }
.mc-link-grok { color: #00ff88; }

/* ── Desktop "More" dropdown ─────────────────────── */
.mc-nav-dropdown { position: relative; }
.mc-dropdown-toggle {
  background: none;
  cursor: pointer;
}
.mc-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: rgba(17, 8, 32, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 0;
  min-width: 160px;
  z-index: 150;
  max-height: 70vh;
  overflow-y: auto;
  flex-direction: column;
}
.mc-nav-dropdown:hover .mc-dropdown-menu,
.mc-nav-dropdown.open .mc-dropdown-menu {
  display: flex;
}
.mc-dropdown-menu .mc-test-link {
  display: block;
  padding: 6px 14px;
  border: none;
  border-radius: 0;
  white-space: nowrap;
}
.mc-dropdown-menu .mc-test-link:hover {
  background: rgba(124, 58, 237, 0.12);
}

/* ── Mobile section labels ───────────────────────── */
.mc-mobile-section-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  padding: 12px 20px 4px;
  text-transform: uppercase;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Hamburger (mobile only) ───────────────────── */
.mc-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  width: 44px;
  height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mc-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.mc-hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.mc-hamburger.open span:nth-child(2) { opacity: 0; }
.mc-hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ── Mobile slide-out menu ─────────────────────── */
.mc-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mc-mobile-overlay.open { display: block; opacity: 1; }

.mc-mobile-menu {
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100%;
  background: rgba(17, 8, 32, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding-top: max(12px, env(safe-area-inset-top));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mc-mobile-menu.open { right: 0; }

.mc-mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.mc-mobile-menu-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.2em;
}

.mc-mobile-link {
  display: block;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.12em;
  text-decoration: none;
  border-bottom: 1px solid rgba(59, 26, 92, 0.3);
  transition: background 0.15s, color 0.15s, padding-left 0.2s;
}
.mc-mobile-link:hover,
.mc-mobile-link.active {
  background: rgba(124, 58, 237, 0.1);
  color: var(--text-bright);
  padding-left: 28px;
}
.mc-mobile-link.active {
  border-left: 3px solid var(--orange);
  color: var(--orange);
}
.mc-mobile-menu-footer {
  margin-top: auto;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

/* ── Main layout ─────────────────────────────────── */
.mc-main {
  padding: 16px;
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}
.mc-content {
  height: 100%;
}
.mc-content > .row {
  height: 100%;
  flex-wrap: nowrap;
}

/* ── Sidebar ─────────────────────────────────────── */
.mc-sidebar {
  overflow-y: auto;
  min-height: 0;
  max-height: 100%;
}

/* ── Chat column ─────────────────────────────────── */
.mc-chat-panel {
  min-height: 0;
  max-height: 100%;
}
.mc-chat-panel > .card {
  height: 100%;
  min-height: 0;            /* flex child: allow shrink below content */
  margin-bottom: 0;         /* override Bootstrap .card margin that breaks flex sizing */
  overflow: hidden;
}

/* ── Panel / Card overrides ──────────────────────── */
.mc-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s ease;
}
.mc-panel:hover {
  border-color: rgba(124, 58, 237, 0.3);
}
.mc-panel-header {
  background: rgba(24, 10, 45, 0.90);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 8px 14px;
}

/* ── Agent Card ──────────────────────────────────── */
.mc-agent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: rgba(24, 10, 45, 0.82);
  transition: border-color 0.2s, transform 0.15s;
}
.mc-agent-card:active {
  transform: scale(0.98);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.status-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.status-dot.red   { background: var(--red);   box-shadow: 0 0 6px var(--red); }

.agent-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.1em;
}
.agent-meta { font-size: 11px; line-height: 2; }
.meta-key   { color: var(--text-dim); display: inline-block; width: 60px; }
.meta-val   { color: var(--text); }

/* ── Generic agent card (used by mobile, marketplace, swarm) ── */
.agent-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin-bottom: 10px;
  transition: border-color 0.2s, transform 0.15s;
}
.agent-card:active { transform: scale(0.98); }
.agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--purple), var(--orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}
.agent-info { flex: 1; min-width: 0; }
.agent-info .agent-name {
  font-size: 13px;
  margin-bottom: 2px;
}
.agent-info .agent-meta {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ── Health ──────────────────────────────────────── */
.health-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.health-row:last-child { border-bottom: none; }
.health-label { color: var(--text-dim); letter-spacing: 0.08em; }

/* Status badges */
.mc-badge-up    { background: var(--green-dim) !important; color: var(--green) !important; font-size: 10px; letter-spacing: 0.12em; border-radius: 2px; }
.mc-badge-down  { background: var(--red-dim)   !important; color: var(--red)   !important; font-size: 10px; letter-spacing: 0.12em; border-radius: 2px; }
.mc-badge-ready { background: var(--amber-dim) !important; color: var(--amber) !important; font-size: 10px; letter-spacing: 0.12em; border-radius: 2px; }

/* Generic badges (used across pages) */
.badge-success { background: var(--green-dim) !important; color: var(--green) !important; }
.badge-warning { background: var(--amber-dim) !important; color: var(--amber) !important; }
.badge-danger  { background: var(--red-dim)   !important; color: var(--red)   !important; }
.badge-secondary { background: rgba(59, 26, 92, 0.5) !important; color: var(--text-dim) !important; }
.badge-info    { background: rgba(168, 85, 247, 0.2) !important; color: var(--purple) !important; }

/* ── Chat ────────────────────────────────────────── */
.chat-log {
  flex: 1;
  min-height: 0;            /* allow flex child to shrink below content height */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-message { margin-bottom: 16px; }
.msg-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
  letter-spacing: 0.12em;
}
.chat-message.user      .msg-meta { color: var(--orange); }
.chat-message.agent     .msg-meta { color: var(--purple); }
.chat-message.error-msg .msg-meta { color: var(--red); }

.msg-body {
  background: rgba(24, 10, 45, 0.80);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-message.user      .msg-body { border-color: var(--border-glow); }
.chat-message.agent     .msg-body { border-left: 3px solid var(--purple); }
.chat-message.error-msg .msg-body { border-left: 3px solid var(--red); color: var(--red); }

/* ── Markdown rendering in agent chat ─────────────────── */
.agent-md { white-space: normal; }
.agent-md p { margin: 0 0 0.5em; }
.agent-md p:last-child { margin-bottom: 0; }
.agent-md pre {
  background: #0d0620;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  margin: 0.5em 0;
  white-space: pre;
}
.agent-md code {
  font-family: var(--font);
  font-size: 0.9em;
}
.agent-md :not(pre) > code {
  background: rgba(168, 85, 247, 0.15);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--text-bright);
}
.agent-md ul, .agent-md ol { padding-left: 1.5em; margin: 0.4em 0; }
.agent-md blockquote {
  border-left: 3px solid var(--purple);
  padding-left: 10px;
  color: var(--text-dim);
  margin: 0.5em 0;
}
.agent-md h1, .agent-md h2, .agent-md h3 {
  color: var(--text-bright);
  margin: 0.6em 0 0.3em;
  font-size: 1em;
  font-weight: 700;
}
.agent-md a { color: var(--purple); }

/* Mobile chat classes (used by mobile.html) */
.chat-container {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}
.chat-message .chat-meta {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.chat-message.user .chat-meta { color: var(--orange); }
.chat-message.agent .chat-meta { color: var(--purple); }
.chat-message.agent > div:last-child {
  color: var(--text);
  line-height: 1.6;
}

/* ── Chat input footer ───────────────────────────── */
.mc-chat-footer {
  padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(24, 10, 45, 0.90);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.mc-btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  touch-action: manipulation;
}
.mc-btn-clear:hover { border-color: var(--red); color: var(--red); }

/* Bootstrap form-control overrides */
.mc-input {
  background: rgba(8, 4, 18, 0.75) !important;
  border: 1px solid var(--border) !important;
  border-radius: 3px !important;
  color: var(--text-bright) !important;
  font-family: var(--font) !important;
  font-size: 13px !important;
}
.mc-input:focus {
  border-color: var(--border-glow) !important;
  box-shadow: 0 0 0 1px var(--border-glow), 0 0 10px rgba(124, 58, 237, 0.25) !important;
}
.mc-input::placeholder { color: var(--text-dim) !important; }

.mc-btn-send {
  background: var(--border-glow);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-bright);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 18px;
  letter-spacing: 0.12em;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
  touch-action: manipulation;
  white-space: nowrap;
}
.mc-btn-send:hover {
  background: var(--orange);
  color: #080412;
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.45);
}
.mc-btn-send:active { transform: scale(0.96); }

/* ── Buttons (generic) ──────────────────────────── */
.btn-primary {
  background: var(--border-glow) !important;
  border-color: var(--border-glow) !important;
  color: var(--text-bright) !important;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: background 0.15s, box-shadow 0.2s, transform 0.1s;
}
.btn-primary:hover {
  background: var(--purple) !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.4);
}
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: rgba(59, 26, 92, 0.3) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.btn-secondary:hover {
  background: rgba(59, 26, 92, 0.5) !important;
  border-color: var(--purple) !important;
}

/* ── Grid utilities (used across pages) ────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ── Stat cards ─────────────────────────────────── */
.stat {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-bright);
  font-family: var(--font);
  line-height: 1.2;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── Form elements ──────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: rgba(8, 4, 18, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-bright);
  font-family: var(--font);
  font-size: 13px;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--border-glow);
  box-shadow: 0 0 0 1px var(--border-glow), 0 0 10px rgba(124, 58, 237, 0.2);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-dim);
}
.form-group small {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── Card enhancements (Bootstrap cards in theme) ── */
.card {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-md) !important;
  margin-bottom: 16px;
}
.card-header {
  background: rgba(24, 10, 45, 0.90) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 14px 16px;
}
.card-title {
  color: var(--text-bright);
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 0.06em;
  margin-bottom: 0;
}
.card-body {
  padding: 16px;
}

/* ── HTMX Loading ────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; color: var(--amber); animation: blink 0.8s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-glow); }

/* ── Nav tabs (Bootstrap override) ───────────────── */
.nav-tabs {
  border-bottom-color: var(--border) !important;
}
.nav-tabs .nav-link {
  color: var(--text-dim) !important;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  border-color: transparent !important;
  padding: 8px 16px;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tabs .nav-link:hover {
  color: var(--text) !important;
  border-color: transparent transparent var(--border) !important;
}
.nav-tabs .nav-link.active {
  color: var(--orange) !important;
  background: transparent !important;
  border-color: var(--border) var(--border) var(--bg-deep) !important;
}


/* ════════════════════════════════════════════════════
   MOBILE  (max-width: 768px) — iPhone optimized
   ════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  :root { --header-h: 48px; }

  /* ── Header: hide desktop nav, show hamburger ── */
  .mc-header  {
    padding: 0 12px;
    padding-top: max(0px, env(safe-area-inset-top));
    height: var(--header-h);
    gap: 8px;
  }
  .mc-desktop-nav { display: none !important; }
  .mc-hamburger   { display: flex; }
  .mc-title   { font-size: 14px; letter-spacing: 0.1em; }
  .mc-subtitle { display: none; }

  /* ── Main layout becomes scrollable column stack ── */
  .mc-main {
    height: auto;
    overflow: visible;
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .mc-content, .mc-content > .row { height: auto; }

  /* ── Sidebar becomes a horizontal scroll strip ── */
  .mc-sidebar {
    flex-direction: row !important;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .mc-sidebar::-webkit-scrollbar { display: none; }
  .mc-sidebar .mc-panel {
    min-width: 220px;
    flex-shrink: 0;
  }

  /* ── Chat fills remaining space ── */
  .mc-chat-panel { min-height: 60dvh; }
  .mc-chat-panel > .card { height: 60dvh; }

  /* ── Tighter chat ── */
  .chat-log { padding: 10px !important; }
  .msg-body { padding: 8px 10px; font-size: 13px; }
  .chat-message { margin-bottom: 12px; }

  /* ── Touch-friendly inputs ── */
  .mc-chat-footer {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .mc-input {
    font-size: 16px !important;
    min-height: 44px;
    border-radius: var(--radius-md) !important;
  }
  .mc-btn-send {
    min-height: 44px;
    min-width: 64px;
    font-size: 12px;
    padding: 0 14px;
    border-radius: var(--radius-md);
  }
  .mc-btn-clear {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 10px;
    display: flex;
    align-items: center;
  }

  /* ── Agent cards ── */
  .mc-agent-card { padding: 10px; }

  /* ── Grids collapse ── */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.3rem; }

  /* ── Bootstrap columns stack ── */
  .col-md-3, .col-md-4, .col-md-6, .col-md-9 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .col-lg-4 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* ── Form elements ── */
  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px;
    min-height: 44px;
    border-radius: var(--radius-md);
  }

  /* ── Cards ── */
  .card {
    border-radius: var(--radius-md) !important;
    margin-bottom: 12px;
  }
  .card-header {
    padding: 12px 14px;
  }
  .card-title {
    font-size: 14px;
  }

  /* ── Tab nav scrollable ── */
  .nav-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link {
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 11px;
  }

  /* ── touch-button (used by mobile.html) ── */
  .touch-button {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.1s, box-shadow 0.2s;
  }
  .touch-button:active { transform: scale(0.96); }

  /* ── Display utilities ── */
  .display-6 { font-size: 1.2rem !important; }

  /* ── Container-fluid tight ── */
  .container-fluid { padding-left: 10px; padding-right: 10px; }
}


/* ════════════════════════════════════════════════════
   SMALL MOBILE (max-width: 390px) — iPhone SE / mini
   ════════════════════════════════════════════════════ */
@media (max-width: 390px) {
  .mc-title { font-size: 12px; }
  .mc-sidebar .mc-panel { min-width: 180px; }
  .mc-btn-send { min-width: 54px; padding: 0 10px; }
  .stat-value { font-size: 1.1rem; }
}
