:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #1e2420;
  --muted: #5c635e;
  --line: #e8e3da;
  --sage: #dfe8de;
  --sage-2: #c9d9c9;
  --sage-ink: #34604b;
  --apricot: #f9e1cf;
  --apricot-ink: #a34d22;
  --cream: #efe8dc;
  --danger: #a33a2c;
  --danger-soft: #f8e6e2;
  --r-xl: 28px;
  --r-l: 22px;
  --r-m: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px calc(112px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sim { background: #fff3d6; color: #5b4500; font-size: 13px; padding: 8px 16px; text-align: center; }

.loader { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 4px; }
.spin {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); border-top-color: var(--ink);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* премиум-эмодзи Telegram: адаптивные, перекрашиваются в цвет текста, как в самом Telegram */
.em {
  display: inline-block; flex: none;
  width: var(--s, 22px); height: var(--s, 22px);
  background: currentColor;
  -webkit-mask: var(--src) center / contain no-repeat;
  mask: var(--src) center / contain no-repeat;
}

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 0; }
.top .hello { font-size: 13px; color: var(--muted); }
.top .hello b { display: block; font-size: 17px; color: var(--ink); font-weight: 700; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--apricot); color: var(--apricot-ink);
  display: grid; place-items: center; font-weight: 700; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* большие карточки с объектом, выходящим за край */
.hero {
  position: relative; overflow: hidden;
  background: var(--sage); border-radius: var(--r-xl);
  padding: 22px 20px 20px; min-height: 340px;
  display: flex; flex-direction: column;
}
.hero .eyebrow { font-size: 13px; font-weight: 600; color: var(--sage-ink); }
.hero h1 { font-size: 30px; line-height: 1.08; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; max-width: 72%; position: relative; z-index: 1; }
.hero .tag { margin-top: 10px; max-width: 58%; color: #3b453f; position: relative; z-index: 1; }
.hero .art {
  position: absolute; right: -54px; bottom: 34px; width: 250px; height: auto;
  pointer-events: none;
}
.hero .cta { margin-top: auto; position: relative; z-index: 1; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 0 22px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 16px;
  text-decoration: none; transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.light { background: var(--card); color: var(--ink); }
.btn.sage { background: var(--sage-ink); }
.btn.ghost { background: var(--cream); color: var(--ink); }
.btn .spin { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.btn.light .spin, .btn.ghost .spin { border-color: var(--line); border-top-color: var(--ink); }

/* факты */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--card); border-radius: var(--r-m); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.fact .em { --s: 20px; color: var(--sage-ink); }
.fact b { font-size: 15px; font-weight: 700; }
.fact small { color: var(--muted); font-size: 12px; line-height: 1.3; }

/* ряд действий, как в референсе */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 7px; text-decoration: none; font-size: 12.5px; text-align: center; }
.action .ic { width: 100%; aspect-ratio: 1.2; border-radius: 20px; background: var(--card); display: grid; place-items: center; }
.action .em { --s: 26px; }

.head { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 2px 0; }
.head h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.01em; }
.head a { font-size: 14px; color: var(--sage-ink); font-weight: 600; text-decoration: none; }

/* карточки уроков */
.rail { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.lcard {
  position: relative; overflow: hidden; flex: none;
  width: 168px; height: 212px; border-radius: var(--r-l);
  padding: 14px; text-decoration: none; color: var(--ink);
  scroll-snap-align: start; display: flex; flex-direction: column;
}
.lcard.c0 { background: var(--sage); }
.lcard.c1 { background: var(--apricot); }
.lcard.c2 { background: var(--cream); }
.lcard .mod { font-size: 12px; font-weight: 600; color: var(--muted); }
.lcard h3 { font-size: 15.5px; line-height: 1.2; font-weight: 700; margin-top: 4px; position: relative; z-index: 1; }
.lcard .art { position: absolute; right: -30px; bottom: -26px; width: 140px; height: auto; pointer-events: none; }
.lcard .pill {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border-radius: 999px; padding: 5px 10px 5px 8px;
  font-size: 12px; font-weight: 600;
}
.lcard .pill .em { --s: 15px; }
.pill.free { color: var(--sage-ink); }
.pill.done { color: var(--sage-ink); }

/* закрытый урок: картинка приглушена, сверху замок и подпись */
.lcard.locked .art { filter: grayscale(1); opacity: .45; }
.lcard.locked { background: #ebe7e0; }
.lcard.locked h3, .lcard.locked .mod { color: #6d716d; }
.lcard.locked .pill { background: var(--ink); color: #fff; }

.lock-badge {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--card); color: var(--ink); display: grid; place-items: center;
}
.lcard.locked .mod, .lcard.locked h3 { padding-right: 34px; }

/* программа: сетка */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid .lcard { width: auto; height: 220px; }
.grid .lcard.wide { grid-column: span 2; height: 200px; }
.grid .lcard.wide h3 { max-width: 58%; font-size: 18px; }
.grid .lcard.wide .art { width: 200px; right: -20px; bottom: -40px; }
.grid .lcard .short { font-size: 12.5px; color: var(--muted); margin-top: 6px; max-width: 46%; position: relative; z-index: 1; }

.unlock {
  background: var(--ink); color: #fff; border-radius: var(--r-l);
  padding: 18px; display: flex; align-items: center; gap: 14px; text-decoration: none;
}
.unlock .em { --s: 28px; color: var(--apricot); }
.unlock b { display: block; font-size: 16px; }
.unlock small { color: #c7ccc8; font-size: 13px; }

/* простые карточки */
.card { background: var(--card); border-radius: var(--r-l); padding: 18px; }
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .em { --s: 20px; color: var(--sage-ink); }
.card ul { margin: 0; padding-left: 18px; }
.card li + li { margin-top: 6px; }
.card p + p { margin-top: 8px; }
.muted { color: var(--muted); }

.steps { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; padding-top: 0; }
.step:last-child { padding-bottom: 0; }
.step .n { width: 34px; height: 34px; border-radius: 12px; background: var(--sage); color: var(--sage-ink); font-weight: 700; display: grid; place-items: center; }
.step b { display: block; }
.step span { color: var(--muted); font-size: 14px; }

.author { display: flex; align-items: center; gap: 14px; }
.author .avatar { width: 56px; height: 56px; font-size: 20px; }
.author b { display: block; font-size: 16px; }
.author small { color: var(--muted); font-size: 13.5px; line-height: 1.35; display: block; margin-top: 2px; }

details { border-top: 1px solid var(--line); }
details:first-child { border-top: 0; }
summary { list-style: none; cursor: pointer; padding: 14px 0; font-weight: 600; display: flex; justify-content: space-between; gap: 12px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--sage-ink); font-weight: 500; font-size: 22px; line-height: 1; }
details[open] summary::after { content: "−"; }
details p { padding: 0 0 14px; color: var(--muted); }
.faq { padding-top: 4px; padding-bottom: 4px; }

/* урок */
.lhero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 20px; min-height: 230px; background: var(--sage); }
.lhero.c1 { background: var(--apricot); }
.lhero.c2 { background: var(--cream); }
.lhero .mod { font-size: 13px; font-weight: 600; color: var(--muted); }
.lhero h1 { font-size: 24px; line-height: 1.15; font-weight: 800; margin-top: 6px; max-width: 64%; position: relative; z-index: 1; letter-spacing: -0.01em; }
.lhero .art { position: absolute; right: -40px; bottom: -34px; width: 210px; height: auto; }
.lhero .meta { position: absolute; left: 20px; bottom: 18px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 60%; z-index: 1; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--card); border-radius: 999px; padding: 6px 11px 6px 9px; font-size: 12.5px; font-weight: 600; }
.chip .em { --s: 15px; color: var(--sage-ink); }

.task { background: var(--ink); color: #fff; }
.task h2 { color: #fff; }
.task h2 .em { color: var(--apricot); }

.status { border-radius: var(--r-m); padding: 14px 16px; font-size: 14px; display: flex; gap: 12px; align-items: flex-start; }
.status .em { --s: 22px; margin-top: 1px; }
.status b { display: block; margin-bottom: 2px; }
.status.ok { background: var(--sage); color: #22402f; }
.status.err { background: var(--danger-soft); color: var(--danger); }
.status.info { background: var(--cream); color: var(--ink); }
.stack { display: flex; flex-direction: column; gap: 10px; }

.check { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.check:first-of-type { border-top: 0; padding-top: 2px; }
.check .dot { width: 26px; height: 26px; border-radius: 9px; border: 2px solid #cfd2cb; flex: none; display: grid; place-items: center; }
.check.done .dot { background: var(--sage-ink); border-color: var(--sage-ink); }
.check .dot svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check .txt { flex: 1; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }
.link-btn { background: var(--sage); border: 0; border-radius: 999px; padding: 7px 12px; color: var(--sage-ink); font-weight: 600; cursor: pointer; font-size: 13px; }

textarea {
  width: 100%; min-height: 120px; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 12px 14px; font: inherit; background: #fbfaf7; color: var(--ink);
}
textarea:focus { outline: 2px solid var(--sage-ink); outline-offset: 1px; border-color: transparent; }
label.lbl { font-weight: 700; display: block; }

/* продолжение */
.ohero { position: relative; overflow: hidden; border-radius: var(--r-xl); background: var(--apricot); padding: 22px 20px; min-height: 250px; }
.ohero .eyebrow { font-size: 13px; font-weight: 600; color: var(--apricot-ink); }
.ohero h1 { font-size: 28px; font-weight: 800; line-height: 1.1; margin-top: 6px; letter-spacing: -0.02em; position: relative; z-index: 1; }
.ohero p { margin-top: 10px; max-width: 52%; color: #4a3a30; position: relative; z-index: 1; }
.ohero .art { position: absolute; right: -46px; bottom: -40px; width: 220px; height: auto; }
.ofacts { display: flex; flex-direction: column; }
.ofact { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.ofact:first-child { border-top: 0; padding-top: 0; }
.ofact:last-child { padding-bottom: 0; }
.ofact .em { --s: 20px; color: var(--sage-ink); }
.ofact span { flex: 1; color: var(--muted); }
.ofact b { font-weight: 600; }

.modlist { display: flex; flex-direction: column; }
.mod-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.mod-row:first-child { border-top: 0; padding-top: 0; }
.mod-row:last-child { padding-bottom: 0; }
.mod-row img { width: 44px; height: 44px; object-fit: contain; background: var(--cream); border-radius: 12px; padding: 4px; flex: none; }
.mod-row small { display: block; color: var(--muted); font-size: 12.5px; }

.plans { display: flex; flex-direction: column; gap: 10px; }
.plan { position: relative; display: block; background: var(--card); border-radius: var(--r-l); padding: 18px; border: 2px solid transparent; cursor: pointer; }
.plan:has(input:checked) { border-color: var(--sage-ink); }
.plan input { position: absolute; opacity: 0; pointer-events: none; }
.plan:focus-within { outline: 2px solid var(--sage-ink); outline-offset: 2px; }
.plan .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.plan .name { font-weight: 700; font-size: 17px; }
.plan .price { font-weight: 800; font-size: 20px; white-space: nowrap; }
.plan .note { color: var(--muted); font-size: 13px; margin-top: 2px; }
.plan ul { margin: 12px 0 0; padding: 12px 0 0 18px; border-top: 1px solid var(--line); font-size: 14px; }
.plan li + li { margin-top: 5px; }
.plan .radio { position: absolute; right: 18px; bottom: 18px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #cfd2cb; }
.plan:has(input:checked) .radio { border: 7px solid var(--sage-ink); }

/* нижнее меню: плавающая панель, как в референсе */
.tabs {
  position: fixed; left: 12px; right: 12px; z-index: 5;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 536px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--card); border-radius: 26px; padding: 6px;
  box-shadow: 0 8px 28px rgba(30, 36, 32, .12);
}
.tabs[hidden] { display: none; }
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 56px; border-radius: 20px;
  font-size: 11.5px; text-decoration: none; color: var(--muted);
}
.tabs a .em { --s: 24px; }
.tabs a.on { background: var(--sage); color: var(--sage-ink); font-weight: 600; }

@media (max-width: 370px) {
  .hero h1 { font-size: 26px; }
  .hero .art { width: 210px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .facts .fact:last-child { grid-column: span 2; }
}

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