@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap");

:root {
  --ac-espresso: #1a1a1a;
  --ac-latte: #faf8f5;
  --ac-cream: #f3efe9;
  --ac-warm-gray: #e8e2da;
  --ac-mocha: #d4c8b8;
  --ac-text: #2c2c2c;
  --ac-text-secondary: #6b6058;
  --ac-text-muted: #a09890;
  --ac-accent: #d97706;
  --ac-accent-soft: rgba(217, 119, 6, 0.08);
  --ac-border: rgba(0, 0, 0, 0.06);
  --ac-border-strong: rgba(0, 0, 0, 0.10);

  --font-ui: "Inter", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "Space Mono", "SFMono-Regular", Consolas, monospace;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-menu: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);

  --topbar-h: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ac-text);
  background: var(--ac-cream);
}

/* ---- Top bar ---- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--ac-border);
  background: var(--ac-latte);
}

.brand-block {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--ac-espresso);
}

.brand-logo svg {
  width: 24px;
  height: 24px;
  display: block;
}

.brand-copy h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.brand-copy p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ac-text-muted);
  letter-spacing: 0.01em;
}

.onboard-btn {
  flex-shrink: 0;
  padding: 8px 18px;
  border: 2px solid var(--ac-espresso);
  border-radius: 20px;
  background: var(--ac-espresso);
  color: #7FD858;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  letter-spacing: -0.01em;
}

.onboard-btn:hover {
  background: #7FD858;
  color: var(--ac-espresso);
  transform: translateY(-1px);
}

.runtime-subtitle {
  margin: 0;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ac-text-muted);
}

/* ---- Menu strip ---- */

.menu-strip {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 10px 0 0;
}

.menu-strip::-webkit-scrollbar {
  display: none;
}

/* ---- Menu cards ---- */

#menuList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}

#menuList li {
  margin: 0;
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--ac-latte);
  box-shadow: var(--shadow-menu);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: default;
}

#menuList li:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

#menuList .menu-icon {
  display: block;
  font-size: 20px;
  line-height: 1;
  margin-bottom: 6px;
}

#menuList strong {
  display: block;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  color: var(--ac-text);
}

#menuList .meta {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ac-text-secondary);
}

/* ---- Layout ---- */

.app-layout {
  height: calc(100vh - var(--topbar-h) - 36px);
  width: 100%;
  padding: 12px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  gap: 12px;
}

.left-rail,
.right-rail {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.left-rail .side-panel:first-child {
  flex: 0 0 auto;
  max-height: 40%;
}

.left-rail .side-panel:last-child,
.right-rail .side-panel {
  flex: 1 1 auto;
}

/* ---- Side panels ---- */

.side-panel {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: min-content 1fr;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--ac-border);
  border-radius: var(--radius-lg);
  background: var(--ac-latte);
  box-shadow: var(--shadow-sm);
}

.side-panel h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 14px;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--ac-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-panel h2 .panel-icon {
  font-size: 16px;
  line-height: 1;
}

.meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ac-text-muted);
}

/* ---- Feed lists ---- */

#chatList,
#presenceListFooter,
#ordersList {
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--ac-warm-gray) transparent;
}

#chatList::-webkit-scrollbar,
#presenceListFooter::-webkit-scrollbar,
#ordersList::-webkit-scrollbar {
  width: 4px;
}

#chatList::-webkit-scrollbar-thumb,
#presenceListFooter::-webkit-scrollbar-thumb,
#ordersList::-webkit-scrollbar-thumb {
  background: var(--ac-warm-gray);
  border-radius: 4px;
}

/* ---- Feed items ---- */

.feed-item {
  margin: 0 0 4px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: background 0.15s;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.feed-item:hover {
  background: var(--ac-cream);
}

.feed-item:last-child {
  margin-bottom: 0;
}

.feed-item .agent-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  margin-top: 1px;
}

.feed-item .feed-body {
  flex: 1;
  min-width: 0;
}

.feed-item .feed-body strong {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--ac-text);
}

.feed-item .feed-body .meta {
  margin-top: 2px;
}

/* ---- Chat items ---- */

.chat-item .feed-body .chat-text {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ac-text-secondary);
  word-break: break-word;
}

/* ---- Presence items ---- */

.presence-item .agent-dot {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.presence-item .feed-body .status-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: var(--ac-cream);
  color: var(--ac-text-muted);
}

.presence-item .feed-body .status-badge.active {
  background: rgba(127, 216, 88, 0.15);
  color: #4a8c2a;
}

/* ---- Empty states ---- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  text-align: center;
  color: var(--ac-text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state .empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.6;
}

/* ---- Feed item entrance animations ---- */

@keyframes slide-in {
  0%   { transform: translateY(-6px); opacity: 0 }
  100% { transform: translateY(0); opacity: 1 }
}

@keyframes fade-in {
  0%   { opacity: 0 }
  100% { opacity: 1 }
}

.feed-item.anim-wiggle {
  animation: slide-in 0.35s ease-out;
}

.feed-item.anim-flash {
  animation: slide-in 0.3s ease-out;
}

/* ---- Canvas / World ---- */

.world-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.world-stage {
  width: 100%;
  min-height: 0;
  border: 1px solid var(--ac-border);
  border-radius: var(--radius-lg);
  background: var(--ac-latte);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

canvas {
  max-width: 100%;
  max-height: calc(100vh - var(--topbar-h) - 82px);
  width: auto;
  height: auto;
  aspect-ratio: 5 / 3;
  border: none;
  border-radius: var(--radius-md);
  background: #fdfcfa;
}

/* ---- Responsive ---- */

@media (max-width: 1240px) {
  .app-layout {
    grid-template-columns: 220px minmax(0, 1fr) 260px;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }

  #menuList {
    flex-wrap: wrap;
  }

  #menuList li {
    flex: 1 1 40%;
  }

  .app-layout {
    height: auto;
    min-height: calc(100vh - var(--topbar-h));
    grid-template-columns: 1fr;
  }

  .left-rail .side-panel:first-child {
    max-height: none;
  }

  .side-panel {
    min-height: 200px;
  }

  .world-stage {
    min-height: 340px;
  }

  canvas {
    max-height: 400px;
  }

  .onboard-btn {
    order: 3;
    width: 100%;
  }
}

/* ---- Modal ---- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  position: relative;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  border-radius: var(--radius-lg);
  background: var(--ac-latte);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--ac-border);
  animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
  0%   { transform: translateY(12px) scale(0.97); opacity: 0 }
  100% { transform: translateY(0) scale(1); opacity: 1 }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--ac-cream);
  color: var(--ac-text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover {
  background: var(--ac-warm-gray);
}

.modal-title {
  margin: 0 0 4px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.modal-desc {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--ac-text-secondary);
}

.modal-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ac-espresso);
  color: #7FD858;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--ac-text);
  line-height: 24px;
}

.modal-code-wrap {
  position: relative;
  margin-bottom: 20px;
}

.modal-code {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--ac-espresso);
  color: #c8e6b8;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 12px;
  border: 1px solid rgba(127, 216, 88, 0.3);
  border-radius: 6px;
  background: rgba(127, 216, 88, 0.12);
  color: #7FD858;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.copy-btn:hover {
  background: rgba(127, 216, 88, 0.25);
}

/* ---- Footer ---- */

.site-footer {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ac-text-muted);
  border-top: 1px solid var(--ac-border);
  background: var(--ac-latte);
}

.site-footer a {
  color: var(--ac-text-secondary);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  color: var(--ac-text);
  text-decoration: underline;
}
