/* textbook-art — стили сайта. Mobile-first, системные шрифты, без внешних ресурсов (SPEC §9.8). */

:root {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --surface-2: #f1ece2;
  --ink: #1c2230;
  --muted: #5a6273;
  --line: #e2dbcd;
  --brand: #1f5f5b;
  --brand-2: #174744;
  --brand-ink: #ffffff;
  --accent: #d9682f;
  --accent-soft: #fbe6d8;
  /* контраст WCAG AA (≥ 4.5:1): фон кнопок «Оплатить/Пополнить» и текст на accent-soft */
  --accent-strong: #b4521f;
  --accent-on: #ffffff;
  --accent-text: #a4481a;
  --ok: #2c6e3f;
  --ok-soft: #e1f1e3;
  --warn: #8a5a00;
  --warn-soft: #fff1d6;
  --danger: #a3261d;
  --danger-soft: #fbe3e0;
  --focus: #2f7cf6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28, 34, 48, 0.06), 0 6px 18px rgba(28, 34, 48, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
    sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --surface: #1c2028;
    --surface-2: #232834;
    --ink: #ecebe6;
    --muted: #a7adba;
    --line: #313847;
    --brand: #4fb3a9;
    --brand-2: #6cc7bd;
    --brand-ink: #0f1a19;
    --accent: #f08a54;
    --accent-soft: #3a2a20;
    --accent-strong: #f08a54;
    --accent-on: #1a1209;
    --accent-text: #f08a54;
    --ok: #7fd295;
    --ok-soft: #1f3324;
    --warn: #f3c46b;
    --warn-soft: #362d17;
    --danger: #ff8f84;
    --danger-soft: #3a2020;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--brand);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--brand-2);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.6rem, 4vw + 0.8rem, 2.6rem);
}

h2 {
  font-size: clamp(1.25rem, 2vw + 0.8rem, 1.7rem);
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 0.9em;
}

code,
kbd {
  font-family: var(--mono);
}

[hidden] {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.narrow {
  max-width: 640px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  padding: 8px 12px;
  z-index: 10;
}

.skip-link:focus {
  left: 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9rem;
}

.stack > * + * {
  margin-top: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.spread {
  justify-content: space-between;
}

/* ---------- шапка ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

@media (min-width: 720px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 5;
  }
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: inline-block;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}

.nav a,
.nav button.linkish {
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.95rem;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--surface-2);
}

.account-chip {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.tg-badge {
  display: inline-block;
  font-size: 0.75rem;
  background: #1b78b0; /* цвет Telegram, затемнённый до 4.8:1 с белым */
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 4px;
  font-family: var(--font);
}

.lang-switch {
  display: inline-flex;
  gap: 2px;
  font-size: 0.85rem;
}

.lang-switch a {
  padding: 4px 6px;
}

.lang-switch a[aria-current="true"] {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}

main {
  flex: 1;
  padding: 24px 0 48px;
}

/* ---------- карточки и секции ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 16px;
}

.card h2:first-child,
.card h3:first-child {
  margin-top: 0;
}

.section {
  margin-top: 40px;
}

.grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 720px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- кнопки и формы ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.btn-primary:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: var(--brand-ink);
}

.btn-accent {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-on);
}

.btn-accent:hover {
  filter: brightness(0.95);
  background: var(--accent-strong);
  color: var(--accent-on);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

button.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
}

form.inline {
  display: inline;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.field {
  margin-bottom: 16px;
}

.hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 6px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 96px;
}

input.number-input {
  font-family: var(--mono);
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400;
  cursor: pointer;
}

.check input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--brand);
}

/* ---------- сообщения ---------- */
.notice {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.notice-ok {
  background: var(--ok-soft);
  border-color: var(--ok);
}

.notice-warn {
  background: var(--warn-soft);
  border-color: var(--warn);
}

.notice-error {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.draft-banner {
  background: var(--warn-soft);
  border-bottom: 1px solid var(--warn);
  color: var(--ink);
  text-align: center;
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* ---------- лендинг ---------- */
.hero {
  padding: 24px 0 8px;
}

.hero .lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 46ch;
}

.hero-grid {
  display: grid;
  gap: 24px;
}

@media (min-width: 880px) {
  .hero-grid {
    grid-template-columns: 1.2fr 1fr;
    align-items: center;
  }
}

.hero-art {
  aspect-ratio: 4 / 3;
  border-radius: 20px;
  background: radial-gradient(circle at 25% 30%, var(--accent-soft) 0 22%, transparent 23%),
    radial-gradient(circle at 75% 65%, color-mix(in srgb, var(--brand) 25%, transparent) 0 26%, transparent 27%),
    linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  text-align: center;
  padding: 24px;
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
}

@media (min-width: 720px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

.steps li {
  counter-increment: step;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
  margin-bottom: 10px;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.style-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.style-card .thumb {
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.style-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.style-card .body {
  padding: 10px 12px 12px;
  font-size: 0.9rem;
}

.style-card .body strong {
  display: block;
  font-size: 0.98rem;
}

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
}

/* ---------- цены и таблицы ---------- */
.price-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.price-card .amount {
  font-size: 1.6rem;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

td.num,
th.num {
  text-align: right;
  white-space: nowrap;
}

/* ---------- кабинет ---------- */
.balance-big {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
}

.kv {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 8px 0 0;
}

.kv div {
  min-width: 120px;
}

.kv dt {
  font-size: 0.82rem;
  color: var(--muted);
}

.kv dd {
  margin: 0;
  font-weight: 700;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.list li:last-child {
  border-bottom: 0;
}

.chip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-busy {
  background: var(--accent-soft);
  color: var(--accent-text);
}

progress {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  appearance: none;
  border: 0;
  background: var(--surface-2);
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--brand);
}

progress::-moz-progress-bar {
  background: var(--brand);
}

/* ---------- номер аккаунта ---------- */
.account-number {
  font-family: var(--mono);
  font-size: clamp(1.4rem, 6vw, 2.3rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  user-select: all;
  -webkit-user-select: all;
  word-break: keep-all;
  white-space: nowrap;
  overflow-x: auto;
}

.big-warning {
  border-left: 6px solid var(--accent);
  background: var(--accent-soft);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
}

.code-box {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

/* ---------- документ: главы, стили, смета ---------- */
.chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chapter-list > li {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.chapter-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chapter-row .title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.chapter-row .meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.1rem;
  flex: none;
}

.toggle[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.excluded .title {
  color: var(--muted);
  text-decoration: line-through;
}

details.menu > summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
  color: var(--brand);
  padding: 8px 0;
}

details.menu > summary::-webkit-details-marker {
  display: none;
}

details.menu .menu-body {
  display: grid;
  gap: 10px;
  padding: 10px;
  margin-top: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.choice {
  position: relative;
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.choice > span {
  display: block;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  height: 100%;
  font-weight: 400;
}

.choice strong {
  display: block;
}

.choice .desc {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

@media (max-width: 599px) {
  .card {
    padding: 16px;
  }
  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .choice .desc:not(.keep) {
    display: none;
  }
}

.choice input:checked + span {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--surface));
}

.choice input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 18px;
}

legend {
  font-weight: 700;
  margin-bottom: 8px;
  padding: 0;
}

.estimate {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 12px 0 16px;
}

.estimate .cell {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.estimate .cell .label {
  font-size: 0.82rem;
  color: var(--muted);
}

.estimate .cell .value {
  font-size: 1.5rem;
  font-weight: 800;
}

.estimate .cell.max {
  border: 2px solid var(--brand);
}

@media (max-width: 599px) {
  .estimate {
    grid-template-columns: 1fr;
  }
  .estimate .cell {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
  }
  .estimate .cell .value {
    font-size: 1.25rem;
    text-align: right;
  }
}

/* ---------- галерея ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.gallery figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.gallery figcaption {
  padding: 10px 12px;
  font-size: 0.9rem;
}

.upload-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.upload-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 0.9rem;
}

.upload-list li progress {
  flex: 1;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  background: var(--surface);
}

/* ---------- подвал и баннер cookie ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 28px 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 20;
  font-size: 0.9rem;
}

.legal-doc {
  max-width: 760px;
}

.legal-doc h2 {
  margin-top: 1.6em;
}

.legal-doc li {
  margin-bottom: 0.4em;
}

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

@media print {
  .site-header,
  .site-footer,
  .cookie-banner,
  .btn {
    display: none !important;
  }
}

/* ---------- бесплатные главы (§4.10) ---------- */
.free-line {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 600;
  font-size: 0.92rem;
}

.free-promo {
  display: inline-block;
  margin: 12px 0 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
