/* ==========================================================================
   AGIM STUDIO v3.0 — UNIFIED UI COMPONENTS, DOUBLE-BEZEL BOUNDARY CARDS & NAV
   Enforces Plus Jakarta Sans, 14px/10px Concentric G2 Radii, Universal 56px Bar,
   9-Dot Squircle App Switcher, Cmd+K Palette & 01A Pro <-> 01B Cartoon Bridge
   ========================================================================== */

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
  background-color: var(--bg-canvas, #F4F1EA) !important;
  color: var(--ink-body, #1E2924) !important;
  transition: background-color 0.18s ease, color 0.18s ease;
}

/* 1. SIGNATURE DOUBLE-BEZEL BOUNDARY CARD & SHARED BOX CONTAINERS */
.agim-boundary-card {
  background: var(--bg-card, #FAF8F3);
  border: 1.5px solid var(--border-color, #CFC8B8);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--card-shadow, 0 2px 8px rgba(22, 56, 44, 0.06));
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.agim-boundary-header {
  height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted, #5A6861);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.agim-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--active-app-accent, #2E7D32);
  margin-right: 7px;
}

.agim-boundary-well {
  background: var(--bg-well, #EFECE4);
  border-radius: 10px;
  border: 1px solid rgba(22, 56, 44, 0.08);
  padding: 20px;
}

html[data-skin="night"] .agim-boundary-well,
html[data-skin="pine-dark"] .agim-boundary-well,
html[data-skin="tactical"] .agim-boundary-well,
html[data-skin="sage-dusk"] .agim-boundary-well {
  border-color: rgba(244, 241, 234, 0.08);
}

/* 2. TWO-REGISTER BRIDGE: 01A PROFESSIONAL vs 01B CARTOON / ORIGINALS */
html[data-register="cartoon"] .agim-boundary-card,
html[data-register="cartoon"] .card,
html[data-register="cartoon"] .bento-card,
html[data-register="cartoon"] .panel,
html[data-register="cartoon"] .module-card,
html[data-register="cartoon"] .lesson-card,
html[data-register="cartoon"] .tier-card,
html[data-register="cartoon"] .stat-card {
  border: 2.5px solid #111111 !important;
  border-radius: 14px !important;
  box-shadow: 4px 4px 0px #16382C !important;
}

html[data-skin="night"][data-register="cartoon"] .agim-boundary-card,
html[data-skin="pine-dark"][data-register="cartoon"] .agim-boundary-card,
html[data-skin="night"][data-register="cartoon"] .card,
html[data-skin="pine-dark"][data-register="cartoon"] .card {
  border: 2.5px solid #F4F1EA !important;
  box-shadow: 4px 4px 0px #34D399 !important;
}

/* 3. UNIVERSAL 56PX STICKY ECOSYSTEM NAVBAR (#agim-v3-universal-bar) */
#agim-v3-universal-bar {
  position: sticky;
  top: 0;
  z-index: 9990;
  height: 56px;
  width: 100%;
  background: var(--bg-card, #FAF8F3);
  border-bottom: 1.5px solid var(--border-color, #CFC8B8);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  box-shadow: 0 2px 10px rgba(22, 56, 44, 0.06);
}

html[data-register="cartoon"] #agim-v3-universal-bar {
  border-bottom: 2.5px solid #111111;
}

.agim-v3-nav-left,
.agim-v3-nav-center,
.agim-v3-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#agim-v3-waffle-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1.5px solid var(--border-color, #CFC8B8);
  background: var(--bg-well, #EFECE4);
  display: grid;
  grid-template-columns: repeat(3, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 3px;
  place-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
#agim-v3-waffle-btn:hover {
  border-color: var(--ink-primary, #16382C);
  transform: scale(1.04);
}
.agim-v3-waffle-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-primary, #16382C);
}

.agim-v3-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink-primary, #16382C);
}

#agim-v3-logo-tile {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #16382C;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(244, 241, 234, 0.2);
  flex-shrink: 0;
}

.agim-v3-wordmark {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink-primary, #16382C);
}

#agim-v3-app-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(22, 56, 44, 0.10);
  color: var(--active-app-accent, #2E7D32);
  border: 1px solid var(--active-app-accent, #2E7D32);
  text-transform: lowercase;
}

#agim-v3-cmd-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  background: var(--bg-well, #EFECE4);
  border: 1.5px solid var(--border-color, #CFC8B8);
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--ink-muted, #5A6861);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
#agim-v3-cmd-btn:hover {
  border-color: var(--ink-primary, #16382C);
  color: var(--ink-primary, #16382C);
}

.agim-v3-kbd {
  background: var(--bg-card, #FAF8F3);
  border: 1px solid var(--border-color, #CFC8B8);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--ink-primary, #16382C);
}

.agim-v3-pill-group {
  display: flex;
  background: var(--bg-well, #EFECE4);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border-color, #CFC8B8);
  gap: 2px;
}

.agim-v3-seg-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted, #5A6861);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
}
.agim-v3-seg-btn.active {
  background: #16382C;
  color: #F4F1EA;
}
html[data-skin="night"] .agim-v3-seg-btn.active,
html[data-skin="pine-dark"] .agim-v3-seg-btn.active,
html[data-skin="tactical"] .agim-v3-seg-btn.active,
html[data-skin="sage-dusk"] .agim-v3-seg-btn.active {
  background: #F4F1EA;
  color: #16382C;
}

/* 4. 9-DOT WAFFLE APP SWITCHER POPOVER (#agim-v3-waffle-popover) */
#agim-v3-waffle-popover {
  position: fixed;
  top: 64px;
  left: 20px;
  z-index: 9995;
  width: 356px;
  background: var(--bg-card, #FAF8F3);
  border: 1.5px solid var(--ink-primary, #16382C);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 14px 36px rgba(10, 24, 18, 0.25);
  display: none;
}
#agim-v3-waffle-popover.open {
  display: block;
}
.agim-v3-waffle-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: var(--bg-well, #EFECE4);
  border-radius: 10px;
  padding: 12px;
}
.agim-v3-app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  padding: 6px 4px;
  border-radius: 8px;
  color: var(--ink-primary, #16382C);
  transition: background 0.1s ease, transform 0.1s ease;
}
.agim-v3-app-item:hover {
  background: rgba(22, 56, 44, 0.10);
  transform: translateY(-2px);
}
.agim-v3-app-item img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.agim-v3-app-item span {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

/* 5. CMD+K COMMAND PALETTE MODAL (#agim-v3-cmd-modal) */
#agim-v3-cmd-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(14, 26, 20, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
#agim-v3-cmd-backdrop.open {
  display: flex;
}
#agim-v3-cmd-modal {
  width: 92%;
  max-width: 560px;
  background: var(--bg-card, #FAF8F3);
  border: 2px solid var(--ink-primary, #16382C);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
#agim-v3-cmd-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-color, #CFC8B8);
  border-radius: 9px;
  background: var(--bg-well, #EFECE4);
  color: var(--ink-primary, #16382C);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  margin-bottom: 6px;
}
.agim-v3-cmd-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
}
.agim-v3-cmd-row {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: var(--ink-body, #1E2924);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.agim-v3-cmd-row:hover {
  background: #16382C;
  color: #F4F1EA;
}

@media (max-width: 860px) {
  .agim-v3-nav-center { display: none; }
  .agim-v3-wordmark { font-size: 15px; }
}
