/*
 * Thinker: shared look of the console, the admin page and private input.
 * System fonts only and no outside assets; icons are data: images, which
 * every page's CSP allows.
 */
:root {
  --paper: #faf8f4;
  --surface: #ffffff;
  --sunken: #f2efe8;
  --ink: #1c1b19;
  --ink-2: #45423c;
  --muted: #6b675f;
  --line: #e6e1d8;
  --line-strong: #d3cdc1;
  --accent: #4d3fd6;
  --accent-hover: #3f32bd;
  --accent-soft: #eeebfc;
  --accent-ink: #2e2489;
  --idea: #ffc93c;
  --ok: #1d7a4a;
  --ok-soft: #e3f2e9;
  --warn-soft: #fff4d6;
  --warn-ink: #6b4d12;
  --danger: #a3271b;
  --danger-soft: #fdecea;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(28 27 25 / 5%), 0 4px 16px rgb(28 27 25 / 4%);
  --serif:
    ui-serif, "New York", "Iowan Old Style", Charter, "Bitstream Charter",
    Georgia, Cambria, serif;
  --sans:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234d3fd6' stroke-width='2' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
  --mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle fill='%234d3fd6' cx='18.5' cy='12.5' r='11.5'/%3E%3Ccircle fill='%23ffc93c' cx='18.5' cy='12.5' r='3.6'/%3E%3Ccircle fill='%234d3fd6' cx='6.5' cy='24.5' r='3'/%3E%3Ccircle fill='%234d3fd6' cx='2.6' cy='29.4' r='1.9'/%3E%3C/svg%3E");
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 19px;
  line-height: 1.3;
  margin: 0 0 6px;
}
p {
  font-size: 15px;
  line-height: 1.6;
  margin: 8px 0;
}
a {
  color: var(--accent);
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--sunken);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* Visually hidden but still read by screen readers and reachable by keyboard. */
.visually-hidden,
.attach input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  opacity: 0;
}

/* Brand: the thought-bubble mark and the serif wordmark. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.mark {
  width: 30px;
  height: 30px;
  flex: none;
}
.mark .bubble {
  fill: var(--accent);
}
.mark .spark {
  fill: var(--idea);
}
.wordmark {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.tag {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.tag:empty {
  display: none;
}

/* Controls. */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
button:hover,
a.button:hover {
  background: var(--sunken);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
.primary,
#send,
#cards .card button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.primary:hover,
#send:hover,
#cards .card button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.quiet,
a.button.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}
.quiet:hover,
a.button.quiet:hover {
  background: var(--sunken);
}
.danger {
  color: var(--danger);
  border-color: #e9c2bd;
}
.danger:hover {
  background: var(--danger-soft);
}
.small,
.task button,
details button,
.older-chat {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 13px;
}
input,
textarea,
select {
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 15px;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(77 63 214 / 22%);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Surfaces. */
.card,
#setup,
#signin {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.page > .card,
#setup,
#signin {
  margin-top: 20px;
}
.card p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.card .reference {
  font-size: 13px;
  color: var(--muted);
}
#error,
.error {
  margin: 16px 0;
  padding: 12px 16px;
  border: 1px solid #efc9c3;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}
.banner {
  padding: 12px 16px;
  border: 1px solid #ecd28c;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn-ink);
}

/* Top bar. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgb(250 248 244 / 92%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.topbar h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: inherit;
}
#status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.topbar select {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
}
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}
.page-footer {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}

/* Sign-in. */
#signin {
  max-width: 440px;
  margin: 8vh auto 0;
  text-align: center;
}
#signin .mark {
  width: 48px;
  height: 48px;
}
#signin h2 {
  font-size: 28px;
  margin: 16px 0 6px;
}
#signin p {
  color: var(--muted);
}
#signin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

/* Console chat. */
.console .page {
  padding-bottom: 0;
}
#chat {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px 0 28px;
  min-height: 240px;
}
#chat > .empty {
  max-width: 460px;
  margin: 0 auto;
  padding: 120px 12px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--mark) center 40px / 56px no-repeat;
}
.message {
  max-width: 86%;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.message.user {
  align-self: flex-end;
  padding: 12px 16px;
  border-radius: 18px 18px 6px 18px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.message.assistant {
  align-self: flex-start;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--idea);
}
.source {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 4px;
}
.message a.file {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  text-decoration: none;
}
.older-chat {
  align-self: center;
}
#stream {
  font-size: 15px;
  white-space: pre-wrap;
  color: var(--muted);
  padding-left: 19px;
  margin-bottom: 16px;
}
#cards .card {
  margin-bottom: 16px;
  border-color: #d9d4f7;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%);
}
#cards .card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
#cards .card h2::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: none;
  background: var(--lock) center / contain no-repeat;
}
details {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
summary {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
}
details[open] summary {
  border-bottom: 1px solid var(--line);
}
details > div {
  padding: 4px 16px 12px;
}
details > div:empty {
  display: none;
}
.task {
  margin: 12px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.task > strong:first-child {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.task p {
  font-size: 14px;
  margin: 6px 0;
}
.task > button {
  margin: 6px 8px 0 0;
}
#composer-dock {
  position: sticky;
  bottom: 0;
  padding: 12px 0 18px;
  background: linear-gradient(180deg, rgb(250 248 244 / 0%), var(--paper) 30%);
}
#composer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
#composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(77 63 214 / 18%);
}
#message {
  flex: 1;
  min-height: 44px;
  padding: 10px 8px;
  max-height: 40vh;
  border: 0;
  resize: none;
  field-sizing: content;
  line-height: 1.5;
}
#message:focus {
  box-shadow: none;
}
/* Without field-sizing the box cannot grow by itself, so it can be dragged. */
@supports not (field-sizing: content) {
  #message {
    resize: vertical;
  }
}
.attach {
  position: relative;
  order: -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--ink-2);
  cursor: pointer;
}
.attach:hover {
  background: var(--sunken);
}
.attach:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}
.attach svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#send {
  min-height: 44px;
  padding: 8px 20px;
}
#attached {
  flex-basis: 100%;
  margin: 0 8px 4px;
  font-size: 13px;
  color: var(--muted);
}

/* Setup. */
#setup-status {
  font-size: 13px;
  color: var(--muted);
}
#qr {
  display: block;
  width: 220px;
  height: 220px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}
#export {
  font-size: 14px;
}
.file-row,
.run {
  font-size: 13px;
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.run p,
.run li {
  font-size: 13px;
  margin: 2px 0;
  overflow-wrap: anywhere;
}
.run .reference {
  color: var(--muted);
}

/* Private input. */
.private .page {
  max-width: 560px;
}
.private #status {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--ink-2);
}
/* The page's last word (sent, cancelled, expired…) once nothing is left to do. */
.finished #status {
  margin-top: 8vh;
  padding: 96px 24px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface) var(--mark) center 28px / 48px no-repeat;
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 16px;
  color: var(--ink);
}
.private-note {
  padding: 12px 14px 12px 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft) var(--lock) 14px 14px / 16px no-repeat;
  color: var(--accent-ink);
  font-size: 14px;
}
.private-note:empty {
  display: none;
}
.private-fields {
  display: grid;
  gap: 14px;
  margin: 16px 0;
}
.private-field {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.private-field label {
  display: grid;
  gap: 6px;
  flex: 1;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
}
.private-field input {
  width: 100%;
  font-size: 16px;
}
/* A sign-in form on the private page: one labelled field per row. */
.form-field {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
}
.form-field input {
  width: 100%;
  font-size: 16px;
}
/* The tick that saves the login for this site; never ticked by default. */
.form-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--ink-2);
}
.form-remember input {
  width: 20px;
  height: 20px;
  flex: none;
}
.browser {
  display: block;
  width: 100%;
  height: auto;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: crosshair;
}
/* The site's current sign-in QR code, as large as the phone allows. */
.qr-image {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 12px auto;
  image-rendering: pixelated;
}
#actions {
  margin-top: 14px;
}

@media (max-width: 640px) {
  /* A wrapped bar would take too much of a phone screen if it stayed. */
  .topbar {
    position: static;
    flex-wrap: wrap;
    padding: 10px 14px;
  }
  .topbar .left {
    gap: 10px;
    flex-wrap: wrap;
  }
  .console .topbar .tag,
  .admin .topbar .tag {
    display: none;
  }
  .page {
    padding: 18px 14px 32px;
  }
  .card,
  #setup,
  #signin {
    padding: 18px;
  }
  .message {
    max-width: 94%;
  }
  .private-field {
    flex-direction: column;
    align-items: stretch;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
