/* The chat panel, in the reference's colours (docs/site/index.html): purple accent, grey secondary text.
   System fonts only: the page's CSP loads nothing from other origins. */
:root {
  color-scheme: light dark;
  --text: #000;
  --text-2: #4d4d4d;
  --text-3: #737373;
  --bg: #fff;
  --bg-2: #fafafa;
  --bg-3: #ededed;
  --line: #e7e7e7;
  --accent: #8d4cff;
  --accent-bg: rgba(155, 98, 255, 0.1);
  --button: #9b62ff;
  --button-hover: #8d4cff;
  --error: #c92a3a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #fff;
    --text-2: #bfbfbf;
    --text-3: #8c8c8c;
    --bg: #121211;
    --bg-2: #1d1d1b;
    --bg-3: #2a2a28;
    --line: #2e2e2c;
    --accent: #b48cff;
    --accent-bg: rgba(155, 98, 255, 0.18);
    --error: #ff6775;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-size: 15px; font-weight: 600; }
header .actions { display: flex; gap: 6px; }
header button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text-2);
  border-radius: 6px;
  padding: 3px 9px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
header button:hover { background: var(--bg-3); }

main {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  overscroll-behavior: contain;
}
.intro { color: var(--text-2); }
.intro p { margin: 0 0 10px; }
.note { font-size: 12.5px; color: var(--text-3); }

.turn { margin: 0 0 16px; }
.turn.user .body {
  margin-left: 15%;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--accent-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.turn.assistant .body { overflow-wrap: break-word; }
.turn .body > :first-child { margin-top: 0; }
.turn .body > :last-child { margin-bottom: 0; }
.body p, .body ul, .body ol, .body blockquote { margin: 0 0 10px; }
.body ul, .body ol { padding-left: 20px; }
.body li + li { margin-top: 4px; }
.body h3, .body h4 { margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.body blockquote { padding-left: 10px; border-left: 3px solid var(--line); color: var(--text-2); }
.body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.body code {
  font: 12.5px var(--mono);
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-3);
}
.body .code { position: relative; margin: 0 0 10px; }
.body pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
}
.body pre code { padding: 0; background: none; white-space: pre; line-height: 1.55; }
.body .copy {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text-3);
  font: 12px var(--font);
  cursor: pointer;
}
.body .table { overflow-x: auto; margin: 0 0 10px; }
.body table { border-collapse: collapse; font-size: 13px; }
.body th, .body td { padding: 5px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.body th { background: var(--bg-2); font-weight: 600; }

.status { margin: 4px 0 0; color: var(--text-3); font-size: 12.5px; }
.status:empty { display: none; }
.error { margin: 6px 0 0; color: var(--error); font-size: 13px; }

#challenge { padding: 0 14px 10px; }

#unlock {
  display: block;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
}
#unlock[hidden] { display: none; }
#unlock label { display: block; margin-bottom: 8px; }
#unlock .row { display: flex; gap: 8px; }
#unlock input {
  flex: 1;
  height: 40px;
  padding: 0 11px;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
#unlock input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
#unlock button {
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#unlock button:hover { background: var(--button-hover); }
#ask[hidden] { display: none; }

form {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
}
textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  padding: 9px 11px;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
#send {
  align-self: flex-end;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#send:hover { background: var(--button-hover); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
