:root {
  color-scheme: light;
  --bg: #efefed;
  --room: #f7f6f3;
  --wall: #ffffff;
  --wood: #d7bd94;
  --wood-2: #b99568;
  --desk: #f6f6f4;
  --chair: #e6e8ea;
  --ink: #252525;
  --muted: #747474;
  --soft: #ffffffcc;
  --line: rgba(0, 0, 0, 0.08);
  --green: #39c978;
  --blue: #5ba9ff;
  --amber: #e6b84b;
  --red: #ff5f6d;
  --radius: 8px;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(0,0,0,0.34), transparent 17%, transparent 83%, rgba(0,0,0,0.34)),
    var(--bg);
}

button,
textarea {
  font: inherit;
}

.office-shell {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(820px, 1fr) 360px;
  gap: 0;
  height: 100vh;
}

.left-sidebar,
.right-sidebar {
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(80, 77, 70, 0.22);
  backdrop-filter: blur(18px);
}

.left-sidebar {
  padding: 46px 16px 14px;
}

.right-sidebar {
  padding: 38px 10px 14px;
  justify-content: flex-start;
  gap: 10px;
}

.sidebar-header {
  display: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.brief-composer {
  display: grid;
  gap: 10px;
}

.brief-composer label {
  color: #ffffffd6;
  font-size: 12px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  padding: 10px 12px;
  color: #fff;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 14px;
  line-height: 1.55;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

textarea::placeholder { color: #ffffffa8; }

textarea:focus {
  border-color: rgba(255,255,255,0.72);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.16);
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
}

.research-btn {
  height: 38px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.26);
  color: #fff;
  background: rgba(57,201,120,0.28);
  cursor: pointer;
  font-weight: 800;
}

.research-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.primary-btn,
.ghost-btn,
.tab {
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.26);
  cursor: pointer;
}

.primary-btn {
  color: #2f2f2f;
  font-weight: 800;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.primary-btn:disabled { opacity: 0.7; cursor: wait; }

.ghost-btn {
  color: #fff;
  background: rgba(255,255,255,0.16);
  font-size: 18px;
}

.presence-summary {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  color: #fff;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
}

.presence-summary > div:first-child {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255,255,255,0.22);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #fff;
  transition: width 260ms ease;
}

.roster-section {
  margin-top: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  color: #fff;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
}

.section-title small {
  color: #ffffffa8;
  font-weight: 500;
}

.agent-list {
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 92px);
  overflow: auto;
}

.agent-pill {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 9px;
  border-radius: 14px;
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.16);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.agent-pill.active {
  background: rgba(255,255,255,0.28);
  box-shadow: 0 0 0 1px var(--agent), 0 10px 24px rgba(0,0,0,0.15);
  transform: translateX(2px);
}

.agent-pill.selected {
  background: rgba(255,255,255,0.23);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.42);
}

.agent-list-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.26);
  border: 1px solid rgba(255,255,255,0.3);
  overflow: hidden;
}

.agent-list-avatar::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 9px;
  height: 9px;
  border: 2px solid rgba(255,255,255,0.86);
  border-radius: 50%;
  background: var(--agent);
  box-shadow: 0 0 10px var(--agent);
}

.agent-list-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.28) translateY(5px);
}

.agent-pill.active .agent-list-avatar {
  background: rgba(255,255,255,0.48);
  box-shadow: 0 0 16px var(--agent);
}

.agent-pill.active .agent-list-avatar img {
  animation: active-list-avatar 850ms ease-in-out infinite;
}

.agent-meta strong {
  display: block;
  font-size: 12px;
}

.agent-meta span {
  display: block;
  margin-top: 2px;
  color: #ffffffa8;
  font-size: 10px;
  overflow-wrap: anywhere;
}

.agent-usage {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.agent-usage-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #ffffffb8;
  font-size: 10px;
}

.agent-mini-track {
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255,255,255,0.2);
}

.agent-mini-bar {
  width: var(--usage, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--agent);
  transition: width 260ms ease;
}

.map-column {
  position: relative;
  overflow: hidden;
  background: #fafafa;
}

.map-status {
  position: absolute;
  left: 50%;
  top: 34px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  color: #333;
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
  backdrop-filter: blur(12px);
}

.map-status strong {
  font-size: 13px;
}

.office-status {
  color: #1d9b57;
  font-size: 11px;
  font-weight: 800;
}

.map-status span:last-child {
  color: #666;
  font-size: 12px;
}

.map-viewport {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 292px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 34px 40px 16px;
  overflow: hidden;
}

.map-container {
  position: relative;
  width: min(96%, 1160px);
  aspect-ratio: 16 / 9;
  transform: perspective(1200px) rotateX(0deg);
}

.office-map {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 8px;
  background: url("/assets/office-main-visual-fast.png") center / contain no-repeat;
  box-shadow:
    0 0 0 10px #fff,
    0 0 0 14px #d5d5d2,
    0 36px 90px rgba(0,0,0,0.18);
  clip-path: none;
}

.room {
  position: absolute;
  z-index: 1;
  border: 0;
  background: transparent;
}

.room span {
  display: none;
}

.room-board {
  left: 38%;
  top: 12%;
  width: 26%;
  height: 10%;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.room-board span {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  color: #555;
  font-size: 14px;
  font-weight: 800;
  background: rgba(255,255,255,0.82);
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}

.room-furniture {
  position: absolute;
  z-index: 2;
  display: none;
}

.desk-left,
.desk-right {
  width: 14%;
  height: 6%;
  background: #ffffff;
  border: 1px solid #e2e2df;
  border-radius: 4px;
  box-shadow: 0 12px 18px rgba(0,0,0,0.08);
}

.desk-left { left: 35%; top: 37%; }
.desk-right { left: 56%; top: 37%; }

.table-main {
  left: 36%;
  top: 55%;
  width: 30%;
  height: 11%;
  border-radius: 50%;
  background: rgba(220, 220, 218, 0.55);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}

.table-main::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 40%;
  width: 48%;
  height: 36%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 10px 14px rgba(0,0,0,0.06);
}

.sofa {
  left: 15%;
  top: 58%;
  width: 4%;
  height: 22%;
  background: linear-gradient(#9cc07d, #6e9558);
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}

.plant-one,
.plant-two {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 36%, #77a969 0 9px, transparent 10px),
    radial-gradient(circle at 58% 36%, #80b973 0 10px, transparent 11px),
    radial-gradient(circle at 46% 62%, #5f924f 0 12px, transparent 13px);
  box-shadow: 0 10px 18px rgba(0,0,0,0.12);
}

.plant-one { left: 16%; top: 23%; }
.plant-two { right: 15%; top: 48%; }

.speech-bubble {
  position: absolute;
  left: 50%;
  top: 31%;
  z-index: 30;
  min-width: 280px;
  max-width: 520px;
  padding: 10px 18px;
  transform: translateX(-50%);
  color: #555;
  background: rgba(255,255,255,0.92);
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.12);
  text-align: center;
  line-height: 1.5;
  font-size: 13px;
  font-weight: 700;
}

.speech-bubble:empty {
  display: none;
}

.avatars {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.avatar {
  --agent: var(--green);
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 92px;
  height: 116px;
  transform: translate(-50%, -58%);
  cursor: pointer;
  transition: left 0.8s ease, top 0.8s ease, transform 0.15s, opacity 0.2s;
}

.avatar:hover { transform: translate(-50%, -58%) scale(1.05); }
.avatar.active { animation: active-bob 850ms ease-in-out infinite; }
.avatar.thinking { animation: idle-bob 2.4s ease-in-out infinite; }
.avatar.done { opacity: 0.88; }

.shadow {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 62px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0,0,0,0.09);
}

.agent-art {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 108px;
  height: 108px;
  object-fit: contain;
  transform: translateX(-50%);
  filter: drop-shadow(0 10px 10px rgba(0,0,0,0.12));
  user-select: none;
  pointer-events: none;
}

.nameplate {
  position: absolute;
  left: 50%;
  top: -20px;
  transform: translateX(-50%);
  max-width: 100px;
  padding: 3px 8px;
  color: #333;
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
}

.avatar.walking .agent-art {
  animation: walk-wiggle 420ms ease-in-out infinite;
}

.avatar.sipping .agent-art {
  animation: sip 900ms ease-in-out infinite;
}

.avatar.pantry .nameplate::after {
  content: " \2615";
}

.bottom-chat-dock {
  position: absolute;
  left: clamp(48px, 7vw, 118px);
  right: clamp(48px, 7vw, 118px);
  bottom: 14px;
  z-index: 80;
  height: 254px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 0;
}

.tab {
  color: #fff;
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.2);
}

.tab.active {
  color: #333;
  background: rgba(255,255,255,0.88);
  font-weight: 800;
}

.tab-view {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.director-panel {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.42);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.14)),
    rgba(90,90,90,0.26);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 48px rgba(0,0,0,0.12);
}

.bottom-chat-dock .director-panel {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 88px;
  height: 100%;
  min-height: 0;
  border-color: rgba(255,255,255,0.62);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.36), rgba(255,255,255,0.18)),
    rgba(70,70,70,0.28);
}

.director-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.12);
}

.director-avatar,
.message-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #2f2f2f;
  font-size: 13px;
  font-weight: 900;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}

.director-chat-header strong,
.director-chat-header span {
  display: block;
}

.director-chat-header strong {
  font-size: 14px;
}

.director-chat-header span {
  margin-top: 2px;
  color: #ffffffb8;
  font-size: 11px;
}

.director-chat {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px 8px;
  overscroll-behavior: contain;
}

.bottom-chat-dock .director-chat {
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

.director-message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 10px;
  color: #fff;
}

.director-message.user {
  flex-direction: row-reverse;
}

.director-message.user .message-avatar {
  color: #fff;
  background: rgba(60,60,60,0.72);
}

.message-body {
  max-width: 84%;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px 14px 14px 4px;
  background: rgba(0,0,0,0.22);
  overflow-wrap: anywhere;
}

.director-message.user .message-body {
  color: #2f2f2f;
  border-color: rgba(255,255,255,0.28);
  border-radius: 14px 14px 4px 14px;
  background: rgba(255,255,255,0.86);
}

.director-message strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.director-message.user strong {
  color: #333;
  text-align: right;
}

.director-message p {
  margin: 0;
  line-height: 1.65;
  white-space: pre-wrap;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.director-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.1);
  min-height: 0;
  overflow: hidden;
}

.director-compose textarea {
  min-height: 72px;
  max-height: 96px;
  color: #fff;
  resize: none;
}

.director-actions {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  align-self: stretch;
}

.director-actions .primary-btn,
.director-actions .ghost-btn {
  height: auto;
  min-height: 72px;
}

.send-btn {
  font-size: 14px;
  font-weight: 800;
}

.dispatch-btn {
  font-size: 14px;
}

.side-summary {
  padding: 13px;
  border-radius: 14px;
  color: #fff;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.14);
}

.side-summary strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.side-summary p {
  margin: 0;
  color: #ffffffe0;
  line-height: 1.6;
  font-size: 12px;
}

.agent-test-panel {
  display: grid;
  grid-template-rows: auto auto 40px minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.test-target {
  padding: 12px;
  border-radius: 14px;
  color: #fff;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.14);
}

.test-target span,
.test-target strong,
.test-target small {
  display: block;
}

.test-target span,
.test-target small {
  color: #ffffffb8;
  font-size: 11px;
}

.test-target strong {
  margin: 4px 0;
  font-size: 14px;
}

.agent-test-panel textarea {
  min-height: 112px;
  resize: vertical;
}

.test-output {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border-radius: 14px;
  color: #fff;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.14);
  line-height: 1.68;
  white-space: pre-wrap;
  font-size: 13px;
}

.test-output.empty {
  color: #ffffffa8;
}

.research-output {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 12px;
  border-radius: 14px;
  color: #fff;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.14);
  line-height: 1.68;
  white-space: pre-wrap;
  font-size: 13px;
}

.research-output.empty {
  color: #ffffffa8;
}

.log,
.final-output,
.activity-log {
  height: auto;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 2px 0 0;
}

.log-entry,
.activity-item,
.final-output {
  margin-bottom: 8px;
  padding: 12px;
  border-radius: 14px;
  color: #fff;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.14);
}

.log-entry.active { border-color: rgba(255,255,255,0.45); }
.log-entry.error { border-color: rgba(255,95,109,0.72); }

.log-entry h3 {
  margin: 0 0 7px;
  font-size: 13px;
}

.log-entry p,
.activity-item p,
.final-output {
  margin: 0;
  line-height: 1.68;
  white-space: pre-wrap;
  font-size: 13px;
}

.final-output.empty { color: #ffffffa8; }

@keyframes active-bob {
  0%, 100% { transform: translate(-50%, -58%) translateY(0); }
  50% { transform: translate(-50%, -58%) translateY(-5px); }
}

@keyframes idle-bob {
  0%, 100% { transform: translate(-50%, -58%); }
  50% { transform: translate(-50%, calc(-58% - 2px)); }
}

@keyframes walk-wiggle {
  0%, 100% { transform: translateX(-50%) rotate(-2deg); }
  50% { transform: translateX(-50%) rotate(2deg) translateY(-3px); }
}

@keyframes sip {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  50% { transform: translateX(-50%) rotate(-6deg) translateY(2px); }
}

@keyframes active-list-avatar {
  0%, 100% { transform: scale(1.28) translateY(5px); }
  50% { transform: scale(1.34) translateY(2px); }
}

@media (max-width: 1180px) {
  .office-shell {
    grid-template-columns: 280px 1fr;
    overflow: auto;
  }
  .right-sidebar {
    grid-column: 1 / -1;
    padding-top: 16px;
    min-height: 420px;
  }
  .bottom-chat-dock {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    height: 220px;
    margin: 0 16px 16px;
  }
  .log, .final-output, .activity-log { height: 350px; }
}

@media (max-width: 780px) {
  body { overflow: auto; }
  .office-shell {
    display: block;
    height: auto;
  }
  .left-sidebar, .right-sidebar {
    min-height: 420px;
    padding: 16px;
  }
  .map-column { height: 620px; }
}
