:root {
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --floor: #151922;
  --hall: #1a1f2b;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaef;
  --muted: #8b93a7;
  --working: #f5c542;
  --idle: #5eead4;
  --blocked: #fb7185;
  --offline: #64748b;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { position: relative; overflow-x: hidden; }

.bg-glow {
  pointer-events: none;
  position: fixed;
  inset: -20% -10% auto;
  height: 55vh;
  background:
    radial-gradient(ellipse 50% 60% at 20% 0%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(ellipse 40% 50% at 80% 10%, rgba(245, 197, 66, 0.1), transparent 55%),
    radial-gradient(ellipse 35% 40% at 55% 0%, rgba(45, 212, 191, 0.08), transparent 50%);
  z-index: 0;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(11, 13, 18, 0.85);
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-mark {
  width: 2.25rem; height: 2.25rem;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  font-size: 0.85rem;
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.45);
}
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { margin: 0.1rem 0 0; font-size: 0.75rem; color: var(--muted); }

.summary { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1; justify-content: center; }
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.35rem 0.7rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border); color: var(--muted);
}
.pill b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.pill-working b { color: var(--working); }
.pill-idle b { color: var(--idle); }
.pill-blocked b { color: var(--blocked); }
.pill-offline b { color: var(--offline); }

.clock-wrap { display: flex; align-items: baseline; gap: 0.4rem; font-variant-numeric: tabular-nums; }
#clock { font-family: var(--mono); font-size: 0.95rem; font-weight: 500; }
.tz { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.poll-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--idle);
  box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.5);
  animation: pulse-dot 2.4s ease-out infinite;
  margin-left: 0.35rem; align-self: center;
}
.poll-dot.err { background: var(--blocked); animation: none; }
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(94, 234, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); }
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 360px);
  gap: 0;
  min-height: calc(100vh - 120px);
  max-width: 1600px;
  margin: 0 auto;
}

.office-wrap {
  padding: 1.25rem 1.5rem 0.5rem;
  overflow: auto;
}

.office {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 72px 1fr 72px 1fr;
  grid-template-rows: minmax(200px, 1fr) 56px minmax(200px, 1fr);
  gap: 0;
  min-height: 520px;
  background: var(--floor);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 0 80px rgba(0, 0, 0, 0.35);
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Rooms */
.room {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
  overflow: hidden;
  outline: none;
}
.room:hover, .room:focus-visible {
  z-index: 2;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), 0 8px 28px rgba(0,0,0,0.4);
}
.room.is-selected {
  border-color: color-mix(in srgb, var(--accent) 70%, white);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent), 0 0 36px color-mix(in srgb, var(--accent) 25%, transparent);
}
.room.is-working {
  border-color: color-mix(in srgb, var(--accent, var(--working)) 45%, var(--border));
}
.room.is-working .room-stage::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, color-mix(in srgb, var(--accent) 14%, transparent) 50%, transparent 60%);
  background-size: 200% 100%;
  animation: shimmer 2.8s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.room-stage {
  position: relative;
  height: 110px;
  overflow: hidden;
  flex-shrink: 0;
}
.room-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.room-body {
  display: flex; flex-direction: column; gap: 0.45rem;
  padding: 0.65rem 0.75rem 0.75rem; flex: 1; min-height: 0;
}
.room-head { display: flex; align-items: center; gap: 0.55rem; }
.avatar {
  flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 10px;
  display: grid; place-items: center; font-size: 1rem;
  background: color-mix(in srgb, var(--accent) 22%, #1a1d26);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.room-title { min-width: 0; flex: 1; }
.room-title h2 { margin: 0; font-size: 0.88rem; font-weight: 650; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.personality { margin: 0.1rem 0 0; font-size: 0.65rem; line-height: 1.3; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.status-row { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.22rem 0.55rem; border-radius: 999px;
  font-size: 0.62rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-working { color: #1a1400; background: var(--working); }
.badge-working::before { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.badge-idle { color: #042f2e; background: var(--idle); }
.badge-blocked { color: #4c0519; background: var(--blocked); }
.badge-offline { color: #e2e8f0; background: var(--offline); }
.ago { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); }

.task-snip {
  margin: 0; font-size: 0.72rem; line-height: 1.35; color: #c5cad6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Hallways */
.hall {
  background: var(--hall);
  position: relative;
  border: 1px solid rgba(255,255,255,0.04);
}
.hall::before {
  content: "";
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 18px,
      rgba(255,255,255,0.03) 18px,
      rgba(255,255,255,0.03) 19px
    );
  opacity: 0.7;
}
.hall-v::before {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 18px,
      rgba(255,255,255,0.03) 18px,
      rgba(255,255,255,0.03) 19px
    );
}
.hall-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 0.58rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(139, 147, 167, 0.55);
  z-index: 1; pointer-events: none;
  writing-mode: horizontal-tb;
}
.hall-v .hall-label { writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: 0.18em; }

.hall-atrium {
  background: linear-gradient(135deg, #1c2230 0%, #161b26 50%, #1a2030 100%);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(99, 102, 241, 0.15);
}
.hall-atrium .atrium-mark {
  width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a5b4fc, #6366f1 55%, #4338ca);
  box-shadow: 0 0 28px rgba(99, 102, 241, 0.45);
  opacity: 0.85;
}

/* Grid placement: 3 rooms top, hall row, 3 rooms bottom; vertical halls between */
.room-maestro { grid-column: 1; grid-row: 1; border-radius: 18px 0 0 0; }
.hall-v-1 { grid-column: 2; grid-row: 1; }
.room-claude { grid-column: 3; grid-row: 1; }
.hall-v-2 { grid-column: 4; grid-row: 1; }
.room-chatgpt { grid-column: 5; grid-row: 1; border-radius: 0 18px 0 0; }

.hall-h { grid-column: 1 / -1; grid-row: 2; }
.hall-h .hall-label { letter-spacing: 0.2em; }

.room-omnius { grid-column: 1; grid-row: 3; border-radius: 0 0 0 18px; }
.hall-v-3 { grid-column: 2; grid-row: 3; }
.room-finance { grid-column: 3; grid-row: 3; }
.hall-v-4 { grid-column: 4; grid-row: 3; }
.room-scout { grid-column: 5; grid-row: 3; border-radius: 0 0 18px 0; }

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

/* Side panel */
.panel {
  border-left: 1px solid var(--border);
  background: rgba(18, 21, 28, 0.92);
  backdrop-filter: blur(10px);
  padding: 1.25rem 1.15rem;
  position: relative;
  overflow: auto;
}
.panel-empty {
  height: 100%;
  display: grid; place-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 1rem;
}
.panel-body { display: flex; flex-direction: column; gap: 0.9rem; }
.panel-body.hidden { display: none; }
.panel-empty.hidden { display: none; }
.panel-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  width: 2rem; height: 2rem; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 1.25rem; cursor: pointer; line-height: 1;
}
.panel-close:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.panel-head { display: flex; gap: 0.75rem; align-items: flex-start; padding-right: 1.5rem; }
.panel-head .avatar { width: 2.75rem; height: 2.75rem; font-size: 1.25rem; border-radius: 12px; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.panel .personality { -webkit-line-clamp: unset; display: block; }
.task-box {
  padding: 0.7rem 0.8rem; border-radius: 12px;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--border);
}
.task-label {
  display: block; font-size: 0.62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 0.3rem;
}
.task-text { margin: 0; font-size: 0.85rem; line-height: 1.4; }

.history h3 {
  margin: 0 0 0.5rem;
  font-size: 0.62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}
.history ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }
.history li {
  padding: 0.55rem 0.65rem; border-radius: 10px;
  background: rgba(0,0,0,0.22); border: 1px solid var(--border);
  font-size: 0.75rem; line-height: 1.35; color: #c5cad6;
}
.history .h-meta {
  display: flex; justify-content: space-between; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.6rem; color: var(--muted); margin-bottom: 0.25rem;
}
.history .h-status { text-transform: uppercase; letter-spacing: 0.04em; }

.footer {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.65rem 1.5rem 1.1rem;
  font-size: 0.7rem; color: var(--muted);
  max-width: 1600px; margin: 0 auto;
}
.footer code { font-family: var(--mono); font-size: 0.68rem; color: #a5b4fc; }

.theme-maestro { --accent: #f5c542; }
.theme-claude { --accent: #a78bfa; }
.theme-chatgpt { --accent: #34d399; }
.theme-omnius { --accent: #f59e0b; }
.theme-finance { --accent: #22c55e; }
.theme-scout { --accent: #fb923c; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .panel {
    border-left: none; border-top: 1px solid var(--border);
    min-height: 280px; max-height: 40vh;
  }
  .office {
    grid-template-columns: 1fr 48px 1fr;
    grid-template-rows: auto 40px auto 40px auto;
    min-height: 0;
  }
  .room-maestro { grid-column: 1; grid-row: 1; border-radius: 18px 0 0 0; }
  .hall-v-1 { grid-column: 2; grid-row: 1; }
  .room-claude { grid-column: 3; grid-row: 1; border-radius: 0 18px 0 0; }
  .hall-v-2, .hall-v-4 { display: none; }
  .room-chatgpt { grid-column: 1 / -1; grid-row: 3; border-radius: 0; }
  .hall-h { grid-column: 1 / -1; grid-row: 2; }
  .room-omnius { grid-column: 1; grid-row: 5; border-radius: 0 0 0 18px; }
  .hall-v-3 { grid-column: 2; grid-row: 5; }
  .room-finance { grid-column: 3; grid-row: 5; border-radius: 0 0 18px 0; }
  .room-scout { grid-column: 1 / -1; grid-row: 4; border-radius: 0; min-height: 160px; }
  /* Re-map: put scout in row between chatgpt and bottom — simplify */
}

@media (max-width: 640px) {
  .topbar { padding: 0.85rem 1rem; }
  .office-wrap { padding: 1rem; }
  .summary { order: 3; width: 100%; justify-content: flex-start; }
}
