/*
  Motif, second pass. One stylesheet for the landing page, the app, the docs and a take page.
  Tokens follow docs/research/26-llm-app-design.md: one ink at three strengths, no accent
  colour, colour only for state (gain, loss, stop), hairlines instead of boxes.
*/
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-var-latin.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-var-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --page: #101312;
  --surface: #171b1a;
  --ink: 236 241 239;
  --text: rgb(var(--ink));
  --text-2: rgb(var(--ink) / 0.65);
  --text-3: rgb(var(--ink) / 0.5);
  --line: rgb(var(--ink) / 0.1);
  --line-2: rgb(var(--ink) / 0.18);
  --wash: rgb(var(--ink) / 0.06);
  --gain: #9fcfc0;
  --loss: #e3a6ab;
  --stop: #d13438;
  /* Apple's system font on Apple devices; Geist everywhere else. */
  --sans: -apple-system, BlinkMacSystemFont, "Geist", "Segoe UI", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --col: 720px;
}

* { box-sizing: border-box; }
html { background: var(--page); color-scheme: dark; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 400 16px/24px var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }
.num, table { font-variant-numeric: tabular-nums lining-nums; }
.serif { font-family: var(--serif); font-weight: 400; font-optical-sizing: auto; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.loss { color: var(--loss); }
.gain { color: var(--gain); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 20px; border-radius: 8px;
  font-weight: 500; white-space: nowrap;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease);
}
.btn.solid { background: var(--text); color: var(--page); }
.btn.solid:hover { background: #fff; }
.btn.line { border: 1px solid var(--line-2); }
.btn.line:hover { border-color: var(--text-3); }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; }
.btn.text { height: 44px; padding: 0 12px; color: var(--text-2); font-weight: 400; }
.btn.text:hover { color: var(--text); }
/* The stop control never animates: its state shows at once. */
.btn.stop { background: var(--stop); color: #fff; height: 36px; padding: 0 14px; font-size: 14px; transition: none; }
.btn.stop:active { background: #a8262a; }
.btn.stop.done { background: none; color: var(--text); border: 1px solid var(--line-2); }
.btn.stop.idle { background: none; color: var(--text); border: 1px solid var(--line-2); }
.btn.stop.idle::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--stop); margin-right: 8px; }

.wordmark { font-family: var(--serif); font-size: 22px; line-height: 28px; letter-spacing: -0.01em; }

/* ---------- the composer: the one strong shape ---------- */
.composer {
  width: min(var(--col), 100% - 32px); margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 12px; transition: border-color 200ms var(--ease);
}
.composer:focus-within { border-color: var(--line-2); }
.composer textarea {
  display: block; width: 100%; min-height: 48px; resize: none;
  background: none; border: 0; outline: 0; color: var(--text);
  font: inherit; padding: 4px 8px;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer .row { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.mode { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; border-radius: 8px; font-size: 14px; color: var(--text-2); }
.mode:hover { background: var(--wash); color: var(--text); }
.mode svg { width: 12px; height: 12px; }
.send {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--wash); color: var(--text-3);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.send svg { width: 16px; height: 16px; }
.composer.has-text .send { background: var(--text); color: var(--page); }

/* ---------- the app ---------- */
body.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 12px; min-height: 0;
}
.side .wordmark { padding: 0 8px; margin-bottom: 18px; }
.side-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 40px; padding: 0 8px; border-radius: 8px; font-size: 14px; color: var(--text-2); width: 100%; text-align: left;
}
.side-row:hover { background: var(--wash); color: var(--text); }
.side-row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row .r { flex: none; font-variant-numeric: tabular-nums; }
.side-row.on { background: var(--wash); color: var(--text); }
.side .side-label { margin-top: 18px; }
.side-label { font-size: 12px; line-height: 16px; color: var(--text-3); padding: 0 8px 6px; }
.side .grow { flex: 1; }

.scrim { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; height: 100dvh; overflow: hidden; position: relative; }
.top { flex: none; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.top .left { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-2); }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); }
.icon-btn:hover { background: var(--wash); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.acct { display: flex; gap: 8px; padding-left: 16px; margin-left: 4px; border-left: 1px solid var(--line); color: var(--text); }
.acct:hover span:last-child { border-bottom: 1px solid var(--line-2); }

/* ---------- portfolio, limits, activity ---------- */
.page { flex: 1; overflow-y: auto; min-height: 0; }
.page-col { width: min(880px, 100% - 32px); margin: 0 auto; padding: 28px 0 96px; }
.page-title { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 36px; letter-spacing: -0.02em; margin: 0 0 8px; }
.page-note { font-size: 14px; line-height: 20px; color: var(--text-2); margin: 0 0 28px; max-width: 44em; }
.page-note.after-table { margin-top: 14px; }
.big { font-family: var(--serif); font-weight: 400; font-size: 56px; line-height: 64px; letter-spacing: -0.02em; margin: 0 0 6px; font-variant-numeric: lining-nums; }
h2.sec { font-size: 20px; line-height: 28px; font-weight: 500; margin: 48px 0 4px; }
.table-wrap { overflow-x: auto; }
.table-wrap table.legs th { border-top: 0; }
.take-link:hover b { border-bottom: 1px solid var(--line-2); }
table.legs td .btn.text.small { height: 28px; margin: -4px -12px -4px 0; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 150px; gap: 16px; align-items: center; min-height: 52px; border-top: 1px solid var(--line); }
.set-row:first-child, .stop-row:first-child { border-top: 0; }
.set-acts { display: flex; justify-content: flex-end; margin-right: -14px; }
.stop-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.stop-name { margin: 0 0 2px; font-weight: 500; }
.stop-what { margin: 0; font-size: 14px; line-height: 20px; color: var(--text-2); max-width: 40em; }
.log { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 20px; }
.log li { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }

.empty { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-bottom: 14vh; }
.empty h1 { margin: 0 0 28px; text-align: center; font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 36px; letter-spacing: -0.02em; }
.examples { width: min(var(--col), 100% - 32px); margin: 12px auto 0; }
.examples button {
  display: block; width: 100%; height: 48px; padding: 0 20px; text-align: left;
  color: var(--text-2); border-top: 1px solid var(--line);
  transition: color 120ms var(--ease);
}
.examples button:first-child { border-top: 0; }
.examples button:hover { color: var(--text); }
.foot-note { flex: none; text-align: center; font-size: 12px; line-height: 16px; color: var(--text-3); padding: 0 16px 14px; }

.thread { flex: 1; overflow-y: auto; min-height: 0; padding: 8px 0 24px; display: none; }
.thread .col { width: min(var(--col), 100% - 32px); margin: 0 auto; }
.dock { flex: none; padding: 8px 0 12px; display: none; }
.dock .composer textarea { min-height: 24px; }
body.has-thread .empty { display: none; }
body.has-thread .thread, body.has-thread .dock { display: block; }

.bubble { margin: 12px 0 24px auto; width: fit-content; max-width: 80%; background: var(--surface); border-radius: 18px; padding: 10px 16px; }
.status { color: var(--text-2); font-size: 14px; line-height: 20px; margin: 0 0 24px; }
.status span {
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text) 50%, var(--text-3) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- the ticket: a document, not a card ---------- */
.ticket { margin-bottom: 40px; }
.ticket.arrive { animation: arrive 160ms var(--ease) both; }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
.ticket .read { font-size: 20px; line-height: 28px; margin: 0 0 28px; max-width: 34em; }
.ticket .label { font-size: 14px; line-height: 20px; color: var(--text-2); margin: 0; }
.ticket .worst {
  font-family: var(--serif); font-weight: 400; font-size: 56px; line-height: 64px; letter-spacing: -0.02em;
  color: var(--loss); margin: 2px 0 6px; font-variant-numeric: lining-nums;
}
.ticket .worst-note { font-size: 14px; line-height: 20px; color: var(--text-2); margin: 0 0 24px; max-width: 36em; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 40px; padding: 14px 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 20px; margin: 0; }
.facts div { display: flex; gap: 8px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; }

table.legs { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
table.legs th { font-weight: 400; font-size: 12px; line-height: 16px; color: var(--text-3); text-align: right; padding: 10px 0 8px; border-bottom: 1px solid var(--line-2); border-top: 1px solid var(--line); }
table.legs td { text-align: right; padding: 13px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.legs th:first-child, table.legs td:first-child { text-align: left; }
table.legs .venue, table.legs .pct { color: var(--text-3); margin-left: 8px; }
table.legs b { font-weight: 500; }

.key-line { font-size: 14px; line-height: 20px; color: var(--text-2); margin: 18px 0 0; max-width: 40em; }
details.disc { border-top: 1px solid var(--line); }
details.disc + .tools { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 0; }
details.disc summary {
  list-style: none; display: flex; align-items: center; gap: 8px; height: 44px; cursor: pointer;
  font-size: 14px; color: var(--text-2); transition: color 120ms var(--ease);
}
details.disc summary::-webkit-details-marker { display: none; }
details.disc summary:hover { color: var(--text); }
details.disc summary svg { width: 12px; height: 12px; transition: transform 150ms var(--ease); }
details.disc[open] summary svg { transform: rotate(90deg); }
details.disc .body { padding: 0 0 16px 20px; font-size: 14px; line-height: 20px; }
.rows { margin: 0; }
.rows div { display: flex; justify-content: space-between; gap: 24px; padding: 7px 0; border-top: 1px solid var(--line); }
.rows div:first-child { border-top: 0; }
.rows dt { color: var(--text-2); }
.rows dd { margin: 0; text-align: right; }
.rows .strong dt, .rows .strong dd { color: var(--text); font-weight: 500; }
.disc .note { color: var(--text-3); margin: 10px 0 0; max-width: 40em; }
.fill-leg { margin: 12px 0 4px; }
.fill-leg:first-child { margin-top: 0; }

.actions { display: flex; align-items: center; gap: 8px; margin: 20px 0 24px; flex-wrap: wrap; }
.actions .note { margin-left: auto; font-size: 14px; color: var(--text-2); }
.link-steps { margin: 16px 0 -8px; padding: 0; list-style: none; font-size: 14px; line-height: 20px; counter-reset: s; }
.link-steps li { counter-increment: s; display: flex; gap: 12px; padding: 8px 0; color: var(--text-3); }
.link-steps li::before { content: counter(s); width: 20px; color: inherit; font-variant-numeric: tabular-nums; }
.link-steps li.now { color: var(--text); }
.link-steps li.done { color: var(--text-2); }
.after { margin: 24px 0 28px; font-size: 14px; line-height: 20px; color: var(--text-2); display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.after a { color: var(--text); border-bottom: 1px solid var(--line-2); }
.tools { display: flex; gap: 4px; margin-top: 14px; margin-left: -8px; }
.tools button { height: 32px; padding: 0 8px; border-radius: 8px; font-size: 12px; color: var(--text-3); }
.tools button:hover { background: var(--wash); color: var(--text); }
.sample-line { font-size: 12px; line-height: 16px; color: var(--text-3); margin: 14px 0 0; }

/* ---------- landing ---------- */
.nav { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 56px; }
.nav .links { display: flex; align-items: center; gap: 28px; font-size: 14px; color: var(--text-2); }
.nav .links a:not(.btn):hover { color: var(--text); }
.hero {
  display: grid; grid-template-columns: minmax(0, 540px) minmax(0, var(--col)); justify-content: space-between; gap: 48px;
  padding: 56px 56px 0; max-width: 1440px; margin: 0 auto;
  height: calc(100vh - 72px); min-height: 640px; overflow: hidden;
  animation: land 300ms var(--ease) both;
}
@keyframes land { from { opacity: 0; transform: translateY(8px); } }
.hero h1, .section h2, .article h1, .take-col h1 { text-wrap: balance; }
.hero h1 { font-family: var(--serif); font-weight: 400; font-size: 72px; line-height: 76px; letter-spacing: -0.03em; margin: 8px 0 28px; }
.hero .lede { font-size: 18px; line-height: 28px; color: var(--text-2); margin: 0 0 36px; max-width: 24em; }
.claims { list-style: none; margin: 0 0 40px; padding: 0; font-size: 20px; line-height: 28px; }
.claims li { padding: 4px 0; color: var(--text-2); }
.claims b { color: var(--text); font-weight: 500; display: inline-block; min-width: 1.6em; font-variant-numeric: tabular-nums; }
.hero .buttons { display: flex; gap: 12px; }
.hero .product { position: relative; padding-top: 12px; }
.hero .product .composer { width: 100%; }
.hero .product .ticket { margin: 28px 12px 0; }
.hero .product::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 120px; pointer-events: none;
  background: linear-gradient(to top, var(--page), transparent);
}
.section { max-width: 1440px; margin: 0 auto; padding: 96px 56px 0; display: grid; grid-template-columns: minmax(0, 540px) minmax(0, var(--col)); justify-content: space-between; gap: 48px; }
.section h2 { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 44px; letter-spacing: -0.02em; margin: 0; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.steps li { counter-increment: st; display: grid; grid-template-columns: 48px 1fr; padding: 20px 0; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; padding-top: 4px; }
.steps li::before { content: counter(st); font-family: var(--serif); font-size: 28px; line-height: 28px; color: var(--text-3); }
.steps h3 { margin: 0 0 4px; font-size: 20px; line-height: 28px; font-weight: 500; }
.steps p { margin: 0; color: var(--text-2); max-width: 34em; }
.plain p { margin: 0 0 16px; color: var(--text-2); max-width: 36em; }
.plain p b { color: var(--text); font-weight: 500; }
.footer { max-width: 1440px; margin: 120px auto 0; padding: 28px 56px 48px; border-top: 1px solid var(--line); font-size: 14px; line-height: 20px; color: var(--text-2); display: grid; grid-template-columns: minmax(0, 540px) minmax(0, var(--col)); justify-content: space-between; gap: 48px; }
.footer p { margin: 0 0 8px; max-width: 44em; }
.footer .links { display: flex; gap: 20px; }
.footer .links a:hover { color: var(--text); }

/* ---------- docs ---------- */
body.docs .nav { height: 56px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.docs-grid { display: grid; grid-template-columns: 248px minmax(0, 680px) 208px; gap: 40px; justify-content: center; padding: 40px 24px 96px; }
.docs-nav { font-size: 14px; line-height: 20px; position: sticky; top: 24px; align-self: start; }
.docs-nav p { margin: 20px 0 6px; color: var(--text-3); font-size: 12px; line-height: 16px; }
.docs-nav p:first-child { margin-top: 0; }
.docs-nav a { display: block; padding: 6px 10px; margin-left: -10px; border-radius: 8px; color: var(--text-2); }
.docs-nav a:hover { color: var(--text); background: var(--wash); }
.docs-nav a.on { color: var(--text); background: var(--wash); }
.article { font-size: 16px; line-height: 26px; }
.article h1 { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 44px; letter-spacing: -0.02em; margin: 0 0 12px; }
.article .updated { font-size: 14px; color: var(--text-3); margin: 0 0 32px; }
.article h2 { font-size: 20px; line-height: 28px; font-weight: 500; margin: 48px 0 12px; }
.article p { margin: 0 0 16px; color: var(--text-2); }
.article p b, .article li b { color: var(--text); font-weight: 500; }
.article ul { margin: 0 0 16px; padding-left: 20px; color: var(--text-2); }
.article li { margin: 6px 0; }
.article table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; margin: 8px 0 24px; }
.article th { text-align: left; font-weight: 400; font-size: 12px; color: var(--text-3); padding: 8px 16px 8px 0; border-bottom: 1px solid var(--line-2); }
.article td { padding: 11px 16px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.article td:first-child { color: var(--text); white-space: nowrap; }
.article td { color: var(--text-2); }
.article .pager { display: flex; justify-content: space-between; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.article .pager a:hover { color: var(--text); }
.toc { font-size: 14px; line-height: 20px; position: sticky; top: 24px; align-self: start; }
.toc p { margin: 0 0 8px; color: var(--text-3); font-size: 12px; }
.toc a { display: block; padding: 4px 0; color: var(--text-2); }
.toc a:hover { color: var(--text); }

/* ---------- a take's own page ---------- */
body.take .nav { height: 56px; padding: 0 24px; }
.take-col { width: min(var(--col), 100% - 32px); margin: 0 auto; padding: 48px 0 96px; }
.take-col .meta { font-size: 14px; line-height: 20px; color: var(--text-2); margin: 0 0 12px; }
.take-col h1 { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 44px; letter-spacing: -0.02em; margin: 0 0 16px; }
.take-col .view { font-size: 20px; line-height: 28px; margin: 0 0 40px; color: var(--text-2); }
.take-col .result { font-family: var(--serif); font-weight: 400; font-size: 72px; line-height: 76px; letter-spacing: -0.03em; margin: 2px 0 8px; font-variant-numeric: lining-nums; }
.take-col .result-note { font-size: 14px; line-height: 20px; color: var(--text-2); margin: 0 0 32px; max-width: 38em; }
.take-col .actions .note { margin-left: 0; }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .hero, .section, .footer { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .hero { height: auto; padding-bottom: 0; }
  .hero .product { max-height: 520px; overflow: hidden; }
  .docs-grid { grid-template-columns: 220px minmax(0, 680px); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  body.app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20; transform: translateX(-100%); transition: transform 240ms var(--ease); }
  body.side-open .side { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 10; display: none; }
  body.side-open .scrim { display: block; }
  .menu-btn { display: grid; }
  .acct { display: none; }
  .set-row { grid-template-columns: minmax(0, 1fr) auto; }
  .set-acts { grid-column: 1 / -1; justify-content: flex-start; margin: -8px 0 8px -14px; }
  .stop-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .stop-row .btn { justify-self: start; }
  .big { font-size: 44px; line-height: 52px; }
  .top { padding: 0 12px; }
  .icon-btn, .send, .mode { min-width: 44px; height: 44px; }
  .send { width: 44px; }
  .empty { justify-content: flex-end; padding-bottom: 8px; }
  .empty h1 { margin-bottom: auto; margin-top: 26vh; font-size: 28px; line-height: 32px; }
  .examples { margin: 0 auto 12px; order: 1; }
  .empty .composer { order: 2; }
  .ticket .worst { font-size: 44px; line-height: 52px; }
  table.legs .venue, table.legs .pct { display: block; margin-left: 0; }
  .actions .note { margin-left: 0; width: 100%; order: 3; }
  .nav { padding: 0 16px; height: 56px; }
  .nav .links .hide-s { display: none; }
  .hero { padding: 24px 16px 0; }
  .hero h1 { font-size: 44px; line-height: 48px; margin-bottom: 20px; }
  .claims { font-size: 18px; line-height: 26px; }
  .section { padding: 64px 16px 0; }
  .section h2, .article h1, .take-col h1 { font-size: 32px; line-height: 36px; }
  .footer { padding: 24px 16px 40px; margin-top: 72px; }
  .docs-grid { grid-template-columns: minmax(0, 1fr); padding: 24px 16px 64px; }
  .docs-nav { display: none; }
  .take-col .result { font-size: 56px; line-height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .status span { color: var(--text-2); background: none; }
}
