/* BUYCARDAI Visual AI Office — 3D cutaway scene mode (v16 full-body molds)
   Brand: purple #7c3aed + red #e11d48
   Scene: scene/tower-3d.jpg architectural dollhouse cutaway — NOT a flat floor plan.
*/
:root,
[data-theme="campus"] {
  --bg: #f3e8d8;
  --bg-elev: #fff8ee;
  --bg-card: #fffaf2;
  --bg-soft: #f6ecdc;
  --line: rgba(92, 64, 51, 0.12);
  --line-strong: rgba(92, 64, 51, 0.22);
  --text: #3b2a1f;
  --muted: #7a6354;
  --accent: #7c3aed;
  --accent-2: #e11d48;
  --warn: #d97706;
  --danger: #e11d48;
  --shadow: 0 14px 36px rgba(80, 50, 30, 0.16);
  --shadow-soft: 0 4px 14px rgba(80, 50, 30, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --header-h: 68px;
  --header-bg: rgba(255, 248, 238, 0.9);
}

[data-theme="dark"] {
  --bg: #0b0e17;
  --bg-elev: #12182a;
  --bg-card: #161d33;
  --bg-soft: #1c2540;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7c5cff;
  --accent-2: #3dd6c6;
  --warn: #ffb020;
  --danger: #ff5d7a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.3);
  --header-bg: rgba(11, 14, 23, 0.85);
}

*, *::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 {
  background:
    radial-gradient(1100px 560px at 8% -8%, rgba(124, 58, 237, 0.1), transparent 55%),
    radial-gradient(900px 480px at 92% 0%, rgba(225, 29, 72, 0.08), transparent 50%),
    var(--bg);
}
[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(61, 214, 198, 0.1), transparent 55%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* —— Header —— */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  padding: 10px 18px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-mark, .brand-mark { flex-shrink: 0; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-soft); }
.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #7c3aed, #e11d48);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.header-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--bg-card);
}
.badge-preview { color: #9a3412; background: #ffedd5; border-color: #fdba74; }
[data-theme="dark"] .badge-preview { color: #ffd89a; background: rgba(217,119,6,0.18); border-color: rgba(251,191,36,0.35); }
.badge-shops { color: #6b21a8; background: #f3e8ff; border-color: #d8b4fe; }
[data-theme="dark"] .badge-shops { color: #e9d5ff; background: rgba(124,58,237,0.2); border-color: rgba(167,139,250,0.35); }
.domain-link {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.mobile-feed-toggle { display: none; }

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #e11d48);
  color: #fff;
  border-color: transparent;
}
.btn-ghost { background: transparent; }
.btn-theme { font-size: 12px; }
.btn-icon {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-card);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* —— Main layout —— */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: 16px;
  padding: 16px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.office-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.office-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.55), transparent);
  flex-wrap: wrap;
}
[data-theme="dark"] .office-toolbar { background: rgba(255,255,255,0.02); }
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.campus-hint { font-weight: 700; color: var(--accent); font-size: 12px; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.55);
  animation: pulse 1.8s ease infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(52, 199, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
.sep { opacity: 0.4; }

.status-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.status-pill i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #94a3b8;
}
.status-idle i { background: #94a3b8; }
.status-working i { background: #22c55e; }
.status-done i { background: #7c3aed; }

/* —— 3D Cutaway stage —— */
.office-stage {
  position: relative;
  flex: 1;
  min-height: 520px;
  overflow: auto;
  background: #0b0e17;
  padding: 0;
}

.cutaway-scene {
  position: relative;
  width: 100%;
  margin: 0 auto;
  aspect-ratio: 1280 / 720;
  max-height: min(78vh, 900px);
  background: #05070e;
  overflow: hidden;
}

.cutaway-bg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  user-select: none;
  pointer-events: none;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.layer-agents { z-index: 20; }
.layer-bubbles { z-index: 30; }

/* Hotspots — thin labels only */
.hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}
.hotspot-layer[data-visible="0"] { opacity: 0; visibility: hidden; }
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(10, 14, 28, 0.55);
  color: #f8fafc;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
  opacity: 0.85;
}
.hotspot:hover, .hotspot:focus-visible {
  opacity: 1;
  background: rgba(124, 58, 237, 0.75);
  transform: translate(-50%, -50%) scale(1.06);
  outline: none;
}
.hotspot-room {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(15, 23, 42, 0.62);
}

/* —— Agents overlays (anchor = feet on floor) —— */
.agent {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -96%);
  z-index: 10;
  border: 0;
  background: transparent;
  padding: 0;
  will-change: left, top;
  animation: agentIdleBob 2.4s ease-in-out infinite;
}
.agent[data-floor="upper"],
.agent[data-floor="rooftop"] {
  transform: translate(-50%, -96%) scale(0.88);
  transform-origin: 50% 100%;
}
.agent:nth-child(2) { animation-delay: 0.3s; }
.agent:nth-child(3) { animation-delay: 0.6s; }
.agent:nth-child(4) { animation-delay: 0.9s; }
.agent:nth-child(5) { animation-delay: 1.2s; }
.agent:nth-child(6) { animation-delay: 1.5s; }
.agent:hover, .agent:focus-visible { filter: brightness(1.12); z-index: 25; }
.agent:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 10px;
}
@keyframes agentIdleBob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -3px; }
}
.agent.walking { animation: none; }
.agent.walking .agent-avatar { animation: bobFast 0.32s ease-in-out infinite; }

/* Full-body transparent mold — no circular frame / ring / halo */
.agent-avatar {
  position: relative;
  width: var(--agent-w, 64px);
  height: var(--agent-h, 108px);
  border-radius: 0;
  display: grid;
  place-items: end center;
  padding: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.agent-avatar .chibi-face,
.agent-avatar .portrait-face {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  background: transparent;
}
.agent.size-小 { --agent-w: 52px; --agent-h: 90px; --agent-size: 52px; }
.agent.size-中 { --agent-w: 64px; --agent-h: 108px; --agent-size: 64px; }
.agent.size-大 { --agent-w: 72px; --agent-h: 120px; --agent-size: 72px; }

/* stub body removed — full PNG includes torso/legs */
.agent-body { display: none !important; }

.agent-shadow {
  position: absolute;
  left: 50%;
  top: 98%;
  width: calc(var(--agent-w, 64px) * 0.72);
  height: 10px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.22) 45%, transparent 72%);
  pointer-events: none;
  filter: blur(0.5px);
  z-index: 0;
}

.agent.working .agent-avatar {
  animation: workBounce 0.7s ease-in-out infinite;
  box-shadow: none;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--agent-color, var(--accent)) 45%, transparent));
}
/* Non-circle working indicator: soft top pulse bar */
.agent.working .agent-avatar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 18px;
  height: 3px;
  transform: translateX(-50%);
  border-radius: 999px;
  border: 0;
  background: color-mix(in srgb, var(--agent-color, var(--accent)) 80%, #fff);
  box-shadow: 0 0 8px color-mix(in srgb, var(--agent-color, var(--accent)) 55%, transparent);
  animation: workPulse 0.75s ease-in-out infinite;
}
@keyframes bobFast {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes workBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.03); }
}
@keyframes workPulse {
  0%, 100% { opacity: 0.45; transform: translateX(-50%) scaleX(0.7); }
  50% { opacity: 1; transform: translateX(-50%) scaleX(1); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.agent-nameplate {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255,255,255,0.14);
  color: #f8fafc;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  z-index: 2;
}
.agent-nameplate .agent-region {
  display: none;
}

.bubble {
  position: absolute;
  z-index: 30;
  transform: translate(-50%, calc(-100% - 118px));
  pointer-events: none;
  max-width: 160px;
  padding: 6px 10px;
  border-radius: 12px 12px 12px 4px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .bubble {
  background: rgba(22, 29, 51, 0.96);
  color: #eef1ff;
}

/* —— TV drawer (playlist only; no big overlay on cutaway) —— */
.tv-drawer {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: min(360px, calc(100% - 24px));
  max-height: 48%;
  overflow: auto;
  z-index: 40;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}
.tv-drawer[hidden] { display: none !important; }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.drawer-head h2 { margin: 0; font-size: 14px; }
.drawer-hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.tv-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg-soft);
}
.tv-card h3 { margin: 0 0 6px; font-size: 13px; }
.tv-card iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 8px;
  background: #000;
}
.tv-card .tv-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* —— Sidebar —— */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow: auto;
}
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.panel-head {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 14px; }
.panel-sub { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.feed-list, .roster-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: 260px;
  overflow: auto;
}
.feed-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;
}
.feed-item:nth-child(odd) { background: var(--bg-soft); }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; }
.feed-time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.roster-item {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 8px;
  border: 0;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
}
.roster-item:hover { background: var(--bg-soft); }
.roster-avatar {
  width: 40px; height: 64px;
  border-radius: 0;
  overflow: visible;
  display: grid;
  place-items: end center;
  background: transparent;
  box-shadow: none;
  flex-shrink: 0;
}
.roster-avatar .chibi-face,
.roster-avatar .portrait-face {
  width: 100%; height: 100%; object-fit: contain; object-position: center bottom; border-radius: 0;
  background: transparent;
}
.roster-meta .name { font-weight: 800; font-size: 13px; }
.roster-meta .role { font-size: 11px; color: var(--muted); }
.roster-meta .school { font-size: 10px; color: var(--muted); opacity: 0.85; line-height: 1.3; margin-top: 2px; }
.roster-tags { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.info-dl {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 6px 10px;
  margin: 0;
  padding: 12px 14px 14px;
  font-size: 12px;
}
.info-dl dt { color: var(--muted); font-weight: 600; }
.info-dl dd { margin: 0; }

/* —— Modal —— */
.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(480px, calc(100vw - 24px));
}
.modal::backdrop { background: rgba(8, 10, 20, 0.55); backdrop-filter: blur(4px); }
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-foot { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-end; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 14px; }
.preview-chip {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.modal-portrait {
  width: 96px; height: 160px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: end center;
  background: transparent;
  flex-shrink: 0;
}
.modal-portrait img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; background: transparent; }
.profile-dl { padding: 0; }
.qs-note, .contact-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
.look-summary {
  margin: 0;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.footer {
  padding: 12px 18px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.footer p { margin: 0; max-width: 920px; margin-inline: auto; line-height: 1.5; }

/* —— Responsive —— */
@media (max-width: 980px) {
  .main { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    z-index: 60;
    padding: 12px;
    background: var(--bg);
    border-left: 1px solid var(--line);
    transform: translateX(105%);
    transition: transform 0.22s ease;
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .mobile-feed-toggle { display: grid; }
  .cutaway-scene { max-height: none; }
  .agent.size-大 { --agent-size: 50px; }
  .agent.size-中 { --agent-size: 44px; }
  .agent.size-小 { --agent-size: 38px; }
  .hotspot { font-size: 9px; padding: 2px 6px; }
}
