/* ЮИП — «Полевой дневник» и темы на выбор. Цвета — переменные, тема — атрибут data-theme на <html>. */
:root,
[data-theme="classic"] {
  --bg: #ECEEE3; --card: #F7F7F0; --line: #D5D8C7; --ink: #1E2A1C; --muted: #4B5A46;
  --accent: #24402A; --accent-ink: #24402A; --on-accent: #F1EFE4;
  --ochre: #8A5A1C; --ochre-text: #7A4E15; --on-ochre: #FFFFFF;
  --soft: #E2E6D6; --rule: #E6E8DB; --ok: #2E8B4A; --ok-soft: rgba(46,139,74,.18); --danger: #A33A22;
  --head: 'Literata', Georgia, serif; --body: 'Golos Text', system-ui, sans-serif;
  --h1: 30px; --h2: 22px; --h3: 18px;
}
[data-theme="herbarium"] {
  --bg: #F1EDE2; --card: #FBF8F0; --line: #DDD4C0; --ink: #2A2418; --muted: #5E5543;
  --accent: #4F5B2A; --accent-ink: #4F5B2A; --on-accent: #FBF8F0;
  --ochre: #9A3B22; --ochre-text: #8A341D; --soft: #ECE6D2; --rule: #EFE8D6;
  --head: 'Cormorant Garamond', Georgia, serif; --body: 'PT Sans', system-ui, sans-serif;
  --h1: 34px; --h2: 25px; --h3: 21px;
}
[data-theme="autumn"] {
  --bg: #F2E8DA; --card: #FBF5EC; --line: #E0D0B8; --ink: #2E1F14; --muted: #6A5240;
  --accent: #7A2E14; --accent-ink: #7A2E14; --on-accent: #FBF1E6;
  --ochre: #46612C; --ochre-text: #3E5627; --soft: #F0E2CD; --rule: #EEE1CC;
  --head: 'PT Serif', Georgia, serif; --body: 'PT Sans', system-ui, sans-serif;
}
[data-theme="pencil"] {
  --bg: #EEEEEA; --card: #FBFBF8; --line: #CFCFC8; --ink: #222222; --muted: #55554F;
  --accent: #2B4C8C; --accent-ink: #2B4C8C; --on-accent: #F4F6FB;
  --ochre: #B03A2E; --ochre-text: #9E3226; --soft: #E4E8F0; --rule: #D9E1EF;
  --head: 'Caveat', 'Comic Sans MS', cursive; --body: 'Golos Text', system-ui, sans-serif;
  --h1: 40px; --h2: 30px; --h3: 25px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--body); font-size: 15px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }
.page { padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.top { padding: 22px 20px 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.overline { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ochre); font-weight: 600; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; margin: 0; line-height: 1.15; }
h1 { font-size: var(--h1); margin-top: 4px; }
h2 { font-size: var(--h2); }
h3 { font-size: var(--h3); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ochre { color: var(--ochre-text); }
.num { font-family: var(--head); font-weight: 600; font-size: 30px; line-height: 1; }
.big-num { font-family: var(--head); font-weight: 600; font-size: 36px; line-height: 1; color: var(--ochre); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px; }
.card.hero { background: var(--accent); color: var(--on-accent); border-color: var(--accent); border-radius: 18px; padding: 18px; }
.card.hero .muted, .card.hero .overline { color: var(--on-accent); opacity: .85; }
.card.ruled { background-image: repeating-linear-gradient(transparent 0 23px, var(--rule) 23px 24px); }
.card.dashed { background: transparent; border: 1.5px dashed var(--ochre); color: var(--ochre-text); flex-direction: row; align-items: center; gap: 10px; }
.card svg, .row svg, .btn svg { flex: none; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.sep { border-top: 1px dashed var(--line); padding-top: 10px; }
.chip { background: var(--soft); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; white-space: nowrap; }
.hero .chip { background: rgba(255,255,255,.16); }
.pill { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.pill[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }

.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent);
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.hero .btn { background: var(--on-accent); color: var(--accent); }
.hero .btn.ghost { background: transparent; color: var(--on-accent); border-color: rgba(255,255,255,.35); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; }
.btns > * { flex: 1; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; position: relative; cursor: pointer; color: var(--ink); text-decoration: none; }
.badge { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  background: var(--ochre); color: var(--on-ochre); font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; text-decoration: none; flex: none; }
.avatar.sm { width: 36px; height: 36px; border: 0; background: var(--soft); font-size: 13px; }

.bar { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ochre > i { background: var(--ochre); }
.hero .bar { background: rgba(255,255,255,.2); }
.hero .bar > i { background: var(--on-accent); }

.status { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); flex: none; }
.dot.off { background: var(--line); box-shadow: none; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day { height: 62px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: var(--card); border: 1px solid var(--line); }
.day b { font-size: 16px; }
.day i { width: 5px; height: 5px; border-radius: 50%; }
.day.today { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.medals { display: flex; gap: 6px; }
.medal { width: 22px; height: 22px; border-radius: 50%; border: 2px dashed var(--line); }
.medal.on { border-style: solid; }

.list { display: flex; flex-direction: column; }
.list > .li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.list > .li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }

.mark { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: transparent; flex: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--on-accent); }
.mark.on { background: var(--accent); border-color: var(--accent); }
.mark.left { border-style: dashed; }

.months { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.month { border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 12px; background: var(--soft); }
.month.paid { background: color-mix(in srgb, var(--ok) 18%, var(--card)); }
.month.due { background: transparent; border: 1.5px dashed var(--ochre); color: var(--ochre-text); }
.month.overdue { background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); font-weight: 600; }
.month.future { opacity: .55; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); padding: 8px 12px; color: var(--ink); font-size: 15px; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--danger); font-size: 13px; }
.tabs { display: flex; gap: 8px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(70px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); z-index: 10; }
.nav a { color: var(--muted); text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; }
.nav a[aria-current="page"] { color: var(--accent-ink); font-weight: 600; }
@media (min-width: 600px) { .nav { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: 90vw; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.skeleton { height: 120px; border-radius: 16px; background: linear-gradient(90deg, var(--card), var(--soft), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th, table.t td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rule); }
table.t th { color: var(--muted); font-weight: 500; font-size: 12px; }
.scroll-x { overflow-x: auto; }

/* Видео */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.video-tile { position: relative; background: #111; border-radius: 12px; aspect-ratio: 16/10; overflow: hidden; }
.video-tile video { width: 100%; height: 100%; object-fit: cover; }
.video-tile.main { grid-column: 1 / -1; aspect-ratio: 16/9; }
.video-tile.main video { object-fit: contain; }
.video-tile span { position: absolute; left: 8px; bottom: 6px; color: #fff; font-size: 12px; text-shadow: 0 1px 2px #000; }
.player { width: 100%; border-radius: 12px; background: #000; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Закреплённые объявления — самое заметное на главной */
.pinned-stack { display: flex; flex-direction: column; gap: 10px; }
.card.pinned { background: var(--ochre); color: var(--on-ochre); border: 0; border-radius: 18px; padding: 16px 18px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--ochre) 35%, transparent); }
.card.pinned .overline { color: var(--on-ochre); opacity: .9; display: flex; gap: 6px; align-items: center; }
.card.pinned .overline span { display: inline-flex; gap: 6px; align-items: center; }
.card.pinned h3 { font-size: calc(var(--h3) + 2px); }
.card.pinned a, .card.pinned .linkish { color: var(--on-ochre); }
.card.pinned.unread { outline: 3px solid color-mix(in srgb, var(--ochre) 40%, transparent); outline-offset: 2px; }
.pinned-foot { border-top: 1px solid rgba(255,255,255,.3); padding-top: 8px; }
.pinned-foot a { display: inline-flex; gap: 6px; align-items: center; }
.pre { white-space: pre-line; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-ink); text-decoration: underline; cursor: pointer; font-size: 13px; }

/* Идёт трансляция */
.card.live { flex-direction: row; align-items: center; gap: 12px; text-decoration: none; color: var(--ink);
  border: 2px solid var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--card)); }
.card.live .overline { color: var(--danger); }
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); flex: none;
  animation: pulse 1.4s infinite; box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 50%, transparent); }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Кто едет */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; }
.polls { display: flex; flex-direction: column; gap: 10px; }
.card.poll { gap: 10px; }
.poll-head { border-left: 4px solid var(--accent); padding-left: 10px; display: flex; flex-direction: column; gap: 4px; }
.poll-q { background: var(--soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.answers { display: flex; gap: 6px; flex-wrap: wrap; }
.answers .pill { height: 38px; padding: 0 14px; }
.poll-count { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.poll-count .go b { color: var(--ok); font-size: 16px; }
.chip.person { background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
details summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
details .sub { margin: 6px 0 4px; color: var(--muted); }
.card.action { text-decoration: none; color: inherit; }

/* Лента ребёнка */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.feed-item:last-child { border-bottom: 0; }
.feed-time { font-size: 12px; font-weight: 600; width: 40px; flex: none; line-height: 1.25; font-variant-numeric: tabular-nums; }
.feed-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--soft); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* В этот день */
.card.thisday .overline { display: inline-flex; gap: 6px; align-items: center; }
.td-item { display: flex; gap: 12px; align-items: flex-start; padding-top: 8px; border-top: 1px dashed var(--line); }
.td-item:first-of-type { border-top: 0; padding-top: 0; }
.td-item img, .td-ph { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; flex: none; background: var(--soft);
  display: flex; align-items: center; justify-content: center; color: var(--accent-ink); }
.td-item b { display: block; margin: 2px 0; }

/* Формы */
fieldset.card { margin: 0; }
.check { display: flex; gap: 10px; align-items: center; min-height: 36px; cursor: pointer; }
.check.card { flex-direction: row; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.field textarea { min-height: 110px; resize: vertical; }

/* Трансляция */
.broadcast-hint { border: 1.5px dashed var(--ochre); border-radius: 12px; padding: 10px 12px; color: var(--ochre-text); }
.mode-online { color: #2B6CB0; }
