/* Builder tools: the look of the chat page (kit/chat.js). Walkthroughs use kit/kit.css instead.
   Black and white and quiet, like ChatGPT; Newsreader (serif) for the headline, the tool name and headings, Inter for
   everything else. The tool's own colour (site.json accent / accentDark) appears only in small places: the favicon,
   highlights in examples, and a site's own drawings (var(--tool)). Follows the system light / dark setting. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,400;6..72,500&display=swap');

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f4f4f4; --border: #e5e5e5; --border-strong: #cfcfcf;
  --ink: #0d0d0d; --muted: #5d5d5d; --faint: #8f8f8f;
  --accent: #0d0d0d; --accent-ink: #ffffff;
  --tool: var(--tool-accent, #3b78d8);
  --code-bg: #f9f9f9; --code-ink: #0d0d0d; --code-head: #5d5d5d; --code-border: #ececec;
  --bubble-bg: #f4f4f4;
  --error-bg: #fef2f2; --error-ink: #b91c1c;
  --good: #2e8b57; --bad: #c2453d; --warn: #b45309;
  --r-box: 28px; --shadow-box: 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 28px rgba(0, 0, 0, 0.07);
  --col: 768px; --top-h: 56px;
  /* names used by site drawings written for kit.css (e.g. the harness diagram) */
  --panel: var(--surface); --panel-2: var(--surface-2); --edge: var(--border); --edge-strong: var(--border-strong);
  --body: var(--font); --head: var(--font-display);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121; --surface: #303030; --surface-2: #2a2a2a; --border: #3d3d3d; --border-strong: #565656;
    --ink: #ececec; --muted: #b4b4b4; --faint: #8a8a8a;
    --accent: #ececec; --accent-ink: #0d0d0d;
    --tool: var(--tool-accent-dark, #6fa3f0);
    --code-bg: #181818; --code-ink: #e8e8e8; --code-head: #a8a8a8; --code-border: #2e2e2e;
    --bubble-bg: #303030; --shadow-box: none;
    --error-bg: #3b1d1d; --error-ink: #fca5a5;
    --good: #5cc48a; --bad: #ef7d73; --warn: #fbbf24;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.65 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 2px; }

/* ---------- top bar ---------- */
.c-top {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px 0 20px; background: var(--bg);
}
.c-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.c-mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); }
.c-name { font: 500 18px/1.2 var(--font-display); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.c-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; background: transparent; font-size: 14px; font-weight: 500; color: var(--ink); transition: background 0.15s;
}
.c-pill:hover { background: var(--surface-2); }
.is-empty .c-new { visibility: hidden; }
.c-icon-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 1px solid var(--border);
  background: transparent; color: var(--ink); transition: background 0.15s;
}
.c-icon-btn:hover { background: var(--surface-2); }
/* the "?" stands out: filled, with a soft ring; the same look in the "New here?" line */
.c-help-btn {
  width: 38px; height: 38px; border: 0; background: var(--ink); color: var(--bg); font-size: 16px; font-weight: 600;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 10%, transparent), 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s, box-shadow 0.15s;
}
.c-help-btn:hover { background: var(--ink); transform: scale(1.06); box-shadow: 0 0 0 6px color-mix(in srgb, var(--ink) 12%, transparent), 0 6px 18px rgba(0, 0, 0, 0.22); }

/* ---------- empty chat: everything in the middle ---------- */
.c-hero { display: none; }
.is-empty .c-hero { display: flex; min-height: calc(100vh - var(--top-h)); min-height: calc(100dvh - var(--top-h)); align-items: center; justify-content: center; padding: 0 16px 12vh; }
.c-hero-in { width: 100%; max-width: var(--col); text-align: center; }
.c-headline { margin: 0 0 12px; font: 400 46px/1.1 var(--font-display); letter-spacing: -0.02em; }
.c-tagline { margin: 0 auto 28px; max-width: 580px; color: var(--muted); font-size: 16.5px; line-height: 1.55; }
.c-hero-slot { text-align: left; }
.c-hint { margin: 18px 0 0; font-size: 14px; color: var(--muted); }
.c-q {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0; margin: 0 2px;
  background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; cursor: pointer; transition: transform 0.12s;
}
.c-q:hover { transform: scale(1.08); }

/* ---------- the input ---------- */
.c-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-box); box-shadow: var(--shadow-box);
  padding: 14px 12px 10px 20px; transition: border-color 0.15s;
}
.c-box:focus-within { border-color: var(--border-strong); }
.c-input {
  display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink);
  font: 16px/1.55 var(--font); padding: 4px 0 6px; max-height: 240px; min-height: 30px;
}
.c-input::placeholder { color: var(--faint); }
.c-box-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 36px; }
.c-send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); transition: opacity 0.15s, transform 0.1s;
}
.c-send:disabled { opacity: 0.25; cursor: default; }
.c-send:not(:disabled):active { transform: scale(0.94); }
.c-send[hidden] { display: none; }

/* ---------- the conversation ---------- */
.c-thread { max-width: var(--col); margin: 0 auto; padding: 20px 20px 200px; display: flex; flex-direction: column; gap: 28px; }
.is-empty .c-thread { display: none; }
.c-turn.user { display: flex; justify-content: flex-end; }
.c-bubble { max-width: 80%; background: var(--bubble-bg); border-radius: 20px; padding: 10px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.c-answer { min-width: 0; overflow-wrap: anywhere; }
.c-answer > :first-child { margin-top: 0; }
.c-answer > :last-child { margin-bottom: 0; }
.c-answer p { margin: 0 0 14px; }
.c-answer ul, .c-answer ol { margin: 0 0 14px; padding-left: 22px; }
.c-answer li { margin: 4px 0; }
.c-answer h2, .c-answer h3, .c-answer h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; line-height: 1.3; margin: 24px 0 10px; }
.c-answer h2 { font-size: 24px; } .c-answer h3 { font-size: 20.5px; } .c-answer h4 { font-size: 18px; }
.c-answer blockquote { margin: 12px 0; padding: 2px 16px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.c-answer hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.c-answer code { font: 0.875em var(--mono); background: var(--surface-2); border-radius: 6px; padding: 0.1em 0.4em; }
.c-actions { display: flex; gap: 4px; margin-top: 8px; }
.c-act {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.c-act:hover { background: var(--surface-2); color: var(--ink); }
.c-typing { display: flex; gap: 5px; padding: 8px 0; }
.c-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: 0.35; animation: c-blink 1.2s infinite; }
.c-typing i:nth-child(2) { animation-delay: 0.2s; } .c-typing i:nth-child(3) { animation-delay: 0.4s; }
/* A long answer (a whole system prompt) can take some seconds to start: after 2.5 s the dots get a word of explanation. */
.c-typing { align-items: center; }
.c-typing .c-wait { margin-left: 8px; color: var(--muted); font-size: 14px; opacity: 0; animation: c-wait-in 0.4s 2.5s forwards; }
@keyframes c-wait-in { to { opacity: 1; } }
@keyframes c-blink { 50% { opacity: 1; } }
.c-limit { margin-top: 10px; color: var(--warn); font-size: 14px; font-weight: 500; }
.k-error { color: var(--error-ink); background: var(--error-bg); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
.k-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.k-loading::before { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--ink); animation: c-spin 0.8s linear infinite; }
@keyframes c-spin { to { transform: rotate(360deg); } }

/* ---------- the input docked at the bottom once the chat has started ---------- */
.c-dock { display: none; }
.c-app:not(.is-empty) .c-dock {
  display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 28px 16px 10px;
  background: linear-gradient(to bottom, transparent, var(--bg) 34%);
}
.c-dock-in { max-width: var(--col); margin: 0 auto; }
.c-dock-note { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- code and result blocks (md() / renderBlocks()) ---------- */
.k-code { margin: 14px 0; border-radius: 14px; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--code-border); overflow: hidden; }
.k-code-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; font-size: 12.5px; font-weight: 500; color: var(--code-head); border-bottom: 1px solid var(--code-border); }
.k-code pre { margin: 0; padding: 14px 16px; overflow: auto; font: 13.5px/1.6 var(--mono); white-space: pre; }
.k-code pre.wrap { white-space: pre-wrap; word-break: break-word; }
.k-code code { background: none; border: 0; padding: 0; color: inherit; font: inherit; }
.k-code-btns { display: flex; gap: 4px; }
.k-copy { font-size: 12.5px; font-weight: 500; color: var(--code-head); background: transparent; border: 0; border-radius: 7px; padding: 5px 9px; cursor: pointer; }
.k-copy:hover { background: color-mix(in srgb, var(--code-ink) 9%, transparent); color: var(--code-ink); }
.k-code.k-result { border-color: var(--border-strong); }

.k-table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--border); border-radius: 12px; }
.k-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.k-table th, .k-table td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.k-table th { font-weight: 600; font-size: 13px; color: var(--muted); background: var(--surface-2); }
.k-table tr:last-child td { border-bottom: 0; }

/* buttons a site draws inside an answer (e.g. a "Download design" button) */
.k-btn {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg); font-size: 13.5px; font-weight: 500;
}
.k-btn.ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.k-btn:hover { opacity: 0.88; }
.k-btn.ghost:hover { opacity: 1; background: var(--surface-2); }

/* technique chips: click to see the one-line explanation */
.k-term {
  font: 500 13px/1.3 var(--font); color: var(--ink); background: transparent; border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 1px 7px; cursor: pointer; white-space: nowrap; vertical-align: 1px;
}
.k-term:hover { background: var(--surface-2); }
.k-term.unknown { color: var(--muted); }
.k-term-pop {
  position: absolute; z-index: 40; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14); padding: 12px 14px; font-size: 14px; line-height: 1.5;
}
.k-term-pop b { display: block; margin-bottom: 4px; }

/* ---------- the "?" panel ---------- */
dialog.c-help {
  border: 1px solid var(--border); border-radius: 20px; padding: 0; max-width: 620px; width: calc(100% - 32px); max-height: 86vh;
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}
dialog.c-help::backdrop { background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(2px); }
.c-help-in { padding: 22px 26px 26px; }
.c-help-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.c-help-top h2 { margin: 0; font: 500 26px/1.2 var(--font-display); letter-spacing: -0.01em; }
.c-help-lead { color: var(--muted); margin: 10px 0 0; }
.c-help h3 { margin: 22px 0 6px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.c-help p, .c-help ul, .c-help ol { margin: 0 0 8px; font-size: 15px; }
.c-help ol, .c-help ul { padding-left: 20px; }
.c-help li { margin: 4px 0; }

.k-toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 50; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.k-toast.on { opacity: 1; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .c-top { padding: 0 10px 0 14px; }
  .c-name { font-size: 17px; }
  .c-new span { display: none; }
  .c-new { width: 36px; padding: 0; justify-content: center; }
  .c-headline { font-size: 34px; }
  .c-tagline { font-size: 15px; margin-bottom: 20px; }
  .is-empty .c-hero { padding-bottom: 8vh; }
  .c-thread { padding: 12px 14px 190px; }
  .c-bubble { max-width: 88%; }
}
