/* ============================================================
   «Рядом» — спокойный, тёплый, минималистичный интерфейс
   Мобильный в первую очередь, без внешних зависимостей
   ============================================================ */

:root {
  /* Палитра: тёплая бумага + спокойные акценты */
  --bg: #FFF8F0;
  --bg-soft: #FDF1E4;
  --surface: #FFFFFF;
  --ink: #3B332C;
  --ink-soft: #7A6F64;
  --ink-faint: #7E7366;
  --line: #EFE4D6;
  --accent: #BE5A16;          /* тёплый терракотовый (WCAG AA на белом) */
  --accent-soft: #FBE7D4;
  --accent-ink: #8A4510;
  --green: #4C7F58;
  --green-soft: #E4F1E7;
  --blue: #4A7BA3;
  --blue-soft: #E3EEF6;
  --violet: #7563AE;
  --violet-soft: #ECE7F6;
  --rose: #A85A5A;
  --rose-soft: #F6E5E5;
  --danger: #B84A4A;
  --danger-soft: #F7E4E4;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(59, 51, 44, .05), 0 4px 14px rgba(59, 51, 44, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 17px;
  min-height: 100dvh;
}

/* ---------- Доступность ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus { left: 8px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Шапка ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header__inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.app-logo__mark {
  width: 30px; height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #FFC98A 0%, #F2A65A 55%, #E8843C 100%);
  box-shadow: 0 0 0 5px var(--accent-soft);
  flex: none;
}
.app-logo__name { font-weight: 700; font-size: 19px; letter-spacing: .01em; }

.lang-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Основная область ---------- */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px calc(var(--nav-h) + 40px);
}

.view > * + * { margin-top: 18px; }

/* ---------- Типографика ---------- */
h1 { font-size: 27px; line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 21px; line-height: 1.3; margin: 0; }
h3 { font-size: 17px; margin: 0; }
p  { margin: 0; }
.lead { color: var(--ink-soft); font-size: 18px; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.faint { color: var(--ink-faint); }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease;
}
.card-link:hover { border-color: var(--accent); }
.card-link:active { transform: scale(.985); }
.card-link__body { flex: 1; min-width: 0; }
.card-link__title { font-weight: 650; font-size: 17px; line-height: 1.35; }
.card-link__sub { color: var(--ink-soft); font-size: 14px; margin-top: 3px; }
.card-link__chev { color: var(--ink-faint); flex: none; }

/* ---------- Направления ---------- */
.dir-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 420px) { .dir-grid { grid-template-columns: 1fr; } }

.dir-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
  padding: 20px 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.dir-card:active { transform: scale(.98); }
.dir-card__icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.dir-card__icon svg { width: 26px; height: 26px; }
.dir-card__title { font-weight: 700; font-size: 18px; line-height: 1.3; }
.dir-card__sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

.dir-card--autism   { background: linear-gradient(160deg, #FFFFFF, var(--blue-soft)); }
.dir-card--autism .dir-card__icon   { background: var(--blue-soft); color: var(--blue); }
.dir-card--palsy    { background: linear-gradient(160deg, #FFFFFF, var(--green-soft)); }
.dir-card--palsy .dir-card__icon    { background: var(--green-soft); color: var(--green); }
.dir-card--down     { background: linear-gradient(160deg, #FFFFFF, var(--violet-soft)); }
.dir-card--down .dir-card__icon     { background: var(--violet-soft); color: var(--violet); }
.dir-card--oncology { background: linear-gradient(160deg, #FFFFFF, var(--rose-soft)); }
.dir-card--oncology .dir-card__icon { background: var(--rose-soft); color: var(--rose); }

/* ---------- Быстрые действия ---------- */
.quick-actions { display: grid; gap: 12px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  border-radius: 999px;
  padding: 13px 24px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: 48px;
  transition: filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { filter: brightness(.95); }
.btn--soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn--ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 8px 18px; font-size: 15px; }

/* ---------- Списки разделов ---------- */
.section-list { display: grid; gap: 12px; list-style: none; margin: 0; padding: 0; }

.tag {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .02em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
}
.tag--checked { background: var(--green-soft); color: #2F6B3F; }

/* ---------- Статья / занятие ---------- */
.article-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.step-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.step-list li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.step-list li::before {
  content: counter(step);
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 1px;
}

.notice {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.notice--warn { background: var(--danger-soft); color: #7A3232; }
.notice--info { background: var(--blue-soft); color: #31597D; }
.notice--calm { background: var(--green-soft); color: #2F6B3F; }
.notice strong { font-weight: 700; }

/* ---------- Формы ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 15px; }
.field .hint { font-size: 13px; color: var(--ink-faint); }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  min-height: 48px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  min-height: 44px;
}
.choice[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ---------- Дневник ---------- */
.diary-entry { display: grid; gap: 6px; }
.diary-entry__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.diary-entry__date { font-weight: 700; }
.diary-entry__del {
  border: none; background: none; color: var(--ink-faint);
  font: inherit; font-size: 14px; cursor: pointer; padding: 6px;
}
.diary-entry__del:hover { color: var(--danger); }

.result-pill { font-size: 13px; font-weight: 650; padding: 3px 12px; border-radius: 999px; }
.result-pill--good { background: var(--green-soft); color: #2F6B3F; }
.result-pill--ok   { background: var(--blue-soft); color: #31597D; }
.result-pill--hard { background: var(--rose-soft); color: #8C4545; }
/* «Не получилось» — нейтральный, не «наказывающий» вид */
.result-pill--fail { background: var(--bg-soft); color: var(--ink-soft); }

/* ---------- Утилиты (вместо inline-стилей — CSP запрещает style="...") ---------- */
.mt-8 { margin-top: 8px; }
.mt-18 { margin-top: 18px; }
.mt-26 { margin-top: 26px; }
.mb-14 { margin-bottom: 14px; }
.row--center { align-items: center; }
.link-inherit { color: inherit; }
.link-strong { color: inherit; font-weight: 650; }
.notice__icon { flex: none; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-soft);
}
.empty-state__icon { font-size: 0; margin-bottom: 14px; color: var(--ink-faint); }
.empty-state__icon svg { width: 52px; height: 52px; }

/* ---------- Поиск ---------- */
.search-box { position: relative; }
.search-box input { padding-left: 46px; }
.search-box svg {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  color: var(--ink-faint);
  pointer-events: none;
}

/* ---------- Организации ---------- */
.org-card h3 { margin-bottom: 6px; }
.org-card__contacts { margin-top: 10px; display: grid; gap: 4px; font-size: 15px; }
.org-card__contacts a { color: var(--accent-ink); word-break: break-all; }

/* ---------- Хлебная крошка / назад ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 0;
}
.back-link:hover { color: var(--accent-ink); }

/* ---------- Герой главной ---------- */
.hero { text-align: left; padding: 8px 0 4px; }
.hero h1 { margin-bottom: 10px; }
.hero .lead { max-width: 34em; }

.divider { border: none; border-top: 1px solid var(--line); margin: 26px 0 0; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
}
.section-title a { font-size: 14px; color: var(--accent-ink); text-decoration: none; font-weight: 600; white-space: nowrap; }

/* ---------- Нижняя навигация ---------- */
.app-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.app-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--ink-faint);
  font-size: 11.5px;
  font-weight: 600;
  min-width: 0;
}
.app-nav__item svg { width: 23px; height: 23px; }
.app-nav__item.active { color: var(--accent-ink); }

@media (min-width: 721px) {
  .app-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 720px;
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
  }
}

/* ---------- Офлайн-индикатор ---------- */
.offline-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 40;
  background: var(--ink);
  color: #FFF8F0;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: min(92vw, 560px);
  text-align: center;
}

/* ---------- Утилиты ---------- */
.stack-sm > * + * { margin-top: 10px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }

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