/* =============================================================
   Ситуационный помощник
   Эстетика: editorial calm / swiss-japanese
   Бумага, тушь, охра, тревожный терракот для safety.
   ============================================================= */

:root {
  /* paper palette */
  --paper:        #f4ede0;
  --paper-2:      #ede4d2;
  --paper-edge:   #e2d7be;
  --ink:          #1b1a1f;
  --ink-2:        #3a3833;
  --ink-3:        #6b6760;
  --ink-4:        #a39d92;
  --rule:         #cdc3ad;

  /* accents */
  --ochre:        #b8754d;   /* primary accent */
  --ochre-deep:   #8a4f30;
  --ochre-soft:   #e6c9a8;
  --olive:        #6c6b3a;   /* category tag */
  --moss:         #4a6b4a;   /* helpful / saved */
  --terracotta:   #b34a2a;   /* safety fallback */
  --terracotta-2: #6e2818;
  --bone:         #faf6ec;   /* card */
  --shadow-ink:   18 17 22;

  /* type */
  --serif: "Iowan Old Style", "Charter", "Cochin", "Palatino Linotype", "Palatino", "Georgia", "Times New Roman", serif;
  --sans:  "Optima", "Avenir Next", "Avenir", "Geneva", "Helvetica Neue", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:  "JetBrains Mono", "SFMono-Regular", ui-monospace, "Menlo", "Consolas", monospace;

  /* rhythm */
  --r-1: 6px;
  --r-2: 8px;
  --r-pill: 999px;

  /* motion */
  --ease:    cubic-bezier(.2, .7, .2, 1);
  --ease-in: cubic-bezier(.6, .04, .98, .34);
  --t-fast: 160ms;
  --t-med:  320ms;
  --t-slow: 600ms;
}

/* ----------  Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 85% -10%, #f8efde 0%, transparent 60%),
    radial-gradient(900px 700px at -10% 110%, #ece2c9 0%, transparent 55%),
    var(--paper);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, button { font-family: inherit; }
textarea { resize: vertical; }
ul, ol, dl { margin: 0; padding: 0; list-style: none; }
dt, dd { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
em { font-style: italic; }

/* ----------  A11y helpers ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: 8px; left: 8px;
  padding: 8px 14px; background: var(--ink); color: var(--paper);
  text-decoration: none; border-radius: var(--r-1);
  transform: translateY(-200%);
  transition: transform var(--t-fast) var(--ease);
  z-index: 100;
}
.skip-link:focus { transform: none; }
:focus-visible {
  outline: 2px solid var(--ochre);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ----------  Grain overlay ---------- */
.grain {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  opacity: .55;
  mix-blend-mode: multiply;
  z-index: 1;
}

/* ----------  Top bar ---------- */
.top {
  position: sticky; top: 0;
  z-index: 10;
  background: linear-gradient(var(--paper) 70%, rgb(244 237 224 / 0));
  backdrop-filter: blur(2px);
}
.top__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 40px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex; align-items: center; gap: 16px;
}
.brand__mark {
  display: inline-grid;
  grid-template-columns: repeat(3, 8px);
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--bone);
}
.brand__mark span {
  width: 8px; height: 8px;
  background: var(--ink);
  border-radius: 1px;
}
.brand__mark span:nth-child(1) { background: var(--ochre); }
.brand__mark span:nth-child(2) { background: var(--ink); animation: blink 4.2s var(--ease) infinite; }
.brand__mark span:nth-child(3) { background: var(--olive); }
@keyframes blink {
  0%, 92%, 100% { opacity: 1; }
  94%, 98% { opacity: .15; }
}
.brand__eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.brand__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(20px, 2.4vw, 26px);
  letter-spacing: -.005em;
  line-height: 1.1;
  margin-top: 2px;
}
.status {
  display: inline-flex;
  align-items: center; gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  background: var(--bone);
  white-space: nowrap;
}
.status__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--olive);
  box-shadow: 0 0 0 3px rgb(108 107 58 / .15);
  animation: breathe 2.6s var(--ease) infinite;
}
.status.is-error .status__dot { background: var(--terracotta); box-shadow: 0 0 0 3px rgb(179 74 42 / .18); }
.status.is-busy  .status__dot { background: var(--ochre);     box-shadow: 0 0 0 3px rgb(184 117 77 / .18); }
@keyframes breathe {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.25); opacity: .85; }
}

/* ----------  Page layout ---------- */
.page {
  position: relative;
  z-index: 2;
  max-width: 1320px;
  margin: 0 auto;
  padding: 56px 40px 80px;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 64px;
  align-items: start;
}

/* ----------  Left rail ---------- */
.rail__eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 14px;
}
.intro__headline {
  font-family: var(--serif);
  font-size: clamp(34px, 4.4vw, 52px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -.015em;
  color: var(--ink);
  margin-bottom: 28px;
}
.intro__headline em {
  color: var(--ochre-deep);
  font-style: italic;
  font-family: var(--serif);
}
.intro__body {
  font-size: 15px;
  color: var(--ink-2);
  max-width: 36ch;
  margin-bottom: 26px;
}
.intro__list {
  display: grid; gap: 10px;
  margin-bottom: 28px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
}
.intro__list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: baseline;
  font-size: 14.5px;
  color: var(--ink-2);
}
.intro__list li span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ochre-deep);
  letter-spacing: .1em;
}
.intro__disclaimer {
  font-size: 13px;
  color: var(--ink-3);
  padding: 14px 16px;
  background: var(--bone);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--terracotta);
  border-radius: var(--r-1);
}
.intro__disclaimer strong {
  font-family: var(--serif);
  font-style: italic;
  color: var(--terracotta-2);
  font-weight: 600;
  letter-spacing: .02em;
}

.rail__card {
  margin-top: 4px;
  padding: 20px 22px;
  background: var(--bone);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  box-shadow: 0 1px 0 var(--paper-edge);
  animation: lift var(--t-med) var(--ease);
}
@keyframes lift {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.meta {
  display: grid; gap: 12px;
  margin-bottom: 16px;
}
.meta > div {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--rule);
}
.meta > div:last-of-type { border-bottom: 0; padding-bottom: 0; }
.meta dt {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.meta dd {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
}
.meta__id {
  font-family: var(--mono) !important;
  font-size: 11.5px !important;
  color: var(--ink-3) !important;
  word-break: break-all;
}
.link {
  background: none; border: 0;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ochre-deep);
  border-bottom: 1px solid currentColor;
  transition: color var(--t-fast) var(--ease), letter-spacing var(--t-fast) var(--ease);
}
.link:hover { color: var(--ink); letter-spacing: .16em; }

.rail__foot {
  margin-top: 28px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-4);
  display: flex; gap: 10px; align-items: center;
}

/* ----------  Stage ---------- */
.stage {
  position: relative;
  display: grid; gap: 28px;
  min-width: 0;
}
.stage__header { margin-bottom: 6px; }
.stage__eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ochre-deep);
  margin: 0 0 12px;
}
.stage__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.12;
  letter-spacing: -.01em;
  margin-bottom: 10px;
}
.stage__sub {
  font-size: 15px;
  color: var(--ink-3);
  max-width: 56ch;
  margin: 0;
}
.rule {
  display: block;
  width: 60px; height: 1px;
  background: var(--ink);
  margin-bottom: 18px;
}

/* ----------  Cities ---------- */
.cities {
  display: flex; flex-wrap: wrap; gap: 10px;
  min-height: 56px;
  position: relative;
}
.cities__skeleton {
  display: flex; flex-wrap: wrap; gap: 10px;
  width: 100%;
}
.cities__skeleton span {
  display: block;
  height: 40px;
  width: 110px;
  border-radius: var(--r-pill);
  background:
    linear-gradient(90deg, var(--paper-2) 0%, var(--bone) 50%, var(--paper-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.cities__skeleton span:nth-child(2) { width: 160px; }
.cities__skeleton span:nth-child(3) { width: 90px;  }
.cities__skeleton span:nth-child(4) { width: 140px; }
.cities__skeleton span:nth-child(5) { width: 130px; }
.cities__skeleton span:nth-child(6) { width: 100px; }
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.cities:not(.is-loading) .cities__skeleton { display: none; }
.city {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--bone);
  padding: 10px 18px;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  border-radius: var(--r-pill);
  transition:
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
  position: relative;
  animation: cityIn var(--t-med) var(--ease) backwards;
}
@keyframes cityIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.city:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.city.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 0 6px 18px -10px rgb(var(--shadow-ink) / .55);
}
.city.is-active::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid var(--ochre);
  border-radius: var(--r-pill);
  opacity: .35;
  pointer-events: none;
  animation: ringPop var(--t-med) var(--ease);
}
@keyframes ringPop {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: .35; transform: scale(1); }
}

.cities__error {
  padding: 16px 18px;
  border: 1px dashed var(--terracotta);
  background: #faecdf;
  border-radius: var(--r-2);
  display: flex; align-items: center; gap: 16px;
  color: var(--terracotta-2);
}
.cities__error p { margin: 0; font-size: 14.5px; }

.setup__actions {
  display: flex; align-items: center; gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.setup__hint {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
}

/* ----------  Buttons ---------- */
.btn {
  --bg: var(--ink);
  --fg: var(--paper);
  --bd: var(--ink);
  appearance: none;
  border: 1px solid var(--bd);
  background: var(--bg);
  color: var(--fg);
  padding: 13px 22px;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  transition:
    transform var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease);
  box-shadow: 0 1px 0 var(--paper-edge), 0 10px 24px -16px rgb(var(--shadow-ink) / .5);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 1px 0 var(--paper-edge), 0 14px 28px -16px rgb(var(--shadow-ink) / .55); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 1px 0 var(--paper-edge); }
.btn--primary { --bg: var(--ink); --fg: var(--paper); --bd: var(--ink); }
.btn--ghost   { --bg: transparent; --fg: var(--ink); --bd: var(--ink); box-shadow: none; }
.btn--ghost:hover { background: var(--ink); --fg: var(--paper); }
.btn--sm { padding: 9px 16px; font-size: 11px; }
.btn__arrow {
  display: inline-block;
  transition: transform var(--t-fast) var(--ease);
}
.btn:hover .btn__arrow { transform: translateX(3px); }
.btn.is-busy { pointer-events: none; }
.btn.is-busy .btn__arrow { animation: spin 1s linear infinite; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ----------  Chat thread ---------- */
.thread {
  display: grid; gap: 18px;
  padding: 6px 0;
}
.bubble {
  --bubble-bg: var(--bone);
  --bubble-fg: var(--ink);
  --bubble-bd: var(--rule);
  position: relative;
  max-width: 78ch;
  padding: 16px 20px;
  background: var(--bubble-bg);
  color: var(--bubble-fg);
  border: 1px solid var(--bubble-bd);
  border-radius: var(--r-2);
  font-size: 15.5px;
  line-height: 1.55;
  animation: bubbleIn var(--t-med) var(--ease) backwards;
}
.bubble__role {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.bubble--user {
  justify-self: end;
  --bubble-bg: var(--ink);
  --bubble-fg: var(--paper);
  --bubble-bd: var(--ink);
}
.bubble--user .bubble__role { color: rgb(244 237 224 / .55); }
.bubble.is-pending {
  opacity: .68;
}
.bubble--assistant {
  justify-self: start;
  --bubble-bg: var(--bone);
}
.bubble--assistant::before {
  content: "";
  position: absolute;
  left: -10px; top: 18px;
  width: 8px; height: 8px;
  border-left: 1px solid var(--rule);
  border-top:  1px solid var(--rule);
  background: var(--bone);
  transform: rotate(-45deg);
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.bubble__time {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: .08em;
}
.bubble--user .bubble__time { color: rgb(244 237 224 / .45); }

/* ----------  Thinking dots ---------- */
.thinking {
  display: inline-flex;
  align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--bone);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  width: max-content;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  animation: lift var(--t-med) var(--ease);
}
.thinking__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ochre);
  display: inline-block;
  animation: dotPulse 1.4s var(--ease) infinite;
}
.thinking__dot:nth-child(2) { animation-delay: .18s; background: var(--ink); }
.thinking__dot:nth-child(3) { animation-delay: .36s; background: var(--olive); }
@keyframes dotPulse {
  0%, 80%, 100% { transform: translateY(0);   opacity: .4; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

/* ----------  Answer card ---------- */
.answer {
  position: relative;
  padding: 28px 30px;
  background: var(--bone);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  box-shadow: 0 1px 0 var(--paper-edge), 0 24px 40px -34px rgb(var(--shadow-ink) / .35);
  animation: lift var(--t-slow) var(--ease);
}
.answer__type {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 5px 12px 5px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  background: var(--paper);
}
.answer__type::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ochre);
}
.answer--question  .answer__type::before { background: var(--ochre); }
.answer--rec       .answer__type::before { background: var(--moss); }
.answer--safety    .answer__type::before { background: var(--terracotta); }

.answer__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.answer__meta {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  color: var(--ink-2);
}
.confidence {
  display: inline-flex; align-items: center; gap: 8px;
}
.confidence__bar {
  width: 64px; height: 4px;
  background: var(--paper-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.confidence__fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--ochre), var(--ochre-deep));
  width: 0;
  transition: width var(--t-slow) var(--ease);
}

.answer__title {
  font-family: var(--serif);
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -.005em;
  margin: 6px 0 14px;
}
.answer__body {
  font-size: 15.5px;
  color: var(--ink-2);
  max-width: 64ch;
}

.questions {
  margin-top: 18px;
  display: grid; gap: 10px;
  counter-reset: q;
}
.questions li {
  counter-increment: q;
  padding: 14px 16px 14px 52px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  position: relative;
  font-size: 15px;
  color: var(--ink);
}
.questions li::before {
  content: counter(q, decimal-leading-zero);
  position: absolute;
  left: 16px; top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--ochre-deep);
}

.route {
  margin-top: 22px;
  display: grid; gap: 10px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
}
.route__caption {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.step {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 16px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  align-items: start;
  animation: bubbleIn var(--t-med) var(--ease) backwards;
}
.step__n {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ochre-deep);
  line-height: 1;
}
.step__title {
  font-family: var(--serif);
  font-size: 17px;
  margin: 0 0 4px;
}
.step__body {
  font-size: 14.5px;
  color: var(--ink-2);
  margin: 0;
}
.step__contact {
  align-self: center;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--ink);
  padding: 8px 12px;
  border: 1px solid var(--ink);
  border-radius: var(--r-pill);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.step__contact:hover { background: var(--ink); color: var(--paper); }
.step__contact:not(a) {
  color: var(--ink-2);
  border-color: var(--rule);
}
.step__contact:not(a):hover {
  background: transparent;
  color: var(--ink-2);
}

/* Safety variant */
.answer--safety {
  background: linear-gradient(180deg, #f7e3d4 0%, var(--bone) 70%);
  border-color: #d8a78a;
}
.answer--safety .answer__title { color: var(--terracotta-2); }
.answer--safety .answer__type {
  background: var(--terracotta);
  color: var(--paper);
  border-color: var(--terracotta);
}
.answer--safety .answer__type::before { background: var(--paper); }
.answer--safety .step__contact {
  border-color: var(--terracotta);
  background: var(--terracotta);
  color: var(--paper);
}
.answer--safety .step__contact:hover { background: var(--terracotta-2); border-color: var(--terracotta-2); }
.answer--safety .step__contact:not(a) {
  background: transparent;
  color: var(--terracotta-2);
  border-color: #d8a78a;
}
.answer--safety .step__contact:not(a):hover {
  background: transparent;
  color: var(--terracotta-2);
}

/* ----------  Composer ---------- */
.composer {
  margin-top: 4px;
  background: var(--bone);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 14px 16px 12px;
  box-shadow: 0 1px 0 var(--paper-edge);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.composer:focus-within {
  border-color: var(--ink);
  box-shadow: 0 1px 0 var(--paper-edge), 0 10px 28px -22px rgb(var(--shadow-ink) / .5);
}
.composer textarea {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--ink);
  resize: vertical;
  min-height: 64px;
  padding: 4px 2px;
}
.composer textarea::placeholder { color: var(--ink-4); font-style: italic; }
.composer__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
}
.counter {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--ink-3);
}
.counter.is-warn { color: var(--ochre-deep); }
.counter.is-over { color: var(--terracotta); }
.composer__hint {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--ink-4);
}
kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-2);
}

/* ----------  Feedback ---------- */
.feedback {
  overflow: hidden;
  background: var(--bone);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 22px 24px;
  box-shadow: 0 1px 0 var(--paper-edge);
  animation: feedbackIn 420ms var(--ease);
}
@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(8px); max-height: 0; padding-top: 0; padding-bottom: 0; }
  to   { opacity: 1; transform: none; max-height: 800px; }
}
.feedback__head { margin-bottom: 16px; }
.feedback__title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  margin: 0;
}
.feedback__form { display: grid; gap: 18px; }
.feedback__rating,
.feedback__row {
  border: 0; padding: 0; margin: 0;
}
.feedback__rating legend {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.rating {
  display: inline-flex; gap: 6px;
  background: var(--paper);
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
}
.rating__star {
  appearance: none;
  border: 0;
  background: transparent;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  color: var(--ink-4);
  font-family: var(--serif);
  font-size: 18px;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.rating__star:hover { transform: translateY(-1px); color: var(--ochre-deep); }
.rating__star.is-active { color: var(--ochre-deep); }
.rating__star.is-selected {
  background: var(--ink);
  color: var(--paper);
}
.feedback__row {
  display: flex; flex-wrap: wrap; gap: 18px 24px;
}
.check {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 14.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.check input {
  appearance: none;
  width: 18px; height: 18px;
  border: 1px solid var(--ink-3);
  border-radius: 4px;
  background: var(--paper);
  display: inline-grid; place-items: center;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  position: relative;
}
.check input:checked {
  background: var(--ink);
  border-color: var(--ink);
}
.check input:checked::after {
  content: "";
  width: 5px; height: 9px;
  border: solid var(--paper);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.field { display: grid; gap: 6px; }
.field__label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field__label em {
  font-style: normal;
  color: var(--ink-4);
  margin-left: 6px;
  letter-spacing: .08em;
}
.field textarea {
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  background: var(--paper);
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color var(--t-fast) var(--ease);
}
.field textarea:focus { border-color: var(--ink); }

.feedback__actions {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.feedback__status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--moss);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.feedback__status.is-visible { opacity: 1; }
.feedback.is-sent { opacity: .6; }

/* ----------  Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px 12px 14px;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px);
  z-index: 50;
  box-shadow: 0 20px 40px -16px rgb(var(--shadow-ink) / .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.toast__icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--terracotta);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
}
.toast__text {
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: .01em;
}
.toast__close {
  background: transparent;
  border: 0;
  color: var(--paper);
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
  opacity: .6;
  transition: opacity var(--t-fast) var(--ease);
}
.toast__close:hover { opacity: 1; }

/* ----------  Hidden states ---------- */
[hidden] { display: none !important; }

/* ----------  Responsive ---------- */
@media (max-width: 960px) {
  .page {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 36px 24px 64px;
  }
  .top__inner {
    padding: 18px 24px 14px;
    flex-wrap: wrap;
    align-items: center;
  }
  .intro__headline {
    font-size: clamp(30px, 8vw, 44px);
  }
  .status { order: -1; }
}
@media (max-width: 520px) {
  .top__inner { gap: 12px; }
  .brand { gap: 12px; }
  .page { padding: 28px 18px 56px; }
  .answer { padding: 22px 20px; }
  .step { grid-template-columns: 36px 1fr; }
  .step__contact { grid-column: 1 / -1; justify-self: start; }
  .bubble { max-width: 100%; }
  .feedback { padding: 18px; }
  .composer textarea { font-size: 16px; }
}

/* ----------  Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .status__dot,
  .brand__mark span,
  .thinking__dot {
    animation: none !important;
  }
}
