/* ==========================================================================
 * COMMAND DASHBOARD — Desktop Split Layout
 * Unified Tier operating system for the desktop experience.
 *
 * ARCHITECTURE (absolute-positioning, no DOM restructuring):
 *   #main-content  (position:fixed; inset:0)  — unchanged
 *   ├── #command-dashboard   (position:absolute; left:0; width:320px)
 *   └── #synapse-main-view   (position:absolute; left:320px → right:0)
 *       #synapse-svg         (unchanged inside synapse-main-view)
 *
 * DESKTOP ONLY: activates at min-width 1024px.
 * Mobile gets the unchanged full-screen graph experience.
 * ========================================================================== */

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --cd-width: 420px; /* wider sidebar for better readability */
  --cd-bg: rgba(5, 7, 15, 0.78);
  --cd-border: rgba(0, 224, 255, 0.15);
  --cd-accent: #00e0ff;
  --cd-accent-dim: rgba(0, 224, 255, 0.25);
  --cd-text: #e0e8ff;
  --cd-text-dim: rgba(200, 210, 255, 0.55);
  --cd-section-gap: 1px;
  --cd-section-bg: rgba(10, 14, 39, 0.5);
  --cd-tier-active-bg: rgba(0, 224, 255, 0.18);
  --cd-tier-active-border: rgba(0, 224, 255, 0.6);
  --cd-tier-inactive-bg: rgba(255, 255, 255, 0.04);
  --cd-tier-inactive-border: rgba(255, 255, 255, 0.1);
  --cd-stat-bg: rgba(0, 224, 255, 0.05);
  --cd-stat-border: rgba(0, 224, 255, 0.12);
  --cd-insight-bg: rgba(0, 200, 140, 0.06);
  --cd-insight-border: rgba(0, 200, 140, 0.18);
  --cd-resource-hover: rgba(0, 224, 255, 0.08);
  --cd-scrollbar: rgba(0, 224, 255, 0.2);
}

/* ============================================================
   DESKTOP SPLIT LAYOUT (≥ 1024px)
   Pure absolute-positioning approach — no DOM restructuring.
   Dashboard is inserted as a sibling of #synapse-main-view
   inside the existing #main-content (position:fixed; inset:0).
   ============================================================ */
@media (min-width: 1024px) {

  /* ── LEFT: Command Dashboard ── */
  /* Positioned absolutely inside #main-content */
  #command-dashboard {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: var(--cd-width) !important;
    height: 100% !important;
    overflow: hidden !important;
    background: var(--cd-bg) !important;
    border-right: 1px solid var(--cd-border) !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 500 !important;
  }

  /* Scrollable inner area — fills remaining height between top and footer */
  #command-dashboard .cd-scroll-area {
    flex: 1;
    min-height: 0;        /* essential for flex child overflow to work */
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Custom scrollbar on the scroll area */
  #command-dashboard .cd-scroll-area::-webkit-scrollbar { width: 4px; }
  #command-dashboard .cd-scroll-area::-webkit-scrollbar-track { background: transparent; }
  #command-dashboard .cd-scroll-area::-webkit-scrollbar-thumb {
    background: var(--cd-scrollbar);
    border-radius: 4px;
  }

  /* ── RIGHT: Synapse graph — shift left edge past dashboard ── */
  /* #synapse-main-view normally has position:absolute; inset:0 */
  /* We override left so the graph only fills right portion */
  #synapse-main-view {
    left: var(--cd-width) !important;   /* 320px — right of dashboard */
  }

  /* ── Search container: center within graph area ── */
  /* Graph area: from var(--cd-width) to 100vw. Center = cd-width/2 + 50vw */
  /* Uses CSS var so it tracks panel width changes automatically.
     No !important so drag-start inline styles (left/transform) can override. */
  #centered-search-container {
    left: calc(50% + var(--cd-width) / 2);
    transform: translateX(-50%);
  }

  /* ── Node side panel: slides from right of viewport ── */
  /* Panel already uses position:fixed; right:-450px → right:0 */
  /* It naturally overlaps only the graph area (not the left dashboard) */
  #node-side-panel {
    z-index: 2000 !important;
  }
}

/* ============================================================
   MOBILE: Dashboard hidden by default; shown when .cd-mobile-panel
   is added (injected into the split-view bottom pane).
   ============================================================ */
@media (max-width: 1023px) {
  #command-dashboard:not(.cd-mobile-panel) {
    display: none !important;
  }

  /* ── Mobile split-view panel ─────────────────────────────── */
  #command-dashboard.cd-mobile-panel {
    display: flex !important;
    flex-direction: column;
    width: 100% !important;
    position: static !important;   /* no longer absolute inside main-content */
    height: auto !important;
    background: transparent !important;
    border-right: none !important;
    border-top: 1px solid rgba(0, 224, 255, 0.12);
    overflow: visible !important;  /* parent pane handles scroll */
    z-index: auto !important;
  }

  /* On mobile the scroll area should not clip — let parent scroll */
  #command-dashboard.cd-mobile-panel .cd-scroll-area {
    flex: none;
    min-height: unset;
    overflow: visible;
  }

  /* Compact header */
  #command-dashboard.cd-mobile-panel .cd-header {
    padding: 0.45rem 1rem 0.35rem;
    border-bottom: 1px solid rgba(0, 224, 255, 0.1);
    flex-shrink: 0;
  }
  #command-dashboard.cd-mobile-panel .cd-brand {
    font-size: 0.6rem;
    letter-spacing: 0.07em;
  }
  #command-dashboard.cd-mobile-panel .cd-brand-title {
    font-size: 0.9rem;
    margin-top: 0.1rem;
  }

  /* Tighter section padding */
  #command-dashboard.cd-mobile-panel .udc-section {
    padding: 0.55rem 0.75rem;
  }

  /* Tier buttons — full-width horizontal row */
  #command-dashboard.cd-mobile-panel .udc-tier-buttons {
    flex-direction: row;
    gap: 0.3rem;
  }
  #command-dashboard.cd-mobile-panel .udc-tier-btn {
    flex: 1;
    padding: 0.45rem 0.3rem;
    min-height: unset;
  }
  /* Hide "Tier 1 / Tier 2 / Tier 3" label; keep the name ("You / Extended / Ecosystem") */
  #command-dashboard.cd-mobile-panel .tier-label {
    display: none;
  }
  #command-dashboard.cd-mobile-panel .tier-name {
    font-size: 0.78rem;
  }
  #command-dashboard.cd-mobile-panel .udc-tier-desc {
    font-size: 0.75rem;
    margin: 0.2rem 0 0;
  }

  /* Stats — always 3 columns */
  #command-dashboard.cd-mobile-panel .udc-stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }
  #command-dashboard.cd-mobile-panel .udc-stat-card {
    padding: 0.5rem 0.25rem;
    gap: 0.15rem;
  }
  #command-dashboard.cd-mobile-panel .udc-stat-icon {
    font-size: 0.85rem;
  }
  #command-dashboard.cd-mobile-panel .udc-stat-value {
    font-size: 1rem;
  }
  #command-dashboard.cd-mobile-panel .udc-stat-label {
    font-size: 0.58rem;
  }

  /* Intelligence cards — horizontal scroll strip */
  #command-dashboard.cd-mobile-panel #udc-intelligence-cards {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.3rem;
  }
  #command-dashboard.cd-mobile-panel .udc-insight-card {
    flex: 0 0 220px;
    scroll-snap-align: start;
    min-width: 0;
  }

  /* Resource list — constrained height, scrollable */
  #command-dashboard.cd-mobile-panel #udc-resource-list {
    max-height: 140px;
    overflow-y: auto;
  }
  #command-dashboard.cd-mobile-panel .udc-resource-item {
    padding: 0.35rem 0.5rem;
  }
}

/* ============================================================
   COMMAND DASHBOARD PANEL STYLES
   ============================================================ */

/* ── Dashboard header ── */
.cd-header {
  padding: 1.1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--cd-border);
  background: rgba(0, 224, 255, 0.03);
  flex-shrink: 0;
}

.cd-brand {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cd-accent);
  opacity: 0.8;
  margin-bottom: 0.2rem;
}

.cd-brand-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cd-text);
  margin: 0;
  line-height: 1.2;
}

/* ── Section wrapper ── */
.udc-section {
  padding: 1rem;
  border-bottom: 1px solid var(--cd-border);
  flex-shrink: 0;
}

.udc-section:last-child {
  border-bottom: none;
  flex: 1; /* Resources section expands to fill remaining space */
}

.udc-section-header {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cd-text-dim);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============================================================
   TIER CONTROLLER
   ============================================================ */

#udc-tier-controller {
  background: rgba(0, 224, 255, 0.02);
}

.udc-tier-buttons {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.udc-tier-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem 0.25rem;
  background: var(--cd-tier-inactive-bg);
  border: 1px solid var(--cd-tier-inactive-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--cd-text-dim);
  font-family: inherit;
}

.udc-tier-btn:hover {
  background: rgba(0, 224, 255, 0.1);
  border-color: rgba(0, 224, 255, 0.35);
  color: var(--cd-text);
}

.udc-tier-btn.active {
  background: var(--cd-tier-active-bg);
  border-color: var(--cd-tier-active-border);
  color: var(--cd-accent);
  box-shadow: 0 0 12px rgba(0, 224, 255, 0.15);
}

.udc-tier-btn .tier-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.udc-tier-btn .tier-name {
  font-size: 0.75rem;
  font-weight: 600;
}

.udc-tier-btn.active .tier-label,
.udc-tier-btn.active .tier-name {
  opacity: 1;
}

.udc-tier-desc {
  font-size: 0.72rem;
  color: var(--cd-text-dim);
  line-height: 1.5;
  margin: 0;
  font-style: italic;
}

/* ============================================================
   ASSET SUMMARY (TIER-AWARE STATS)
   ============================================================ */

.udc-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.udc-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.65rem 0.4rem;
  background: var(--cd-stat-bg);
  border: 1px solid var(--cd-stat-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.udc-stat-card:hover {
  background: rgba(0, 224, 255, 0.1);
  border-color: var(--cd-accent-dim);
  transform: translateY(-1px);
}

.udc-stat-icon {
  font-size: 0.85rem;
  color: var(--cd-accent);
  opacity: 0.8;
}

.udc-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cd-text);
  line-height: 1;
}

.udc-stat-label {
  font-size: 0.6rem;
  color: var(--cd-text-dim);
  line-height: 1.3;
  text-align: center;
}

/* ============================================================
   INTELLIGENCE CARDS
   ============================================================ */

#udc-intelligence-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.udc-insight-card {
  padding: 0.7rem 0.75rem;
  background: var(--cd-insight-bg);
  border: 1px solid var(--cd-insight-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s;
}

.udc-insight-card:hover {
  border-color: rgba(0, 200, 140, 0.4);
}

.udc-insight-text {
  font-size: 0.75rem;
  color: var(--cd-text);
  line-height: 1.5;
  margin: 0;
}

.udc-insight-cta {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #00c88c;
  background: rgba(0, 200, 140, 0.1);
  border: 1px solid rgba(0, 200, 140, 0.25);
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.udc-insight-cta:hover {
  background: rgba(0, 200, 140, 0.2);
  border-color: rgba(0, 200, 140, 0.5);
  color: #00e89f;
}

/* Loading state */
.udc-insight-card.loading {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.06);
  animation: cdPulse 1.5s ease-in-out infinite;
}

@keyframes cdPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============================================================
   RESOURCE BUCKETS
   ============================================================ */

.udc-resource-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.udc-resource-tab {
  /* 3 per row on row-1, 2 per row on row-2 via flex-basis */
  flex: 1 1 28%;
  padding: 0.3rem 0.25rem;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--cd-tier-inactive-bg);
  border: 1px solid var(--cd-tier-inactive-border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--cd-text-dim);
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
  text-align: center;
}

.udc-resource-tab:hover {
  background: rgba(0, 224, 255, 0.07);
  border-color: rgba(0, 224, 255, 0.25);
  color: var(--cd-text);
}

.udc-resource-tab.active {
  background: rgba(0, 224, 255, 0.1);
  border-color: rgba(0, 224, 255, 0.4);
  color: var(--cd-accent);
}

.udc-resource-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cd-text-dim);
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

#udc-resource-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.udc-resource-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.udc-resource-item:hover {
  background: var(--cd-resource-hover);
  border-color: rgba(0, 224, 255, 0.2);
}

.udc-resource-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.udc-resource-name {
  font-size: 0.78rem;
  color: var(--cd-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.udc-resource-meta {
  font-size: 0.6rem;
  color: var(--cd-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.75;
  margin-top: 0.1rem;
}

.udc-resource-show-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  background: rgba(0, 224, 255, 0.06);
  border: 1px solid rgba(0, 224, 255, 0.15);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cd-accent);
  font-size: 0.7rem;
  transition: all 0.15s;
  font-family: inherit;
}

.udc-resource-show-btn:hover {
  background: rgba(0, 224, 255, 0.15);
  border-color: rgba(0, 224, 255, 0.4);
  transform: scale(1.08);
}

.udc-resource-empty {
  font-size: 0.72rem;
  color: var(--cd-text-dim);
  text-align: center;
  padding: 1rem 0;
  opacity: 0.6;
}


/* ============================================================
   TRANSITION ANIMATIONS
   ============================================================ */

@media (min-width: 1024px) {
  #command-dashboard {
    animation: cdSlideIn 0.35s ease-out;
  }

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

.udc-tier-btn {
  /* Prevent text selection on quick clicks */
  user-select: none;
}

/* ============================================================
   UTILITY: TIER TRANSITION STATE
   Briefly applied during tier transitions
   ============================================================ */

.udc-tier-transitioning .udc-stat-value,
.udc-tier-transitioning .udc-insight-text {
  opacity: 0.4;
  transition: opacity 0.2s;
}

/* ============================================================
   ADD RESOURCE BUTTON (in section header)
   ============================================================ */

.udc-resource-add-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: rgba(0, 224, 255, 0.07);
  border: 1px solid rgba(0, 224, 255, 0.18);
  border-radius: 4px;
  color: var(--cd-accent);
  font-size: 0.58rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: all 0.15s;
  user-select: none;
}

.udc-resource-add-btn:hover {
  background: rgba(0, 224, 255, 0.16);
  border-color: rgba(0, 224, 255, 0.4);
}

.udc-resource-add-btn.active {
  background: rgba(0, 224, 255, 0.18);
  border-color: rgba(0, 224, 255, 0.5);
  color: #fff;
  transform: rotate(45deg); /* × when open */
}

/* ============================================================
   INLINE ADD FORM (inside Your Resources section)
   ============================================================ */

.udc-add-form {
  background: rgba(0, 224, 255, 0.03);
  border: 1px solid rgba(0, 224, 255, 0.15);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  margin-bottom: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  animation: cdFadeIn 0.15s ease-out;
}

.udc-add-form.hidden {
  display: none;
}

@keyframes cdFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.udc-add-form-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cd-accent);
  opacity: 0.9;
}

.udc-add-form input,
.udc-add-form textarea,
.udc-add-form select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 224, 255, 0.18);
  border-radius: 5px;
  color: var(--cd-text);
  font-size: 0.72rem;
  padding: 0.38rem 0.55rem;
  font-family: inherit;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.udc-add-form input:focus,
.udc-add-form select:focus {
  border-color: rgba(0, 224, 255, 0.4);
}

.udc-add-form input::placeholder {
  color: rgba(200, 210, 255, 0.35);
}

.udc-add-form select option {
  background: #0a0e27;
  color: var(--cd-text);
}

.udc-add-form-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

.udc-add-form-submit {
  font-size: 0.65rem;
  padding: 0.32rem 0.7rem;
  background: rgba(0, 224, 255, 0.1);
  border: 1px solid rgba(0, 224, 255, 0.35);
  border-radius: 5px;
  color: var(--cd-accent);
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: all 0.15s;
}

.udc-add-form-submit:hover {
  background: rgba(0, 224, 255, 0.18);
  border-color: rgba(0, 224, 255, 0.6);
}

.udc-add-form-cancel {
  font-size: 0.65rem;
  padding: 0.32rem 0.65rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: var(--cd-text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.udc-add-form-cancel:hover {
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--cd-text);
}

.udc-add-form-hint {
  font-size: 0.68rem;
  color: var(--cd-text-dim);
  line-height: 1.4;
  padding: 0.2rem 0;
}

/* stub badge on resource items */
.udc-resource-stub-badge {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(200, 210, 255, 0.4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  flex-shrink: 0;
  margin-left: 0.3rem;
}

/* ============================================================
   UNIFIED DAILY COMMAND — NEW LAYER STYLES
   Identity · Network Status · Today's Focus · Explore · Deep Actions
   ============================================================ */

/* ── Layer 1: Identity ── */
.cd-identity {
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid var(--cd-border);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(0, 224, 255, 0.025);
  flex-shrink: 0;
}

/* ── Avatar — clickable button ── */
.cd-identity-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00e0ff, #0060cc);
  border: 2px solid rgba(0, 224, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cd-identity-avatar:hover {
  border-color: rgba(0, 224, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(0, 224, 255, 0.18);
}
.cd-identity-avatar:hover .cd-avatar-edit-hint {
  opacity: 1;
}

.cd-identity-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  position: absolute;
  inset: 0;
}

/* Pencil overlay shown on avatar hover */
.cd-avatar-edit-hint {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  font-size: 0.7rem;
  color: #fff;
}

/* ── Identity info ── */
.cd-identity-info {
  flex: 1;
  min-width: 0;
}

/* Name + action icons row */
.cd-identity-info-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.22rem;
}

.cd-identity-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--cd-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* ── Icon button base (admin + bell) ── */
.cd-identity-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.cd-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  padding: 0;
  color: inherit;
}

/* Admin — amber */
.cd-admin-btn {
  color: #ffa500;
  border-color: rgba(255, 165, 0, 0.3);
  background: rgba(255, 165, 0, 0.08);
}
.cd-admin-btn:hover {
  background: rgba(255, 165, 0, 0.2);
  border-color: rgba(255, 165, 0, 0.55);
}

/* Bell — cyan */
.cd-bell-btn {
  color: var(--cd-accent);
  border-color: rgba(0, 224, 255, 0.3);
  background: rgba(0, 224, 255, 0.06);
}
.cd-bell-btn:hover {
  background: rgba(0, 224, 255, 0.15);
  border-color: rgba(0, 224, 255, 0.5);
}

/* Unread badge on the bell */
.cd-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff3b30;
  color: #fff;
  font-size: 0.52rem;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* ── Panel footer — report button ── */
.cd-panel-footer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--cd-border);
  flex-shrink: 0;
}

.cd-report-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 224, 255, 0.2);
  background: rgba(0, 224, 255, 0.05);
  color: var(--cd-text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cd-report-btn:hover {
  background: rgba(0, 224, 255, 0.12);
  border-color: rgba(0, 224, 255, 0.4);
  color: var(--cd-accent);
}
.cd-report-btn i {
  font-size: 0.8rem;
}

.cd-identity-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.cd-level-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cd-accent);
  background: rgba(0, 224, 255, 0.12);
  border: 1px solid rgba(0, 224, 255, 0.25);
  border-radius: 4px;
  padding: 0.1rem 0.42rem;
  white-space: nowrap;
}

.cd-streak {
  font-size: 0.6rem;
  color: #ff8c42;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 600;
}

.cd-xp-bar-wrap {
  height: 3px;
  background: rgba(0, 224, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.cd-xp-bar {
  height: 100%;
  background: linear-gradient(90deg, #00e0ff, #0080ff);
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  min-width: 3px;
}

/* Profile completeness bar */
#cd-profile-completeness {
  margin-bottom: 0.3rem;
}

.cd-completeness-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: var(--cd-text-dim);
  margin-bottom: 0.25rem;
}

.cd-completeness-bar-wrap {
  height: 3px;
  background: rgba(0, 255, 136, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.cd-completeness-bar {
  height: 100%;
  background: linear-gradient(90deg, #00cc70, #00ff88);
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  min-width: 3px;
}

.cd-greeting {
  font-size: 0.67rem;
  color: var(--cd-text-dim);
  font-style: italic;
  line-height: 1.4;
}

/* ── Layer 2: Network Status ── */
.cd-network-status {
  padding: 0.55rem 1rem 0.6rem;
  border-bottom: 1px solid var(--cd-border);
  flex-shrink: 0;
}

.cd-section-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cd-text-dim);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cd-status-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}

.cd-status-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08rem;
  padding: 0.35rem 0.15rem;
  background: var(--cd-stat-bg);
  border: 1px solid var(--cd-stat-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.cd-status-pill:hover,
.cd-status-pill:focus-visible {
  background: rgba(0, 224, 255, 0.1);
  border-color: var(--cd-accent-dim);
  outline: none;
}

.cd-status-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cd-text);
  line-height: 1;
}

.cd-status-label {
  font-size: 0.5rem;
  color: var(--cd-text-dim);
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

/* ── Layer 3: Today's Focus ── */
.cd-focus {
  padding: 0.55rem 1rem 0.65rem;
  border-bottom: 1px solid var(--cd-border);
  flex-shrink: 0;
}

.cd-focus.cd-focus--collapsed .cd-focus-card {
  display: none;
}

.cd-focus-dismiss {
  background: none;
  border: none;
  color: var(--cd-text-dim);
  font-size: 0.6rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s, transform 0.25s;
  font-family: inherit;
}

.cd-focus-dismiss:hover {
  color: var(--cd-text);
}

.cd-focus--collapsed .cd-focus-dismiss i {
  transform: rotate(180deg);
}

.cd-focus-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  animation: focusCardIn 0.3s ease-out;
}

@keyframes focusCardIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Primary CTA block */
.cd-focus-primary {
  background: rgba(0, 255, 136, 0.055);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.cd-focus-primary-label {
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #00ff88;
  opacity: 0.8;
  margin-bottom: 0.28rem;
}

.cd-focus-primary-text {
  font-size: 0.78rem;
  color: var(--cd-text);
  line-height: 1.5;
  margin-bottom: 0.45rem;
}

.cd-focus-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #00ff88;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 5px;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  user-select: none;
}

.cd-focus-cta:hover {
  background: rgba(0, 255, 136, 0.18);
  border-color: rgba(0, 255, 136, 0.55);
}

/* Secondary signal items */
.cd-focus-secondary-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 224, 255, 0.04);
  border: 1px solid rgba(0, 224, 255, 0.1);
  border-radius: 6px;
  padding: 0.38rem 0.6rem;
  font-size: 0.7rem;
  color: var(--cd-text-dim);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  text-decoration: none;
}

.cd-focus-secondary-item:hover {
  background: rgba(0, 224, 255, 0.09);
  border-color: rgba(0, 224, 255, 0.25);
  color: var(--cd-text);
}

.cd-focus-secondary-icon {
  color: var(--cd-accent);
  font-size: 0.72rem;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

/* Messages alert (amber) */
.cd-focus-messages-alert {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 160, 0, 0.07);
  border: 1px solid rgba(255, 160, 0, 0.25);
  border-radius: 6px;
  padding: 0.38rem 0.6rem;
  font-size: 0.7rem;
  color: #ffa040;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  width: 100%;
  text-align: left;
  animation: focusCardIn 0.2s ease-out;
}

.cd-focus-messages-alert:hover {
  background: rgba(255, 160, 0, 0.14);
  border-color: rgba(255, 160, 0, 0.5);
}

/* Loading state */
.cd-focus-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  color: var(--cd-text-dim);
  font-size: 0.7rem;
}

.cd-focus-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cd-accent);
  animation: cdPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

/* ── Layer 4: Explore ── */
.cd-explore {
  padding: 0.55rem 1rem 0.5rem;
  flex: 1;
  border-bottom: 1px solid var(--cd-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cd-explore #udc-resource-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ── Deep Actions (collapsible) ── */
.cd-deep-actions {
  flex-shrink: 0;
}

.cd-deep-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  border-top: 1px solid var(--cd-border);
  color: var(--cd-text-dim);
  font-family: inherit;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
  text-align: left;
}

.cd-deep-toggle:hover {
  color: var(--cd-text);
}

.cd-deep-toggle i {
  transition: transform 0.25s ease;
}

.cd-deep-toggle[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.cd-deep-content {
  padding: 0 1rem 0.85rem;
  animation: cdFadeIn 0.2s ease-out;
  border-top: 1px solid rgba(0, 224, 255, 0.06);
}

/* ── Mobile adjustments for new layers ── */
@media (max-width: 1023px) {
  #command-dashboard.cd-mobile-panel .cd-identity {
    padding: 0.5rem 0.75rem 0.45rem;
    gap: 0.6rem;
  }
  #command-dashboard.cd-mobile-panel .cd-identity-avatar {
    width: 38px;
    height: 38px;
    font-size: 0.82rem;
  }
  #command-dashboard.cd-mobile-panel .cd-identity-name {
    font-size: 0.82rem;
  }
  #command-dashboard.cd-mobile-panel .cd-network-status {
    padding: 0.4rem 0.75rem 0.45rem;
  }
  #command-dashboard.cd-mobile-panel .cd-status-row {
    gap: 0.25rem;
  }
  #command-dashboard.cd-mobile-panel .cd-status-value {
    font-size: 0.9rem;
  }
  #command-dashboard.cd-mobile-panel .cd-focus {
    padding: 0.4rem 0.75rem 0.5rem;
  }
  #command-dashboard.cd-mobile-panel .cd-explore {
    padding: 0.4rem 0.75rem 0.4rem;
  }
  #command-dashboard.cd-mobile-panel #udc-resource-list {
    max-height: 120px;
    overflow-y: auto;
  }
  #command-dashboard.cd-mobile-panel .cd-deep-actions {
    display: none; /* hide tier toggle on mobile — graph gestures handle it */
  }
}

/* ============================================================
   ACCORDION: shared toggle-row + section-body patterns
   Used by Network Insights and Explore sections.
   ============================================================ */

.cd-section-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cd-section-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  border-top: 1px solid var(--cd-border);
  color: var(--cd-text-dim);
  font-family: inherit;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
  text-align: left;
}

.cd-section-toggle:hover {
  color: var(--cd-text);
}

.cd-section-toggle .cd-chevron {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.cd-section-toggle[aria-expanded="true"] .cd-chevron {
  transform: rotate(180deg);
}

.cd-section-body {
  padding: 0 1rem 0.85rem;
  animation: cdFadeIn 0.2s ease-out;
}

/* ── Messages-only focus strip ── */
.cd-focus {
  flex-shrink: 0;
}

.cd-focus .cd-focus-messages-alert {
  margin: 0 1rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 180, 0, 0.08);
  border: 1px solid rgba(255, 180, 0, 0.3);
  border-radius: 8px;
  font-size: 0.78rem;
  color: #ffd56b;
}

.cd-focus .cd-focus-messages-alert .cd-focus-cta {
  margin-left: auto;
  padding: 0.25rem 0.65rem;
  background: rgba(255, 180, 0, 0.15);
  border: 1px solid rgba(255, 180, 0, 0.35);
  border-radius: 6px;
  color: #ffd56b;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.cd-focus .cd-focus-messages-alert .cd-focus-cta:hover {
  background: rgba(255, 180, 0, 0.25);
}

/* ── Network Insights section ── */
.cd-insights {
  flex-shrink: 0;
}

.cd-insights .cd-section-body {
  padding-top: 0.5rem;
}

/* Insights primary card */
#cd-insights-primary .cd-focus-primary-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cd-accent);
  margin-bottom: 0.35rem;
}

#cd-insights-primary .cd-focus-primary-text {
  font-size: 0.82rem;
  color: var(--cd-text);
  line-height: 1.45;
  margin-bottom: 0.6rem;
}

/* Explore toggle-row: add-btn sits alongside the toggle */
.cd-explore .cd-section-toggle-row {
  padding-right: 0.75rem;
}

.cd-explore .udc-resource-add-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--cd-text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.3rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.cd-explore .udc-resource-add-btn:hover {
  color: var(--cd-accent);
  background: rgba(0, 224, 255, 0.08);
}

/* Explore body: resource tabs + list */
.cd-explore .cd-section-body {
  padding: 0 0.75rem 0.75rem;
}

/* Remove old static padding from explore when using new accordion */
.cd-explore > .udc-resource-tabs,
.cd-explore > #udc-resource-list,
.cd-explore > #udc-add-form {
  display: none; /* these are now inside .cd-section-body */
}

/* ============================================================
   PANEL COLLAPSE — desktop only
   Toggle tab sits on right edge of panel; panel slides off-screen.
   State controlled by body.panel-collapsed class (set by JS).
   ============================================================ */

/* Tab hidden on mobile */
#cd-panel-tab {
  display: none;
}

@media (min-width: 1024px) {
  /* Smooth transitions when collapsing / expanding */
  #command-dashboard {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #synapse-main-view {
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  #centered-search-container {
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  /* Toggle tab — pill attached to right edge of panel */
  #cd-panel-tab {
    display: flex;
    position: fixed;
    left: var(--cd-width);
    top: 50%;
    transform: translateY(-50%);
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 56px;
    background: var(--cd-bg);
    border: 1px solid var(--cd-border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    z-index: 600;
    cursor: pointer;
    color: var(--cd-text-dim);
    font-size: 0.75rem;
    padding: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.2s,
                border-color 0.2s,
                border-radius 0.3s;
  }
  #cd-panel-tab:hover {
    color: var(--cd-accent);
    border-color: var(--cd-accent);
  }

  /* ── Collapsed state ─────────────────────────────────────── */
  body.panel-collapsed #command-dashboard {
    transform: translateX(calc(-1 * var(--cd-width)));
  }
  body.panel-collapsed #synapse-main-view {
    left: 0 !important;
  }
  /* Tab flips to left wall when panel is hidden */
  body.panel-collapsed #cd-panel-tab {
    left: 0;
    border-left: 1px solid var(--cd-border);
    border-right: none;
    border-radius: 8px 0 0 8px;
  }
  /* Re-centre the search bar when panel is gone */
  body.panel-collapsed #centered-search-container {
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
}

/* ============================================================
   RESIZE HANDLE — drag to widen / narrow the panel (desktop)
   ============================================================ */
#cd-resize-handle {
  display: none; /* hidden on mobile */
}

@media (min-width: 1024px) {
  #cd-resize-handle {
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 20;
    background: transparent;
    transition: background 0.2s;
  }

  /* Grip indicator — short vertical bar that appears on hover/drag */
  #cd-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    border-radius: 2px;
    background: var(--cd-border);
    transition: background 0.2s, height 0.2s;
  }

  #cd-resize-handle:hover,
  #cd-resize-handle.dragging {
    background: rgba(0, 224, 255, 0.07);
  }
  #cd-resize-handle:hover::after,
  #cd-resize-handle.dragging::after {
    background: var(--cd-accent);
    height: 64px;
  }

  /* Hide handle when panel is collapsed */
  body.panel-collapsed #cd-resize-handle {
    display: none;
  }
}
