/* The prompt field with the liquid metal running on its edge while it thinks: the chat of a made-up AI assistant
   (Ondra) on a near black page. The field is real; the metal on its edge is a WebGL canvas laid over it. */
:root {
  --page: #07080a;            /* the page */
  --page-light: #12151b;      /* the soft light behind the field */
  --field: #0e0f12;           /* the body of the field */
  --field-top: #15171b;       /* the light at the top of the field */
  --ink: #eceef2;             /* the words */
  --muted: #7d828c;           /* the small words and the placeholder */
  --line: rgba(255, 255, 255, 0.07); /* the thin lines */
  --accent: #a9d2ff;          /* ice blue: the glow of the metal, the stop square, the thinking sheen */
  --chrome-a: #f4f6fa;        /* the bright chrome of the fallback rim */
  --chrome-b: #5b616c;        /* the dark chrome of the fallback rim */
  --radius: 22px;             /* the corners of the field (the metal follows them) */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background:
    radial-gradient(60% 46% at 50% 62%, var(--page-light), transparent 72%),
    var(--page);
  color: var(--ink);
  font-family: 'Geist Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

.chat {
  width: min(540px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.4vh, 18px);
}

/* ---------------------------------------------------------------- the head */
.head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
}

.head__mark,
.reply__mark {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.head__name {
  font-size: 14px;
  font-weight: 560;
  letter-spacing: -0.01em;
}

.head__tag {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted);
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 99px;
}

/* ---------------------------------------------------------------- the thread above the field */
.thread {
  position: relative;
  height: clamp(92px, 24vh, 132px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 6px;
}

.ask {
  margin: 0;
  align-self: flex-end;
  max-width: 82%;
  opacity: 0;
}

.ask__in {
  display: block;
  padding: 9px 14px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink);
  background: linear-gradient(180deg, #1b1e23, #15171b);
  border: 1px solid var(--line);
  border-radius: 16px 16px 5px 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 18px -10px rgba(0, 0, 0, 0.8);
}

.reply {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 40px;
  opacity: 0;
}

.reply__mark {
  flex: none;
  margin-top: 1px;
}

.reply__body {
  position: relative;
  flex: 1;
  min-width: 0;
}

.thinking {
  position: absolute;
  left: 0;
  top: 1px;
  font-size: 13.5px;
  color: transparent;
  background: linear-gradient(90deg, #a3a8b2 0%, #a3a8b2 36%, #ffffff 46%, var(--accent) 52%, #a3a8b2 64%, #a3a8b2 100%) 0 0 / 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  opacity: 0;
}

.answer {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
}

.answer .w {
  display: inline-block;
  white-space: pre;
}

/* ---------------------------------------------------------------- the field */
.field {
  position: relative;
  margin: 0;
  padding: 14px 14px 10px 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--field-top), var(--field) 60%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 24px 48px -24px rgba(0, 0, 0, 0.9),
    0 2px 6px rgba(0, 0, 0, 0.5);
}

.field__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid var(--line);
  pointer-events: none;
}

.field__input {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 22px;
  caret-color: var(--accent);
}

.field__input::placeholder {
  color: var(--muted);
}

.field__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.tool {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.model {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  border-radius: 99px;
}

.model svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send {
  margin-left: auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 99px;
}

.send:disabled {
  cursor: default;
}

.send__face {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #2a2d33;
  color: #6f7480;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  transition: background-color 0.35s cubic-bezier(0.16, 1, 0.3, 1), color 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.send.is-ready .send__face,
.send.is-busy .send__face {
  background: linear-gradient(180deg, #ffffff, #d9dde4);
  color: #0b0c0e;
  box-shadow: 0 1px 0 #fff inset, 0 6px 14px -6px rgba(169, 210, 255, 0.45);
}

.send__arrow {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send__stop {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 3px;
  background: #0b0c0e;
  opacity: 0;
  transform: scale(0.4);
}

.send:focus-visible,
.tool:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (hover: hover) {
  .tool:hover {
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.16);
  }
}

/* ---------------------------------------------------------------- the metal (WebGL), over the edge of the field */
.metal {
  position: absolute;
  left: -40px;
  top: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  pointer-events: none;
}

.has-gl .field__rim {
  border-color: transparent;
}

/* without WebGL: a chrome rim in CSS, a conic gradient that turns and thickens while it thinks */
@property --turn {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.no-gl .metal {
  display: none;
}

.no-gl .field__rim {
  inset: -0.5px;
  border: 0;
  padding: 1px;
  background: conic-gradient(from var(--turn), var(--chrome-b), var(--chrome-a) 12%, var(--chrome-b) 26%, #2b2f36 50%, var(--chrome-a) 64%, var(--chrome-b) 80%, var(--chrome-b));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0.55;
  transition: padding 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), inset 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.no-gl .field.is-thinking .field__rim {
  inset: -1.5px;
  padding: 3px;
  opacity: 1;
  animation: rim-turn 2.4s linear infinite;
}

@keyframes rim-turn {
  to {
    --turn: 360deg;
  }
}

/* ---------------------------------------------------------------- the pointer of the walk on its own */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #ffffff;
  stroke: #0b0c0e;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

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

@media (prefers-reduced-motion: reduce) {
  .no-gl .field.is-thinking .field__rim {
    animation: none;
  }
}
