@import url("./public/fonts/fonts.css");

:root {
  --red: #b90505;
  --petrol: #066678;
  --paper: #f2f0ea;
  --ink: #24211c;
  --ink-soft: #5d574d;
  --line: #d8d3c8;
  --card: #fffdf8;
  --focus: 2px solid var(--petrol);
  --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "PT Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.5;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ── Шапка ─────────────────────────────────────── */
.top { background: var(--card); border-bottom: 3px solid var(--red); }
.top .wrap { padding-top: 18px; padding-bottom: 22px; }
.brand { margin: 0 0 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.brand-mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px;
  background: var(--red); color: #fff; border-radius: 6px;
  font-family: "PT Serif", serif; font-weight: 700; font-size: 12px; letter-spacing: 0;
}
h1 {
  margin: 0 0 6px; font-family: "PT Serif", serif; font-weight: 700;
  font-size: clamp(24px, 4vw, 34px); line-height: 1.15;
}
h1::after { content: ""; display: block; width: 56px; height: 3px; background: var(--red); margin-top: 8px; }
.sub { margin: 12px 0 0; max-width: 60ch; color: var(--ink-soft); }

/* ── Сетка ─────────────────────────────────────── */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; padding-top: 24px; padding-bottom: 56px; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 20px; margin: 0 0 18px;
}
legend { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 0; font-family: "PT Serif", serif; font-size: 20px; font-weight: 700; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  background: var(--ink); color: #fff; border-radius: 50%; font-family: "PT Sans", sans-serif; font-size: 14px; font-weight: 700;
}

/* ── Поля ─────────────────────────────────────── */
.field { margin: 16px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.field-label { margin: 0; font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.field-label small { text-transform: none; letter-spacing: 0; font-weight: 400; }

.check { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; cursor: pointer; }
.check.main-check { font-weight: 700; font-size: 17px; }
.check input { width: 20px; height: 20px; accent-color: var(--red); flex: none; translate: 0 4px; }
.check small { color: var(--ink-soft); }

.sub-block { margin: 6px 0 6px 30px; padding: 10px 14px; border-left: 3px solid var(--line); display: flex; flex-direction: column; gap: 6px; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span {
  display: inline-block; padding: 8px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; min-height: 40px; line-height: 22px;
}
.seg input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg input:focus-visible + span { outline: var(--focus); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span {
  display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; cursor: pointer; min-height: 36px; line-height: 20px; font-size: 15px;
}
.chip input:checked + span { background: #fdecec; border-color: var(--red); color: var(--red); font-weight: 700; }
.chip input:focus-visible + span { outline: var(--focus); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: grid; justify-items: center; gap: 4px; cursor: pointer; width: 74px; }
.swatch input { position: absolute; opacity: 0; }
.swatch .dot {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--c, #fff); box-shadow: inset 0 0 0 3px #fff;
}
.swatch .dot-photo { background: repeating-linear-gradient(45deg, #e8e2d5 0 6px, #cfc7b5 6px 12px); box-shadow: none; }
.swatch .sw-label { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.2; }
.swatch input:checked ~ .dot { border-color: var(--red); outline: 3px solid #f4b8b8; outline-offset: 1px; }
.swatch input:focus-visible ~ .dot { outline: var(--focus); outline-offset: 2px; }
.swatch input:checked ~ .sw-label { color: var(--ink); font-weight: 700; }

.textfield { display: flex; flex-direction: column; gap: 4px; max-width: 420px; }
.textfield.inline { max-width: 300px; }
.textfield span { font-size: 14px; color: var(--ink-soft); }
.textfield input, .textfield select {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.textfield input:focus-visible, .textfield select:focus-visible { outline: var(--focus); }

/* Счётчик окон */
.win-count { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.win-count output { min-width: 88px; text-align: center; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.step-btn { width: 44px; height: 44px; font-size: 22px; padding: 0; }
.win-hint { font-size: 13px; color: var(--ink-soft); }

/* ── Фото ─────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); background: #fff;
  padding: 30px 20px; text-align: center; cursor: pointer;
}
.photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.slot-label { margin: 0 0 6px; font-weight: 700; font-size: 14px; }
.slot-label small { display: block; font-weight: 400; color: var(--ink-soft); }
.photo-grid .dropzone { padding: 24px 14px; min-height: 112px; display: flex; flex-direction: column; justify-content: center; }
.photo-grid .photo-preview img { max-height: 220px; }
.dropzone.small { padding: 16px 14px; }
.dropzone.small .dz-title { font-size: 15px; }
.project-slot { margin-top: 6px; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover { border-color: var(--petrol); background: #f0f7f8; }
.dropzone:focus-visible { outline: var(--focus); }
.dz-title { margin: 0 0 4px; font-weight: 700; }
.dz-hint { margin: 0; color: var(--ink-soft); font-size: 14px; }
.photo-preview { margin: 14px 0 0; }
.photo-preview img { max-width: 100%; max-height: 340px; border-radius: 8px; border: 1px solid var(--line); }
.photo-preview figcaption { display: flex; gap: 10px; margin-top: 8px; }
.error { color: var(--red); font-weight: 700; margin: 10px 0 0; }
.auto-badge {
  margin: 14px 0 0; padding: 10px 14px; background: #fdf6dd; border: 1px solid #e5d489;
  border-radius: 8px; font-size: 14px; color: #6b5b12;
}

/* ── Карточки декора ──────────────────────────── */
.decor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.decor-grid.three { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.dcard { position: relative; display: grid; gap: 6px; cursor: pointer; }
.dcard input { position: absolute; opacity: 0; inset: 0; }
.dcard img {
  width: 100%; aspect-ratio: 3 / 2.2; object-fit: cover; border-radius: 8px;
  border: 2px solid var(--line); background: #fff;
}
.d-name { font-size: 14px; font-weight: 700; line-height: 1.25; display: grid; gap: 1px; }
.d-name small { font-weight: 400; color: var(--ink-soft); }
.d-name.plain { padding: 10px 4px; }
.dcard input:checked ~ img { border-color: var(--red); outline: 2px solid #f4b8b8; }
.dcard input:checked ~ .d-name { color: var(--red); }
.dcard input:focus-visible ~ img { outline: var(--focus); outline-offset: 2px; }
.dcard:hover img { border-color: var(--ink-soft); }

/* Ближайший пример */
.example-box { margin-top: 20px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.example-box img { width: 100%; border-radius: 6px; }
.example-title { margin: 8px 0 0; font-size: 13px; color: var(--ink-soft); text-align: center; }

/* ── Кнопки, футер формы ──────────────────────── */
.btn {
  font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; min-height: 44px;
}
.btn.primary { background: var(--red); color: #fff; width: 100%; }
.btn.primary:hover { background: #970404; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink-soft); }
.btn.ghost.danger { color: var(--red); }
.btn:focus-visible { outline: var(--focus); outline-offset: 2px; }
.btn[aria-pressed="true"], .btn.copied { background: var(--petrol); border-color: var(--petrol); color: #fff; }

.form-footer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 2px; }
.draft-status { font-size: 13px; color: var(--ink-soft); }

/* ── Результат ────────────────────────────────── */
.result .sticky { position: sticky; top: 16px; }
.test-note { margin: 0 0 14px; padding: 10px 14px; background: #fdf6dd; border: 1px solid #e5d489;
  border-radius: 8px; font-size: 13.5px; color: #6b5b12; } /* янтарная заметка — как auto-badge, но над блоком */
.result h2 { font-family: "PT Serif", serif; font-size: 19px; margin: 0 0 6px; }
.result h2.mt { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.res-hint { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-soft); }
#prompt {
  width: 100%; min-height: 320px; resize: vertical; font: 13px/1.55 ui-monospace, Consolas, monospace;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfaf6; color: var(--ink);
}
#prompt:focus-visible { outline: var(--focus); }

.reflist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.reflist li { display: flex; align-items: center; gap: 10px; }
.reflist img { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.reflist .r-name { flex: 1; font-size: 14px; }
.reflist a {
  color: var(--petrol); font-weight: 700; text-decoration: none; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line);
}
.reflist a:hover { border-color: var(--petrol); }
.reflist a:focus-visible { outline: var(--focus); }
.empty-refs { font-size: 13.5px; color: var(--ink-soft); margin: 0; }

.mt-s { margin-top: 12px; }

/* ── Смета по отчёту ИИ ───────────────────────── */
#report-in {
  width: 100%; resize: vertical; font: 13px/1.5 ui-monospace, Consolas, monospace;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fbfaf6; color: var(--ink);
  margin-bottom: 8px;
}
#report-in:focus-visible { outline: var(--focus); }
.report-out { margin-top: 12px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.report-table td { padding: 6px 6px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.report-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-total { margin: 10px 0 2px; font-size: 15px; }
.report-range {
  margin: 4px 0 0; font-size: 17px; color: var(--petrol); font-weight: 700;
}
.report-range small { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 400; margin-top: 2px; }

.tg-status { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.tg-status.err { color: var(--red); font-weight: 700; }
.tg-status.ok { color: var(--petrol); font-weight: 700; }
.tg-status .link { color: var(--petrol); }

.disclaimer {
  margin: 18px 0 0; padding: 10px 12px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-soft);
}

.foot { padding-bottom: 40px; color: var(--ink-soft); font-size: 13px; }

@media (max-width: 640px) {
  .dcard img { aspect-ratio: 4 / 2.6; }
  .swatch { width: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
