/* Спарринг: тёплые нейтрали + один кирпично-бордовый акцент (см. DESIGN.md) */
:root {
  --bg: #f6f4ef;
  --surface: #fdfcfa;
  --text: #292521;
  --muted: #7a746b;
  --line: #e6e2da;
  --accent: #8f2d2b;
  --accent-ink: #ffffff;
  --accent-soft: #f3e6e0;
  --ok: #4e7d5b;
  --warn: #b3543f;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
body.dark {
  --bg: #1b1917;
  --surface: #242120;
  --text: #ece9e4;
  --muted: #98918a;
  --line: #37332f;
  --accent: #d07a5c;
  --accent-ink: #221410;
  --accent-soft: #33241e;
  --ok: #7fae8d;
  --warn: #d98a75;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
  touch-action: pan-y;
}
.screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  overflow-x: hidden;
}
h1, .lead, .chat-title b, .chat-title span { overflow-wrap: anywhere; }
.hidden { display: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:active { transform: scale(.985); transition: transform 150ms var(--ease); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Типографика */
.kicker {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); margin-bottom: 6px;
}
h1 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 14px; margin-top: 8px; max-width: 62ch; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.footnote { color: var(--muted); font-size: 12px; text-align: center; margin-top: auto; padding-top: 24px; }

/* Кнопки */
.primary {
  display: block; width: 100%; padding: 13px; margin-top: 18px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 10px; font-weight: 600; font-size: 15px;
}
.primary:disabled { opacity: .5; }
.secondary {
  display: block; width: 100%; padding: 13px; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; font-weight: 500;
}
.back {
  color: var(--muted); font-size: 13px; padding: 0 0 10px;
  text-align: left; width: fit-content;
}
.back::before { content: "‹ "; }

/* Согласие и ниша */
.consent-wrap { margin: auto 0; padding: 24px 0; }
.consent-box {
  margin-top: 20px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  font-size: 13.5px; color: var(--text);
}
input[type="text"], textarea {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 13px; font: inherit; outline: none;
  font-size: 16px; /* меньше 16px нельзя: iOS зумит страницу при фокусе */
}

/* Выбор формата продаж */
.segment { display: grid; gap: 8px; margin-top: 14px; }
.segment-opt {
  text-align: left; padding: 11px 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.segment-opt b { font-size: 14.5px; }
.segment-opt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.segment-opt.on { border-color: var(--accent); }
.segment-opt.on b { color: var(--accent); }
input[type="text"] { margin-top: 18px; }
input[type="text"]:focus, textarea:focus { border-color: var(--accent); }

/* Главная */
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 8px 2px 16px; }
.niche-chip {
  max-width: 46%; padding: 7px 11px; margin-top: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.niche-chip::after { content: " ›"; color: var(--accent); }

/* Очки и лига */
.points-line { font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 8px; }

/* Сообщество: предложить / голосовать */
.community-cta {
  text-align: left; padding: 13px; margin-top: 14px;
  background: var(--surface); border: 1px dashed var(--accent); border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--accent);
}
.community-cta::before { content: "+ "; }
.propose-box { display: grid; gap: 8px; margin-bottom: 8px; }
.vote {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 12px; border-radius: 10px; align-self: center;
  border: 1px solid var(--line); background: var(--surface);
  font-variant-numeric: tabular-nums; min-width: 46px;
}
.vote b { font-size: 15px; font-weight: 700; }
.vote small { font-size: 10px; color: var(--muted); }
.vote.on { border-color: var(--accent); background: var(--accent-soft); }
.vote.on b { color: var(--accent); }
.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ok); font-weight: 700;
}

/* Заявки на доступ (владелец) */
.admin-row {
  text-align: left; padding: 11px 13px; margin-bottom: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--accent);
}
.approve {
  padding: 8px 14px; border-radius: 999px; align-self: center;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 600;
}
.reject {
  padding: 8px 12px; border-radius: 999px; align-self: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-size: 13px;
}
.empty { color: var(--muted); font-size: 14px; padding: 22px 2px; text-align: center; }

/* Списки-ряды */
.rows { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 2px 12px;
  align-items: baseline; text-align: left;
  padding: 14px 2px; border-bottom: 1px solid var(--line);
  min-width: 0; max-width: 100%;
}
.row b, .row small { overflow-wrap: anywhere; }
.row:first-child { border-top: 1px solid var(--line); }
.row .num {
  font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted);
}
.row b { font-size: 15.5px; font-weight: 600; }
.row small { grid-column: 2; color: var(--muted); font-size: 13px; }
.row .aside { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row .aside.free { color: var(--ok); font-weight: 600; }
.row.locked b, .row.locked .num { color: var(--muted); }
.row.locked .aside { color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .row:hover b { color: var(--accent); } .row.locked:hover b { color: var(--muted); } }

.sub-head { padding: 6px 2px 16px; }

/* Спарринг */
.chat-head { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 6px 2px 12px; border-bottom: 1px solid var(--line); }
.chat-head .back { grid-column: 1 / -1; }
.chat-title { min-width: 0; }
.chat-title b { display: block; font-size: 15.5px; }
.chat-title span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.twist {
  align-self: center; padding: 8px 14px;
  border: 1px solid var(--accent); color: var(--accent);
  border-radius: 999px; font-size: 13px; font-weight: 600;
}
.twist:disabled { opacity: .45; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px 0; }
.msg {
  max-width: 88%; padding: 9px 13px; border-radius: 13px; font-size: 14.5px; white-space: pre-wrap;
  overflow-wrap: anywhere;
  opacity: 0; transform: translateY(4px); animation: pop 200ms var(--ease) forwards;
}
@keyframes pop { to { opacity: 1; transform: none; } }
.msg.client { background: var(--surface); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.seller { background: var(--accent-soft); border: 1px solid transparent; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.system {
  align-self: center; background: none; border: 0; color: var(--muted);
  font-size: 12.5px; text-align: center; max-width: 100%; padding: 2px 8px;
}
.msg.typing { color: var(--muted); }
.msg.typing i { display: inline-block; font-style: normal; animation: blink 1.2s infinite; }
@keyframes blink { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 4px; }
textarea { flex: 1; resize: none; max-height: 120px; font-size: 16px; }
.send {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.send:disabled { opacity: .45; }
.finish { margin-top: 10px; padding: 11px; border-radius: 10px; color: var(--muted); font-size: 13.5px; border: 1px dashed var(--line); }
.restart {
  margin-top: 10px; padding: 12px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14px;
}

/* Разбор */
.scores { display: grid; gap: 11px; padding: 16px 2px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.score-row { display: grid; grid-template-columns: 1fr 44px; gap: 5px 10px; align-items: center; }
.score-row label { font-size: 13px; color: var(--muted); }
.score-row .num { font-variant-numeric: tabular-nums; text-align: right; font-size: 14.5px; font-weight: 600; }
.bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform 240ms var(--ease); }
.block-note { padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.block-note h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 6px; font-weight: 600;
}
.block-note.good h3 { color: var(--ok); }
.block-note.bad h3 { color: var(--warn); }
.block-note ul { list-style: none; }
.block-note li { padding: 3px 0 3px 16px; position: relative; }
.block-note li::before { content: "·"; position: absolute; left: 4px; color: var(--accent); }
.debrief-actions { margin-top: 18px; }

@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; opacity: 1; transform: none; }
  .bar i { transition: none; }
}
