/* KRA Design System — Adapted from Munder Difflin tokens */
:root {
  /* Surfaces & Backgrounds */
  --cream-50:    #FFFDF5;
  --cream-100:   #FFF8E7;
  --cream-200:   #F4E9C7;
  --cream-300:   #E8D9A0;
  --paper-100:   #FCFAF0;
  --paper-200:   #F0EAD2;

  /* Ink & Borders */
  --ink-900:     #1A1320;
  --ink-700:     #3D2E4A;
  --ink-500:     #6B5878;
  --ink-300:     #A899B5;
  --ink-100:     #D9CFE0;

  /* Brand Accents */
  --maroon:      #6E1423;
  --gold:        #F4D35E;
  --coral:       #FF6B6B;
  --mint:        #6BCF7F;
  --sky:         #4ECDC4;
  --lemon:       #FFD93D;
  --lilac:       #B197FC;
  --peach:       #FFA07A;

  /* Office World Tiles */
  --floor-wood-light: #E5C896;
  --floor-wood-dark:  #C9A66B;
  --floor-exec-light: #9B5D34;
  --floor-exec-dark:  #753E1B;
  --wall-brown:       #593E2B;
  --rug-red:          #9E2A2B;
  --server-blue:      #2A3B4C;

  /* Fonts */
  --font-display: 'Press Start 2P', monospace;
  --font-ui:      'Pixelify Sans', cursive, sans-serif;
  --font-mono:    'VT323', monospace;
}

body.dark-mode {
  --cream-50: #17141D;
  --cream-100: #211D29;
  --cream-200: #2C2635;
  --cream-300: #3A3146;
  --paper-100: #19161F;
  --paper-200: #100E14;
  --ink-900: #F2EAF7;
  --ink-700: #D2C4DA;
  --ink-500: #A99BB2;
  --ink-300: #796B84;
  --ink-100: #4A3E55;
  --maroon: #FF8FAB;
}

body.dark-mode .chat-tab[data-channel="terminal"],
body.dark-mode .terminal-bar,
body.dark-mode .chat-context-bar {
  background-color: #0B090E;
}

body.dark-mode .kra-terminal-wrapper {
  background-color: #0B090E;
}

body.dark-mode .kra-input {
  color: var(--ink-900);
}

body.dark-mode .audit-target-bar .kra-input {
  background-color: var(--cream-200);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: none;
  text-rendering: pixelated;
}

html,
body {
  width: 100%;
  max-width: 100%;
}

body {
  background-color: var(--paper-200);
  color: var(--ink-900);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

input,
textarea,
select {
  user-select: text;
  -webkit-user-select: text;
}

#app-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
  gap: 12px;
  overflow: hidden;
}

#app-root > * {
  min-width: 0;
  max-width: 100%;
}

/* SNES 3-Layer Panel System */
.kra-panel {
  background-color: var(--cream-100);
  border: 2px solid var(--ink-900);
  box-shadow: 
    inset 0 0 0 2px var(--cream-200),
    inset 0 0 0 4px var(--ink-700),
    4px 4px 0 rgba(26, 19, 32, 0.3);
  position: relative;
}

/* Header Title Bar */
.kra-titlebar {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  align-items: center;
  background-color: var(--cream-100);
  border: 4px solid var(--ink-900);
  box-shadow: 
    inset 0 0 0 2px var(--cream-200),
    inset 0 0 0 4px var(--ink-700),
    0 6px 0 rgba(26, 19, 32, 0.2);
  padding: 10px 20px;
  image-rendering: pixelated;
}

.titlebar-left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
}

.brand-badge {
  background-color: var(--maroon);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 14px;
  padding: 6px 10px;
  border: 3px solid var(--ink-900);
  box-shadow: 3px 3px 0 var(--ink-700);
  letter-spacing: 1px;
}

.app-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--ink-900);
  letter-spacing: -0.5px;
  text-shadow: 2px 2px 0 var(--cream-200);
}

.floor-pill {
  background-color: var(--cream-200);
  color: var(--ink-700);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 4px 12px;
  border: 2px solid var(--ink-500);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.4);
}

.titlebar-right {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink-700);
  background: var(--cream-50);
  padding: 4px 10px;
  border: 1px solid var(--ink-100);
}

.pulse-dot {
  width: 12px;
  height: 12px;
  background-color: var(--mint);
  border: 2px solid var(--ink-900);
  box-shadow: 0 0 0 2px var(--mint);
  animation: pulse 0.8s infinite steps(2);
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

/* Buttons */
.kra-btn {
  font-family: var(--font-display);
  font-size: 9px;
  padding: 7px 10px;
  cursor: pointer;
  border: 3px solid var(--ink-900);
  box-shadow: 3px 3px 0 var(--ink-900);
  transition: transform 0.05s steps(1), background-color 0.05s steps(1);
  text-transform: uppercase;
}

.kra-btn:focus-visible,
.profile-header-btn:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 2px;
}

.icon-action {
  min-height: 38px;
  white-space: nowrap;
}

.icon-action .ui-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
  filter: drop-shadow(1px 1px 0 var(--cream-200));
}

/* Dropdown Menus */
.hud-dropdown {
  position: relative;
  display: inline-block;
}

.hud-drop-btn {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-caret {
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}

.hud-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  background-color: var(--cream-100);
  border: 3px solid var(--ink-900);
  box-shadow: 4px 4px 0 var(--ink-900);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1050;
  image-rendering: pixelated;
}

.hud-menu.hidden {
  display: none;
}

.hud-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-900);
  font-family: var(--font-display);
  font-size: 9px;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.hud-item:hover,
.hud-item:focus-visible {
  background: var(--cream-200);
  border-color: var(--ink-700);
  outline: none;
}

.hud-item .ui-icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
  flex-shrink: 0;
}

.hud-item-text {
  flex: 1 1 auto;
}

.hud-item-state {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-500);
}

.hud-divider {
  height: 2px;
  background: var(--ink-100);
  margin: 2px 0;
}

.hud-item-danger {
  color: var(--maroon);
}

.hud-item-danger:hover {
  background: #FFE5E5;
}

body.dark-mode .hud-menu {
  background-color: var(--cream-100);
}

body.dark-mode .hud-item-danger:hover {
  background: rgba(255, 107, 107, 0.2);
}

.kra-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.kra-btn-primary {
  background-color: var(--ink-900);
  color: var(--cream-50);
}

.kra-btn-primary:hover {
  background-color: var(--ink-700);
}

.kra-btn-secondary {
  background-color: var(--cream-100);
  color: var(--ink-900);
}

.kra-btn-secondary:hover {
  background-color: var(--cream-200);
}

.small-btn {
  font-family: var(--font-display);
  font-size: 8px;
  padding: 2px 6px;
  border: 1px solid var(--ink-900);
  background: var(--cream-200);
  cursor: pointer;
}

.floor-toggle-btn.active {
  background: #00F5D4;
  color: #071016;
  box-shadow: 0 0 6px rgba(0, 245, 212, 0.7);
}

/* Main Split View */
.kra-main-stage {
  display: grid;
  /* minmax(0,...) is essential: a plain 1fr track still has an automatic
     content minimum, so wide canvas/legend content could push the chat
     panel beyond the right edge of the viewport. */
  grid-template-columns: minmax(0, 1fr) clamp(328px, 28vw, 396px);
  gap: 12px;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Left column stacks office canvas + roster; chat panel runs full height. */
.kra-stage-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 12px;
}

.kra-stage-left .floor-viewport {
  flex: 1 1 auto;
}

.kra-stage-left .agent-strip {
  flex: 0 0 auto;
}

/* Floor Viewport */
.floor-viewport {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  background-color: var(--cream-100);
  min-height: 0;
  overflow: hidden;
}

.floor-viewport > * {
  min-width: 0;
  max-width: 100%;
}

.panel-header {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px 8px;
  border-bottom: 2px solid var(--ink-100);
}

.panel-title-wrapper {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.panel-heading {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--ink-900);
}

.audit-target-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 2px solid var(--ink-100);
}

.audit-target-bar label {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-700);
  white-space: nowrap;
  text-transform: uppercase;
}

.audit-target-bar .kra-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 2px solid var(--ink-900);
  background: var(--cream-50);
  color: var(--ink-900);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 5px 8px;
  box-shadow: inset 1px 1px 0 rgba(0,0,0,0.1);
}

.audit-target-bar .kra-input:focus {
  outline: 2px solid var(--sky);
  outline-offset: 1px;
}

.audit-target-bar .small-btn {
  font-size: 9px;
  padding: 5px 10px;
  border: 2px solid var(--ink-900);
  box-shadow: 2px 2px 0 var(--ink-900);
  background: var(--cream-200);
  font-family: var(--font-display);
  cursor: pointer;
  white-space: nowrap;
}

.audit-target-bar .small-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink-900);
}

#btn-browse-folder {
  background: var(--gold);
}

#btn-live-audit {
  background: var(--mint);
}

.decor-bar {
  margin: 4px 0;
  padding: 6px;
  border: 1px solid #00a896;
  background: linear-gradient(90deg, rgba(0, 245, 212, 0.12), rgba(177, 151, 252, 0.12));
  box-shadow: 0 0 8px rgba(0, 245, 212, 0.22);
}

.decor-bar.hidden { display: none; }
.decor-bar-header, .decor-items-row, .decor-actions { display: flex; align-items: center; gap: 6px; }
.decor-bar-header { justify-content: space-between; margin-bottom: 5px; }
.decor-bar-title { font: 8px var(--font-display); color: #00a896; }
.decor-items-row { flex-wrap: wrap; }
.decor-btn { font: 8px var(--font-display); padding: 3px 5px; border: 1px solid #536878; background: #111a24; color: #eef; cursor: pointer; }
.decor-btn.active { border-color: #00f5d4; color: #00f5d4; box-shadow: 0 0 5px rgba(0,245,212,.55); }
.decor-btn.decor-remove { color: #ff6b6b; }
#decor-officer-select { font: 8px var(--font-display); padding: 2px 4px; background: #0b141d; color: #00f5d4; border: 1px solid #00a896; cursor: pointer; }

/* Canvas fullscreen */
.floor-viewport.canvas-fullscreen {
  position: fixed !important;
  inset: 0;
  z-index: 9999;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0;
  border: none;
  margin: 0;
}
.floor-viewport.canvas-fullscreen .canvas-container {
  height: 100%;
  max-width: 100%;
}
#btn-canvas-fullscreen {
  min-width: 26px;
  font-size: 14px;
}

.canvas-container {
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  position: relative;
  /* Dark picture-frame mat, matching the reference floor-plan framing:
     any contain-fit margin reads as frame, not as a black void. */
  background:
    radial-gradient(ellipse at 50% 42%, #221C26 0%, #14101A 58%, #0B0810 100%);
  border: 2px solid var(--ink-900);
  box-shadow:
    inset 0 0 0 2px #2E2633,
    inset 0 0 34px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  image-rendering: pixelated;
}

#office-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  /* Camera owns the display dimensions (contain-fit of the 1280x448 world). */
  max-width: none;
  max-height: none;
  flex: 0 0 auto;
  object-fit: cover;
  box-shadow:
    0 0 0 2px #0E0A08,
    0 0 0 4px #4A3826,
    0 10px 32px rgba(0, 0, 0, 0.65);
}

.floor-legend {
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 16px;
  padding: 6px 6px 0;
  font-size: 12px;
  white-space: nowrap;
  color: var(--ink-700);
}

.floor-legend::-webkit-scrollbar { display: none; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink-900);
  display: inline-block;
}

.legend-boss { background-color: var(--floor-exec-light); }
.legend-bullpen { background-color: var(--floor-wood-light); }
.legend-server { background-color: var(--server-blue); }
.legend-break { background-color: #7fa988; }

/* Speech Bubble on Canvas */
.speech-bubble {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--cream-50);
  border: 2px solid var(--ink-900);
  padding: 8px 12px;
  box-shadow: 3px 3px 0 var(--ink-900);
  max-width: min(240px, calc(100% - 24px));
  z-index: 10;
  pointer-events: none;
  font-size: 14px;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 20px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--ink-900);
}

.speech-bubble.hidden {
  display: none;
}

#speech-sender {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--maroon);
  display: block;
  margin-bottom: 2px;
}

/* Sidebar & Terminal */
.command-sidebar {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  gap: 6px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

/* Keep the command composer anchored inside short desktop viewports. */
.command-sidebar > * {
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}
.command-sidebar .kra-terminal-wrapper { flex: 1 1 auto; min-height: 0; }
.command-sidebar .quick-actions-bar { max-height: 36px; }
.command-sidebar .command-input-container { flex: 0 0 48px; min-height: 48px; }

.kra-badge {
  font-family: var(--font-display);
  font-size: 8px;
  padding: 2px 6px;
  border: 1px solid var(--ink-900);
}

.badge-active {
  background-color: var(--gold);
  color: var(--ink-900);
}

/* Boss Dossier Header Box */
.boss-briefing-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: var(--cream-200);
  border: 1px solid var(--ink-700);
  flex-shrink: 0;
  max-height: 42px;
  overflow: hidden;
}

/* Autonomy Budget Meter Bar (Phase 3) */
.budget-meter-container {
  display: flex;
  flex-direction: column;
  background: #0d1117;
  border: 1px solid var(--ink-700);
  border-radius: 2px;
  padding: 3px 6px;
  gap: 2px;
  flex-shrink: 0;
}

.budget-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.budget-label {
  font-family: var(--font-display);
  font-size: 8px;
  color: #00F5D4;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.meter-track {
  display: flex;
  flex: 1;
  gap: 3px;
  background: #161b22;
  padding: 2px;
  border-radius: 2px;
  border: 1px solid #30363d;
}

.meter-seg {
  flex: 1;
  background: #21262d;
  color: #8b949e;
  text-align: center;
  font-size: 9px;
  line-height: 14px;
  border-radius: 2px;
  transition: all 0.2s ease;
  overflow: hidden;
  white-space: nowrap;
}

.meter-seg.active {
  background: rgba(0, 245, 212, 0.18);
  color: #00F5D4;
  border: 1px solid #00F5D4;
  font-weight: bold;
}

.meter-seg.warning {
  background: rgba(255, 179, 0, 0.2);
  color: #ffb300;
  border: 1px solid #ffb300;
}

.meter-seg.exhausted {
  background: rgba(255, 68, 68, 0.25);
  color: #ff4444;
  border: 1px solid #ff4444;
}

.budget-stop {
  font-size: 8px;
  font-family: var(--font-display);
  padding: 1px 4px;
  border-radius: 2px;
  background: #21262d;
  color: #8b949e;
  border: 1px solid #30363d;
  text-transform: uppercase;
  flex-shrink: 0;
}

.budget-stop.active {
  background: rgba(0, 245, 212, 0.15);
  color: #00F5D4;
  border-color: #00F5D4;
}

.budget-stop.alert {
  background: rgba(255, 68, 68, 0.2);
  color: #ff4444;
  border-color: #ff4444;
}

.boss-portrait-frame {
  width: 32px;
  height: 32px;
  background: var(--cream-50);
  border: 1.5px solid var(--ink-900);
  display: flex;
  justify-content: center;
  align-items: center;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.boss-meta {
  flex: 1;
  min-width: 0;
}

.boss-name {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--maroon);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.boss-title {
  font-size: 11px;
  color: var(--ink-700);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.boss-quote {
  font-style: italic;
  font-size: 10px;
  color: var(--ink-500);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

/* Team and Agent Conversation Tabs */
.chat-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  gap: 4px;
  padding: 2px 0;
  width: 100%;
  flex-shrink: 0;
}
.chat-tabs:active { cursor: grabbing; }
.chat-tabs::-webkit-scrollbar { display: none; }

.chat-tab {
  flex: 0 0 auto;
  min-width: 60px;
  max-width: 120px;
  min-height: 28px;
  height: 28px;
  border: 1.5px solid var(--ink-900);
  background: var(--cream-200);
  color: var(--ink-900);
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: 8px;
  line-height: 1.1;
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--ink-900);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
  text-overflow: ellipsis;
  overflow: hidden;
}

.hired-chat-tab {
  border-style: dashed;
}

.chat-tab[data-channel="terminal"] {
  background: #241A12;
  color: var(--gold);
}

.chat-tab:hover {
  background: var(--paper-200);
}

.chat-tab.active {
  background: var(--gold);
  color: var(--ink-900);
  font-weight: bold;
}

.chat-tab:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 1px;
}

.chat-context-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 6px;
  background: var(--ink-900);
  color: var(--cream-50);
  font-family: var(--font-display);
  font-size: 8px;
}

.chat-live-status { color: var(--mint); }
.chat-live-status.offline { color: var(--coral); }

.exec-status-badge {
  font-family: var(--mono, monospace);
  font-size: 11px;
  color: var(--mint);
  min-width: 120px;
  text-align: right;
}
.exec-status-badge.offline { color: var(--coral); }

.chat-expand-btn {
  margin-left: 6px;
  padding: 3px 6px;
  border: 1px solid var(--gold);
  background: var(--ink-900);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 8px;
  cursor: pointer;
}

.chat-expand-btn:hover { background: var(--maroon); }

body.chat-fullscreen .command-sidebar {
  position: fixed;
  inset: 10px;
  z-index: 1000;
  height: auto;
  padding: 14px;
  background: var(--cream-100);
  box-shadow: 8px 8px 0 rgba(26, 19, 32, .45);
}

body.chat-fullscreen .command-sidebar .boss-briefing-box { max-height: 86px; }
body.chat-fullscreen .command-sidebar .kra-terminal-wrapper { min-height: 0; }
body.chat-fullscreen .command-sidebar .terminal-body { font-size: 22px; line-height: 1.4; }
body.chat-fullscreen .command-sidebar .chat-bubble { font-size: 20px; padding: 10px 12px; }
body.chat-fullscreen .chat-expand-btn { font-size: 9px; }
body.chat-fullscreen #btn-chat-fullscreen { display: none !important; }
body:not(.chat-fullscreen) #btn-chat-close-fullscreen { display: none !important; }

body.chat-fullscreen::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(10, 8, 14, .72);
}

/* Terminal Viewport */
.kra-terminal-wrapper {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  background-color: var(--paper-100);
  border: 2px solid var(--ink-900);
  box-shadow: inset 0 0 0 1px var(--ink-500);
  overflow: hidden;
}

.terminal-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  background-color: var(--ink-900);
  color: var(--cream-50);
  font-family: var(--font-mono);
  font-size: 14px;
}

.terminal-clear {
  cursor: pointer;
  color: var(--gold);
}

.terminal-clear:hover {
  text-decoration: underline;
}

.terminal-body {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: #121015;
  color: #d1cbdb;
}

/* Chat output (WAG-style): overrides mono font for readable bubbles */
.chat-output {
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 15px;
  padding: 12px 10px;
  gap: 8px;
  background-color: #0d1117;
}

.term-line,
.chat-bubble {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.term-line.sys { color: var(--gold); }
.term-line.info { color: var(--sky); }
.term-line.boss { color: #ff8fab; font-weight: bold; }
.term-line.prompt { color: var(--mint); }
.term-line.warn { color: var(--coral); }
.term-line.user { color: #ffffff; }

/* WhatsApp-style Team and private-agent conversation view. */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 88%;
}

.chat-message-agent {
  align-self: flex-start;
}

.chat-message-user {
  align-self: flex-end;
  margin-left: auto;
}

.chat-message-agent .chat-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.chat-message-user .chat-row {
  display: flex;
  justify-content: flex-end;
}

.chat-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  border: none;
  box-shadow: none;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 80px;
  max-width: 100%;
  padding: 8px 10px 6px;
  border: 1px solid #2a2e35;
  border-radius: 2px 10px 10px 10px;
  background: #1c1f24;
  color: #e8e8e8;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.2);
}

.chat-message-user .chat-bubble {
  border-radius: 10px 2px 10px 10px;
  background: #005c4b; /* WhatsApp dark mode user bubble */
  color: #e9edef;
  border-color: #005c4b;
}

.chat-sender {
  display: inline-block;
  color: var(--agent-accent, #00F5D4);
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.chat-message-user .chat-sender {
  display: none;
}

.chat-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-time {
  align-self: flex-end;
  margin-top: 4px;
  color: #6a6a6a;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.chat-message-user .chat-time {
  color: #8696a0;
}

/* --- User Profile & Header --- */
.profile-header-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 3px 10px 3px 5px !important;
  background: var(--ink-900) !important;
  border: 3px solid var(--ink-900) !important;
  box-shadow: 3px 3px 0 var(--ink-700) !important;
  text-align: left;
}

.profile-header-btn:hover {
  background: var(--ink-700) !important;
}

.profile-header-btn .user-header-avatar {
  image-rendering: pixelated;
  box-shadow: 2px 2px 0 var(--coral);
}

.user-header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--ink-900);
}

.profile-header-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.profile-header-name {
  font-family: var(--font-display);
  font-size: 8px;
  color: #F1F5F9;
}

.profile-header-status {
  font-family: var(--font-mono);
  font-size: 8px;
  color: #00F5D4;
}

.profile-card {
  max-width: 520px;
}

.profile-modal-body {
  padding: 16px !important;
}

.profile-preview-section {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 12px;
}

.large-avatar {
  width: 64px !important;
  height: 64px !important;
  flex: 0 0 64px;
  border-radius: 8px !important;
  border: 2px solid var(--ink-900) !important;
}

.profile-main-inputs {
  flex: 1;
}

.profile-avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
  border: 1px solid var(--ink-700);
}

.profile-avatar-grid .char-card {
  padding: 6px;
  font-size: 8px;
}

.profile-avatar-grid .char-avatar {
  width: 24px;
  height: 24px;
}

/* Agent accent colors */
.chat-message-agent[data-agent="rama"]   { --agent-accent: #ff8fab; }
.chat-message-agent[data-agent="budi"]   { --agent-accent: #4ECDC4; }
.chat-message-agent[data-agent="maya"]   { --agent-accent: #FF6B6B; }
.chat-message-agent[data-agent="dimas"]  { --agent-accent: #B197FC; }
.chat-message-agent[data-agent="siti"]   { --agent-accent: #6BCF7F; }
.chat-message-agent[data-agent="jarvis"] { --agent-accent: #4ECDC4; }

/* thinking line removed per user request; keep class for potential future use */
.chat-thinking { display: none; }

.react-card {
  align-self: stretch;
  margin: 3px 8px;
  padding: 6px 8px;
  border-left: 3px solid var(--ink-900);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: pointer;
  user-select: none;
  transition: max-height 0.2s ease, opacity 0.2s ease;
}

.react-card.collapsed {
  max-height: 24px;
  overflow: hidden;
  opacity: 0.75;
}

/* Handoff Packet Structured Card (Phase 3) */
.handoff-packet-card {
  align-self: stretch;
  margin: 6px 8px;
  background: #1e152a;
  border: 1.5px solid #a855f7;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  font-family: var(--font-mono);
  font-size: 11px;
}

.packet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2e1065;
  padding: 4px 8px;
  border-bottom: 1px solid #7e22ce;
}

.packet-tag {
  font-family: var(--font-display);
  font-size: 8px;
  color: #d8b4fe;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.packet-route {
  color: #38bdf8;
  font-weight: bold;
}

.packet-body {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #e2e8f0;
}

.packet-field strong {
  color: #c084fc;
}

.packet-findings {
  margin-top: 2px;
  background: rgba(0,0,0,0.25);
  padding: 4px;
  border-radius: 2px;
}

.packet-findings ul {
  margin: 2px 0 0 14px;
  padding: 0;
  color: #cbd5e1;
}

.packet-budget {
  margin-top: 4px;
  font-size: 9px;
  color: #34d399;
  border-top: 1px dashed rgba(255,255,255,0.1);
  padding-top: 3px;
}

.react-thought { background: #E4E7EC; border-left-color: #667085; color: #344054; }
.react-action { background: #D9EEFF; border-left-color: #1570EF; color: #004E99; }
.react-observation { background: #FFF1CC; border-left-color: #DC8B00; color: #7A4B00; }
.react-handoff { background: #F3E8FF; border-left-color: #9333EA; color: #581C87; }
.react-budget { background: #ECFDF5; border-left-color: #059669; color: #064E3B; font-weight: bold; }
body.dark-mode .react-thought { background: #344054; color: #F2F4F7; }
body.dark-mode .react-action { background: #123A5B; color: #D9EEFF; }
body.dark-mode .react-observation { background: #5B410F; color: #FFF1CC; }
body.dark-mode .react-handoff { background: #3B1D54; color: #F3E8FF; }
body.dark-mode .react-budget { background: #064E3B; color: #ECFDF5; }

body.dark-mode .chat-bubble {
  background: var(--cream-200);
}

body.dark-mode .chat-message-user .chat-bubble {
  background: #275E51;
  color: #F2FFF8;
}

/* Quick Actions */
.skills-card {
  max-width: 900px;
  width: 90vw;
}

.skills-hub-content {
  max-height: 65vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}

.skills-agent-card {
  border: 1px solid var(--ink-100);
  padding: 12px;
  background: var(--paper-100);
  border-radius: 4px;
  max-height: 55vh;
  overflow-y: auto;
}

.skills-agent-card h4 {
  margin: 0 0 8px;
  color: var(--maroon);
  position: sticky;
  top: 0;
  background: var(--paper-100);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ink-100);
  z-index: 2;
}

.skills-agent-card h4 {
  margin: 0 0 8px;
  color: var(--maroon);
}

.skills-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  font-size: 0.9rem;
}

.skills-row small { color: var(--ink-500); }

.quick-actions-bar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  gap: 6px;
  flex: 0 0 auto;
  max-height: 32px;
  padding: 2px 0;
}
.quick-actions-bar:active { cursor: grabbing; }
.quick-actions-bar::-webkit-scrollbar { display: none; }

.action-chip {
  flex: 0 0 auto;
  min-height: 28px;
  background: var(--cream-200);
  border: 1.5px solid var(--ink-900);
  padding: 4px 10px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--ink-900);
  white-space: nowrap;
}

.action-chip:hover {
  background: var(--gold);
}

.action-chip:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

/* Command Input Bar */
.command-input-container {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 42px;
  min-height: 42px;
  background: #0D1117;
  border: 2px solid var(--ink-900);
  border-radius: 4px;
  padding: 3px 6px;
  gap: 6px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
  flex-shrink: 0;
}

.command-input-container:focus-within {
  border-color: #00F5D4;
  box-shadow: 0 0 8px rgba(0, 245, 212, 0.35), inset 0 1px 3px rgba(0,0,0,0.6);
}

.input-prefix {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: bold;
  color: #00F5D4;
  padding-left: 4px;
}

.kra-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-900);
  outline: none;
}

body.dark-mode .kra-input {
  color: #F1F5F9;
}

/* Command console bar always has dark background (#0D1117) in both themes */
.command-input-container .kra-input {
  color: #F1F5F9;
  caret-color: #00F5D4;
}

.command-input-container .kra-input::placeholder {
  color: #8B949E;
}

/* --- Slash command autocomplete --- */
.cmd-suggest {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 40;
  max-height: 220px;
  overflow-y: auto;
  background: #0D1117;
  border: 2px solid var(--ink-900);
  border-radius: 4px;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.55);
}

.cmd-suggest.hidden { display: none; }

.cmd-suggest-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  text-align: left;
  cursor: pointer;
}

.cmd-suggest-item.active {
  background: rgba(0, 245, 212, 0.12);
  border-left-color: #00F5D4;
}

.cmd-suggest-name {
  flex: 0 0 190px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #F1F5F9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-suggest-item.active .cmd-suggest-name { color: #00F5D4; }

.cmd-suggest-desc {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #8B949E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kra-input::placeholder {
  color: #64748B;
  font-size: 12px;
}

#btn-send-cmd {
  height: 32px;
  padding: 0 14px;
  background-color: var(--gold);
  color: var(--ink-900);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: bold;
  border: 1.5px solid var(--ink-900);
  border-radius: 3px;
  box-shadow: 2px 2px 0 var(--ink-900);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
}

#btn-send-cmd:hover {
  background-color: #00F5D4;
  color: #07090E;
  box-shadow: 2px 2px 0 #00F5D4;
}

#btn-send-cmd:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink-900);
}

/* Agent Strip Footer */
.agent-strip {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  max-height: 112px;
  overflow: hidden;
  padding: 6px 12px;
  background-color: var(--cream-100);
}

.strip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.strip-header-left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-700);
}

/* Add Agent 4-Tab Modal Styles (Authentic KRA/Munder Difflin Design) */
.add-agent-card {
  width: min(840px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background-color: #FFFDF5;
  border: 2px solid #1A1320;
  box-shadow: 4px 4px 0 rgba(26, 19, 32, 0.4);
}

.add-agent-header {
  background-color: #FBF7E7;
  border-bottom: 2px solid #1A1320;
  padding: 8px 14px;
}

.add-agent-title {
  font-family: var(--font-display);
  font-size: 13px;
  color: #1A1320;
  letter-spacing: 0.5px;
}

.add-agent-body {
  display: grid;
  grid-template-columns: 190px 1fr;
  flex: 1 1 auto;
  min-height: 380px;
  background-color: #FFFDF5;
}

/* Left Navigation Column */
.add-agent-nav {
  display: flex;
  flex-direction: column;
  background-color: #FAF4E1;
  border-right: 2px solid #1A1320;
  padding: 10px;
  gap: 8px;
}

.agent-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s ease;
}

.agent-tab-btn:hover {
  background-color: #EFE6CD;
}

.agent-tab-btn.active {
  background-color: #D3E6ED;
  border: 1.5px solid #23394A;
  box-shadow: inset 1px 1px 0 #FFF;
}

.tab-num-title {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: bold;
  color: #1A1320;
}

.tab-sub {
  font-family: var(--font-ui);
  font-size: 11px;
  color: #6B5878;
  margin-top: 2px;
}

/* Right Content Area */
.add-agent-content {
  padding: 16px 20px;
  overflow-y: auto;
  background-color: #FFFDF5;
}

.agent-tab-pane {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.agent-tab-pane.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-label {
  font-family: var(--font-display);
  font-size: 9px;
  color: #1A1320;
  letter-spacing: 0.5px;
}

.text-field {
  width: 100%;
  border: 1.5px solid #A899B5;
  background: #FFFDF5;
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 15px;
  color: #1A1320;
  box-sizing: border-box;
}

.text-field:focus {
  border-color: #1A1320;
  outline: 1px solid #1A1320;
}

.mono-field {
  font-family: var(--font-mono);
  font-size: 16px;
  background: #FAF8F0;
}

.textarea-field {
  resize: vertical;
}

/* Character Grid in Tab 1 */
.character-group-title {
  font-size: 12px;
  color: #6B5878;
  margin-bottom: 4px;
}

.character-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
  background: #FAF6E8;
  border: 1px solid #D9CFE0;
}

.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 6px;
  cursor: pointer;
  border: 1.5px solid transparent;
  background: #FFF;
  min-width: 52px;
  font-size: 11px;
}

.char-card:hover {
  background: #F0EAD2;
}

.char-card.active {
  border-color: #1A1320;
  background: #D3E6ED;
}

.char-avatar {
  width: 32px;
  height: 40px;
  background-size: 608px 160px;
  background-repeat: no-repeat;
  background-position: 0 0;
  margin-bottom: 2px;
  image-rendering: pixelated;
  background-color: #E2DCCD;
}

/* Batch 2 sheets: 19 columns x 4 rows, 32 x 40 per frame. */
.char-rama { background-image: url('../assets/argon/Batch2_Agents_Core/01_Agent_Spritesheets/rama_spritesheet_diffuse.png'); background-color: #2C1D15; }
.char-jarvis { background-image: url('../assets/argon/Batch2_Agents_Core/01_Agent_Spritesheets/jarvis_spritesheet_diffuse.png'); background-color: #243343; }
.char-maya { background-image: url('../assets/argon/Batch2_Agents_Core/01_Agent_Spritesheets/maya_spritesheet_diffuse.png'); background-color: #4ECDC4; }
.char-budi { background-image: url('../assets/argon/Batch2_Agents_Core/01_Agent_Spritesheets/budi_spritesheet_diffuse.png'); background-color: #4ECDC4; }
.char-siti { background-image: url('../assets/argon/Batch2_Agents_Core/01_Agent_Spritesheets/siti_spritesheet_diffuse.png'); background-color: #6BCF7F; }
.char-dimas { background-image: url('../assets/argon/Batch2_Agents_Core/01_Agent_Spritesheets/dimas_spritesheet_diffuse.png'); background-color: #B197FC; }
.char-rama, .char-jarvis, .char-maya, .char-budi, .char-siti, .char-dimas { background-position: 0 0; }
.char-michael { background-color: #2C1D15; }
.char-jim { background-color: #4ECDC4; }
.char-pam { background-color: #B197FC; }
.char-dwight { background-color: #FFD93D; }
.char-kevin { background-color: #FFA07A; }
.char-angela { background-color: #FFF8E7; }
.char-oscar { background-color: #6BCF7F; }
.char-stanley { background-color: #3D2E4A; }
.char-phyllis { background-color: #B197FC; }
.char-andy { background-color: #FF6B6B; }
.char-kelly { background-color: #FF007F; }
.char-ryan { background-color: #796B84; }
.char-toby { background-color: #D9CFE0; }
.char-creed { background-color: #1A1320; }
.char-meredith { background-color: #FFA07A; }

.custom-avatar-section {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.custom-avatar-title {
  font-size: 12px;
}

.custom-avatar-title .dim {
  color: #796B84;
  margin-left: 6px;
}

.avatar-new-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.new-avatar-box {
  width: 54px;
  height: 54px;
  border: 1px dashed #796B84;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #FFF;
  font-size: 9px;
  color: #6B5878;
}

.new-avatar-box .plus-icon {
  font-size: 16px;
}

/* Color Swatches */
.color-swatches {
  display: flex;
  gap: 6px;
}

.swatch-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid transparent;
  cursor: pointer;
}

.swatch-btn.active {
  border-color: #1A1320;
  box-shadow: 0 0 0 2px #FFF, 0 0 0 3px #1A1320;
}

/* Pills in Engine and Briefing */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.engine-pill, .template-chip {
  padding: 5px 10px;
  background: #FFFDF5;
  border: 1.5px solid #A899B5;
  font-family: var(--font-ui);
  font-size: 12px;
  color: #1A1320;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.engine-pill:hover, .template-chip:hover {
  background: #F0EAD2;
}

.engine-pill.active {
  background: #D3E6ED;
  border-color: #23394A;
  font-weight: bold;
}

/* Workspace Path and Add Project */
.workspace-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.add-proj-btn {
  font-size: 9px;
  padding: 2px 8px;
}

.dim-desc {
  font-size: 12px;
  color: #6B5878;
}

.agent-project-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.agent-project-list li {
  padding: 5px 8px;
  border-left: 2px solid #23394A;
  background: #F2EBDD;
  color: #1A1320;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.path-input-row {
  display: flex;
  gap: 6px;
}

.pick-folder-btn {
  padding: 4px 12px;
  border: 1.5px solid #1A1320;
  background: #FFF;
  cursor: pointer;
  font-size: 12px;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* Bottom Footer Action Bar */
.add-agent-footer {
  border-top: 2px solid #1A1320;
  background: #FFFDF5;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.import-hire-banner {
  border: 1px solid #D9CFE0;
  background: #FFFDF5;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.banner-text {
  font-size: 11px;
  color: #4A3E55;
  flex: 1;
}

.ai-gen-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  background: #FFF;
  border: 1px solid #1A1320;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.ai-gen-btn:hover {
  background: #F4E9C7;
}

.footer-buttons-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Phase 4: Task Board */
.task-board-card {
  max-width: 900px;
  width: 90%;
}
.task-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--ink-500);
  padding-bottom: 4px;
}
.task-tab {
  background: none;
  border: none;
  color: var(--ink-700);
  font-family: var(--font-display);
  font-weight: bold;
  cursor: pointer;
  padding: 4px 12px;
}
.task-tab.active {
  color: var(--mint);
  border-bottom: 3px solid var(--mint);
}
.task-list-grid {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  max-height: 52vh;
}
.task-item {
  background: var(--paper-100);
  border: 1.5px solid var(--ink-900);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.task-id {
  font-family: var(--font-mono);
  font-size: 13px;
}
.task-status {
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--ink-900);
  font-weight: bold;
}
.status-WAITING_APPROVAL { background: var(--gold); }
.status-APPROVED { background: var(--mint); }
.status-FAILED { background: var(--coral); color: #FFF; }
.task-title {
  font-weight: bold;
  font-size: 16px;
}
.task-summary {
  font-size: 13px;
  color: var(--ink-700);
}
.task-actions {
  display: flex;
  gap: 8px;
}
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--ink-500);
  font-style: italic;
}

.footer-right {
  display: flex;
  gap: 8px;
}

.spawn-btn {
  background: #000 !important;
  color: #FFF !important;
  padding: 8px 20px !important;
}

.spawn-btn:hover {
  background: #23394A !important;
}


.role-preview {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-700);
  background: var(--paper-200);
  border: 1px dashed var(--ink-500);
  padding: 6px 8px;
  max-height: 96px;
  overflow-y: auto;
}

.role-preview .role-skills {
  color: var(--maroon);
  font-family: var(--font-display);
  font-size: 8px;
}

.name-input-group {
  display: flex;
  gap: 6px;
}

.name-input-group .kra-input {
  flex: 1;
  min-width: 0;
}

.appearance-options {
  border: 1px solid var(--ink-500);
  padding: 8px;
  margin: 0;
}

.appearance-options legend {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-700);
  padding: 0 4px;
}

.agent-avatar-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 5px 8px;
  border: 1px solid #D9CFE0;
  background: #FAF6E8;
  color: #6B5878;
  font-size: 11px;
}

.preview-sprite {
  width: 32px;
  height: 40px;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 608px 160px;
  image-rendering: pixelated;
}

.appearance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.appearance-grid label {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-700);
}

.appearance-grid .kra-input {
  border: 1px solid var(--ink-500);
  background: var(--paper-100);
  padding: 5px;
}

.hidden {
  display: none !important;
}

.strip-title {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--ink-700);
}

.strip-count {
  font-size: 13px;
  color: var(--ink-500);
}

.roster-grid {
  display: flex;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 2px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-500) var(--cream-200);
  scroll-behavior: smooth;
}

.roster-grid::-webkit-scrollbar {
  height: 8px;
}

.roster-grid::-webkit-scrollbar-track {
  background: var(--cream-200);
}

.roster-grid::-webkit-scrollbar-thumb {
  background: var(--ink-500);
  border: 1px solid var(--ink-900);
}

.roster-grid .roster-card {
  flex: 0 0 210px;
}

@media (max-width: 900px) {
  .roster-grid .roster-card { flex-basis: 185px; }
}

/* --- Project Path Gate styles --- */
.project-path-card {
  max-width: 580px;
}

.path-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted, #94A3B8);
  margin-top: 10px;
  margin-bottom: 4px;
}

.path-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  color: var(--color-text, #F1F5F9);
  background: var(--color-bg-dark, #0B132B);
  border: 1px solid var(--color-border, #1E293B);
  border-radius: 4px;
  outline: none;
}

.path-input:focus {
  border-color: var(--color-accent, #00F5D4);
}

.path-status {
  min-height: 1.4rem;
  font-size: 0.74rem;
  margin-top: 4px;
  color: var(--color-text-muted, #94A3B8);
}

.path-status.is-valid {
  color: #10B981;
}

.path-status.is-invalid {
  color: #EF4444;
}

.path-browser {
  margin-top: 8px;
  border: 1px solid var(--color-border, #1E293B);
  border-radius: 4px;
  background: rgba(11, 19, 43, 0.5);
  padding: 6px;
}

.path-browser-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border, #1E293B);
  font-size: 0.72rem;
}

.path-current {
  flex: 1;
  font-family: var(--font-mono, monospace);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-muted, #94A3B8);
}

.path-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
  padding-top: 6px;
}

.path-entry {
  display: inline-block;
  padding: 3px 8px;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  background: var(--color-panel, #1E293B);
  color: var(--color-text, #F1F5F9);
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}

.path-entry:hover {
  border-color: var(--color-accent, #00F5D4);
  color: var(--color-accent, #00F5D4);
}

.path-empty {
  font-size: 0.72rem;
  color: var(--color-text-muted, #64748B);
  padding: 4px;
}

/* UI SVG Icons & Compact Actions */
.ui-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.title-icon.ui-icon {
  width: 16px;
  height: 16px;
  color: #1A1320;
}

.icon-action,
.chat-tab,
.action-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.chat-tab .ui-icon,
.action-chip .ui-icon,
.icon-action .ui-icon {
  pointer-events: none;
}

.card-avatar-box canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  display: block;
}

/* Step 3: Approval Gate Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 19, 32, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200; /* above chat-fullscreen (1000) and its backdrop (999) */
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(560px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  animation: modal-snap 0.2s steps(2);
}

@keyframes modal-snap {
  from { transform: scale(0.92); }
  to { transform: scale(1); }
}

.modal-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.modal-agent-badge {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--maroon);
  background: var(--gold);
  border: 1px solid var(--ink-900);
  padding: 4px 8px;
  align-self: flex-start;
}

.modal-summary {
  font-size: 15px;
  color: var(--ink-700);
}

.modal-diff-wrapper {
  border: 1px solid var(--ink-900);
  background: var(--paper-200);
}

.diff-header {
  font-family: var(--font-mono);
  font-size: 15px;
  background: var(--ink-900);
  color: var(--cream-50);
  padding: 3px 8px;
}

.diff-content {
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 8px;
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink-900);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.roster-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: var(--cream-200);
  border: 2px solid var(--ink-700);
  padding: 6px;
  cursor: pointer;
  transition: all 0.05s steps(1);
}

.roster-card.hired-agent-card {
  border-style: dashed;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--agent-accent, var(--sky)) 42%, transparent);
}

.roster-card:hover {
  border-color: var(--ink-900);
  background: var(--cream-50);
}

.roster-card.active {
  border-color: var(--maroon);
  background: var(--cream-50);
  box-shadow: inset 0 0 0 2px var(--gold);
}

.card-avatar-box {
  width: 34px;
  height: 34px;
  background: var(--paper-100);
  border: 1px solid var(--ink-900);
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-info {
  flex: 1;
  overflow: hidden;
}

.card-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-name {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--ink-900);
}

.card-badge {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 2px;
}

.badge-boss { background: var(--maroon); color: var(--gold); }
.badge-idle { background: var(--ink-300); color: #fff; }
.badge-active-sub { background: var(--mint); color: var(--ink-900); }

.card-role {
  font-size: 12px;
  color: var(--ink-500);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}


/* ---------- Proportional viewport guards ---------- */
@media (max-width: 1100px) {
  #app-root {
    padding: 8px;
    gap: 8px;
  }

  .kra-main-stage {
    grid-template-columns: minmax(0, 1fr) clamp(300px, 34vw, 360px);
    gap: 8px;
  }

  .terminal-body {
    font-size: 14px;
  }

  .kra-titlebar {
    padding-inline: 10px;
  }

  .titlebar-right {
    gap: 6px;
  }
}

@media (max-width: 820px) {
  #app-root {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .kra-main-stage {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }

  .floor-viewport {
    min-height: 420px;
  }

  .canvas-container {
    min-height: 260px;
  }

  .command-sidebar {
    height: 520px;
  }

  .kra-titlebar,
  .titlebar-right {
    flex-wrap: wrap;
  }

  .agent-strip {
    max-height: none;
  }
}
