* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #f7f7f9;
  color: #1d1d1f;
}
a { color: #0a66c2; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e5e9;
}
.topbar h1 { font-size: 16px; margin: 0; }
.topbar nav a {
  margin-left: 16px;
  font-size: 14px;
  color: #555;
}
.topbar nav a.active { color: #0a66c2; font-weight: 600; }

.container { max-width: 980px; margin: 0 auto; padding: 24px; }
.container.wide { max-width: 1280px; }

.card {
  background: #fff;
  border: 1px solid #e5e5e9;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 { font-size: 15px; margin: 0 0 12px; }
.card .hint { color: #777; font-size: 12px; margin-bottom: 12px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  margin-bottom: 4px;
  margin-top: 12px;
}
input[type=text], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d1d6;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 100px;
  resize: vertical;
}
textarea.big { min-height: 260px; }

button, .btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #d1d1d6;
  border-radius: 6px;
  background: #fff;
  color: #1d1d1f;
  font-size: 13px;
  cursor: pointer;
  margin-right: 8px;
  margin-top: 12px;
}
button.primary, .btn.primary {
  background: #0a66c2;
  border-color: #0a66c2;
  color: #fff;
}
button.danger { background: #fff; border-color: #d34c4c; color: #d34c4c; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid.three { grid-template-columns: repeat(3, 1fr); }

.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.list-table th, .list-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
}
.list-table th { background: #fafafa; font-size: 11px; text-transform: uppercase; color: #777; }

.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
}
.chat .messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e5e9;
  border-radius: 8px;
  margin-bottom: 12px;
}
.message {
  margin-bottom: 12px;
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}
.message.user {
  background: #0a66c2;
  color: #fff;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.message.ai {
  background: #f0f0f3;
  color: #1d1d1f;
  border-bottom-left-radius: 4px;
}
.message.pending { opacity: 0.55; font-style: italic; }
.message .meta { font-size: 11px; opacity: 0.6; margin-bottom: 2px; }
.message .body { white-space: pre-wrap; }

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mic-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #d34c4c;
  color: #fff;
  font-size: 18px;
  border: none;
  margin: 0;
}
.mic-btn.recording { background: #b53636; box-shadow: 0 0 0 6px rgba(211, 76, 76, 0.2); }
.mic-btn:disabled { background: #999; }

.status {
  font-size: 13px;
  color: #555;
  padding: 8px 12px;
  background: #fafafa;
  border-radius: 6px;
}

.call-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
}

/* On the call screen, pin the layout to the viewport so the chat list scrolls
   inside its panel instead of pushing the controls off-screen. Scoped via
   body.call-page so other pages (Prompts, Avatars, etc.) keep normal page-scroll. */
body.call-page,
body.call-page html { height: 100%; }
body.call-page { height: 100vh; overflow: hidden; }
body.call-page .container.wide {
  height: calc(100vh - 50px); /* topbar */
  padding-top: 16px;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
body.call-page .call-grid {
  flex: 1;
  min-height: 0;
}
body.call-page .call-grid > div:first-child {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
body.call-page .call-grid > div:first-child > .card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-height: 0;
}
body.call-page .messages {
  flex: 1;
  max-height: 68vh;
  overflow: auto;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e5e9;
  border-radius: 8px;
  margin-bottom: 12px;
}
body.call-page .call-grid .side {
  height: 100%;
  overflow-y: auto;
  min-height: 0;
}
.call-grid .side .card { margin-bottom: 12px; }
.call-grid .side h3 { font-size: 13px; margin: 0 0 8px; color: #555; }
.preview-json {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  background: #fafafa;
  padding: 10px;
  border-radius: 6px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.tag { display: inline-block; padding: 2px 8px; font-size: 11px; background: #eee; border-radius: 10px; margin-right: 4px; }
