* { box-sizing: border-box; }

:root {
  --border: #e5e7eb;
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #111827;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --radius: 10px;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topnav {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
.tagline { color: var(--muted); font-size: 12px; }
.topnav { align-items: center; }
.nav-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.nav-link:hover { color: var(--text); }
.logout-form { display: inline; margin-left: 14px; }
.linklike { background: none; border: none; padding: 0; cursor: pointer; font: inherit; }

.update-banner {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100;
  display: flex; align-items: center; gap: 10px;
  background: var(--accent); color: var(--accent-text);
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.update-banner .btn { background: var(--panel); }

.login-wrap { display: flex; justify-content: center; padding-top: 60px; }
.login-panel { width: 380px; }
.login-panel h1 { margin-top: 0; font-size: 20px; }

.page { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }

/* ---------- agent list ---------- */
.list-header { display: flex; justify-content: space-between; align-items: center; }
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.agent-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .15s, border-color .15s;
}
.agent-card:hover { border-color: #c7cdd6; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.agent-card-name { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.agent-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.agent-card-prompt { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.empty-state {
  background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 40px; text-align: center; color: var(--muted);
}

/* ---------- pills / buttons / inputs ---------- */
.pill {
  display: inline-block; padding: 2px 9px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 11.5px; color: var(--muted); background: var(--bg);
}
.pill.muted { opacity: .6; }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { opacity: .88; }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; }

.pill-select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel); font-size: 13px; max-width: 230px;
}

/* ---------- agent editor ---------- */
.agent-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px;
}
.agent-name-input {
  font-size: 16px; font-weight: 600; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 8px; background: transparent; min-width: 200px;
}
.agent-name-input:hover, .agent-name-input:focus { border-color: var(--border); background: var(--panel); outline: none; }
.mono, code { font-family: Consolas, "Cascadia Code", monospace; }
.spacer { flex: 1; }
.saved-flash { color: #059669; font-size: 13px; }
.temp-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.temp-input { width: 60px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 8px; }
.check-label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }

.agent-layout, .fn-layout {
  display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start;
}
@media (max-width: 900px) { .agent-layout, .fn-layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 8px; }
.panel h2:first-child, .panel-head h2 { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.hint-inline { text-transform: none; letter-spacing: 0; font-weight: 400; }
.hint.warn { color: #b45309; }

.prompt-box {
  width: 100%; min-height: 420px; resize: vertical;
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: Consolas, "Cascadia Code", monospace; font-size: 13px; line-height: 1.55;
}
.welcome-row { display: flex; gap: 10px; }
.welcome-input { flex: 1; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }

.side-column { display: flex; flex-direction: column; gap: 16px; }

.fn-list { list-style: none; margin: 0; padding: 0; }
.fn-list li { border-top: 1px solid var(--border); }
.fn-list li:first-child { border-top: none; }
.fn-link { display: block; padding: 9px 4px; text-decoration: none; color: var(--text); }
.fn-link:hover { background: var(--bg); }
.fn-link code { font-size: 13px; }
.fn-desc { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- chat tester ---------- */
.chat-log {
  height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 8px;
  resize: vertical; min-height: 180px; max-height: 85vh;
}
.transcript-log { height: auto; max-height: none; resize: none; }
.call-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.call-row .fn-desc { flex-basis: 100%; margin-top: 2px; }
.call-kind { font-size: 16px; }
.call-date { color: var(--muted); font-size: 12px; }
.bubble { max-width: 85%; padding: 7px 11px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); }
.bubble.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }
.bubble.tool { align-self: stretch; max-width: 100%; background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3; font-family: Consolas, monospace; font-size: 11.5px; }
.bubble.error { align-self: stretch; max-width: 100%; background: #fef2f2; border: 1px solid #fca5a5; color: var(--danger); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }

.voice-controls { display: flex; gap: 8px; margin-bottom: 10px; }
.voice-log { height: 180px; }
.voice-log:empty { display: none; }

/* ---------- function editor ---------- */
.breadcrumb { margin: 0 0 12px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.code-box {
  width: 100%; min-height: 140px; resize: vertical;
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: Consolas, "Cascadia Code", monospace; font-size: 13px; line-height: 1.5;
  background: #0b1220; color: #e2e8f0;
}
.code-box.tall { min-height: 320px; }
.test-output {
  margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--bg);
  border: 1px solid var(--border); font-size: 12px; white-space: pre-wrap; min-height: 40px;
}
.test-output.error { background: #fef2f2; border-color: #fca5a5; color: var(--danger); }

.danger-zone { margin-top: 24px; }

/* ---------- settings: api connections ---------- */
.conn-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 4px; }
.conn-form { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.conn-form textarea { resize: vertical; font-family: inherit; }
