@font-face {
  font-family: 'Manrope';
  src: url('/fonts/Manrope-Variable.ttf') format('truetype-variations');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #f4f5f1;
  --fg: #202b23;
  --brand: #00471b;
  --brand-hover: #0b5a2b;
  --zinc-200: #d9ded5;
  --zinc-300: #bbc4b8;
  --zinc-500: #626f60;
  --card-shadow: 0 2px 4px rgb(21 45 29 / 0.02), 0 12px 32px -20px rgb(21 45 29 / 0.18);
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Manrope', -apple-system, ui-sans-serif, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.55;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { text-wrap: balance; margin: 0; }

.app-header {
  background: linear-gradient(180deg, #0b5526 0%, #00471b 100%);
  color: #fff;
  padding: 16px 20px 12px;
}
.app-header .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 640px; margin: 0 auto; }
.app-header .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-header .logo { width: 40px; height: 40px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,30,10,0.35); }
.app-header .logo img { width: 34px; height: 34px; border-radius: 50%; }
.app-header .names { display: flex; flex-direction: column; min-width: 0; }
.app-header .name { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .tag { font-size: 11.5px; font-weight: 500; color: #b9dcc0; margin-top: 1px; }
.app-header .tagline { margin: 10px auto 0; max-width: 640px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; font-size: 12.5px; color: #cfe6cf; }
.app-header .share-btn { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(208,239,186,.3); background: rgba(255,255,255,.07); color: #d9ecd6; flex-shrink: 0; }
.app-header .share-btn svg { width: 17px; height: 17px; }

/* Заголовок экрана + описание — ВНЕ белой карточки, прямо на фоне
 * страницы, с волосяной линией снизу (перенос PageTitle из
 * app/components/page-shell.tsx: .page-title { border-bottom; padding-bottom }). */
.screen-head { max-width: 420px; margin: 20px auto 0; padding: 0 16px 20px; border-bottom: 1px solid var(--zinc-200); }
.screen-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: var(--fg); }
.screen-head p { margin-top: 10px; font-size: 14px; line-height: 1.5; color: var(--zinc-500); }
/* Нижняя панель — перенос BottomNav, фиксирована внизу экрана, как в
 * основном приложении (там это последний flex-child на всю высоту
 * вьюпорта; здесь, без SPA-обёртки, проще и надёжнее через position:fixed). */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--zinc-200); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.bottom-nav ul { display: flex; justify-content: space-around; max-width: 640px; margin: 0 auto; padding: 0; list-style: none; }
.bottom-nav li { flex: 1; min-width: 0; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 2px; color: var(--zinc-500); text-decoration: none; }
.bottom-nav a:hover { text-decoration: none; color: var(--brand); }
.bottom-nav .icon-tile { display: flex; align-items: center; justify-content: center; width: 46px; height: 30px; border-radius: 10px; transition: background .15s, color .15s; }
.bottom-nav .icon-tile svg { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.active .icon-tile { background: var(--brand); color: #fff; }
.bottom-nav .label { font-size: 10px; font-weight: 600; line-height: 1.1; text-align: center; padding: 0 1px; }

main { display: flex; justify-content: center; padding: 24px 16px calc(84px + env(safe-area-inset-bottom)); }
.card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 20px; box-shadow: var(--card-shadow); border: 1px solid #ebeee6; }
.card.wide { max-width: 560px; }

h1.page-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 16px; color: var(--fg); }
h2.section-title { font-size: 14px; font-weight: 700; margin: 22px 0 8px; color: var(--fg); }

input[type=text], input[type=email], input[type=tel], input[type=number], textarea, select {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--zinc-200);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 10px;
  background: var(--bg);
  color: var(--fg);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 71 27 / 0.15); }
input[type=checkbox] { accent-color: var(--brand); }

/* Перенос PhotoPicker (app/components/photo-picker.tsx): до выбора файла —
 * две плитки "Сделать фото"/"Из галереи" (используют одно и то же поле
 * ввода — на мобильных capture="environment" сам предлагает камеру, но
 * показываем два явных варианта для совпадения с оригиналом), после
 * выбора — превью на всю ширину и те же два пункта строкой ниже. */
.photo-picker-label { display: block; font-size: 15px; font-weight: 600; color: var(--fg); margin-bottom: 10px; }
.photo-picker { border: 1px solid var(--zinc-200); border-radius: 16px; overflow: hidden; margin-bottom: 14px; background: #fff; }
.photo-picker .preview { display: none; width: 100%; max-height: 220px; object-fit: contain; background: var(--zinc-200); }
.photo-picker.has-file .preview { display: block; }
.photo-picker .tiles { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--zinc-200); }
.photo-picker:not(.has-file) .tiles { border-top: none; }
.photo-picker .tile { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 26px 10px; font-size: 13.5px; font-weight: 500; color: var(--zinc-500); border-right: 1px solid var(--zinc-200); }
.photo-picker:not(.has-file) .tile { flex-direction: column; gap: 9px; }
.photo-picker.has-file .tile { padding: 13px 10px; font-size: 13px; }
.photo-picker .tile:last-child { border-right: none; }
.photo-picker .tile svg { width: 26px; height: 26px; flex-shrink: 0; }
.photo-picker.has-file .tile svg { width: 17px; height: 17px; }
.photo-picker .tile input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-picker .filename { font-size: 11.5px; color: var(--zinc-500); text-align: center; padding: 6px 10px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }
.photo-picker.has-file .filename { display: block; }

/* Переключатель метода (SEGMENT_GROUP/segmentClass из app/components/ui.ts):
 * серая пилюля-контейнер, выбранный сегмент — сплошная зелёная заливка. */
.segment-group { display: flex; border-radius: 12px; background: #eef0ea; padding: 4px; gap: 2px; margin-bottom: 14px; }
.segment-group label { flex: 1; text-align: center; padding: 9px 6px; border-radius: 10px; font-size: 13px; font-weight: 500; color: var(--zinc-500); cursor: pointer; position: relative; }
.segment-group input { position: absolute; opacity: 0; }
.segment-group label:has(input:checked) { background: var(--brand); color: #fff; font-weight: 600; }

button, .btn {
  display: inline-block;
  padding: 13px 20px;
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 20px -10px rgb(0 71 27 / 0.55);
}
button:hover, .btn:hover { background: var(--brand-hover); text-decoration: none; }
button:disabled { background: var(--zinc-300); cursor: not-allowed; box-shadow: none; }
button.secondary { background: #fff; color: var(--fg); border: 1px solid var(--zinc-200); box-shadow: none; }
button.secondary:hover { background: #f7f8f4; }
button.block { width: 100%; }

.error { color: #c21807; font-size: 13.5px; margin-bottom: 12px; background: #fdecea; border-radius: 10px; padding: 10px 12px; }
.ok { color: var(--brand); font-size: 13.5px; margin-bottom: 12px; background: #eaf5ea; border-radius: 10px; padding: 10px 12px; }
.note, .hint { font-size: 12.5px; color: var(--zinc-500); margin-top: 8px; }
.demo { background: #fdf3d9; color: #8a6d00; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.warn { background: #fdf3d9; color: #8a6d00; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; margin-bottom: 16px; }

.swatch { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); vertical-align: -2px; }

/* Чипы (поверхность/алмазная грань/что на фото) — перенос chipClass()
 * из app/components/ui.ts: рамка, при выборе — зелёная рамка/текст и
 * лёгкая зелёная заливка. Нативный radio спрятан, но остаётся кликабельным
 * и доступным — подсветка через :has(:checked), без JS. */
.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 6px; border: 1px solid var(--zinc-200); border-radius: 12px; padding: 9px 13px; cursor: pointer; font-size: 13.5px; background: #fff; min-height: 40px; }
.chip:has(input:checked) { border-color: var(--brand); background: rgb(0 71 27 / 0.05); color: var(--brand); font-weight: 600; box-shadow: 0 0 0 1px var(--brand); }
.chip input { width: auto; margin: 0; position: absolute; opacity: 0; }

/* Сетка цветов — перенос COLOR_PALETTE.map(...) из generate-flow.tsx:
 * 2 колонки (как на телефоне), круглый образец цвета + название, при
 * выборе — зелёная рамка/кольцо и лёгкая заливка. */
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 420px) { .color-grid { grid-template-columns: 1fr 1fr 1fr; } }
.color-opt { position: relative; display: flex; align-items: center; gap: 9px; border: 1px solid var(--zinc-200); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-size: 13.5px; background: #fff; min-width: 0; }
.color-opt:has(input:checked) { border-color: var(--brand); background: rgb(0 71 27 / 0.05); font-weight: 600; box-shadow: 0 0 0 1px var(--brand); }
.color-opt input { position: absolute; opacity: 0; }
.color-opt .swatch { width: 20px; height: 20px; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1); }
.color-opt span.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); min-width: 0; flex: 1; }

fieldset { border: none; padding: 0; margin: 0 0 14px; }
legend { font-size: 12.5px; color: var(--zinc-500); margin-bottom: 6px; padding: 0; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--zinc-200); }

.stat { background: #eaf5ea; border-radius: 10px; padding: 10px 14px; font-size: 13px; min-width: 110px; }
.stat b { display: block; font-size: 18px; color: var(--brand); }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }

.balance-pill { display: inline-block; background: #eaf5ea; color: var(--brand); padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 13.5px; }

img.result { width: 100%; border-radius: 14px; margin-top: 16px; display: block; }

.msg { padding: 10px 14px; border-radius: 14px; margin-bottom: 8px; font-size: 14px; max-width: 85%; }
.msg.user { background: var(--brand); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.msg.assistant { background: #eef0ea; color: var(--fg); border-bottom-left-radius: 4px; }
.suggestion { margin-top: 6px; font-size: 12.5px; }
.suggestion a { font-weight: 700; }

.hist { font-size: 13px; border-bottom: 1px solid var(--zinc-200); padding: 8px 0; display: flex; justify-content: space-between; }
