:root {
  --bg-1: #f8f3ea;
  --bg-2: #f0f8f3;
  --ink: #1f2c24;
  --ink-soft: #4f6458;
  --line: #d7e2d9;
  --brand: #0e7a64;
  --brand-2: #d86c2f;
  --panel: rgba(255, 255, 255, 0.82);
  --ok: #1f9959;
  --warn: #dd8a21;
  --danger: #c7362f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 20%, #fff6e5, transparent 45%),
    radial-gradient(circle at 90% 10%, #e6fff1, transparent 40%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2));
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(6px);
  opacity: 0.45;
}

.bg-shape-1 {
  width: 300px;
  height: 300px;
  left: -90px;
  top: 60px;
  background: linear-gradient(60deg, #ffd4aa, #fff7e8);
  animation: driftA 16s infinite ease-in-out;
}

.bg-shape-2 {
  width: 380px;
  height: 380px;
  right: -130px;
  top: 140px;
  background: linear-gradient(60deg, #b6f2d2, #e4fff3);
  animation: driftB 20s infinite ease-in-out;
}

@keyframes driftA {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(24px) rotate(8deg);
  }
}

@keyframes driftB {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(-9deg);
  }
}

.topbar {
  padding: 20px 24px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.02em;
}

.room-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.scope-hint {
  width: 100%;
  color: var(--ink-soft);
  font-size: 12px;
  padding: 2px 0 0;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.layout {
  padding: 12px 20px 24px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.4fr) minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 18px rgba(35, 56, 44, 0.09);
  animation: reveal 0.4s ease;
  min-width: 0;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  margin: 8px 0 10px;
  font-size: 15px;
  color: #17382d;
}

label {
  font-size: 12px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.create-agents-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-soft);
}

.create-agents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.create-agent-row {
  border: 1px solid #dbe8e0;
  border-radius: 10px;
  padding: 8px;
  background: #fdfefd;
  display: grid;
  gap: 6px;
}

input,
select,
textarea,
button {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(14, 122, 100, 0.2);
  border-color: var(--brand);
}

button {
  cursor: pointer;
  border: 0;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

button:active {
  transform: translateY(0);
}

button.ghost {
  background: #f4f8f6;
  color: #1f6555;
  border: 1px solid var(--line);
}

button.warn {
  background: var(--warn);
}

button.ok {
  background: var(--ok);
}

button.danger {
  background: var(--danger);
}

.inline-group {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.meta-box {
  border: 1px dashed #bad0c2;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  padding: 10px;
  line-height: 1.45;
  color: var(--ink-soft);
  margin-bottom: 10px;
  min-height: 92px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#liveBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  background: #e7f8ee;
  color: #1c7c4b;
  border: 1px solid #bde9ce;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.timeline {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  max-height: 70vh;
  overflow: auto;
  padding: 10px;
}

.left-panel,
.right-panel {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.right-panel {
  position: sticky;
  top: 10px;
}

.msg,
.memory-item {
  border: 1px solid #deebe3;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  background: #fcfffd;
  padding: 10px;
  margin-bottom: 8px;
}

.msg.system {
  border-left-color: var(--brand-2);
  background: #fff9f4;
}

.msg-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.name {
  font-weight: 700;
  color: #114435;
}

.meta {
  color: #6a8374;
  font-size: 11px;
}

.msg-body {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 13px;
}

.msg-citations {
  margin-top: 6px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.chip {
  background: #eff8f2;
  border: 1px solid #d6ebde;
  color: #27614d;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.memory-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  max-height: 44vh;
  overflow: auto;
  padding: 10px;
  margin-bottom: 12px;
}

.console {
  border: 1px solid #c7ddd1;
  border-radius: 12px;
  background: #11352c;
  color: #d9f8e8;
  max-height: 25vh;
  overflow: auto;
  padding: 10px;
  font-size: 11px;
  line-height: 1.45;
}

.preset-panel {
  border: 1px solid #dbe8e0;
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.78);
  margin-bottom: 12px;
}

.preset-panel > summary {
  cursor: pointer;
  font-weight: 700;
  color: #1f6555;
}

.preset-panel[open] > summary {
  margin-bottom: 8px;
}

.preset-panel textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  max-height: 240px;
}

.advanced-editor {
  border: 1px dashed #cfe0d6;
  border-radius: 10px;
  padding: 8px;
  background: #fbfdfc;
}

.advanced-editor > summary {
  cursor: pointer;
  color: #376b58;
  font-size: 12px;
}

.preset-library {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preset-card {
  border: 1px solid #dbe8e0;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
}

.preset-title {
  font-weight: 700;
  color: #143f33;
  font-size: 13px;
}

.preset-desc {
  color: #5b7266;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 2px;
}

.preset-meta {
  margin-top: 4px;
  color: #2d5a4a;
  font-size: 11px;
}

.empty {
  color: #789084;
  text-align: center;
  padding: 20px 8px;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .right-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .timeline,
  .memory-list,
  .console {
    max-height: 40vh;
  }

  .filter-row {
    grid-template-columns: 1fr 1fr;
  }
}
