:root {
  --bg: #f4f2ed;
  --paper: #ffffff;
  --ink: #16171a;
  --ink-2: #4a4c53;
  --ink-3: #8b8d94;
  --line: rgba(22, 23, 26, 0.08);
  --accent: #3550ff;
  --accent-soft: rgba(53, 80, 255, 0.1);
  --accent-glow: rgba(53, 80, 255, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 60%),
    var(--bg);
}

/* the grain of the page, very soft */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the soft light that sits behind the field and follows it */
.glow {
  position: absolute;
  left: 0;
  top: 0;
  width: min(80vw, 90vh, 720px);
  aspect-ratio: 2.2 / 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-glow), rgba(53, 80, 255, 0) 100%);
  filter: blur(18px);
  pointer-events: none;
  z-index: 0;
  will-change: transform, opacity;
}

.brand {
  position: absolute;
  top: clamp(12px, 3.4vh, 26px);
  left: clamp(14px, 3vw, 30px);
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 6;
  font-size: 14px;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
}
.brand__mark { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand__beam { stroke: var(--accent); }

/* ------------------------------------------------------------------ home */
.home {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3.4vh, 26px);
  padding: 0 18px;
  z-index: 2;
  pointer-events: none;
}
.home__head {
  margin: 0;
  text-align: center;
  font-size: clamp(20px, min(5.4vw, 5.6vh), 38px);
  line-height: 1.12;
  font-weight: 600;
  font-stretch: 96%;
  letter-spacing: -0.025em;
}
.home__head span { display: block; color: var(--ink-3); font-weight: 480; }
.home__slot {
  width: min(560px, 100%);
  height: clamp(48px, 8.4vh, 60px);
}
.home__hint {
  margin: 0;
  font-size: clamp(11px, 1.9vh, 12.5px);
  color: var(--ink-3);
  font-stretch: 102%;
}
.home__hint kbd {
  display: inline-block;
  padding: 1px 6px 2px;
  margin: 0 2px;
  font: inherit;
  font-weight: 560;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------ the field that flies */
.ask {
  position: absolute;
  inset: 0;
  margin: 0;
  z-index: 5;
  pointer-events: none;
}
.ask__shell {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 999px;
  background: var(--paper);
  box-shadow:
    0 0 0 1px rgba(22, 23, 26, 0.07),
    0 1px 1px rgba(22, 23, 26, 0.04),
    0 6px 14px -6px rgba(22, 23, 26, 0.1),
    0 22px 44px -18px rgba(40, 52, 120, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 1);
  pointer-events: auto;
}
.ask__shell.is-flown { pointer-events: none; }
.ask__lens {
  position: absolute;
  left: 18px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.5;
  stroke-linecap: round;
}
.ask__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0 56px 0 44px;
  border: 0;
  outline: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  font-size: 16px;
  border-radius: inherit;
}
.ask__shell:focus-within { box-shadow:
    0 0 0 1px rgba(53, 80, 255, 0.5),
    0 0 0 4px rgba(53, 80, 255, 0.1),
    0 6px 14px -6px rgba(22, 23, 26, 0.1),
    0 22px 44px -18px rgba(40, 52, 120, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 1); }
.ask__send {
  position: absolute;
  right: 7px;
  top: 50%;
  width: 38px;
  height: 38px;
  margin-top: -19px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 50%;
}
.ask__send-face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(180deg, #2a2c33, var(--ink));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 6px -2px rgba(22, 23, 26, 0.5);
}
.ask__send svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ask__send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ask__text {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font-weight: 600;
  font-stretch: 98%;
  letter-spacing: -0.02em;
  line-height: 1.2;
  transform-origin: 0 50%;
  will-change: transform;
}
.ask__ph { color: var(--ink-3); font-weight: 440; }
.ask__caret {
  display: inline-block;
  width: 0.07em;
  min-width: 1.5px;
  height: 1.05em;
  margin-left: 0.06em;
  vertical-align: -0.16em;
  background: var(--accent);
  border-radius: 1px;
}
.measure {
  position: absolute;
  left: -9999px;
  top: 0;
  visibility: hidden;
  white-space: nowrap;
  font-weight: 600;
  font-stretch: 98%;
  letter-spacing: -0.02em;
  font-size: 100px;
}

/* ------------------------------------------------------------------ the answer page */
.page {
  position: absolute;
  inset: 0;
  z-index: 3;
  visibility: hidden;
}
.page.is-on { visibility: visible; }
.page__col {
  container-type: inline-size;
  width: min(660px, calc(100% - 32px));
  margin: 0 auto;
  padding-top: clamp(46px, 13vh, 140px);
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 0 11px 0 6px;
  margin: 0 0 clamp(6px, 1.6vh, 14px) -6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 540;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s;
}
.back svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.back:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.back.is-hover, .back:active { background: rgba(22, 23, 26, 0.06); color: var(--ink); }
.back.is-hover svg { transform: translateX(-2px); }
@media (hover: hover) {
  .back:hover { background: rgba(22, 23, 26, 0.06); color: var(--ink); }
  .back:hover svg { transform: translateX(-2px); }
}
.page__title-slot { width: 100%; }
.page__meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: clamp(8px, 2vh, 18px) 0 clamp(6px, 1.4vh, 10px);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.page__meta-n { font-weight: 440; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.sources {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1.4vw, 10px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.source {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 9px 10px 10px;
  border-radius: 12px;
  background: var(--paper);
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 2px rgba(22, 23, 26, 0.04),
    0 8px 18px -10px rgba(22, 23, 26, 0.16);
  cursor: default;
  transition: box-shadow 0.35s;
}
.source.is-lit {
  box-shadow:
    0 0 0 1px rgba(53, 80, 255, 0.38),
    0 1px 2px rgba(22, 23, 26, 0.04),
    0 12px 24px -12px rgba(53, 80, 255, 0.34);
}
.source__top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.fav { flex: none; width: 16px; height: 16px; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.fav rect { stroke: none; }
.fav--a rect { fill: #1f2a24; } .fav--a path { stroke: #e9efe6; }
.fav--b rect { fill: #efe3d3; } .fav--b circle, .fav--b path { stroke: #6b4a2b; }
.fav--c rect { fill: #24252b; } .fav--c path { stroke: #f2efe8; fill: none; }
.fav--d rect { fill: #e3e7ef; } .fav--d path { stroke: #36435f; }
.source__domain {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  color: var(--ink-3);
  font-stretch: 96%;
}
.source__n {
  flex: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 640;
  color: var(--ink-3);
  background: rgba(22, 23, 26, 0.05);
  font-variant-numeric: tabular-nums;
  transition: background-color 0.3s, color 0.3s;
}
.source.is-cited .source__n { background: var(--accent); color: #fff; }
.source__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 540;
  color: var(--ink);
  min-height: 2.6em;
}

@container (max-width: 520px) {
  .source { padding: 8px 8px 9px; gap: 5px; border-radius: 10px; }
  .source__top { justify-content: space-between; }
  .source__domain { order: 3; flex-basis: 100%; }
  .source__top { flex-wrap: wrap; row-gap: 5px; }
  .source__title { display: none; }
}

.status {
  position: relative;
  height: 18px;
  margin: clamp(10px, 2.6vh, 22px) 0 clamp(4px, 1vh, 8px);
  font-size: 11.5px;
  font-weight: 600;
}
.status__reading, .status__answer {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.status__reading {
  color: transparent;
  background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink-3) 40%, var(--ink) 50%, var(--ink-3) 60%, var(--ink-3) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}
.status__answer { color: var(--ink); }
.status__answer svg { width: 13px; height: 13px; fill: var(--accent); }

.answer {
  margin: 0;
  font-size: clamp(13px, min(3.6vw, 2.6vh), 16.5px);
  line-height: 1.58;
  color: #2a2b31;
  font-stretch: 100%;
  text-wrap: pretty;
}
.answer .w { display: inline-block; will-change: transform, opacity; }
.cite {
  display: inline-grid;
  place-items: center;
  min-width: 1.3em;
  height: 1.3em;
  padding: 0 0.28em;
  margin: 0 0.06em;
  border-radius: 0.38em;
  vertical-align: 0.14em;
  font-size: 0.66em;
  font-weight: 680;
  line-height: 1;
  color: var(--accent);
  background: var(--accent-soft);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}
.cite.is-lit { background: var(--accent); color: #fff; }
.page__foot {
  margin: clamp(8px, 2vh, 16px) 0 0;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ the hooks and the pointer */
.hooks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}
.hooks path { fill: none; stroke: var(--accent); stroke-opacity: 0.7; stroke-width: 1.1; stroke-linecap: round; }

.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  fill: var(--ink);
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(22, 23, 26, 0.25));
}

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

/* the small extra states: a lit top edge on the cards, the send button that leans in under the pointer */
.source::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 40%);
}
.ask__send-face { transition: background 0.3s, box-shadow 0.3s; }
@media (hover: hover) {
  .ask__send:hover .ask__send-face { background: linear-gradient(180deg, #343844, #1c1e26); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 4px 10px -3px rgba(53, 80, 255, 0.45); }
  .cite:hover { background: var(--accent); color: #fff; }
}
