/* ============================================================
   Чистый лист — генератор печатных планеров
   Швейцарская редакционная минималистика:
   белое пространство, строгая сетка, одна алая линия,
   Playfair Display (дисплей) + Golos Text (гротеск).
   ============================================================ */

:root {
  --paper: #f6f5f0;
  --white: #ffffff;
  --ink: #17160f;
  --body: #3b3a30;
  --grey: #716e62;
  --hair: #dbd8cc;
  --hair-dark: #b9b6aa;
  --red: #c42b1c;
  --red-dark: #a01f12;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: 'Golos Text', 'Helvetica Neue', Helvetica, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

img { max-width: 100%; }

/* ---------- появление: одна оркестрованная волна ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.r1, .r2, .r3, .r4, .r5 { animation: rise .65s cubic-bezier(.2, .7, .2, 1) both; }
.r2 { animation-delay: .06s; }
.r3 { animation-delay: .12s; }
.r4 { animation-delay: .2s; }
.r5 { animation-delay: .3s; }
@media (prefers-reduced-motion: reduce) {
  .r1, .r2, .r3, .r4, .r5 { animation: none; }
}

/* ---------- шапка ---------- */
.site-head { border-bottom: 1px solid var(--hair); }
.head-in {
  max-width: 1220px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: baseline; gap: 28px; flex-wrap: wrap;
}
.logo {
  font-family: var(--serif); font-weight: 800; font-size: 23px;
  color: var(--ink); text-decoration: none; letter-spacing: .005em;
}
.logo i { color: var(--red); font-style: normal; }
.nav { display: flex; gap: 22px; margin-left: auto; overflow-x: auto; }
.nav a {
  font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .09em;
  color: var(--grey); text-decoration: none; white-space: nowrap;
  padding: 4px 0 5px; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav a:hover { color: var(--ink); }
.nav a.here { color: var(--ink); border-color: var(--red); }

/* ---------- герой ---------- */
.hero { max-width: 1220px; margin: 0 auto; padding: 52px 24px 6px; }
.kicker {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--red); margin-bottom: 18px;
}
.kicker::before { content: ''; width: 36px; height: 2px; background: var(--red); }
h1 {
  font-family: var(--serif); font-weight: 800;
  font-size: clamp(30px, 4.4vw, 52px); line-height: 1.08;
  letter-spacing: -.01em; max-width: 24ch;
}
.lead { margin-top: 16px; color: var(--grey); font-size: 17px; max-width: 60ch; }

/* ---------- вкладки хаба ---------- */
.tabs-wrap { max-width: 1220px; margin: 0 auto; padding: 28px 24px 0; }
.tool-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-tabs button {
  padding: 9px 18px; border: 1px solid var(--hair); background: var(--white);
  font: 500 14px var(--sans); color: var(--grey); cursor: pointer;
  transition: all .15s;
}
.tool-tabs button:hover { border-color: var(--ink); color: var(--ink); }
.tool-tabs button.on { background: var(--ink); border-color: var(--ink); color: var(--white); }

/* ---------- инструмент: панель + сцена ---------- */
.tool {
  max-width: 1220px; margin: 0 auto; padding: 26px 24px 56px;
  display: grid; grid-template-columns: 370px minmax(0, 1fr); gap: 34px;
  align-items: start;
}
.panel {
  background: var(--white); border: 1px solid var(--hair);
  border-top: 3px solid var(--red);
  padding: 24px 22px 22px; position: sticky; top: 18px;
}
.field { margin-bottom: 20px; }
.f-label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; color: var(--grey);
  margin-bottom: 8px;
}
.h-count { color: var(--hair-dark); letter-spacing: .05em; }
.row { display: flex; gap: 8px; }
select, input[type='date'], input[type='text'] {
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  padding: 9px 10px; border: 1px solid var(--hair); border-radius: 0;
  background: var(--white); width: 100%; min-width: 0;
}
select:focus, input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.seg { display: flex; border: 1px solid var(--hair); }
.seg button {
  flex: 1; padding: 9px 4px; background: none; border: 0;
  border-right: 1px solid var(--hair);
  font: 500 13px var(--sans); color: var(--grey); cursor: pointer;
  transition: all .12s;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--white); }
.check {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 14px; color: var(--body); cursor: pointer; margin-bottom: 20px;
}
.check input { margin-top: 3px; accent-color: var(--red); }
.btn-primary {
  display: inline-block; background: var(--red); color: #fff; border: 0;
  padding: 14px 24px; font: 600 15px var(--sans); letter-spacing: .03em;
  cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--red-dark); }
#btn-generate { width: 100%; }

.h-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.h-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 1px solid var(--hair); background: var(--paper);
  padding: 7px 11px; font-size: 14px;
}
.h-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-del {
  border: 0; background: none; color: var(--grey); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0 2px; flex: 0 0 auto;
}
.h-del:hover { color: var(--red); }
.btn-add {
  flex: 0 0 44px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer; transition: background .15s;
}
.btn-add:hover { background: var(--red); border-color: var(--red); }

/* ---------- сцена предпросмотра ---------- */
.stage { min-width: 0; }
.result-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.result-hint { font-size: 12.5px; color: var(--grey); max-width: 42ch; }
.preview-scroll {
  overflow-x: auto; background: #e9e7de; border: 1px solid var(--hair);
  padding: 22px;
}
#preview { display: flex; justify-content: center; width: max-content; margin: 0 auto; }
/* на узких экранах JS вписывает лист по ширине через --fit; печать не затронута */
@media screen {
  #preview { zoom: var(--fit, 1); }
}
.sheet-pair { display: flex; gap: 18px; }

/* ---------- CPA ---------- */
.cpa {
  margin-top: 20px; background: var(--white);
  border: 1px solid var(--hair); border-left: 3px solid var(--red);
  padding: 22px 24px;
}
.cpa-kick { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--grey); margin-bottom: 7px; }
.cpa-title { font-family: var(--serif); font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.cpa-note { font-size: 14px; color: var(--grey); margin-bottom: 14px; max-width: 62ch; }
.cpa-links { display: flex; gap: 22px; flex-wrap: wrap; }
.cpa-links a {
  color: var(--red); font-weight: 600; font-size: 14.5px; text-decoration: none;
  border-bottom: 1px solid currentColor; padding-bottom: 2px;
}
.cpa-links a:hover { color: var(--red-dark); }

/* ---------- карточки каталога ---------- */
.cards {
  max-width: 1220px; margin: 0 auto; padding: 0 24px 56px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px;
}
.card {
  position: relative; background: var(--white); border: 1px solid var(--hair);
  padding: 24px 22px 20px; text-decoration: none; color: var(--ink);
  transition: transform .18s, box-shadow .18s;
}
.card::before { content: ''; position: absolute; top: -1px; left: -1px; width: 38px; height: 3px; background: var(--red); }
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(23, 22, 15, .09); }
.card b { font-family: var(--serif); font-size: 19px; font-weight: 700; display: block; margin-bottom: 7px; }
.card span { font-size: 13.5px; color: var(--grey); line-height: 1.5; display: block; }

/* ---------- SEO-текст и FAQ ---------- */
.seo, .faq { max-width: 780px; margin: 0 auto; padding: 8px 24px; }
.seo h2, .faq h2 {
  font-family: var(--serif); font-weight: 700; font-size: 27px;
  margin: 36px 0 14px; letter-spacing: -.005em;
}
.seo p { margin-bottom: 14px; color: var(--body); }
.seo ul, .seo ol { margin: 0 0 14px 20px; color: var(--body); }
.seo li { margin-bottom: 6px; }
.faq { padding-bottom: 64px; }
.faq details { border-bottom: 1px solid var(--hair); }
.faq summary {
  cursor: pointer; padding: 17px 34px 17px 0; font-weight: 600; font-size: 16px;
  list-style: none; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+'; position: absolute; right: 4px; top: 50%; transform: translateY(-54%);
  font-family: var(--serif); font-size: 24px; font-weight: 400; color: var(--red);
}
.faq details[open] summary::after { content: '\2013'; }
.faq details p { padding: 0 0 17px; color: var(--body); font-size: 15.5px; max-width: 68ch; }

/* ---------- подвал ---------- */
.site-foot { border-top: 1px solid var(--hair); margin-top: 8px; }
.foot-in {
  max-width: 1220px; margin: 0 auto; padding: 26px 24px 42px;
  display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: baseline;
  font-size: 13px; color: var(--grey);
}
.foot-in a { color: var(--grey); text-decoration: none; border-bottom: 1px solid var(--hair); }
.foot-in a:hover { color: var(--ink); border-color: var(--ink); }
.foot-brand { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: 15px; }
.foot-note { margin-left: auto; }

/* ============================================================
   ЛИСТ — печатный продукт. Размеры в mm, типографика в em
   от базового кегля листа (А4 = 10.5pt, А5 = 7.6pt).
   ============================================================ */
.sheet {
  width: 190mm; min-height: 277mm; padding: 12mm 12mm 10mm;
  background: #fff; color: #141410;
  font-size: 10.5pt; line-height: 1.4;
  display: flex; flex-direction: column; flex: 0 0 auto;
  box-shadow: 0 3px 18px rgba(23, 22, 15, .14);
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.sheet--a5 { width: 138mm; min-height: 193mm; padding: 8mm; font-size: 7.6pt; }

.s-head { margin-bottom: 1.6em; }
.s-kick {
  font-size: .72em; letter-spacing: .22em; text-transform: uppercase;
  color: #85826f; margin-bottom: .7em;
}
.s-title {
  display: flex; align-items: baseline; gap: 1em; flex-wrap: wrap;
  border-bottom: 2.4pt solid var(--red); padding-bottom: .4em;
}
.s-title b {
  font-family: var(--serif); font-weight: 700; font-size: 2.5em;
  line-height: 1.05; letter-spacing: -.01em;
}
.s-sub { font-size: .95em; color: #85826f; margin-left: auto; white-space: nowrap; }
.bw .s-title { border-color: #141410; }

.wline { display: inline-block; border-bottom: .6pt solid #85826f; width: 8em; height: .9em; vertical-align: baseline; }
.wline.long { width: 14em; }
.s-foot {
  margin-top: auto; padding-top: 1.1em; border-top: .6pt solid var(--hair-dark);
  display: flex; gap: 3em; flex-wrap: wrap; font-size: .82em; color: #444;
}
.dots { letter-spacing: .35em; }

.box-label {
  font-size: .7em; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  color: var(--red); margin-bottom: .7em;
}
.bw .box-label { color: #141410; }

/* фоновые фактуры: линовка и клетка */
.style-lined .pat {
  background-image: repeating-linear-gradient(to bottom,
    transparent 0, transparent calc(2.1em - .5pt),
    #c9c6b8 calc(2.1em - .5pt), #c9c6b8 2.1em);
}
.style-grid .pat {
  background-image:
    linear-gradient(#d6d3c5 .5pt, transparent .5pt),
    linear-gradient(90deg, #d6d3c5 .5pt, transparent .5pt);
  background-size: 5mm 5mm;
}
.sheet--a5.style-grid .pat { background-size: 4mm 4mm; }

/* ---- трекер привычек ---- */
.t-grid { width: 100%; border-collapse: collapse; table-layout: fixed; flex: 1; }
.t-grid th, .t-grid td { border: .5pt solid var(--hair-dark); }
.t-grid thead th { height: 2.9em; vertical-align: bottom; padding-bottom: .3em; font-weight: 500; }
.t-grid tbody td { height: 2.35em; }
.t-grid .dn { display: block; font-size: .76em; line-height: 1.15; }
.t-grid .dw { display: block; font-size: .58em; color: #85826f; text-transform: uppercase; letter-spacing: .04em; }
.t-grid .hcol { width: 24%; text-align: left; padding: 0 .6em; }
.t-grid th.hcol { font-size: .7em; letter-spacing: .16em; text-transform: uppercase; color: #85826f; font-weight: 600; vertical-align: middle; }
.t-grid td.hcol { font-size: .82em; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.t-grid .scol { width: 4.6%; }
.t-grid th.scol { font-family: var(--serif); font-style: italic; font-size: 1em; color: var(--red); vertical-align: middle; }
.bw .t-grid th.scol { color: #141410; }
.t-grid .wknd { background: #efede2; }
.bw .t-grid .wknd { background: none; }
.bw .t-grid thead .wknd .dn { font-weight: 700; border-bottom: 1.1pt solid #141410; }
.t-legend { margin-top: 1.2em; display: flex; gap: 2.2em; flex-wrap: wrap; font-size: .72em; color: #85826f; }

/* ---- планер на неделю ---- */
.wk-prio { border: 1pt solid #141410; padding: 1em 1.2em .9em; margin-bottom: 1.3em; }
.wk-prio ol { list-style: none; counter-reset: p; display: flex; gap: 2.4em; }
.wk-prio li {
  flex: 1; counter-increment: p; border-bottom: .6pt solid #85826f;
  height: 1.8em; position: relative; padding-left: 1.5em;
}
.wk-prio li::before {
  content: counter(p); position: absolute; left: 0; bottom: .1em;
  font-family: var(--serif); font-style: italic; font-size: 1.1em; color: var(--red);
}
.bw .wk-prio li::before { color: #141410; }
.wk-grid {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr;
  gap: 1em; min-height: 150mm;
}
.sheet--a5 .wk-grid { min-height: 100mm; }
.wk-day { border: .5pt solid var(--hair-dark); padding: .75em .9em; display: flex; flex-direction: column; }
.wk-day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: .6em;
  border-bottom: 1.2pt solid #141410; padding-bottom: .4em; margin-bottom: .2em;
}
.wk-day-head b { font-family: var(--serif); font-size: 1.08em; font-weight: 700; }
.wk-day-head span { font-size: .74em; color: #85826f; }
.wk-day.wknd .wk-day-head b { color: var(--red); }
.bw .wk-day.wknd .wk-day-head b { color: #141410; font-style: italic; }
.wk-lines { flex: 1; }
.wk-summary { background: #f4f2e8; border-width: 1pt; }
.bw .wk-summary { background: none; border-style: double; border-width: 2.5pt; }

/* ---- планер на день ---- */
.day-body { flex: 1; display: grid; grid-template-columns: 1.12fr 1fr; gap: 2.2em; margin-bottom: 1.4em; }
.hour-row { display: flex; align-items: flex-end; gap: .8em; height: 2.35em; }
.hour { font-size: .74em; color: #85826f; width: 3.4em; flex: 0 0 auto; }
.hline { flex: 1; border-bottom: .6pt solid var(--hair-dark); height: 100%; }
.day-col { display: flex; flex-direction: column; gap: 1.5em; }
.day-box { border: .5pt solid var(--hair-dark); padding: .9em 1.1em; }
.top3 { list-style: none; counter-reset: t; }
.top3 li {
  counter-increment: t; border-bottom: .6pt solid #85826f;
  height: 2em; position: relative; padding-left: 1.6em;
}
.top3 li::before {
  content: counter(t); position: absolute; left: 0; bottom: .15em;
  font-family: var(--serif); font-style: italic; font-size: 1.15em; color: var(--red);
}
.bw .top3 li::before { color: #141410; }
.task-row { display: flex; gap: .7em; align-items: flex-end; height: 2em; }
.cb { width: .95em; height: .95em; border: .9pt solid #141410; flex: 0 0 auto; margin-bottom: .2em; }
.day-box.notes { flex: 1; display: flex; flex-direction: column; }
.notes-pat { flex: 1; min-height: 7em; }

/* ---- челлендж 100 дней ---- */
.c-miles { display: flex; gap: 2em; flex-wrap: wrap; font-size: .78em; color: #444; margin-bottom: 1em; }
.c100 {
  flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); grid-auto-rows: 1fr;
  border-left: .5pt solid var(--hair-dark); border-top: .5pt solid var(--hair-dark);
  margin-bottom: 1.4em; min-height: 150mm;
}
.sheet--a5 .c100 { min-height: 100mm; }
.c100 span {
  position: relative; border-right: .5pt solid var(--hair-dark);
  border-bottom: .5pt solid var(--hair-dark); min-height: 3.2em;
}
.c100 span i { position: absolute; top: .3em; left: .4em; font-style: normal; font-size: .62em; color: #a5a292; }
.c100 .ms { background: #f4f2e8; }
.c100 .ms i { color: var(--red); font-weight: 700; }
.bw .c100 .ms { background: none; }
.bw .c100 .ms i { color: #141410; text-decoration: underline; }

/* ============================================================
   Адаптив
   ============================================================ */
@media (max-width: 1020px) {
  .tool { grid-template-columns: 1fr; gap: 22px; }
  .panel { position: static; }
  /* ≥16px в полях — иначе iOS приближает страницу при фокусе */
  select, input[type='date'], input[type='text'] { font-size: 16px; padding: 11px 12px; }
}
@media (max-width: 640px) {
  .head-in { padding: 13px 16px; gap: 14px; }
  .nav { gap: 15px; width: 100%; }
  .hero { padding: 28px 16px 2px; }
  .kicker { margin-bottom: 14px; }
  h1 { overflow-wrap: break-word; }
  .lead { font-size: 15.5px; margin-top: 12px; }
  .tabs-wrap { padding: 18px 16px 0; }
  .tool-tabs button { padding: 12px 14px; font-size: 14px; flex: 1 1 auto; }
  .tool { padding: 18px 16px 40px; }
  .panel { padding: 20px 16px 18px; }
  .seg button { padding: 13px 4px; font-size: 14px; min-height: 44px; }
  .btn-primary { width: 100%; padding: 15px 24px; text-align: center; }
  .h-list li { padding: 10px 12px; }
  .h-del { font-size: 22px; padding: 10px 10px; margin: -10px -10px -10px 0; }
  .btn-add { flex-basis: 50px; }
  .check { font-size: 15px; }
  .check input { width: 18px; height: 18px; flex: 0 0 auto; }
  .result-bar { gap: 10px; margin-bottom: 12px; }
  .cards { padding: 0 16px 40px; }
  .seo, .faq { padding-left: 16px; padding-right: 16px; }
  .faq summary { padding-right: 30px; }
  .preview-scroll { padding: 12px; }
  .cpa { padding: 18px 16px; }
  .foot-note { margin-left: 0; }
}

/* ============================================================
   Печать: лист — единственное содержимое страницы
   ============================================================ */
@page { size: A4; margin: 10mm; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  main, .tool, .stage { display: block; padding: 0; margin: 0; max-width: none; }
  .preview-scroll { overflow: visible; background: none; border: 0; padding: 0; }
  #preview { display: block; width: auto; margin: 0; }
  .sheet {
    box-shadow: none; margin: 0;
    width: auto; min-height: 275mm;
    page-break-inside: avoid;
  }
  .sheet-pair { display: flex; gap: 5mm; }
  .sheet-pair .sheet { width: 49%; min-height: 191mm; }
  .sheet-pair .sheet:first-child { border-right: .4pt dashed #999; }
  .wk-grid, .c100 { min-height: 150mm; }
  .sheet--a5 .wk-grid, .sheet--a5 .c100 { min-height: 100mm; }
}
