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

:root {
  --bg-primary: #0A0E1A;
  --bg-mascot: #0D1220;
  --bg-terminal: #0A0F14;
  --bg-office: #0D1220;
  --border-color: #1A2040;
  --text-primary: #C8D0E0;
  --text-dim: #5A6580;
  --green: #00FF66;
  --green-dim: #00CC52;
  --red: #FF4466;
  --cyan: #00DDFF;
  --yellow: #FFCC00;
  --purple: #AA66FF;
  --glow-idle: #00DDFF;
  --glow-listening: #00FF66;
  --glow-thinking: #FFCC00;
  --glow-working: #AA66FF;
  --glow-happy: #00FF66;
  --glow-error: #FF4466;
  --glow-sleeping: #334466;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
}

#command-center {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 28% 24% 24% 24%;
  grid-template-rows: 26% 24% 25% 25%;
  gap: 4px;
  padding: 4px;
}

.zone {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.zone-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  text-transform: uppercase;
}

.zone-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Mascot Zone --- */
#zone-mascot {
  grid-column: 1;
  grid-row: 1 / 3;
  background: var(--bg-mascot);
  align-items: center;
}

#mascot-canvas {
  flex: 1;
  width: 100%;
  image-rendering: pixelated;
}

#mascot-label {
  padding: 6px 0 10px;
  font-family: 'VT323', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--glow-idle);
  text-align: center;
  text-shadow: 0 0 8px var(--glow-idle);
  transition: color 0.3s, text-shadow 0.3s;
}

/* --- Terminal Zone --- */
#zone-terminal {
  grid-column: 1;
  grid-row: 3 / 5;
  background: var(--bg-terminal);
}

#terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  line-height: 1.4;
  scrollbar-width: thin;
  scrollbar-color: #1A2040 transparent;
}

#terminal-output::-webkit-scrollbar {
  width: 4px;
}

#terminal-output::-webkit-scrollbar-thumb {
  background: #1A2040;
  border-radius: 2px;
}

.log-entry {
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-entry .timestamp {
  color: var(--text-dim);
  margin-right: 6px;
}

.log-entry.type-info { color: var(--green); }
.log-entry.type-error { color: var(--red); }
.log-entry.type-agent { color: var(--cyan); }
.log-entry.type-tool { color: var(--yellow); }
.log-entry.type-system { color: var(--purple); }

.cursor-blink::after {
  content: '\2588';
  animation: blink 1s step-end infinite;
}

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

/* --- Office Zone --- */
#zone-health {
  grid-column: 2 / 5;
  grid-row: 1;
  background: var(--bg-terminal);
  min-height: 120px;
}

#health-panel {
  flex: 1;
  padding: 12px;
}

#selection-bar {
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

#selection-bar strong {
  color: var(--cyan);
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.health-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.02);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 72px;
}

.health-card span {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.health-card strong {
  font-size: 16px;
  color: var(--text-primary);
}

#zone-audit {
  grid-column: 2;
  grid-row: 2;
  background: var(--bg-terminal);
}

#zone-recent {
  grid-column: 3;
  grid-row: 2;
  background: var(--bg-terminal);
}

#zone-detail {
  grid-column: 4;
  grid-row: 2;
  background: var(--bg-terminal);
  display: flex;
  flex-direction: column;
}

#zone-incidents {
  grid-column: 4;
  grid-row: 3;
  background: var(--bg-terminal);
}

.detail-actions {
  display: flex;
  gap: 8px;
  padding: 8px 10px 12px;
}

.detail-btn {
  flex: 1;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
}

.detail-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

#zone-pending {
  grid-column: 2 / 4;
  grid-row: 3;
  background: var(--bg-terminal);
}

#zone-operators {
  grid-column: 4;
  grid-row: 4;
  background: var(--bg-terminal);
}

#zone-projects {
  grid-column: 1 / 2;
  grid-row: 4;
  background: var(--bg-terminal);
}

.list-panel {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
}

.list-item.active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(0,221,255,0.35) inset;
  background: rgba(0,221,255,0.08);
}

.list-item strong {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--cyan);
}

.list-item p {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.35;
}

#zone-office {
  grid-column: 2 / 4;
  grid-row: 4;
  background: var(--bg-office);
}

#office-canvas {
  flex: 1;
  width: 100%;
  image-rendering: pixelated;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* --- Mascot Glow Effects --- */
#zone-mascot[data-emotion="idle"] { box-shadow: inset 0 0 30px rgba(0, 221, 255, 0.05); }
#zone-mascot[data-emotion="listening"] { box-shadow: inset 0 0 30px rgba(0, 255, 102, 0.08); }
#zone-mascot[data-emotion="thinking"] { box-shadow: inset 0 0 30px rgba(255, 204, 0, 0.08); }
#zone-mascot[data-emotion="working"] { box-shadow: inset 0 0 30px rgba(170, 102, 255, 0.08); }
#zone-mascot[data-emotion="happy"] { box-shadow: inset 0 0 30px rgba(0, 255, 102, 0.1); }
#zone-mascot[data-emotion="error"] { box-shadow: inset 0 0 30px rgba(255, 68, 102, 0.1); }
#zone-mascot[data-emotion="sleeping"] { box-shadow: inset 0 0 30px rgba(51, 68, 102, 0.08); }

/* --- Mascot tap hint --- */
#zone-mascot {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#zone-mascot:active {
  background: rgba(0, 255, 102, 0.05);
}

/* --- Responsive for 7" LCD (800x480) --- */
@media (max-width: 800px) {
  .zone-header {
    padding: 4px 8px;
    font-size: 9px;
  }

  #terminal-output {
    font-size: 12px;
  }

  #mascot-label {
    font-size: 15px;
  }
}
