/*
  Стили мини-аппа «Мой Орешек» (WP-1). Бренд-токены — из my_page._STYLE, чтобы
  SPA и подписанная страница /my выглядели одинаково:
    фон #faf6f0, акцент #c9741f, текст #2b2320, muted #7a6f66, границы #ece2d6.
  Вёрстка мобильная, самодостаточная (без внешних зависимостей/CDN — CSP аппа
  и офлайн встроенного браузера).
*/

:root {
  color-scheme: light;
  --bg: #faf8f1;
  --accent: #326c52;
  --text: #1a201d;
  --muted: #656c63;
  --border: #d9d9cf;
  --card: #fffdf7;
  --card-soft: #e0f1e3;
  --card-soft-border: #a4cdb2;
  --heading: #1a201d;
  --tabbar-h: 3.5rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Rubik, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Контейнер экрана: отступ снизу под нижние вкладки. */
.app {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(.25rem, env(safe-area-inset-top, 0px)) 1rem calc(var(--tabbar-h) + 1.5rem + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
}

/* --- Шапка --- */
.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  padding-bottom: .75rem;
  margin-bottom: .5rem;
  border-bottom: 2px solid var(--accent);
  flex-wrap: wrap;
}
.brand {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}
.brand .nut { margin-right: .35rem; }
.platform {
  font-size: .9rem;
  color: var(--muted);
  font-weight: 600;
}

h2 {
  font-size: .95rem;
  margin: 1.5rem 0 .6rem;
  color: var(--heading);
}

/* --- Плитки статистики --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: .6rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .8rem;
  padding: .8rem .85rem;
}
.card .n { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.card .l { font-size: .76rem; color: var(--muted); margin-top: .15rem; }

/* --- CTA --- */
.cta {
  display: block;
  width: 100%;
  margin: 1.25rem 0 .25rem;
  padding: .85rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: .8rem;
  cursor: pointer;
  text-align: center;
}
.cta:active { opacity: .9; }

button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--heading);
  outline-offset: 3px;
}
.home-start { padding: .9rem 0 .25rem; }
.home-start h1 { font-size: 1.55rem; line-height: 1.2; margin: .5rem 0 .7rem; }
.home-intro { color: var(--heading); margin: 0; }
.action-hint { margin: .6rem 0; font-size: .83rem; color: var(--muted); }
.home-start .cta { background: #a95110; }
.home-recent > h2:first-child { margin-top: 1.1rem; }
.home-recent .latest-solution { border: 2px solid var(--accent); background: var(--card-soft); }
.continue-label { display: block; margin-top: .6rem; color: #91450e; font-weight: 700; }
.home-recent .item-cond {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-stats { margin-top: 1.75rem; border-top: 1px solid var(--border); }
.home-stats summary { cursor: pointer; padding: 1rem 0; font-weight: 600; color: var(--heading); }
.start-tips { padding-left: 1.35rem; color: var(--heading); }
.start-tips li { padding-left: .2rem; margin: .65rem 0; }
.screen-back {
  min-height: 44px;
  padding: .5rem 0;
  color: var(--heading);
  font: inherit;
  font-weight: 600;
  border: 0;
  background: none;
  cursor: pointer;
}

/* --- Список решений --- */
.list { display: flex; flex-direction: column; gap: .6rem; }
.item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .8rem;
  padding: .75rem .85rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.item-head {
  font-size: .76rem;
  color: var(--muted);
  margin-bottom: .3rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.item-cond { font-weight: 600; word-wrap: break-word; overflow-wrap: break-word; }
.item-foot {
  margin-top: .45rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.fb { font-size: .95rem; }

/* Кнопка «Показать ещё». */
.more {
  display: block;
  width: 100%;
  margin: .8rem 0 0;
  padding: .7rem 1rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .8rem;
  cursor: pointer;
}

/* --- Состояния: empty / error / скелетон --- */
.empty {
  background: var(--card-soft);
  border: 1px solid var(--card-soft-border);
  border-radius: .9rem;
  padding: 1.1rem 1rem;
  text-align: center;
  color: var(--heading);
}
.empty .nut { font-size: 2rem; display: block; margin-bottom: .4rem; }

.error {
  background: var(--card-soft);
  border: 1px solid var(--card-soft-border);
  border-radius: .9rem;
  padding: 1.1rem 1rem;
  text-align: center;
  color: var(--heading);
}
.error .retry {
  display: inline-block;
  margin-top: .6rem;
  padding: .5rem .9rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: .6rem;
  cursor: pointer;
}

/* Скелетон загрузки: мягкое «дыхание» плейсхолдеров. */
.skeleton {
  background: var(--border);
  border-radius: .6rem;
  animation: pulse 1.2s ease-in-out infinite;
}
.skel-card { height: 4.6rem; border-radius: .8rem; }
.skel-row { height: 3.6rem; border-radius: .8rem; margin-bottom: .6rem; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* Спиннер (мелкие ожидания «Показать ещё»). */
.spinner {
  width: 1.4rem; height: 1.4rem;
  margin: .8rem auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Футер с юр. ссылками --- */
.footer {
  margin-top: 2.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
  text-align: center;
}
.footer a { color: var(--muted); }

/* --- Экран «Тариф» (WP-5) --- */
/* Карточка текущего положения: тариф + пакет + остаток на сегодня. */
.tariff-current {
  background: var(--card-soft);
  border: 1px solid var(--card-soft-border);
  border-radius: .9rem;
  padding: 1rem 1.05rem;
  margin-top: .5rem;
}
.tariff-plan { display: flex; align-items: center; gap: .5rem; }
.tariff-plan-icon { display: flex; align-items: center; flex-shrink: 0; font-size: 1.15rem; }
.tariff-plan-icon .mascot { width: 1.8rem; height: 1.8rem; }
.tariff-plan-name { font-size: 1.05rem; font-weight: 800; color: var(--heading); }
.tariff-pack { margin-top: .4rem; font-size: .9rem; color: var(--accent); font-weight: 600; }
.tariff-quota { margin-top: .4rem; font-size: .88rem; color: var(--muted); }

/* Карточка продукта: заголовок + цена, описание, поле e-mail, кнопка «Купить». */
.product {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .9rem;
  padding: .95rem 1.05rem;
  margin-bottom: .8rem;
}
.product-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
}
.product-title { font-weight: 700; }
.product-price { font-size: 1.15rem; font-weight: 800; color: var(--accent); white-space: nowrap; }
.product-desc { margin-top: .35rem; font-size: .88rem; color: var(--muted); }

/* Поле e-mail для чека (только при requires_email). */
.product-email { margin-top: .75rem; }
.email-input {
  width: 100%;
  padding: .65rem .8rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: .7rem;
}
.email-input:focus { outline: none; border-color: var(--accent); }
.email-hint { margin-top: .3rem; font-size: .76rem; color: var(--muted); }

/* Кнопка «Купить» — тот же CTA, но без большого верхнего отступа; disabled — блёкло. */
.product-buy { margin: .75rem 0 0; }
.product-buy:disabled { opacity: .5; cursor: default; }
.product-err:empty { display: none; }
.product-err { min-height: 1rem; margin-top: .4rem; font-size: .82rem; color: var(--muted); }

/* Мягкая подпись, когда платежи выключены (enabled=false). */
.pay-soon {
  margin-top: .5rem;
  text-align: center;
  font-size: .88rem;
  color: var(--muted);
}

/* Stars subscription renewal switch: always visible while the subscription lives. */
.tariff-renewal { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.tariff-renewal-text { font-size: .88rem; color: var(--heading); }
.renewal-toggle {
  min-height: 44px;
  padding: .4rem 0;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  border: 0;
  background: none;
  cursor: pointer;
}
.renewal-toggle:disabled { opacity: .5; cursor: default; }

/* Скелетон карточки продукта. */
.skel-product { height: 6.5rem; border-radius: .9rem; margin-bottom: .8rem; }

/* --- Тост (уведомление об исходе оплаты) --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 1rem);
  transform: translate(-50%, 1rem);
  max-width: 90%;
  padding: .7rem 1.1rem;
  border-radius: .8rem;
  font-size: .92rem;
  font-weight: 600;
  color: #fff;
  background: var(--heading);
  box-shadow: 0 .4rem 1.2rem rgba(0, 0, 0, .18);
  opacity: 0;
  transition: opacity .28s ease, transform .28s ease;
  z-index: 10;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-success { background: #1f7a34; }
.toast-neutral { background: var(--heading); }

/* --- Лендинг в браузере (не из бота) --- */
.landing { text-align: center; padding-top: 2rem; }
.landing .nut { font-size: 4rem; }
.landing h1 { font-size: 1.5rem; margin: .5rem 0 1rem; color: var(--accent); }
.landing p { margin: .75rem 0; }
.landing .hint { color: var(--muted); font-size: .9rem; }

/* --- Экран разбора (WP-2) --- */
/* Секционный ярлык (капсом, как на странице /s). */
.label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 1.4rem 0 .5rem;
}

/* Условие «как понял бот». */
.condition {
  background: var(--card-soft);
  border: 1px solid var(--card-soft-border);
  border-radius: .9rem;
  padding: .9rem 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.sol-meta { font-size: .8rem; color: var(--muted); margin-top: .45rem; }

/* Шаги: раскрываются по одному. */
.steps { display: flex; flex-direction: column; gap: .8rem; }
.step {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .9rem;
  padding: .85rem 1rem;
}
.step-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .35rem; }
.step-num {
  flex: none;
  width: 1.55rem; height: 1.55rem;
  border-radius: 50%;
  background: var(--card-soft);
  color: var(--accent);
  font-weight: 800; font-size: .88rem;
  display: flex; align-items: center; justify-content: center;
}
.step-title { font-weight: 700; }
.step-formula { margin: .45rem 0; overflow-x: auto; }
.step-explanation { color: var(--muted); font-size: .95rem; }

/* «Не понял этот шаг» — неброская ссылка (WP-6: грузит объяснение шага). */
.step-puzzled {
  margin-top: .6rem;
  padding: 0;
  font: inherit;
  font-size: .82rem;
  color: var(--muted);
  background: none;
  border: none;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}
.step-puzzled:active { color: var(--accent); }

/* Объяснение шага (WP-6): muted-карточка под кнопкой «Не понял этот шаг». */
.explain-slot:empty { display: none; }
.explain {
  margin-top: .55rem;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: .8rem;
  padding: .7rem .85rem;
  font-size: .92rem;
  color: var(--heading);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.explain-error { color: var(--muted); }
.explain-error .step-puzzled { margin-top: .5rem; }
.explain-upsell { text-align: center; }
.explain-upsell-text { color: var(--muted); margin-bottom: .6rem; }
.explain-upsell-cta { display: inline-block; width: auto; padding: .5rem 1.1rem; }

/* Ответ (выделенный блок). */
.answer {
  margin-top: .25rem;
  background: #eef7ee;
  border: 2px solid #bfe2c4;
  border-radius: 1rem;
  padding: .9rem 1.05rem;
  display: flex;
  align-items: baseline;
  gap: .6rem;
  flex-wrap: wrap;
}
.answer-label { font-weight: 800; color: #1f7a34; white-space: nowrap; }
.answer-value { font-size: 1.25rem; font-weight: 700; color: #1f7a34; overflow-x: auto; }

/* Самопроверка. */
.check {
  font-size: .95rem;
  color: var(--muted);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Оценка 👍/👎 под разбором. */
.sol-feedback { margin-top: 1.6rem; text-align: center; }
.sol-feedback-label { font-size: .9rem; color: var(--heading); margin-bottom: .5rem; }
.sol-feedback-row { display: flex; justify-content: center; gap: .75rem; }
.fb-btn {
  font-size: 1.4rem;
  width: 3.2rem; height: 3.2rem;
  border: 1px solid var(--border);
  border-radius: .9rem;
  background: var(--card);
  cursor: pointer;
  line-height: 1;
}
.fb-btn.active { border-color: var(--accent); background: var(--card-soft); }
.fb-btn:active { opacity: .85; }
.sol-feedback-hint { font-size: .82rem; color: var(--muted); margin-top: .6rem; min-height: 1rem; }

/* KaTeX не должен раздувать строку на узком экране. */
.katex { font-size: 1.05em; }
.katex-display { margin: .2em 0; overflow-x: auto; overflow-y: hidden; }

/* --- Нижние вкладки --- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  font-size: .72rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.tab .ic { font-size: 1.15rem; line-height: 1; }
.tab.active { color: var(--accent); font-weight: 700; }

/* Рабочая тетрадь: выбранный золотистый орешек, жёлтый и мятный акценты. */
:root { --yellow: #ffce47; --mint: #b9e5ca; --tabbar-h: 4.5rem; --display: "Balsamiq Sans", Nunito, sans-serif; }
[hidden] { display: none !important; }
button, input { font-family: inherit; }
button { touch-action: manipulation; }
button:disabled { opacity: .55; cursor: wait; }
.app { max-width: 30rem; padding-left: 1.35rem; padding-right: 1.35rem; }
.head { border: 0; align-items: center; flex-wrap: nowrap; margin-bottom: .75rem; padding-bottom: 0; }
.brand { color: #111411; font-family: var(--display); font-size: 2rem; font-weight: 700; letter-spacing: -.035em; -webkit-text-stroke: 1px currentColor; }
.platform { display: none; }
.quota-badge { border: 1px solid var(--text); background: none; border-radius: 2rem; font-size: .78rem; font-weight: 600; padding: .45rem .7rem; color: var(--text); white-space: nowrap; cursor: pointer; }
h1 { font-family: var(--display); font-size: 1.95rem; font-weight: 700; line-height: 1.2; letter-spacing: -.025em; margin: .8rem 0; -webkit-text-stroke: 1px currentColor; }
h2 { font-family: var(--display); font-size: 1.22rem; font-weight: 700; letter-spacing: -.02em; margin-top: 1.7rem; -webkit-text-stroke: 1px currentColor; }
.home-start { position: relative; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; gap: .5rem; padding: .25rem 0 .5rem; margin: 0 0 .5rem; }
.home-copy { position: relative; z-index: 1; min-width: 0; padding-top: .5rem; pointer-events: none; }
.home-start h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -.025em; overflow-wrap: anywhere; margin: .5rem 0 .65rem; }
.home-intro { font-size: .92rem; line-height: 1.45; max-width: 11.3rem; color: #323730; }
.mascot { object-fit: cover; width: 7rem; height: 7rem; border-radius: 50%; mix-blend-mode: multiply; flex-shrink: 0; }
.cta, .home-start .cta { font-family: var(--display); font-size: 1.07rem; display: flex; align-items: center; justify-content: center; gap: .65rem; -webkit-text-stroke: .4px currentColor; color: var(--text); background: var(--yellow); border: 1.5px solid var(--text); border-radius: 1rem; font-weight: 700; box-shadow: 0 4px 0 #dfb03c40; min-height: 3.3rem; }
.action-hint { text-align: center; font-size: .74rem; margin-top: .5rem; margin-bottom: 1rem; }
.screen-intro { color: #535850; font-size: .9rem; line-height: 1.5; }
.notebook-item { position: relative; display: flex; align-items: flex-start; gap: .1rem; border: 1px solid var(--border); background: var(--card); border-radius: .9rem; margin-bottom: .65rem; }
.notebook-open { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; font: inherit; padding: .9rem .3rem .9rem .6rem; }
.item-title { font-family: var(--display); font-weight: 700; font-size: 1rem; line-height: 1.35; letter-spacing: -.025em; margin: .2rem 0; overflow-wrap: anywhere; }
.notebook-item .item-cond { font-size: .85rem; line-height: 1.45; color: var(--heading); font-weight: 400; }
.reading-status { display: inline-block; margin-top: .6rem; background: #dceee1; border-radius: .4rem; padding: .2rem .45rem; font-size: .73rem; }
.home-recent > h2:first-child { margin-top: 1.1rem; }
.home-recent .latest-solution { border: 1px solid #68a389; background: var(--card-soft); }
.continue-label { color: #235e43; font-size: .86rem; }
.favorite-control { flex-shrink: 0; width: 2.3rem; padding-top: .7rem; }
.bookmark { border: 0; background: none; color: var(--text); padding: .6rem .5rem; cursor: pointer; min-height: 44px; }
.bookmark.selected .icon { fill: var(--yellow); }
.save-error { position: absolute; left: .7rem; right: .7rem; top: 100%; background: #fff0c3; font-size: .73rem; z-index: 2; border-radius: .5rem; }
.save-error:not(:empty) { padding: .5rem; box-shadow: 0 2px 5px #0002; }
.icon { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.notebook-search { width: 100%; min-width: 0; border: 1px solid var(--border); background: #f1f0e8; color: var(--text); border-radius: .8rem; padding: .9rem 1rem; font: inherit; margin: .3rem 0 .75rem; }
.subject-filters { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding-bottom: .1rem; }
.subject-filters button { flex-shrink: 0; }
.subject-filters button { border: 0; padding: .65rem .8rem; background: #efeee7; border-radius: 2rem; color: var(--text); font-size: .8rem; cursor: pointer; min-height: 42px; }
.subject-filters .active, .segmented .active { background: var(--mint); font-weight: 800; }
.segmented { display: flex; padding: 3px; border: 1px solid #c6ccbf; border-radius: .8rem; margin: .8rem 0 1rem; }
.segmented button { flex: 1; border: 0; background: none; border-radius: .55rem; padding: .65rem .2rem; color: var(--text); font-size: .86rem; cursor: pointer; min-height: 42px; }
.tabbar { max-width: 30rem; margin: auto; background: #faf8f1f5; border-radius: 1.2rem 1.2rem 0 0; backdrop-filter: blur(8px); }
.tab { position: relative; gap: .3rem; font-size: .73rem; }
.tab.active { color: var(--text); font-weight: 900; }
.tab.active .icon { fill: var(--yellow); }
.tab.active:after { content: ''; width: 1.8rem; height: .25rem; border-radius: .25rem; background: var(--yellow); position: absolute; bottom: .25rem; }
.tab .icon { width: 1.55rem; height: 1.55rem; }
.empty .mascot { display: block; width: 4.5rem; height: 4.5rem; margin: 0 auto .8rem; }
.footer { font-size: .7rem; line-height: 1.6; }
.profile-screen > .mascot { display: block; width: 5rem; height: 5rem; margin: 1rem auto .6rem; }
.profile-screen > h1, .profile-screen .screen-intro { text-align: center; }
.profile-screen .cards { margin-top: 1rem; }
.solution-heading { position: relative; display: flex; gap: .4rem; align-items: center; }
.solution-heading h1 { flex: 1; min-width: 0; font-size: 1.8rem; overflow-wrap: anywhere; }
.solution-heading .favorite-control { padding: 0; }
.reading { padding-bottom: 2rem; }
.condition { background: var(--card); margin-top: .8rem; }
.condition .label { margin: 0; }
.condition p { margin: .6rem 0 .2rem; white-space: pre-wrap; }
.progress-label { font-size: .78rem; color: var(--muted); margin-bottom: .5rem; }
.progress-track { height: .5rem; border-radius: 1rem; background: #dedfd6; overflow: hidden; margin-bottom: 1.1rem; }
.progress-fill { height: 100%; border-radius: 1rem; background: #6bb790; }
.step { padding: 1rem; }
.step-title { font-family: var(--display); font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.35; }
.step-num { background: var(--mint); color: var(--text); }
.step-explanation { color: var(--text); font-size: .94rem; line-height: 1.5; white-space: pre-wrap; }
.step-formula { text-align: center; padding: .7rem 0; font-size: 1.3rem; }
.step-puzzled { font-family: Rubik, sans-serif; font-size: .84rem; display: block; width: 100%; padding: .6rem; min-height: 42px; border: 1px solid var(--heading); border-radius: .6rem; text-decoration: none; color: var(--heading); font-weight: 800; margin-top: .9rem; }
.explain { background: #fff2cd; }
.reading-controls .screen-back { display: block; margin: .5rem auto; }
.save-status, .math-status { font-size: .8rem; color: var(--muted); text-align: center; margin: .8rem 0; }
.math-status:not(:empty) { padding: .7rem; background: #fff2cd; border-radius: .7rem; }
.source-photos summary { cursor: pointer; font-size: .88rem; padding: .8rem 0; font-weight: 700; }
.photo-note { font-size: .74rem; color: var(--muted); line-height: 1.5; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.photo-thumb { border: 1px solid var(--border); background: white; border-radius: .7rem; padding: .3rem; cursor: zoom-in; }
.photo-thumb img { width: 100%; height: 10rem; object-fit: contain; display: block; }
.photo-viewer { width: min(95vw, 60rem); max-height: 94dvh; border: 1px solid var(--text); border-radius: 1rem; background: var(--bg); padding: 1rem; }
.photo-viewer::backdrop { background: #1119; }
.photo-viewer img { display: block; width: 100%; height: auto; }
.photo-viewer .screen-back { position: sticky; top: 0; padding: .5rem 1rem; background: var(--bg); border-radius: .5rem; }
@media (max-width: 355px) {
  .app { padding-left: .9rem; padding-right: .9rem; }
  .home-start h1 { font-size: 1.52rem; }
  .home-intro { font-size: .84rem; max-width: 10rem; }

  .platform { display: none; }
  .brand { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation: none !important; transition: none !important; }
}


/* Поза героя и рисунок клеток — из выбранного эскиза. */
.hero-art { width: 100%; max-width: 9rem; aspect-ratio: 1122 / 1402; justify-self: end; isolation: isolate; }

.home-start .mascot-pencil { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 0; mix-blend-mode: normal; }
.new-task-action .cta { margin-top: .2rem; }
.new-task-action .icon { width: 1.3rem; height: 1.3rem; stroke-width: 3; }
.subject-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2.15rem; height: 2.65rem; border-radius: .6rem; background: #c2e9d0; margin: .95rem 0 0 .75rem; font-size: 1.2rem; font-weight: 600; }
.subject-english { background: #f7cbbf; }
.subject-russian { background: #f7e3a7; }
.latest-solution > .subject-icon { display: none; }
.latest-solution .notebook-open { padding: .95rem .3rem .95rem .95rem; }
.latest-solution .item-head { color: #303c32; font-size: .75rem; }
.latest-solution .item-title { font-size: 1.2rem; line-height: 1.3; margin: .35rem 0 .55rem; }
.latest-solution .continue-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: .8rem; margin-top: 1.1rem; }
.continue-reading { flex: 1; min-width: 0; }
.latest-solution .reading-status { background: none; padding: 0; margin-top: 0; font-size: .78rem; }
.reading-meter { display: flex; gap: 3px; margin-top: .5rem; }
.reading-meter i { display: block; height: .5rem; flex: 1; border-radius: 1rem; background: #d2d8ce; }
.reading-meter .filled { background: #67b58c; }
.latest-solution .continue-label { flex-shrink: 0; border-radius: .65rem; padding: .7rem .75rem; margin-top: 0; color: #142b1d; background: #b8e3c8; font-family: Rubik, sans-serif; font-weight: 600; font-size: .84rem; }
@media (max-width: 355px) {
  .latest-solution .continue-footer { gap: .5rem; }
  .latest-solution .continue-label { font-size: .76rem; padding: .65rem .6rem; }
  .latest-solution .item-title { font-size: 1.07rem; }
}

.home-recent .notebook-item:not(.latest-solution) .item-cond,
.home-recent .notebook-item:not(.latest-solution) .reading-status { display: none; }

/* Растровые заголовки буквально из эскиза, с доступным текстовым эквивалентом. */
.illustrated-heading { width: var(--lettering-width); max-width: 100%; }
.lettering-art { display: none; position: relative; width: 100%; overflow: hidden; mix-blend-mode: multiply; }
.lettering-art img { filter: grayscale(1) contrast(1.5) brightness(1.1); position: absolute; display: block; max-width: none; height: auto; }
.lettering-loaded .lettering-art { display: block; }
.lettering-loaded .lettering-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.brand.illustrated-heading { flex-shrink: 0; }
@media (max-width: 355px) {
  .brand.illustrated-heading { width: 8rem; }
}

.home-copy { mix-blend-mode: multiply; }
.home-start { overflow: clip; }
@media (max-width: 355px) {
  .home-start .illustrated-heading { width: 11rem; }
}

/* Общая тетрадная бумага на главной, в тетради, разборе и профиле. */
body {
  background-color: var(--bg);
  background-image: linear-gradient(#86b6a02b 1px, transparent 1px),
    linear-gradient(90deg, #86b6a02b 1px, transparent 1px);
  background-size: 20px 20px;
}
.app {
  background-image: linear-gradient(180deg, transparent, #faf8f199 24rem, #faf8f14d 48rem);
}
.segmented, .quota-badge { background-color: var(--bg); }

/* Округлые контуры навигации и маленькая жёлтая молния. */
.quota-badge { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; }
.quota-badge .icon-bolt { width: 1.15rem; height: 1.4rem; flex-shrink: 0; fill: var(--yellow); stroke: #25251c; stroke-width: 1.6; }
.tab .icon { width: 1.7rem; height: 1.7rem; stroke-width: 2.3; stroke: #383b34; fill: #fff8e8; }
.tab.active .icon { fill: var(--yellow); stroke: #24281f; }


/* Explicit palette prevents WebView auto-darkening from changing brand accents. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191e1b;
  --card: #232b26;
  --card-soft: #253d30;
  --card-soft-border: #547b62;
  --text: #f4f1e7;
  --heading: #f4f1e7;
  --muted: #b0bab1;
  --border: #465349;
  --accent: #a3dfb8;
  --mint: #355740;
}
[data-theme="dark"] body {
  background-image: linear-gradient(#92b79f10 1px, transparent 1px),
    linear-gradient(90deg, #92b79f10 1px, transparent 1px);
}
[data-theme="dark"] .app {
  background-image: linear-gradient(180deg, transparent, #191e1b99 24rem, #191e1b4d 48rem);
}
[data-theme="dark"] .home-copy { mix-blend-mode: normal; z-index: auto; }
[data-theme="dark"] .lettering-art { mix-blend-mode: screen; }
[data-theme="dark"] .lettering-art img {
  filter: grayscale(1) contrast(1.5) brightness(1.1) invert(1);
}
[data-theme="dark"] .brand,
[data-theme="dark"] .home-intro { color: var(--heading); }
[data-theme="dark"] .screen-intro,
[data-theme="dark"] .latest-solution .item-head { color: var(--muted); }
[data-theme="dark"] .cta,
[data-theme="dark"] .home-start .cta {
  color: #232619;
  border-color: #ffdb75;
  box-shadow: 0 4px 0 #a47d2440;
}
[data-theme="dark"] .retry { color: #19291e; }
[data-theme="dark"] .tabbar { background: #202822f5; }
[data-theme="dark"] .tab .icon { stroke: #b0bab1; fill: #303c33; }
[data-theme="dark"] .tab.active .icon { stroke: #ffdb75; fill: var(--yellow); }
[data-theme="dark"] .quota-badge { border-color: var(--border); }
[data-theme="dark"] .quota-badge .icon-bolt { stroke: #ffdb75; }
[data-theme="dark"] .notebook-search,
[data-theme="dark"] .subject-filters button { background: var(--card); }
[data-theme="dark"] .notebook-search::placeholder { color: var(--muted); opacity: 1; }
[data-theme="dark"] .subject-filters .active,
[data-theme="dark"] .segmented .active,
[data-theme="dark"] .reading-status { background: var(--mint); }
[data-theme="dark"] .segmented { border-color: var(--border); }
[data-theme="dark"] .continue-label { color: var(--accent); }
[data-theme="dark"] .latest-solution .continue-label { background: #a3dfb8; color: #19291e; }
[data-theme="dark"] .latest-solution .reading-status { background: none; }
[data-theme="dark"] .progress-track,
[data-theme="dark"] .reading-meter i { background: #48574b; }
[data-theme="dark"] .reading-meter .filled { background: #87cfa1; }
[data-theme="dark"] .subject-icon { background: #355740; }
[data-theme="dark"] .subject-english { background: #69443c; }
[data-theme="dark"] .subject-russian { background: #62542e; }
[data-theme="dark"] .save-error,
[data-theme="dark"] .explain,
[data-theme="dark"] .math-status:not(:empty) { background: #493e24; color: var(--text); }
[data-theme="dark"] .answer { background: var(--card-soft); border-color: var(--card-soft-border); }
[data-theme="dark"] .answer-label,
[data-theme="dark"] .answer-value { color: var(--accent); }
[data-theme="dark"] .mascot { mix-blend-mode: normal; }
[data-theme="dark"] .toast-neutral { background: #e0eadf; color: #19291e; }
