:root {
  --bg: #f0f5ff;
  --card: #ffffff;
  --primary: #0f766e;
  --primary-soft: #99f6e4;
  --text: #0f172a;
  --muted: #64748b;
  --warn: #dc2626;
  --ok: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, #f0f5ff 0%, #e6fffb 100%);
  color: var(--text);
}

.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  margin-bottom: 16px;
}

.topbar h1,
.topbar p {
  margin: 4px 0;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
}

.panel {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

.panel h2,
.panel h3 {
  margin: 10px 0;
}

label {
  display: block;
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

select,
input,
textarea,
button {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 8px;
  margin-top: 6px;
  font-size: 0.95rem;
}

button {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  cursor: pointer;
}

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

.inline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.chat-wrap {
  background: var(--card);
  border-radius: 12px;
  min-height: 680px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: #f8fafc;
}

.msg {
  display: flex;
  margin: 8px 0;
}

.msg.assistant {
  justify-content: flex-start;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 75%;
  padding: 10px;
  border-radius: 14px;
  white-space: pre-wrap;
  line-height: 1.35;
}

.msg.assistant .bubble {
  background: #ecfeff;
  border: 1px solid #bae6fd;
}

.msg.user .bubble {
  background: #dcfce7;
  border: 1px solid #86efac;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e2e8f0;
}

.chat-form input {
  min-height: 40px;
}

.chat-form button {
  width: auto;
  min-width: 110px;
}

#stateBox {
  background: #f1f5f9;
  padding: 10px;
  min-height: 120px;
  border-radius: 8px;
  white-space: pre-wrap;
}

.flow-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 180px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.flow-list li {
  padding: 8px;
  cursor: pointer;
  border-bottom: 1px solid #e2e8f0;
}

.flow-list li.active {
  background: var(--primary-soft);
}

.flow-json {
  width: 100%;
  height: 100%;
  min-height: 560px;
  border: none;
  padding: 12px;
  font-family: ui-monospace, Menlo, Consolas, Monaco, monospace;
  background: #0f172a;
  color: #e2e8f0;
  resize: none;
}

.state-message {
  padding: 10px;
  border-radius: 8px;
  background: #ecfeff;
  color: #0f172a;
  margin-top: 8px;
  min-height: 36px;
}

.admin-layout {
  grid-template-columns: 330px 1fr;
}

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

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .chat-wrap {
    min-height: 560px;
  }
}
