/* Panel styling: plain system font, neutral colours, no external assets.
   The iframe fills the left; the 380px panel sits on the right and stacks below
   the stage on narrow screens. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #dfe3e8;
  --text: #1d2229;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --visitor: #e8f0fe;
  --guide: #f1f3f5;
  --error: #b91c1c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

.layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

.stage {
  flex: 1 1 auto;
  min-width: 0;
  background: #fff;
}

.stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.panel {
  flex: 0 0 380px;
  width: 380px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-head h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

button {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover { background: #f3f4f6; }
button:disabled { opacity: 0.5; cursor: default; }

.transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.guide {
  align-self: flex-start;
  background: var(--guide);
  border-bottom-left-radius: 4px;
}

.msg.visitor {
  align-self: flex-end;
  background: var(--visitor);
  border-bottom-right-radius: 4px;
}

.msg.error {
  align-self: stretch;
  max-width: none;
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}

.msg.streaming::after {
  content: "▍";
  color: var(--muted);
  animation: blink 1s steps(2) infinite;
}

@keyframes blink { to { visibility: hidden; } }

.status {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  min-height: 28px;
}

.status.busy::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

.composer input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.composer input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

#btn-send {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

#btn-send:hover { filter: brightness(1.05); }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .stage { flex: 0 0 50vh; flex-basis: 50dvh; }
  .panel {
    flex: 1 1 auto;
    width: auto;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .panel-head h1 { font-size: 15px; }
  button { padding: 6px 8px; }
}
