/* Мир прогнозов — аварийная версия. Общие стили. */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #2b2620;
  --muted: #7a7064;
  --line: #e8e1d6;
  --accent: #c8752a;
  --accent-ink: #ffffff;
  --plus: #4f9a52;
  --plus-soft: #dcefd9;
  --minus: #c8463c;
  --minus-soft: #f6d9d5;
  --zero: #b9ad9c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 38, 32, .06), 0 6px 24px rgba(43, 38, 32, .06);
  --font: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Lora", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
/* Тёмная тема: по системе, если пользователь не выбрал сам; кнопка в шапке ставит data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916;
    --surface: #25221e;
    --ink: #eee7dc;
    --muted: #a69c8e;
    --line: #3a352f;
    --accent: #e0914a;
    --accent-ink: #1b1916;
    --plus: #78c27a;
    --plus-soft: #2c3f2b;
    --minus: #e2766c;
    --minus-soft: #46292a;
    --zero: #6f665a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1916;
  --surface: #25221e;
  --ink: #eee7dc;
  --muted: #a69c8e;
  --line: #3a352f;
  --accent: #e0914a;
  --accent-ink: #1b1916;
  --plus: #78c27a;
  --plus-soft: #2c3f2b;
  --minus: #e2766c;
  --minus-soft: #46292a;
  --zero: #6f665a;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
}
img, svg { max-width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; font-weight: 600; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0 0 .4em; }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 1.6em 0 .6em; }
.muted { color: var(--muted); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

/* Шапка */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top .wrap { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; }
.logo { font-family: var(--serif); font-size: 1.3rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.logo span { color: var(--accent); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.nav a { padding: 8px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.nav a:hover, .nav a[aria-current] { background: var(--bg); color: var(--accent); }

main { padding: 32px 0 64px; }
.foot { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: .9rem; }

/* Карточки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.grid2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.tile { display: block; text-decoration: none; color: var(--ink); transition: transform .15s; }
.tile:hover { transform: translateY(-2px); }
.tile h2 { margin-top: 0; color: var(--accent); }

/* Формы */
form .row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 16px; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.field-error input, .field-error select { border-color: var(--minus); background: var(--minus-soft); }
.field-msg { color: var(--minus); font-size: .85rem; margin: 4px 0 0; }
.hint { font-size: .85rem; color: var(--muted); margin: 4px 0 0; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; margin-bottom: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 13px 26px; border: 0;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font: 600 1rem var(--font); cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.error-box { background: var(--minus-soft); color: var(--ink); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.time-toggle { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.time-toggle label { display: inline-flex; gap: 6px; align-items: center; margin: 0; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.time-toggle input { width: auto; }

/* Поиск города */
.city { position: relative; }
.city-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px;
  list-style: none; max-height: 280px; overflow: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.city-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.city-list li[aria-selected="true"], .city-list li:hover { background: var(--bg); }
.city-list small { color: var(--muted); }
.city-picked { font-size: .85rem; color: var(--plus); margin-top: 4px; }

/* Загрузка */
.loading { display: flex; gap: 12px; align-items: center; color: var(--muted); padding: 24px 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Результат: шапка */
.result-head { margin-bottom: 8px; }
.result-head p { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }

/* Переключатель вида ромашек */
.switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.switch button { border: 0; background: none; font: inherit; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Ромашки */
.chamomiles { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); margin-top: 16px; }
.chamomile-card h3 { margin: 0 0 8px; font-size: 1.1rem; text-align: center; }
.chamomile-svg { display: block; width: 100%; height: auto; }
.chamomile-svg text { font-family: var(--font); fill: var(--ink); }
.chamomile-svg .lbl { font-size: 15px; }
.chamomile-svg .val { font-size: 16px; font-weight: 700; }

/* Оригинальные ромашки (png-клетки) */
.orig-wrap { overflow-x: auto; }
.orig { position: relative; margin: 0 auto; background: #fff; border-radius: 10px; color: #333; }
.orig img { position: absolute; max-width: none; }
.orig .olbl { position: absolute; font-size: 11px; line-height: 1.2; text-align: center; width: 110px; margin-left: -55px; }
.orig .oval { position: absolute; font-size: 12px; font-weight: 700; width: 24px; margin-left: -12px; text-align: center; }

/* Шкалы черт */
.traits { display: grid; gap: 10px; margin-top: 16px; }
.trait { padding: 16px 18px; }
.trait-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.trait-title { font-weight: 600; }
.trait-verdict { font-size: .92rem; }
.trait-verdict.plus { color: var(--plus); }
.trait-verdict.minus { color: var(--minus); }
.scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; margin: 10px 0 4px; }
.scale i { height: 12px; border-radius: 3px; background: var(--line); }
.scale i.on.minus { background: var(--minus); }
.scale i.on.plus { background: var(--plus); }
.scale i.zero { background: var(--zero); }
.poles { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; font-size: .78rem; color: var(--muted); }
.poles span:nth-child(2) { text-align: center; }
.poles span:nth-child(3) { text-align: right; }
.trait details { margin-top: 8px; }
.trait summary { cursor: pointer; color: var(--accent); font-size: .92rem; }
.trait details p { margin: 8px 0 0; }

/* Совместимость */
.rel-cards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 16px; }
.rel-cards h3 { margin: 0 0 14px; font-size: 1.1rem; }
.factor { margin-bottom: 14px; }
.factor-top { display: flex; justify-content: space-between; gap: 10px; }
.factor-name { font-weight: 600; }
.factor-word { color: var(--muted); }
.meter { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 6px; }
.meter i { height: 10px; border-radius: 3px; background: var(--line); }
.meter i.on { background: var(--accent); }
.prose p { margin: 0 0 1em; }

.notice { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; font-size: .9rem; color: var(--muted); }

@media (max-width: 520px) {
  .card { padding: 18px; }
  .poles { font-size: .72rem; }
  .nav { margin-left: 0; }
}
@media print {
  .top, .foot, .actions, .switch, form { display: none !important; }
  .card { box-shadow: none; }
}

/* Анимация лепестков новых ромашек */
@keyframes petal { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chamomile-svg path { animation: none !important; opacity: 1 !important; } }

/* Обёртка оригинальных ромашек: масштаб под ширину экрана */
.chamomiles-orig { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); background: none; margin-top: 16px; }
.orig-box { position: relative; overflow: hidden; width: 100%; max-width: 520px; margin: 0 auto; background: #f2f0e4; border-radius: 10px; }

/* Статья «Об авторе» */
.article { max-width: 760px; margin: 0 auto; line-height: 1.65; }
.article .lead { font-size: 1.08em; }
.article h2.q { font-size: 1.15em; margin: 1.6em 0 .5em; color: var(--accent); }
.article .note { font-size: .92em; color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; }
.article .btn { margin: 6px 6px 0 0; }

/* Кнопка темы в шапке */
.theme-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 1.1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.theme-btn:hover { color: var(--accent); }

/* Кнопка отправки во время расчёта */
.btn[aria-busy="true"]::before { content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .shake { animation: none; } }

/* Подвал: ссылки и оговорка */
.foot p { margin: 0 0 8px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px; }
.foot a { color: var(--muted); }
.foot .legal { font-size: .8rem; line-height: 1.5; max-width: 820px; }

/* Плашка cookie */
.cookie-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 100; max-width: 760px; margin: 0 auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .18); padding: 18px 20px calc(18px + env(safe-area-inset-bottom, 0px)); }
.cookie-bar p { margin: 0 0 12px; font-size: .92rem; }
.cookie-bar .actions { margin: 0; }
.btn-sm { padding: 9px 16px; font-size: .92rem; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.opt input { width: auto; margin-top: 5px; }
.opt b { display: block; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl-wrap { overflow-x: auto; }
@media print { .cookie-bar, .theme-btn { display: none !important; } }
