/* «Тетрадь» — обложка в стиле школьной тетради Hatber + интерфейс в духе Apple.
   Обложка: светло-зелёная, эмблема с пером, «ТЕТРАДЬ», поля-наклейки, бейджи.
   Внутри: тёплый лист в клетку 5 мм с красным полем, перелистывание страниц. */

:root {
  /* обложка */
  --cover:      #a9c9a3;
  --cover-2:    #97ba90;
  --cover-3:    #86ac80;
  --cover-ink:  #2c5138;
  --cover-ink-2:#3d6448;
  /* тетрадный лист */
  --paper:  #fbfaf3;
  --paper-2:#f5f3e8;
  --grid:   #cdd9e6;
  --margin: #e0a3a3;
  --ink:    #22315a;
  --muted:  #8a8d80;
  --line:   #e4e0d2;
  --green:  #35774a;
  --green-2:#2c5f3c;
  --cell: 22px;
  --flip: .6s;
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: #23241f; background: #1c2b20; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- сцена перелистывания ---------- */
.book { position: relative; width: 100%; min-height: 100vh; min-height: 100dvh;
  perspective: 2400px; overflow: hidden; }
.page {
  position: absolute; inset: 0; display: none; flex-direction: column;
  transform-origin: left center; backface-visibility: hidden;
  will-change: transform; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.page.active   { display: flex; z-index: 2; transform: rotateY(0); }
.page.incoming { display: flex; z-index: 1; transform: rotateY(0); }
.page.turning  { z-index: 3; transition: transform var(--flip) cubic-bezier(.4,.05,.2,1);
  transform: rotateY(-162deg); box-shadow: 48px 0 70px rgba(0,0,0,.4); }

/* ================= ОБЛОЖКА ================= */
/* justify-content:flex-start + margin:auto на листе — центрирует, когда есть место,
   и позволяет ПРОКРУТКУ, когда лист выше окна (иначе на ПК низ меню обрезался). */
.cover { align-items: center; justify-content: flex-start; padding: 18px 14px;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(255,255,255,.35), transparent 55%),
    linear-gradient(160deg, var(--cover) 0%, var(--cover-2) 62%, var(--cover-3) 100%); }
.cover__sheet {
  position: relative; width: 100%; max-width: 440px; min-height: min(760px, 94dvh);
  margin: 0 auto; flex-shrink: 0;   /* не сжиматься в высоту — иначе низ меню обрезался без прокрутки */
  padding: 30px 26px 22px; display: flex; flex-direction: column; align-items: center;
  color: var(--cover-ink);
  border-radius: 6px;
  box-shadow: 0 18px 44px rgba(20,45,28,.35), inset 0 0 0 1px rgba(255,255,255,.25);
  background: linear-gradient(160deg, rgba(255,255,255,.10), rgba(255,255,255,0) 40%);
}
.cover__grain { position: absolute; inset: 0; pointer-events: none; border-radius: 6px; opacity: .5;
  background-image: radial-gradient(rgba(44,81,56,.10) .6px, transparent .7px);
  background-size: 4px 4px; }

/* эмблема-медальон с пером */
.emblem { position: relative; width: 132px; height: 138px; margin: 6px 0 4px; color: var(--cover-ink); }
.emblem__frame { position: absolute; inset: 0; }
.emblem__frame ellipse { stroke-width: 2; }
.emblem__frame--thin { stroke-width: 1; opacity: .6; }
.emblem__quill { position: absolute; inset: 8px; stroke-width: 2; }
.emblem__laurel { position: absolute; bottom: 16px; width: 26px; height: 44px;
  border: 2px solid var(--cover-ink); border-top: 0; opacity: .55; }
.emblem__laurel--l { left: 22px; border-right: 0; border-bottom-left-radius: 26px; transform: rotate(6deg); }
.emblem__laurel--r { right: 22px; border-left: 0; border-bottom-right-radius: 26px; transform: rotate(-6deg); }

.cover__title { font-family: Georgia, "Times New Roman", serif; font-weight: 700;
  font-size: clamp(38px, 12vw, 54px); letter-spacing: .14em; margin: 6px 0 2px;
  text-indent: .14em; color: var(--cover-ink);
  text-shadow: 0 1px 0 rgba(255,255,255,.28); }
.cover__subtitle { font-size: 14px; letter-spacing: .32em; text-transform: uppercase;
  color: var(--cover-ink-2); opacity: .85; margin-bottom: 16px; }

.cover__form { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.cover__field { display: flex; align-items: baseline; gap: 10px; font-size: 13px; color: var(--cover-ink-2); }
.cover__field span { flex: 0 0 auto; opacity: .8; }
.cover__field i { flex: 1; border-bottom: 1.5px dotted rgba(44,81,56,.5); height: 12px; }

/* меню — сгруппированный список в духе iOS */
.menu { width: 100%; display: flex; flex-direction: column;
  background: rgba(255,255,255,.5); border-radius: var(--r);
  box-shadow: 0 10px 26px rgba(20,45,28,.18), inset 0 0 0 1px rgba(255,255,255,.5);
  overflow: hidden; backdrop-filter: blur(6px); }
.menu__item { display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; background: transparent; border: 0; cursor: pointer; text-align: left;
  color: #24312a; border-top: 1px solid rgba(44,81,56,.10); transition: background .12s; }
.menu__item:first-child { border-top: 0; }
.menu__item:active { background: rgba(44,81,56,.08); }
.menu__ic { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 11px; color: #fff; background: linear-gradient(160deg, var(--green), var(--green-2));
  box-shadow: 0 4px 10px rgba(44,95,60,.35); }
.menu__ic svg { width: 21px; height: 21px; }
.menu__txt { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.menu__txt b { font-size: 16px; font-weight: 600; }
.menu__txt small { font-size: 12.5px; color: #6f7a6c; }
.menu__go { width: 16px; height: 16px; color: #b7c1b0; stroke-width: 2.4; transform: rotate(180deg); }

/* бейджи-«штампы» снизу обложки */
.cover__badges { display: flex; gap: 10px; margin-top: auto; padding-top: 20px; }
.badge { min-width: 66px; padding: 8px 10px; text-align: center;
  border: 1.5px solid rgba(44,81,56,.5); border-radius: 8px; color: var(--cover-ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: rgba(255,255,255,.16); }
.badge b { font-size: 20px; font-weight: 700; line-height: 1; }
.badge small { font-size: 10px; letter-spacing: .04em; opacity: .8; }
.badge__cells { width: 22px; height: 22px;
  background-image: linear-gradient(var(--cover-ink) 1px, transparent 1px),
                    linear-gradient(90deg, var(--cover-ink) 1px, transparent 1px);
  background-size: 5px 5px; opacity: .7; }

/* ================= ВНУТРЕННИЕ СТРАНИЦЫ ================= */
/* Тонкая тетрадная клетка как фон — светлая, без жирного поля, чтобы не спорить с UI. */
.paper { background-color: var(--paper); color: var(--ink);
  background-image:
    repeating-linear-gradient(rgba(120,150,185,.09) 0 1px, transparent 1px var(--cell)),
    repeating-linear-gradient(90deg, rgba(120,150,185,.09) 0 1px, transparent 1px var(--cell));
  background-position: 0 0;
}
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: linear-gradient(var(--paper) 60%, rgba(251,250,243,.7));
  backdrop-filter: blur(3px); border-bottom: 1px solid rgba(0,0,0,.05); }
.bar h2 { margin: 0 auto 0 4px; font-size: 17px; font-weight: 600; color: #1f3327; }
.back { display: inline-flex; align-items: center; gap: 2px; border: 0; background: transparent;
  color: var(--green-2); font-size: 16px; font-weight: 500; cursor: pointer; padding: 4px 4px; }
.back svg { width: 20px; height: 20px; stroke-width: 2.4; }
.sheet { padding: 4px 20px 44px; }

.lbl { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 20px 2px 8px; }

/* кликабельный «?» с подсказкой под каждым пунктом */
.help { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(53,119,74,.14); color: var(--green-2); font-size: 12px; font-weight: 800;
  line-height: 1; cursor: pointer; display: grid; place-items: center; transition: transform .08s, background .15s; }
.help:active { transform: scale(.88); }
.help.on { background: var(--green); color: #fff; }
.helpbox { font-size: 13px; line-height: 1.55; color: #43493d; margin: 8px 2px 0;
  background: rgba(53,119,74,.08); border: 1px solid rgba(53,119,74,.16); border-radius: 12px; padding: 10px 13px; }
.helpbox b { color: #2f3a2c; }
.helpbox code { background: rgba(53,119,74,.12); color: var(--green-2); border-radius: 5px; padding: 1px 5px; font-size: 12px; }
/* редактор с подложкой-подсветкой: textarea (текст, прозрачный фон) поверх подложки,
   на которой рисуются выделения ровно под буквами. Геометрия ОБОИХ слоёв обязана совпадать. */
.ed { position: relative; }
.ed__hl { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  border: 1px solid transparent; border-radius: 14px; padding: 13px;
  background: rgba(255,255,255,.82); box-shadow: inset 0 1px 2px rgba(0,0,0,.03); }
.ed__hlinner { font-size: 16px; font-family: inherit; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; color: transparent;
  will-change: transform; }
.ed__hlinner span { -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.ed textarea { position: relative; z-index: 1; background: transparent; margin: 0; display: block; }

textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px;
  font-size: 16px; font-family: inherit; line-height: 1.4; background: rgba(255,255,255,.82);
  overflow-wrap: break-word; word-break: normal;
  resize: vertical; color: #222; box-shadow: inset 0 1px 2px rgba(0,0,0,.03); }
textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(53,119,74,.14); }

/* строка карточек шрифтов */
.fontrow { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.fontrow::-webkit-scrollbar { height: 0; }
.fontcard { flex: 0 0 auto; scroll-snap-align: start; width: 172px; border: 2px solid transparent;
  border-radius: 14px; background: #fff; padding: 6px; cursor: pointer; transition: border-color .15s, transform .06s;
  box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.fontcard:active { transform: scale(.98); }
.fontcard.active { border-color: var(--green); box-shadow: 0 4px 14px rgba(53,119,74,.28); }
.fontcard img { width: 100%; height: 46px; object-fit: cover; border-radius: 8px; display: block; }
.fontcard span { display: block; font-size: 12px; color: #5b6157; text-align: center; margin-top: 5px; font-weight: 500; }

/* сегментированный контрол (iOS) */
.seg { display: flex; gap: 3px; background: #e9e7dc; border-radius: 12px; padding: 3px; }
.seg__b { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 6px;
  font-size: 14px; font-weight: 500; color: #59605a; cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s, box-shadow .15s; }
.seg__b.active { background: #fff; color: #1f3327; box-shadow: 0 1px 4px rgba(0,0,0,.12); font-weight: 600; }
.seg__b:disabled { opacity: .4; cursor: default; }

.seg--sub { margin-top: 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 2px 0; line-height: 1.5; }
.hint code { background: rgba(53,119,74,.10); color: var(--green-2); border-radius: 5px;
  padding: 1px 5px; font-size: 12px; }

/* профиль / кабинет */
.profile { display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 14px 0 6px; }
.profile__ava { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  font-size: 34px; font-weight: 700; color: #fff; margin-bottom: 10px;
  background: linear-gradient(160deg, var(--green), var(--green-2)); box-shadow: 0 8px 20px rgba(44,95,60,.34); }
.profile__name { font-size: 20px; font-weight: 700; color: #21331f; }
.profile__plan { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 16px 0 4px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 6px;
  text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.stat b { display: block; font-size: 24px; font-weight: 800; color: var(--green-2); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.mini--soon { position: relative; opacity: .96; }
.mini--soon::after { content: "скоро"; position: absolute; top: 12px; right: 12px; font-size: 10px;
  letter-spacing: .04em; text-transform: uppercase; color: var(--green-2);
  background: rgba(53,119,74,.12); border-radius: 6px; padding: 3px 7px; }

/* переключатель разметки (iOS toggle) */
.switch { display: flex; align-items: center; gap: 12px; margin-top: 14px;
  background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.switch__txt { flex: 1; line-height: 1.3; }
.switch__txt b { font-size: 15px; font-weight: 600; }
.switch__txt small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.toggle { flex: 0 0 auto; width: 51px; height: 31px; border-radius: 16px; border: 0; cursor: pointer;
  background: #d3d1c6; position: relative; transition: background .2s; padding: 0; }
.toggle i { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.28); transition: transform .2s; }
.toggle.on { background: #34c759; }
.toggle.on i { transform: translateX(20px); }
.toggle.off { opacity: .45; }

/* цвет ручки */
.inks { display: flex; gap: 12px; }
.ink { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #fff; cursor: pointer;
  background: var(--c); box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(0,0,0,.18); transition: transform .08s; }
.ink:active { transform: scale(.92); }
.ink.active { box-shadow: 0 0 0 2px var(--green), 0 2px 8px rgba(0,0,0,.2); }

/* ползунки (iOS) */
.controls { display: grid; gap: 12px; }
.ctl { display: grid; grid-template-columns: 100px 1fr 48px; align-items: center; gap: 12px; }
.ctl__name { font-size: 13.5px; color: #5b6157; }
.ctl output { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); font-weight: 500; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 5px; border-radius: 5px;
  background: #dcdacd; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.32); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.32); cursor: pointer; }

/* действия */
.actions { display: flex; gap: 10px; margin-top: 22px; }
.btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 13px 12px;
  font-size: 15px; font-weight: 600; color: #223; cursor: pointer; font-family: inherit; transition: transform .06s; }
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); }
.btn--primary { flex: 1.5; background: linear-gradient(160deg, var(--green), var(--green-2));
  color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(44,95,60,.35); }
.btn--primary svg { fill: #fff; stroke: #fff; }
.btn:disabled { opacity: .6; cursor: default; transform: none; }

.preview { margin-top: 16px; min-height: 130px; border: 1px dashed #d5d0bf; border-radius: 14px;
  background: rgba(255,255,255,.55); display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 10px; }
.preview img { width: 100%; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.preview__hint { color: var(--muted); font-size: 14px; text-align: center; padding: 26px 20px; }
.preview__pages { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* галерея почерков */
.gallery { display: grid; grid-template-columns: 1fr; gap: 12px; padding-top: 10px; }
.gallery figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05); cursor: pointer; transition: transform .06s; }
.gallery figure:active { transform: scale(.99); }
.gallery img { width: 100%; height: 58px; object-fit: cover; border-radius: 8px; display: block; }
.gallery figcaption { font-size: 13.5px; color: #4c5349; margin-top: 8px; font-weight: 500; }
@media (min-width: 620px) { .gallery { grid-template-columns: 1fr 1fr; } }

/* «свой почерк» + «о приложении» */
.soon { text-align: center; padding: 18px 4px; }
.soon__ic { width: 66px; height: 66px; margin: 6px auto 10px; border-radius: 20px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(160deg, var(--green), var(--green-2)); box-shadow: 0 8px 20px rgba(44,95,60,.32); }
.soon__ic svg { width: 34px; height: 34px; }
.soon h3 { color: var(--green-2); margin: 8px 0 6px; font-size: 19px; }
.soon p { color: #4c5349; line-height: 1.5; max-width: 360px; margin: 8px auto; }
.steps { list-style: none; padding: 0; max-width: 360px; margin: 16px auto; text-align: left; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: 14.5px; color: #3d443a; }
.steps li span { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--green), var(--green-2)); color: #fff; font-weight: 700; font-size: 14px; }
.note { font-size: 13px; color: var(--muted); background: rgba(53,119,74,.09);
  border-radius: 10px; padding: 10px 14px; display: inline-block; margin-top: 10px; }
.cards { display: grid; gap: 10px; margin: 16px 0; }
.mini { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.mini b { display: block; font-size: 15px; margin-bottom: 3px; }
.mini span { font-size: 13.5px; color: #5b6157; line-height: 1.4; }
.paper p { line-height: 1.55; color: #33382e; }

/* «Свой почерк» — тач-сбор образцов */
@font-face { font-family: "ModelHand"; src: url("/api/model_font.ttf") format("truetype"); font-display: swap; }
.cap-intro p { font-size: 14px; line-height: 1.55; color: #3d443a; margin: 4px 2px 10px; }
.cap-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 2px 8px;
  position: sticky; top: 0; z-index: 5; background: linear-gradient(180deg, var(--paper) 70%, transparent); padding: 6px 0; }
.cap-pen { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); }
.cap-pen input { width: 120px; }
.cap-pendot { width: 12px; height: 12px; border-radius: 50%; background: #1a285c; display: inline-block; }
.cap-prog { font-size: 13px; color: #4c5349; }
.cap-prog b { color: var(--green-2); font-weight: 800; }
.cap-load { text-align: center; color: var(--muted); padding: 24px; }
.cap-sec { font-weight: 700; color: var(--green-2); margin: 14px 2px 6px; font-size: 13.5px; }
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.cap-cell { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 5px 5px 4px;
  display: flex; flex-direction: column; gap: 3px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.cap-cell.done { border-color: var(--green); box-shadow: 0 2px 9px rgba(53,119,74,.22); }
.cap-cvs { width: 100%; aspect-ratio: 1 / 1; display: block; border-radius: 8px; touch-action: none; cursor: crosshair;
  background: #fcfdff; }
.cap-lab { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 2px; }
.cap-lab span { font-size: 11px; color: #6a7065; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap-redo { flex: 0 0 auto; border: 0; background: rgba(53,119,74,.12); color: var(--green-2); border-radius: 6px;
  font-size: 12px; line-height: 1; padding: 3px 6px; cursor: pointer; }
.cap-redo:active { transform: scale(.9); }

/* мастер разметки (панель над текстом) */
.mtools { display: flex; flex-direction: column; gap: 8px; margin: 2px 2px 9px; }
.mcolors { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.clab { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.macts { display: flex; flex-wrap: wrap; gap: 8px; }
.mtool { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; border-radius: 11px; padding: 8px 12px; font-size: 13.5px; font-weight: 600;
  color: #2b3327; cursor: pointer; font-family: inherit; box-shadow: 0 2px 6px rgba(0,0,0,.05);
  transition: transform .06s, box-shadow .15s; }
.mtool:active { transform: scale(.96); }
.mtool.on { background: var(--green); border-color: var(--green); color: #fff; }
.mtool.on u, .mtool.on .mk { color: #fff; }
.mtool u { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.mtool u.dbl { text-decoration-style: double; }
.mtool .mk { color: #d9c26a; font-size: 15px; line-height: 1; }
.mtool--clear { color: #a3564f; }
.dot { width: 20px; height: 20px; border-radius: 50%; background: var(--d); display: inline-block;
  box-shadow: 0 0 0 1px rgba(0,0,0,.14); cursor: pointer; transition: transform .08s, box-shadow .12s; }
.dot:hover { transform: scale(1.15); }
.dot.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--green); transform: scale(1.15); }

/* подпись подраздела (Оформление) + легенда цветов */
.sublbl { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 8px 2px 2px; }
.lg { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--d);
  color: #3a3f33; font-weight: 600; font-size: 12px; margin: 0 1px; }

/* иконка в подписи ползунка */
.ci { width: 15px; height: 15px; vertical-align: -2px; color: var(--green-2); }

/* печатная подсказка */
.hint--print { text-align: center; background: rgba(53,119,74,.07); border-radius: 10px; padding: 8px 10px; margin-top: 12px; }

/* кнопка ИИ-форматирование (заглушка за звёзды) */
.btn--ai { width: 100%; margin-top: 22px; justify-content: center; gap: 9px; font-weight: 700;
  color: #2a2350; border: 0;
  background: linear-gradient(135deg, #f6d365 0%, #b98cff 55%, #7c9cff 100%);
  box-shadow: 0 8px 20px rgba(140,120,220,.35); }
.btn--ai svg { fill: none; stroke: #4a2a7a; }
.star { font-size: .92em; }

/* модал ИИ-форматирования */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(20,30,22,.5); backdrop-filter: blur(3px); }
.modal__card { position: relative; z-index: 1; width: 100%; max-width: 400px; max-height: 88vh; overflow-y: auto;
  background: var(--paper); border-radius: 20px; padding: 22px 20px 18px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.4); animation: pop .22s ease; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal__close { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.06); color: #4c5349; font-size: 15px; cursor: pointer; }
.modal__ic { width: 60px; height: 60px; margin: 4px auto 8px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, #f6d365, #b98cff); box-shadow: 0 8px 20px rgba(140,120,220,.35); }
.modal__ic svg { width: 32px; height: 32px; fill: none; stroke: #3a2a6a; }
.modal__card h3 { margin: 6px 0 8px; color: #2b2350; font-size: 20px; }
.modal__lead { color: #43493d; line-height: 1.5; font-size: 14.5px; margin: 0 0 14px; }
.modal__prompt { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.modal__prompt-h { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.modal__prompt ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.modal__prompt li { font-size: 14px; color: #3d443a; line-height: 1.4; }
.modal .u { text-decoration: underline; text-underline-offset: 3px; }
.modal .u.dbl { text-decoration-style: double; }
.modal__cta { width: 100%; margin-top: 16px; }

/* доступность: без 3D-переворота */
@media (prefers-reduced-motion: reduce) {
  .page.turning { transition: opacity .2s; transform: rotateY(0); opacity: 0; box-shadow: none; }
}

/* ===== кнопка «во весь экран» у поля текста ===== */
.expand { margin-left: auto; border: 1px solid var(--line); background: #fff; color: var(--green-2);
  border-radius: 9px; font: 600 12px/1 inherit; padding: 6px 9px; cursor: pointer; letter-spacing: .01em;
  text-transform: none; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.expand:active { transform: scale(.96); }

/* ===== полноэкранный редактор текста + разметка ===== */
.editfull { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top,0px) + 8px) 12px calc(env(safe-area-inset-bottom,0px) + 10px); }
.editfull[hidden] { display: none; }
.editfull__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px 10px; }
.editfull__ttl { font-weight: 800; color: var(--ink); font-size: 16px; }
.editfull__done { flex: 0 0 auto; min-width: 120px; }
.editfull__slot { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
/* внутри полноэкранного слота поле текста растягивается на всю доступную высоту */
.editfull__slot .mtools { flex: 0 0 auto; }
.editfull__slot .ed { flex: 1 1 auto; display: flex; min-height: 0; }
.editfull__slot .ed textarea { flex: 1; height: 100%; min-height: 0; resize: none; font-size: 17px; }
.editfull__slot .ed__hlinner { font-size: 17px; }

/* ===== полноэкранное окно сбора почерка (по пунктам) ===== */
.capmodal { position: fixed; inset: 0; z-index: 62; background: var(--paper); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top,0px) + 8px) 14px calc(env(safe-area-inset-bottom,0px) + 12px); }
.capmodal[hidden] { display: none; }
.capmodal__head { display: flex; align-items: center; gap: 12px; }
.capmodal__x { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,.06);
  color: #4c5349; font-size: 16px; cursor: pointer; }
.capmodal__progwrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.capbar { flex: 1; height: 8px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.capbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--green-2));
  border-radius: 6px; transition: width .25s ease; }
.capmodal__cnt { font-size: 13px; color: #4c5349; white-space: nowrap; }
.capmodal__cnt b { color: var(--green-2); font-weight: 800; }
.capmodal__title { text-align: center; margin: 12px 0 2px; font-size: 26px; color: var(--ink); }
.capmodal__sec { display: block; font-size: 12.5px; font-weight: 700; color: var(--green-2);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.capmodal__hint { text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 2px 6px 8px; }
.capmodal__stage { flex: 1; display: grid; place-items: center; min-height: 0; }
#capBig { width: min(86vw, 62vh, 470px); aspect-ratio: 1 / 1; background: #fcfdff; border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.08); touch-action: none; cursor: crosshair; }
.capmodal__pen { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 12.5px;
  color: var(--muted); margin: 8px 0 4px; }
.capmodal__pen input { width: 150px; }
.capmodal__acts { display: flex; gap: 9px; margin-top: 4px; }
.capmodal__tip { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 6px 0; line-height: 1.45; }

/* обзорная сетка: ячейка кликабельна (открывает большое окно), «галка» на заполненных */
.cap-cell { position: relative; cursor: pointer; }
.cap-cvs { pointer-events: none; }   /* рисуем в большом окне; клик по ячейке открывает его */
.cap-cell.done::after { content: "✓"; position: absolute; top: 5px; right: 6px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--green); color: #fff; font-size: 12px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 1px 4px rgba(53,119,74,.4); }

/* тост-уведомление */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom,0px) + 22px); transform: translateX(-50%);
  z-index: 90; background: rgba(26,40,60,.95); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px;
  font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: 88vw; text-align: center; }
.toast[hidden] { display: none; }
.toast--err { background: rgba(150,45,45,.96); }

/* ===== приветственная бегущая строка «от руки» на обложке ===== */
.penline { width: 100%; max-width: 320px; height: 34px; margin: 2px 0 14px; display: flex;
  align-items: center; justify-content: center; overflow: hidden; }
#penTxt { font-family: "MyHand", "ModelHand", cursive; font-size: 22px; color: var(--cover-ink);
  white-space: nowrap; letter-spacing: .01em; }
.penCaret { display: inline-block; width: 2px; height: 24px; margin-left: 1px; background: var(--cover-ink-2);
  border-radius: 2px; animation: penblink 1s steps(1) infinite; }
@keyframes penblink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .penCaret { animation: none; } }

/* ===== уместные появления (stagger) ===== */
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.cover.active .menu__item { animation: riseIn .5s both; }
.cover.active .menu__item:nth-child(1) { animation-delay: .05s; }
.cover.active .menu__item:nth-child(2) { animation-delay: .12s; }
.cover.active .menu__item:nth-child(3) { animation-delay: .19s; }
.cover.active .menu__item:nth-child(4) { animation-delay: .26s; }
.cover.active .menu__item:nth-child(5) { animation-delay: .33s; }
.cover.active .badge { animation: riseIn .5s both .38s; }
.paper.active .sheet > * { animation: riseIn .32s both; }
@media (prefers-reduced-motion: reduce) {
  .cover.active .menu__item, .cover.active .badge, .paper.active .sheet > * { animation: none; }
}

/* ===== «Мой почерк»: собранные шрифты сверху ===== */
.myfonts__row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; }
.myfont { flex: 0 0 auto; width: 168px; background: #fff; border: 2px solid var(--green); border-radius: 14px;
  padding: 7px; box-shadow: 0 3px 12px rgba(53,119,74,.2); }
.myfont img { width: 100%; height: 44px; object-fit: cover; border-radius: 8px; display: block; background: #fcfdff; }
.myfont__row2 { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 7px; }
.myfont__row2 b { font-size: 12.5px; color: #3d443a; }
.myfont__use { border: 0; background: linear-gradient(160deg, var(--green), var(--green-2)); color: #fff;
  border-radius: 8px; font: 600 12px/1 inherit; padding: 7px 10px; cursor: pointer; }
.myfont__use:active { transform: scale(.95); }
.cap-free { font-size: 13px; color: #3d5a43; background: rgba(53,119,74,.09);
  border: 1px solid rgba(53,119,74,.16); border-radius: 10px; padding: 8px 11px; margin: 8px 2px 2px; }

/* ===== разделы-тизеры «Свой почерк» ===== */
.capsecs { display: grid; gap: 12px; margin-top: 6px; }
.capsec { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.capsec.done { border-color: rgba(53,119,74,.5); }
.capsec__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.capsec__head b { font-size: 15px; color: #21331f; }
.capsec__prog { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.capsec__prog.full { color: var(--green-2); font-weight: 700; }
.capsec__samples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 11px; }
.capsec__cv { width: 100%; aspect-ratio: 1 / 1; background: #fcfdff; border: 1px solid var(--line);
  border-radius: 10px; display: block; }
.capsec__fill { width: 100%; }

/* ===== оборотка тетради: алфавит ===== */
.backcover .cover__sheet { justify-content: flex-start; }
.backcover__back { position: absolute; top: 12px; left: 12px; color: var(--cover-ink-2); z-index: 2; }
.backcover__ttl { font-family: Georgia, "Times New Roman", serif; font-size: 22px; letter-spacing: .04em;
  color: var(--cover-ink); margin: 30px 0 14px; opacity: .9; }
.alphabet { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 4px;
  padding: 16px 12px; background: rgba(255,255,255,.34); border: 1px solid rgba(44,81,56,.28);
  border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.ab { font-family: "MyHand", "ModelHand", cursive; font-size: clamp(20px, 6vw, 26px); text-align: center;
  color: var(--cover-ink); line-height: 1.15; animation: riseIn .4s both; }
.backcover.active .ab { animation: penIn .5s both; }
@keyframes penIn { from { opacity: 0; transform: translateY(4px) rotate(-3deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .backcover.active .ab { animation: none; } }
.backcover__meta { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 18px; padding-top: 14px; border-top: 1px dashed rgba(44,81,56,.35); }
.backcover__pub { font-size: 11.5px; line-height: 1.5; color: var(--cover-ink-2); }
.backcover__pub b { font-size: 13px; color: var(--cover-ink); }
.backcover__barcode { flex: 0 0 auto; width: 116px; height: 44px;
  background: repeating-linear-gradient(90deg, var(--cover-ink) 0 1px, transparent 1px 2px,
    var(--cover-ink) 2px 4px, transparent 4px 7px, var(--cover-ink) 7px 8px, transparent 8px 11px);
  opacity: .72; border-radius: 2px; }
.backcover__about { font-size: 12.5px; line-height: 1.5; color: var(--cover-ink-2); text-align: center;
  margin: 14px 4px 0; opacity: .92; }

/* ===== листалка предпросмотра ===== */
.pager { display: flex; align-items: center; gap: 10px; margin: 18px 2px 0; flex-wrap: wrap; }
.pager[hidden] { display: none; }
.pager__b { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  color: var(--green-2); font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.pager__b:active { transform: scale(.94); }
.pager__b:disabled { opacity: .4; cursor: default; }
.pager__lbl { font-size: 13px; color: #4c5349; font-variant-numeric: tabular-nums; }
.pager__lbl b { color: var(--green-2); font-weight: 800; }
.pager__zoom { font-size: 12px; color: var(--muted); margin-left: auto; }
.preview img { cursor: zoom-in; }

/* ===== лайтбокс (зум предпросмотра) ===== */
.lightbox { position: fixed; inset: 0; z-index: 80; background: #0f150f; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top,0px) + 6px) 8px calc(env(safe-area-inset-bottom,0px) + 8px); }
.lightbox[hidden] { display: none; }
.lightbox__bar { display: flex; align-items: center; gap: 10px; color: #eaf1ea; padding: 4px 4px 8px; flex-wrap: wrap; }
.lightbox__x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14);
  color: #fff; font-size: 16px; cursor: pointer; }
.lightbox__nav, .lightbox__zoom { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.lightbox__zoom { margin-left: auto; }
.lightbox__b { min-width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.1); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 8px; }
.lightbox__b:active { transform: scale(.94); }
.lightbox__b:disabled { opacity: .35; cursor: default; }
.lightbox__lbl b { color: #fff; }
.lightbox__stage { flex: 1; overflow: hidden; display: grid; place-items: center; touch-action: none; min-height: 0; }
.lightbox__stage img { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  transform-origin: center center; will-change: transform; user-select: none; -webkit-user-drag: none; cursor: grab; }
.lightbox__stage img.grabbing { cursor: grabbing; }
.lightbox__tip { text-align: center; color: rgba(234,241,234,.7); font-size: 11.5px; margin: 6px 6px 0; }

/* эмодзи-иконка в модале лимита */
.modal__ic--emoji { font-size: 30px; }
