/* Engagement layer — light, calm, quietly premium. Violet accent on white,
   Poppins throughout. Motion carries the sense of something being built; the
   nodes are shape only, never content. */

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f2fd;      /* faint violet tint: inputs, your-message bubble */
  --ink: #14121a;          /* near-black */
  --ink-soft: #6b6675;     /* secondary text */
  --line: #e7e1f2;         /* light violet-grey border */
  --accent: #8A05FF;       /* brand violet — buttons, wordmark, area nodes */
  --accent-ink: #ffffff;   /* text on violet */
  --accent-soft: #c9a3ff;  /* light violet — the sweep highlight */
  --accent2: #e0851a;      /* artifact nodes — amber, for contrast on white */
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.6 "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.hidden { display: none !important; }

/* Wordmark — the living mark. A light sweeps through it while Clive composes. */
.wordmark {
  display: inline-flex; gap: 1px; font-weight: 700; letter-spacing: 0.16em;
  font-size: 20px; text-transform: uppercase; user-select: none;
}
.wordmark.big { font-size: 32px; margin-bottom: 6px; }
.wordmark span {
  color: var(--accent);
  background: linear-gradient(90deg, var(--accent) 40%, var(--accent-soft) 50%, var(--accent) 60%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  background-position: 100% 0;
}
body.thinking .wordmark span {
  -webkit-text-fill-color: transparent; color: transparent;
  animation: sweep 1.4s linear infinite;
}
body.thinking .wordmark span:nth-child(2) { animation-delay: 0.08s; }
body.thinking .wordmark span:nth-child(3) { animation-delay: 0.16s; }
body.thinking .wordmark span:nth-child(4) { animation-delay: 0.24s; }
body.thinking .wordmark span:nth-child(5) { animation-delay: 0.32s; }
@keyframes sweep { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Gate + closed panels */
.gate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #f3ebff, var(--bg)), var(--bg);
  padding: 24px; overflow-y: auto;
}
.gate-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 40px; width: 460px; max-width: 100%;
  box-shadow: 0 18px 50px rgba(138, 5, 255, 0.08);
}
.gate-box.wide { width: 560px; }
.lede { margin: 0 0 22px; color: var(--accent); font-size: 17px; font-weight: 500; }
.frame p { margin: 0 0 14px; color: var(--ink-soft); }
.gate-box h1 { font-size: 20px; margin: 6px 0 18px; font-weight: 600; }
.gate-box input {
  width: 100%; padding: 12px; font: inherit; font-size: 16px; margin: 22px 0 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--ink);
}
.gate-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 5, 255, 0.12); }
.error { color: #d62828; margin-top: 10px; min-height: 1em; font-size: 14px; }
.welcome { color: var(--accent); margin: 0 0 2px; font-size: 15px; font-weight: 500; }
.linky { background: transparent; border: none; color: var(--ink-soft); text-decoration: underline;
  padding: 6px 0 0; font-size: 13px; font-weight: 400; cursor: pointer; }
.linky:hover { color: var(--accent); }
.thanks { color: var(--ink); margin: 0 0 18px; font-size: 15px; line-height: 1.6; }

button {
  padding: 12px 20px; font: inherit; font-size: 15px; cursor: pointer; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px;
}
button.secondary { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); font-weight: 500; }
button.secondary:hover { color: var(--accent); border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.waiting { animation: waitpulse 1.6s ease-in-out infinite; }
@keyframes waitpulse { 0%, 100% { opacity: 0.65; } 50% { opacity: 1; } }

/* Surface: full-width header, then the two panes */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar { padding: 16px 24px; background: var(--accent); }
/* CLIVE reversed out to white on the violet bar (gate/close panels stay violet-on-white) */
.topbar .wordmark span {
  color: #fff;
  background: linear-gradient(90deg, #fff 40%, #e9d5ff 50%, #fff 60%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  background-position: 100% 0;
}
.panes { flex: 1; display: flex; min-height: 0; }
.left { flex: 1 1 58%; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-width: 0; }
.right { flex: 1 1 42%; max-width: 460px; position: relative; background: var(--panel-2); }

.transcript { flex: 1; overflow-y: auto; padding: 24px 24px 44px; }
.msg { margin: 0 0 20px; max-width: 680px; white-space: pre-wrap; }
.msg .who { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 5px; }
.msg.you { margin-left: auto; }
.msg.you .body { background: var(--panel-2); padding: 10px 14px; border-radius: 10px; }
.msg.thinking .body { color: var(--ink-soft); }
.dots span { animation: blink 1.2s infinite both; }
.dots span:nth-child(2){ animation-delay:.2s } .dots span:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }

.composer { border-top: 1px solid var(--line); padding: 20px 24px; }
.composer textarea { width: 100%; padding: 12px; font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 5, 255, 0.12); }
.composer-row { display: flex; gap: 10px; margin-top: 10px; justify-content: space-between; }
.left-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.right-controls { display: flex; gap: 10px; align-items: center; }
.mic { background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  padding: 10px 12px; display: inline-flex; align-items: center; justify-content: center; }
.mic:hover { color: var(--accent); border-color: var(--accent); }
.mic.recording { background: #e53e3e; border-color: #e53e3e; color: #fff;
  animation: micpulse 1.2s ease-in-out infinite; }
.mic.unsupported { opacity: 0.4; cursor: not-allowed; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,62,62,0.5); } 50% { box-shadow: 0 0 0 8px rgba(229,62,62,0); } }

/* Brain pane */
.brain { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.pane-empty { position: absolute; left: 0; right: 0; bottom: 28px; text-align: center; color: var(--ink-soft); font-style: italic; font-size: 14px; }

/* Close panel */
#measurements { margin: 8px 0 18px; }
#measurements table { width: 100%; border-collapse: collapse; font-size: 14px; }
#measurements td { padding: 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
#measurements td:first-child { color: var(--ink-soft); padding-right: 16px; white-space: nowrap; }
#artifacts-close h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 18px 0 8px; }
#artifacts-close ul { list-style: none; margin: 0; padding: 0; }
#artifacts-close li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
#artifacts-close .connect { font-size: 13px; padding: 6px 12px; }

@media (prefers-reduced-motion: reduce) {
  body.thinking .wordmark span { animation-duration: 3s; }
}

/* ---- responsive: phones and narrow windows ---- */
@media (max-width: 760px) {
  .app { height: 100dvh; }
  .panes { flex-direction: column; }
  /* pinned strip: flex-basis, not height, so it actually holds its size */
  .right { order: 0; flex: 0 0 140px; width: 100%; max-width: none;
    border-right: none; border-bottom: 1px solid var(--line); }
  /* labels are tiny at desktop sizes in a short strip — bump them so they read */
  .brain text { font-size: 18px; }
  .left { order: 1; flex: 1 1 auto; min-height: 0; border-right: none; }
  .topbar { padding: 12px 16px; text-align: center; }
  .topbar .wordmark { font-size: 30px; }
  .transcript { padding: 16px; }
  .msg { max-width: 100%; }
  .composer { padding: 12px 16px; }
  /* short labels let Finish · Pause · mic · Send share one row, freeing height */
  .composer-row { gap: 8px; }
  .left-controls { gap: 8px; }
  .composer-row button { padding: 10px 14px; font-size: 14px; }
  /* intro + close panels: anchor to top and scroll, so landscape shows the start */
  .gate { align-items: flex-start; padding: 20px 16px; }
  .gate-box, .gate-box.wide { width: 100%; padding: 24px; }
  .wordmark.big { font-size: 28px; }
  .lede { font-size: 16px; margin-bottom: 18px; }
  .frame p { font-size: 15px; }
}
