:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #5c5854;
  --accent: #2d6a6a;
  --accent-soft: #e3f0ef;
  --border: #e0dcd4;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(28, 27, 25, 0.06);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  overflow-x: clip;
  touch-action: manipulation;
}

a {
  color: var(--accent);
}

.wrap {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem max(1rem, env(safe-area-inset-left)) 3rem max(1rem, env(safe-area-inset-right));
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}

header.site {
  margin-bottom: 2rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

h1 {
  font-size: clamp(1.35rem, 4vw, 1.65rem);
  font-weight: 650;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.1rem, 3.2vw, 1.2rem);
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.25rem 1.1rem 1.5rem;
}

.prose {
  color: var(--text);
}

.prose p {
  margin: 0 0 1rem;
}

.prose ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose .callout {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 0.85rem 1rem;
  margin: 1.25rem 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.35rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.45rem;
}

.form-group .hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafaf8;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.scale {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.scale label.opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-weight: 400;
  padding: 0.5rem 0.65rem;
  min-height: 2.75rem;
  min-width: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #fafaf8;
  -webkit-tap-highlight-color: transparent;
}

.scale input {
  width: auto;
}

.radio-list label.opt {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0;
  cursor: pointer;
  font-weight: 400;
  -webkit-tap-highlight-color: transparent;
}

.radio-list input {
  margin-top: 0.35rem;
}

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  min-height: 2.75rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

.theory-actions {
  margin-top: 1.25rem;
}

.thanks-actions {
  margin-top: 1.5rem;
}

.restart-hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.error {
  background: #fdeeed;
  border: 1px solid #e8c4c0;
  color: #6b2e28;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

footer.note {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.theory-hero {
  margin-bottom: 1.5rem;
}

.theory-hero h1 {
  font-size: clamp(1.25rem, 4.2vw, 1.45rem);
  line-height: 1.25;
}

/* Медиа в теории */
.media-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1.25rem 0;
}

.media-figure {
  margin: 0;
  padding: 0;
}

.media-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f0eeea;
}

.media-figure figcaption {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

.video-shell {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1a1a1a;
}

.video-shell video {
  display: block;
  width: 100%;
  max-height: min(70vh, 28rem);
  height: auto;
}

hr.soft {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

@media (min-width: 480px) {
  .card {
    padding: 1.5rem 1.5rem 1.75rem;
  }

  .media-row {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .media-figure--video {
    grid-column: 1 / -1;
  }
}

@media (min-width: 640px) {
  .wrap {
    padding: 2.5rem max(1.5rem, env(safe-area-inset-left)) 4rem max(1.5rem, env(safe-area-inset-right));
  }
}

@media (min-width: 768px) {
  .wrap {
    max-width: 44rem;
  }
}

@media (max-width: 479px) {
  .scale {
    gap: 0.4rem;
  }

  textarea {
    min-height: 5.5rem;
    font-size: 16px; /* меньше авто-зума iOS в полях */
  }

  input[type="text"],
  input[type="number"],
  select {
    font-size: 16px;
  }
}
