/* Flyingkiwi chat application. Tokens, fonts, island/menu primitives and grain come from base.css. */

html { background: var(--bg); }
body.app-page {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-32);
  height: 100vh;
  height: 100dvh;
  padding: var(--s-24) var(--s-16) var(--s-16);
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 0 var(--s-8); }
.sidebar .brand img { width: 30px; height: 30px; }

.new-chat {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  width: 100%;
  min-height: 48px;
  padding: var(--s-8) var(--s-12);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: left;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
    transform var(--dur-1) var(--ease);
}
.new-chat:hover { background: var(--surface-raised); border-color: var(--brand-line); }
.new-chat:active { transform: scale(0.99); }
.new-chat .plus {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: var(--brand-soft);
  color: var(--brand);
  transition: background var(--dur-2) var(--ease);
}
.new-chat .plus svg { width: 15px; height: 15px; }
.new-chat:hover .plus { background: rgba(155, 206, 107, 0.2); }

.explore-nav { display: flex; flex-direction: column; gap: var(--s-2); }
.explore-nav .eyebrow {
  padding: 0 var(--s-12) var(--s-4);
  color: var(--faint);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.quiet {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  min-height: 44px;
  padding: var(--s-8) var(--s-12);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.quiet svg {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}
.quiet:hover { background: var(--surface-raised); color: var(--ink); }
.quiet:active { transform: translateY(1px); }

.sidebar-bottom { display: flex; flex-direction: column; gap: var(--s-2); margin-top: auto; }

/* The author's ebook: a small cover that turns on its spine on hover. */
.sidebar-book {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  margin-bottom: var(--s-12);
  padding: var(--s-12);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
  text-decoration: none;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.sidebar-book img {
  flex: none;
  width: 30px;
  height: 53px;
  border-radius: 2px;
  box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.9);
  transform: perspective(220px) rotateY(-16deg);
  transform-origin: left center;
  transition: transform var(--dur-3) var(--ease);
}
.sidebar-book strong { display: block; color: var(--ink); font-size: var(--text-sm); font-weight: 600; letter-spacing: -0.01em; }
.sidebar-book:hover { background: var(--surface-raised); border-color: var(--line-strong); color: var(--ink-soft); }
.sidebar-book:hover img { transform: perspective(220px) rotateY(-32deg) translateX(1px); }

/* Strings outside app.js: both languages in the markup, the page language picks one. */
html:lang(tr) .i18n-en,
html:not(:lang(tr)) .i18n-tr { display: none; }
.credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-8);
  margin-top: var(--s-12);
  padding: var(--s-16) var(--s-12) 0;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: var(--text-xs);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-2) var(--ease);
}
.credit:hover { color: var(--ink-soft); }

/* ------------------------------------------------------------------- app */

.app {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  gap: var(--s-12);
  min-height: 64px;
  padding: var(--s-12) var(--s-32);
  background: rgba(24, 24, 24, 0.82);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
  border-bottom: 1px solid var(--line);
}
.mobile-brand { display: none; align-items: center; gap: var(--s-8); min-height: 44px; color: var(--ink); font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.04em; text-decoration: none; }
.mobile-brand img { width: 26px; height: 26px; }

.model-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  min-height: 36px;
  padding: 6px var(--s-12);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.model-status:hover { background: var(--surface-raised); color: var(--ink); border-color: var(--line-strong); }
.model-status .chevron { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; }
.model-status .state-dot {
  position: relative;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.model-status[data-state="available"] .state-dot { background: var(--brand); opacity: 0.65; }
.model-status[data-state="ready"] .state-dot { background: var(--brand); }
.model-status[data-state="generating"] .state-dot { background: var(--brand); }
.model-status[data-state="checking"] .state-dot,
.model-status[data-state="loading"] .state-dot { background: var(--warn); }
.model-status[data-state="error"] .state-dot { background: var(--danger); }
.model-status[data-state="ready"] .state-dot::after,
.model-status[data-state="generating"] .state-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid rgba(155, 206, 107, 0.55);
  animation: state-pulse 2.4s var(--ease-out) infinite;
}
@keyframes state-pulse {
  0% { transform: scale(0.7); opacity: 0.85; }
  70%, 100% { transform: scale(2.1); opacity: 0; }
}

.language {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-left: auto;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: border-color var(--dur-2) var(--ease);
}
.language:hover { border-color: var(--line-strong); }
.language .opt {
  display: grid;
  place-items: center;
  min-width: 38px;
  min-height: 34px;
  padding: 0 var(--s-8);
  border-radius: var(--r-full);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.language .sep { color: var(--faint); font-weight: 400; }
html[lang="en"] .language .opt-en,
html[lang="tr"] .language .opt-tr { background: var(--brand-soft); color: var(--brand); }

main {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: var(--s-16) var(--s-32) 0;
}

/* --------------------------------------------------------------- welcome */

.welcome {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--s-48) 0 var(--s-40);
  text-align: center;
}
.mascot {
  width: 92px;
  height: 92px;
  margin: 0 auto var(--s-24);
  filter: drop-shadow(0 20px 40px rgba(155, 206, 107, 0.16));
  animation: mascot-in var(--dur-5) var(--ease-out) both;
}
.welcome h1 {
  font-size: clamp(2rem, 4.6vw, 3rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.035em;
  background: linear-gradient(90deg, #ffffff 0%, #9b9b9b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: welcome-in var(--dur-5) var(--ease-out) 80ms both;
}
.intro {
  max-width: 44ch;
  margin: var(--s-16) auto 0;
  color: var(--muted);
  font-size: var(--text-base);
  line-height: 1.6;
  animation: welcome-in var(--dur-5) var(--ease-out) 160ms both;
}
.suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
  width: 100%;
  max-width: 540px;
  margin: var(--s-40) auto 0;
}
.suggestions button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-12);
  min-height: 54px;
  padding: var(--s-12) var(--s-16);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
    color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
  animation: welcome-in var(--dur-5) var(--ease-out) both;
}
.suggestions button:nth-child(1) { animation-delay: 240ms; }
.suggestions button:nth-child(2) { animation-delay: 320ms; }
.suggestions button:nth-child(3) { animation-delay: 400ms; }
.suggestions button:hover {
  background: var(--surface-raised);
  border-color: var(--brand-line);
  color: var(--ink);
  transform: translateX(2px);
}
.suggestions button:active { transform: translateX(2px) scale(0.995); }
.suggestions .s-index {
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  transition: color var(--dur-2) var(--ease);
}
.suggestions button:hover .s-index { color: var(--brand); }
.suggestions .s-arrow {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--faint);
  transition: color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.suggestions button:hover .s-arrow { color: var(--brand); transform: translate(2px, -2px); }

.local-note {
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  margin: var(--s-32) auto 0;
  color: var(--faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  animation: welcome-in var(--dur-5) var(--ease-out) 480ms both;
}
.local-note .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }

@keyframes mascot-in {
  from { opacity: 0; transform: translateY(10px) scale(0.92); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes welcome-in {
  from { opacity: 0; transform: translateY(14px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

/* ------------------------------------------------------------- messages */

.conversation {
  display: flex;
  flex-direction: column;
  gap: var(--s-32);
  width: 100%;
  padding: var(--s-8) 0 var(--s-24);
}
.message {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
  animation: message-in var(--dur-4) var(--ease-out) both;
}
@keyframes message-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.message.user { align-items: flex-end; }
.message.user .bubble {
  max-width: min(86%, 620px);
  padding: var(--s-8) var(--s-16);
  border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.assistant { padding-left: 44px; }
.message.assistant::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface) url(/assets/kiwi.svg?v=9d466987114b) center / 20px no-repeat;
}
.md {
  min-height: 1.7em;
  font-size: var(--text-base);
  line-height: 1.72;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.85em; }
.md ul, .md ol { margin: 0 0 0.85em; padding-left: 1.35em; }
.md li { margin: 0.3em 0; }
.md li::marker { color: var(--faint); }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6,
.md .md-h1, .md .md-h2, .md .md-h3, .md .md-h4, .md .md-h5, .md .md-h6 {
  margin: 1.3em 0 0.5em;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.md h1, .md .md-h1 { font-size: var(--text-2xl); }
.md h2, .md .md-h2 { font-size: var(--text-xl); }
.md h3, .md .md-h3 { font-size: var(--text-lg); }
.md h4, .md h5, .md h6,
.md .md-h4, .md .md-h5, .md .md-h6 { font-size: var(--text-base); }
.md strong { font-weight: 600; color: var(--ink); }
.md em { font-style: normal; font-weight: 600; color: var(--ink); }
.md del { color: var(--faint); }
.md a { color: var(--brand); text-decoration: underline; text-decoration-color: rgba(155, 206, 107, 0.4); overflow-wrap: anywhere; }
.md a:hover { text-decoration-color: var(--brand); }
.md blockquote {
  margin: 0 0 0.9em;
  padding: var(--s-2) 0 var(--s-2) var(--s-16);
  border-left: 2px solid var(--brand-line);
  color: var(--muted);
}
.md hr { margin: 1.4em 0; border: 0; border-top: 1px solid var(--line); }
.md :not(pre) > code {
  padding: 0.1em 0.38em;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--ink);
}
.md-task { margin-right: 0.4em; color: var(--brand); }
.md-task-item { list-style: none; margin-left: -1.2em; }
.md-math { margin: 0 0 0.9em; padding: var(--s-4) 0; overflow-x: auto; text-align: center; }
.md-math code, .md .md-math-inline {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--mono);
  font-size: 1em;
  color: var(--ink);
}
.md-table-wrap {
  margin: 0 0 0.9em;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.md table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.md th, .md td { padding: var(--s-8) var(--s-12); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { background: rgba(255, 255, 255, 0.03); color: var(--ink); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.md .align-center { text-align: center; }
.md .align-right { text-align: right; }

.md-code {
  margin: 0 0 0.9em;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-deep);
  overflow: hidden;
}
.md-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-12);
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-16);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.md-code-lang { font-family: var(--mono); font-size: var(--text-xs); color: var(--faint); text-transform: lowercase; }
.copy-code {
  min-height: 32px;
  padding: var(--s-4) var(--s-12);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  transition: color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.copy-code:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
.md pre {
  margin: 0;
  padding: var(--s-12) var(--s-16);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  tab-size: 4;
  color: #e6e3dc;
}
.md pre code { padding: 0; border: 0; background: none; font-family: inherit; font-size: inherit; white-space: pre; color: inherit; }

.tok-keyword { color: #e3a967; }
.tok-string { color: #a6d47c; }
.tok-comment { color: #7f7e88; }
.tok-number { color: #e8c872; }
.tok-function { color: #8fc7e0; }
.tok-type { color: #79c9b2; }
.tok-builtin, .tok-literal { color: #ee9a86; }
.tok-operator, .tok-punct { color: #b9b6bf; }
.tok-tag { color: #e3a967; }
.tok-attr { color: #93bfe2; }
.tok-property { color: #8fc7e0; }
.tok-variable { color: #efe9dd; }
.tok-regex { color: #f0b46a; }
.tok-meta { color: #7f7e88; }
.tok-deleted { color: #f4a093; background: rgba(239, 138, 120, 0.08); }
.tok-inserted { color: #b7e08e; background: rgba(155, 206, 107, 0.08); }

.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  border-radius: 2px;
  background: var(--brand);
  vertical-align: -0.15em;
  animation: caret-blink 1.1s steps(2, start) infinite;
}
@keyframes caret-blink { to { visibility: hidden; } }

.reply-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4) var(--s-16);
  margin-top: calc(var(--s-2) * -1);
}
.text-button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  min-height: 36px;
  padding: var(--s-4) 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-2) var(--ease);
}
.text-button:hover { color: var(--brand); }
.reply-meta { color: var(--faint); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------- answer formats */

/* Card, part and column colours: light orchard hues that all carry dark ink at more than 7:1. */
:root {
  --tone-0: #b4dc8a;
  --tone-1: #f2cd66;
  --tone-2: #f4a98a;
  --tone-3: #94cbee;
  --tone-4: #86d6c2;
  --tone-5: #efb1cd;
  --tone-ink: #191710;
}
[data-tone="0"] { --tone: var(--tone-0); }
[data-tone="1"] { --tone: var(--tone-1); }
[data-tone="2"] { --tone: var(--tone-2); }
[data-tone="3"] { --tone: var(--tone-3); }
[data-tone="4"] { --tone: var(--tone-4); }
[data-tone="5"] { --tone: var(--tone-5); }

.md.shaped { container-type: inline-size; padding-top: var(--s-2); }

/* Fact cards: one card in front, the next two as the edge of the stack, tap or swipe to move on. */
.fk-cards { max-width: 540px; }
.fk-deck { display: grid; margin-bottom: 26px; touch-action: pan-y; }
.fk-card {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
  min-height: 212px;
  padding: var(--s-24);
  border-radius: var(--r-xl);
  background: var(--tone);
  color: var(--tone-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 18px 40px -24px rgba(0, 0, 0, 0.85);
  transform-origin: 50% 100%;
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-3) var(--ease-out), filter var(--dur-3) var(--ease-out);
}
.fk-card[data-pos="front"] { z-index: 4; cursor: pointer; }
.fk-card[data-pos="behind"] {
  z-index: calc(4 - var(--d));
  transform: translateY(calc(var(--d) * 11px)) scale(calc(1 - var(--d) * 0.05));
  filter: brightness(calc(1 - var(--d) * 0.18));
}
.fk-card[data-pos="hidden"] { z-index: 0; opacity: 0; transform: translateY(22px) scale(0.9); }
.fk-card[data-pos="past"] { z-index: 5; opacity: 0; transform: translateX(-14%) rotate(-5deg); pointer-events: none; }
.fk-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-12); }
.fk-card-num { font-family: var(--mono); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; color: rgba(25, 23, 16, 0.66); }
.fk-card-hint {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: rgba(25, 23, 16, 0.09);
  color: rgba(25, 23, 16, 0.74);
  transition: transform var(--dur-2) var(--ease);
}
.fk-card-hint svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fk-card-hint svg + svg,
.fk-card-hint.restart svg:first-child { display: none; }
.fk-card-hint.restart svg + svg { display: block; }
.fk-cards.single .fk-card-hint { display: none; }
.fk-card[data-pos="front"]:hover .fk-card-hint { transform: translateX(2px); }
.md .fk-card-title { margin: 0; color: var(--tone-ink); font-size: 1.375rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.025em; }
.md .fk-card-fact { margin: 0; color: rgba(25, 23, 16, 0.86); font-size: 1.0625rem; font-weight: 500; line-height: 1.55; }
.fk-card .caret { background: var(--tone-ink); }
.fk-deck-nav { display: flex; align-items: center; gap: var(--s-8); }
.fk-cards.single .fk-deck-nav { display: none; }
.fk-deck-step {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  color: var(--ink-soft);
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.fk-deck-step:hover { background: var(--surface-raised); border-color: var(--brand-line); color: var(--ink); }
.fk-deck-step:active { transform: scale(0.96); }
.fk-deck-step svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fk-tabs { display: flex; align-items: center; }
.fk-tab { display: grid; place-items: center; width: 30px; height: 44px; border-radius: var(--r-sm); }
.fk-tab-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--r-full);
  background: var(--tone);
  opacity: 0.4;
  transition: width var(--dur-3) var(--ease-out), opacity var(--dur-2) var(--ease);
}
.fk-tab:hover .fk-tab-dot { opacity: 0.8; }
.fk-tab[aria-selected="true"] .fk-tab-dot { width: 22px; opacity: 1; }
.fk-tab.writing .fk-tab-dot { animation: tab-writing 1.2s var(--ease-in-out) infinite; }
@keyframes tab-writing { 50% { opacity: 0.95; transform: scale(1.25); } }
.fk-deck-count { min-width: 4ch; color: var(--muted); font-family: var(--mono); font-size: var(--text-xs); font-variant-numeric: tabular-nums; text-align: center; }
@container (max-width: 379px) {
  .fk-tabs { display: none; }
  .fk-card { min-height: 196px; padding: var(--s-16) var(--s-16) var(--s-24); }
  .md .fk-card-title { font-size: var(--text-xl); }
}

/* Flowchart: start, numbered steps with arrows, yes/no decisions with both outcomes, end. */
.fk-flow { display: flex; flex-direction: column; align-items: center; width: min(100%, 480px); }
.md .fk-terminal {
  position: relative;
  margin: 0;
  padding: 2px var(--s-12);
  border: 1px solid var(--brand-line);
  border-radius: var(--r-full);
  color: var(--brand);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.7;
}
.md .fk-terminal:not(.end) { margin-bottom: 30px; }
.md .fk-terminal[hidden] { display: none; }
.md .fk-steps { width: 100%; margin: 0; padding: 0; list-style: none; }
.md .fk-step { position: relative; margin: 0; padding-bottom: 30px; }
.md .fk-steps:not(.to-end) > .fk-step:last-child { padding-bottom: 0; }
.fk-terminal:not(.end)::after,
.fk-step::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 2px;
  height: 19px;
  margin-left: -1px;
  background: var(--line-strong);
}
.fk-terminal:not(.end)::before,
.fk-step::before {
  content: "";
  position: absolute;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top: 6px solid var(--faint);
  border-bottom: 0;
}
.fk-terminal:not(.end)::after { top: calc(100% + 3px); }
.fk-terminal:not(.end)::before { top: calc(100% + 22px); }
.fk-step::after { bottom: 8px; }
.fk-step::before { bottom: 2px; }
.fk-steps:not(.to-end) > .fk-step:last-child::after,
.fk-steps:not(.to-end) > .fk-step:last-child::before { display: none; }
.fk-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--s-12);
  padding: var(--s-12) var(--s-16);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
}
.fk-num {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 600;
}
.md .fk-text { margin: 0; padding-top: 1px; color: var(--ink); font-size: var(--text-base); line-height: 1.55; }
.decision .fk-box { border-color: rgba(227, 178, 95, 0.5); background: rgba(227, 178, 95, 0.06); }
.decision .fk-num { background: none; color: var(--warn); }
.decision .fk-num::before { content: ""; position: absolute; inset: 4px; border: 1.5px solid var(--warn); border-radius: 3px; transform: rotate(45deg); }
.md .fk-branches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-8); margin: var(--s-12) 0 0; padding: 0; list-style: none; }
.md .fk-branch {
  position: relative;
  display: grid;
  align-content: start;
  gap: var(--s-2);
  margin: 0;
  padding: var(--s-8) var(--s-12);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.fk-branch::before { content: ""; position: absolute; left: 50%; top: -13px; height: 12px; border-left: 1px dashed var(--line-strong); }
.fk-branch-word { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.02em; }
.fk-branch.yes .fk-branch-word { color: var(--brand); }
.fk-branch.no .fk-branch-word { color: var(--danger); }

/* Diagram: the topic in the middle, parts on both sides joined by measured curves; a tree on narrow screens. */
.fk-map-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1fr);
  grid-template-areas: "left center right";
  align-items: center;
  column-gap: var(--s-40);
}
.fk-map-links { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.fk-map-links path { fill: none; stroke: var(--tone); stroke-width: 1.5; stroke-opacity: 0.7; }
.md .fk-map-center {
  position: relative;
  z-index: 1;
  grid-area: center;
  margin: 0;
  padding: var(--s-16);
  border-radius: var(--r-lg);
  background: var(--brand);
  color: var(--brand-ink);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  text-align: center;
  box-shadow: var(--shadow-brand);
}
.fk-map-center .caret { background: var(--brand-ink); }
.md .fk-map-side { position: relative; z-index: 1; display: flex; flex-direction: column; gap: var(--s-12); margin: 0; padding: 0; list-style: none; }
.fk-map-side.right { grid-area: right; }
.fk-map-side.left { grid-area: left; }
.md .fk-map-node {
  position: relative;
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: var(--s-12) var(--s-16);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
}
.fk-map-node::before { content: ""; position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: var(--tone); }
.right .fk-map-node::before { left: -5px; }
.left .fk-map-node::before { right: -5px; }
.fk-map-label { color: var(--tone); font-size: var(--text-sm); font-weight: 700; line-height: 1.35; }
.fk-map-note { color: var(--ink-soft); font-size: var(--text-sm); line-height: 1.5; }
@container (max-width: 559px) {
  .fk-map-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "center" "right" "left"; }
  .fk-map-links { display: none; }
  .md .fk-map-center { justify-self: start; max-width: 100%; text-align: left; }
  .md .fk-map-side { margin-left: 14px; padding: var(--s-12) 0 0 var(--s-16); border-left: 2px solid var(--line-strong); }
  .md .fk-map-side.left:not(:empty) { padding-top: var(--s-12); }
  .right .fk-map-node::before,
  .left .fk-map-node::before { right: auto; left: -22.5px; }
}

/* Comparison table: compared columns carry their colour; scrolls inside itself when narrow. */
.fk-table { border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fk-table:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.md .fk-table th, .md .fk-table td { min-width: 8.5rem; }
.md .fk-table thead th { vertical-align: bottom; }
.md .fk-table tbody th { background: rgba(255, 255, 255, 0.02); color: var(--ink); font-weight: 600; }
.md .fk-table td { color: var(--ink-soft); }
.md .fk-table tbody tr:hover > * { background: rgba(255, 255, 255, 0.035); }
.fk-col-dot { display: inline-block; width: 8px; height: 8px; margin-right: var(--s-8); border-radius: 50%; background: var(--tone); vertical-align: 1px; }

/* Pros and cons: two columns side by side, stacked when narrow. */
.fk-pc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-12); }
.fk-pc-col { padding: var(--s-16); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.fk-pc-col.pros { border-color: rgba(155, 206, 107, 0.3); }
.fk-pc-col.cons { border-color: rgba(240, 138, 120, 0.3); }
.md .fk-pc-title { display: flex; align-items: center; gap: var(--s-8); margin: 0 0 var(--s-12); color: var(--ink); font-size: var(--text-base); }
.fk-pc-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: var(--text-base); font-weight: 700; line-height: 1; }
.pros .fk-pc-mark { background: var(--brand-soft); color: var(--brand); }
.cons .fk-pc-mark { background: rgba(240, 138, 120, 0.14); color: var(--danger); }
.fk-pc-count { margin-left: auto; color: var(--faint); font-family: var(--mono); font-size: var(--text-xs); font-weight: 500; }
.md .fk-pc ul { display: grid; gap: var(--s-8); margin: 0; padding: 0; list-style: none; }
.md .fk-pc li { position: relative; margin: 0; padding-left: var(--s-16); color: var(--ink-soft); font-size: var(--text-sm); line-height: 1.55; }
.fk-pc li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; }
.pros li::before { background: var(--brand); }
.cons li::before { background: var(--danger); }
@container (max-width: 519px) {
  .fk-pc { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------- composer */

.composer-area {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: var(--s-16) 0 var(--s-8);
  margin-top: auto;
  background: var(--bg);
}
.status {
  min-height: 18px;
  margin: 0 var(--s-4) var(--s-8);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.5;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.status.error { color: var(--danger); }
#load-bar {
  display: block;
  width: 100%;
  height: 3px;
  margin: 0 0 var(--s-8);
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: var(--r-full);
  background: var(--surface-raised);
}
#load-bar::-webkit-progress-bar { background: var(--surface-raised); }
#load-bar::-webkit-progress-value { border-radius: var(--r-full); background: var(--brand); }
#load-bar::-moz-progress-bar { border-radius: var(--r-full); background: var(--brand); }

/* The text box over the pickers and the send button; on phones the send button moves up beside the text box. */
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "input input" "tools send";
  align-items: center;
  gap: var(--s-4) var(--s-8);
  padding: var(--s-8);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-3) var(--ease);
}
.composer:focus-within {
  border-color: var(--brand-line);
  box-shadow: var(--shadow-2), 0 0 0 4px var(--brand-soft);
}
.composer textarea {
  grid-area: input;
  width: 100%;
  min-height: 28px;
  max-height: 240px;
  padding: var(--s-8) var(--s-8) 0 var(--s-16);
  overflow-y: auto;
  resize: none;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 1.6;
  scrollbar-width: thin;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-tools { grid-area: tools; display: flex; align-items: center; gap: var(--s-8); min-width: 0; }
.composer > .send { grid-area: send; }

/* Answer format picker: a disclosure button over a group of native radios. */
.shape-picker { position: relative; display: flex; align-items: center; min-width: 0; }
.shape-button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--s-12) 0 var(--s-8);
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.shape-button:hover,
.shape-button[aria-expanded="true"] { background: var(--surface-raised); color: var(--ink); }
.shape-glyph,
.shape-icon svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.shape-name { overflow: hidden; text-overflow: ellipsis; }
.shape-button .chevron {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  transition: transform var(--dur-2) var(--ease);
}
.shape-button[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.shape-picker.active .shape-button { background: var(--brand-soft); color: var(--brand); }
.shape-picker.active .shape-button:hover,
.shape-picker.active .shape-button[aria-expanded="true"] { background: rgba(155, 206, 107, 0.2); }
.shape-clear {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  color: var(--muted);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.shape-clear[hidden] { display: none; }
.shape-clear:hover { background: var(--surface-raised); color: var(--ink); }
.shape-clear svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.shape-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + var(--s-12));
  z-index: 60;
  width: min(340px, calc(100vw - 2 * var(--s-16)));
  max-height: min(456px, calc(100dvh - 220px));
  min-inline-size: 0;
  margin: 0;
  padding: var(--s-8);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-2);
  animation: menu-in var(--dur-2) var(--ease-out) both;
}
.shape-menu[hidden] { display: none; }
.shape-menu legend {
  float: left;
  width: 100%;
  padding: var(--s-4) var(--s-8) var(--s-8);
  color: var(--faint);
  font-size: var(--text-xs);
  font-weight: 600;
}
.shape-option {
  position: relative;
  clear: both;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 18px;
  align-items: center;
  gap: var(--s-12);
  min-height: 52px;
  padding: var(--s-8);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.shape-option + .shape-option { margin-top: var(--s-2); }
.shape-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.shape-option:hover { background: rgba(255, 255, 255, 0.05); }
.shape-option:has(input:checked) { background: var(--brand-soft); }
.shape-option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: -2px; }
.shape-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-high);
  color: var(--ink-soft);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.shape-option:has(input:checked) .shape-icon { background: var(--brand); color: var(--brand-ink); }
.shape-copy { display: grid; gap: 1px; min-width: 0; }
.shape-option-name { color: var(--ink); font-size: var(--text-sm); font-weight: 600; line-height: 1.3; }
.shape-option-hint { color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
.shape-check { width: 18px; height: 18px; fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.shape-option:has(input:checked) .shape-check { opacity: 1; }
@keyframes menu-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* Model picker: the same disclosure over native radios as the answer formats. Its menu is anchored to the composer
   (not to the button) so it fits next to the format picker on a 320 px screen. */
.composer { position: relative; }
.model-picker { display: flex; align-items: center; min-width: 0; }
.model-picker[hidden] { display: none; }
.model-button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--s-8) 0 var(--s-12);
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.model-button:hover,
.model-button[aria-expanded="true"] { background: var(--surface-raised); color: var(--ink); }
.model-button-name { overflow: hidden; text-overflow: ellipsis; }
.model-button .chevron {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  transition: transform var(--dur-2) var(--ease);
}
.model-button[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.model-menu { left: 0; bottom: calc(100% + var(--s-8)); }
.model-option { grid-template-columns: minmax(0, 1fr) 18px; }

/* The pages a reply's library notes came from. */
.reply-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2) var(--s-12);
  margin: var(--s-8) 0 var(--s-4);
  font-size: var(--text-xs);
  line-height: 1.6;
}
.reply-sources-label { color: var(--faint); font-weight: 600; }
.reply-sources a { color: var(--brand); text-decoration: underline; text-decoration-color: rgba(155, 206, 107, 0.4); overflow-wrap: anywhere; }
.reply-sources a:hover { text-decoration-color: var(--brand); }
.reply-sources a::after { content: " ↗"; }
.send {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--surface-raised);
  color: var(--faint);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease),
    transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.send:enabled { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-brand); }
.send:enabled:hover { background: #a8d97b; transform: translateY(-1px); }
.send:enabled:active { transform: scale(0.98); }
.send .icon-stop { display: none; }
.send.stop { background: var(--ink); color: var(--bg); box-shadow: none; }
.send.stop .icon-send { display: none; }
.send.stop .icon-stop { display: block; fill: currentColor; stroke: none; }
.composer-hint {
  margin: var(--s-8) 0 0;
  color: var(--faint);
  font-size: 11px;
  text-align: center;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--s-4) var(--s-16);
  min-height: 56px;
  padding: var(--s-8) var(--s-32) var(--s-16);
  color: var(--faint);
  font-size: var(--text-xs);
}
.app-footer .text-button { min-height: 32px; font-size: var(--text-xs); color: var(--faint); }
.app-footer .text-button:hover { color: var(--brand); }

/* --------------------------------------------------------------- dialogs */

dialog {
  width: min(560px, calc(100% - 32px));
  max-height: min(85dvh, 720px);
  padding: var(--s-24);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
  overscroll-behavior: contain;
}
dialog[open] { animation: dialog-in var(--dur-3) var(--ease-out) both; }
dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
dialog[open]::backdrop { animation: fade-in var(--dur-3) var(--ease) both; }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-16);
  margin-bottom: var(--s-16);
}
.dialog-header h2 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.025em; line-height: 1.25; }
.close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.close:hover { background: var(--surface-raised); color: var(--ink); }
dialog p { margin: 0 0 var(--s-12); color: var(--ink-soft); font-size: var(--text-sm); line-height: 1.7; }
dialog a { font-size: var(--text-sm); }
dialog .dialog-links { display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-16); padding-top: var(--s-16); border-top: 1px solid var(--line); }
dialog .dialog-note { margin: var(--s-16) 0 0; }

dl.model-facts { margin: 0 0 var(--s-16); }
dl.model-facts > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--s-16);
  padding: var(--s-12) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
}
dl.model-facts dt { color: var(--muted); font-weight: 500; }
dl.model-facts dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.subtle { color: var(--muted); font-size: var(--text-xs); line-height: 1.6; }
.model-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-8) var(--s-16); margin: var(--s-8) 0 var(--s-16); }
.model-controls .text-button, dialog .text-button { min-height: 44px; }
.primary {
  min-height: 44px;
  padding: var(--s-8) var(--s-16);
  border-radius: var(--r-sm);
  background: var(--brand);
  color: var(--brand-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.primary:hover { background: #a8d97b; }
.primary:active { transform: scale(0.985); }
#device-result { min-height: 1em; margin-top: var(--s-8); }
#check-device { margin-top: var(--s-4); }

html:not(.js) .composer-area,
html:not(.js) .app-footer { display: none; }

.noscript {
  position: fixed;
  right: var(--s-16);
  bottom: var(--s-16);
  left: var(--s-16);
  z-index: 300;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--s-16);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-raised);
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

/* Short viewports (laptops in landscape, phones in landscape): keep the start view above the composer. */
@media (max-height: 780px) {
  .welcome { padding: var(--s-24) 0 var(--s-16); }
  .mascot { width: 64px; height: 64px; margin-bottom: var(--s-16); }
  .welcome h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
  .intro { margin-top: var(--s-8); }
  .suggestions { margin-top: var(--s-24); gap: var(--s-4); }
  .suggestions button { min-height: 48px; padding: var(--s-8) var(--s-16); }
  .local-note { display: none; }
}

@media (max-height: 560px) {
  .mascot, .intro, .local-note { display: none; }
  .welcome { padding-top: var(--s-8); }
  .suggestions { margin-top: var(--s-8); gap: var(--s-4); }
  .suggestions button { min-height: 44px; }
  .welcome h1 { font-size: clamp(1.5rem, 3.4vw, 1.875rem); }
  /* Landscape phones: put the composer in flow while the start view is shown so nothing is covered. */
  body:has(#conversation[hidden]) .composer-area { position: static; }
}

@media (max-width: 899px) and (max-height: 560px) and (orientation: landscape) {
  .suggestions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-8);
    max-width: none;
  }
  .suggestions button {
    min-height: 60px;
    padding: var(--s-8) var(--s-12);
    font-size: var(--text-xs);
  }
  .suggestions .s-index { display: none; }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  body.app-page { grid-template-columns: 232px minmax(0, 1fr); }
  .sidebar { padding: var(--s-16) var(--s-12) var(--s-12); gap: var(--s-24); }
}

@media (max-width: 899px) {
  body.app-page { display: block; }
  .sidebar { display: none; }
  .app { min-height: 100dvh; }
  .topbar { min-height: 60px; padding: var(--s-8) var(--s-16); }
  .mobile-brand { display: inline-flex; }
  .model-status { display: none; }
  .language { margin-left: auto; }
  body.app-page .menu-toggle { margin-left: var(--s-4); }
  main { max-width: none; padding: var(--s-8) var(--s-16) 0; }
  .welcome { max-width: none; padding: var(--s-24) 0 var(--s-16); }
  .mascot { width: 72px; height: 72px; margin-bottom: var(--s-16); }
  .welcome h1 { font-size: clamp(1.9rem, 8vw, 2.375rem); }
  .intro { margin-top: var(--s-12); max-width: 34ch; }
  .suggestions { max-width: none; margin-top: var(--s-24); }
  .suggestions button { min-height: 56px; }
  .local-note { margin-top: var(--s-24); }
  .conversation { gap: var(--s-24); padding-bottom: var(--s-16); }
  .message.assistant { padding-left: 38px; }
  .message.assistant::before { width: 28px; height: 28px; background-size: 17px; }
  .composer-area { padding: var(--s-12) 0 max(var(--s-8), env(safe-area-inset-bottom)); }
  .composer { padding: var(--s-8); }
  .composer textarea { padding-left: var(--s-8); font-size: 16px; }
  .status { text-align: left; padding-left: var(--s-4); }
  .app-footer { display: none; }
  dialog {
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: auto 0 0;
    padding: var(--s-24) var(--s-16) max(var(--s-24), env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
}

@media (hover: none) {
  .composer-hint { display: none; }
}

/* Phones: the send button sits beside the text box, so both pickers share the row below and stay fully readable; on the
   narrowest screens with the longest names (Pros & cons with its reset button, Blazing fast) they wrap. */
@media (max-width: 479px) {
  .composer { grid-template-areas: "input send" "tools tools"; }
  .composer > .send { align-self: end; }
  .composer-tools { flex-wrap: wrap; gap: var(--s-4) var(--s-8); }
}

@media (max-width: 639px) {
  main { padding: var(--s-8) var(--s-16) 0; }
  .welcome h1 { font-size: clamp(1.75rem, 8.6vw, 2.125rem); }
  .md pre { font-size: 13px; padding: var(--s-12); }
  .message.user .bubble { max-width: 92%; }
  .reply-footer .text-button { min-height: 44px; }
}

@media (max-width: 359px) {
  main { padding-left: var(--s-12); padding-right: var(--s-12); }
  .welcome h1 { font-size: 1.625rem; }
  .intro { font-size: var(--text-sm); }
  .message.assistant { padding-left: 0; }
  .message.assistant::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .model-status[data-state="ready"] .state-dot::after,
  .model-status[data-state="generating"] .state-dot::after { animation: none; opacity: 0; }
  .mascot, .welcome h1, .intro, .suggestions button, .local-note, .message, dialog[open],
  dialog[open]::backdrop, .shape-menu, .fk-tab.writing .fk-tab-dot { animation: none; }
  .fk-card, .fk-tab-dot, .shape-button .chevron { transition: none; }
}
