:root {
  --color-bg-page: #f6f5f7;
  --color-surface: #ffffff;
  --color-muted: #f2f3f5;
  --color-text-primary: #313d50;
  --color-text-secondary: #5f6c80;
  --color-brand-primary: #256bba;
  --color-brand-primary-hover: #1f5fa8;
  --color-brand-secondary: #f2f3f5;
  --color-border: #e3e6eb;
  --color-shadow-rgba: rgba(0, 0, 0, 0.1);
  --color-success: #91b196;
  --color-danger: #d66b63;
  --color-tab-bg: #f2f3f5;
  --color-tab-active-bg: #4f86c9;
  --color-tab-active-text: #ffffff;
  --color-link: #256bba;

  --font-primary: system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --fs-h1: 44px;
  --lh-h1: 54px;
  --fw-h1: 700;
  --ls-h1: -0.01em;

  --fs-h2: 28px;
  --lh-h2: 36px;
  --fw-h2: 700;
  --ls-h2: -0.005em;

  --fs-h3: 18px;
  --lh-h3: 26px;
  --fw-h3: 700;
  --ls-h3: 0;

  --fs-body: 16px;
  --lh-body: 26px;
  --fw-body: 400;

  --fs-small: 13px;
  --lh-small: 18px;
  --fw-small: 400;

  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.1);

  --border-width: 1px;
  --border-style: solid;

  --container-max: 1140px;
  --container-px: 24px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-body);
  color: var(--color-text-primary);
  background: var(--color-bg-page);
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--color-text-primary);
}

h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: var(--fw-h1);
  letter-spacing: var(--ls-h1);
}

h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: var(--fw-h2);
  letter-spacing: var(--ls-h2);
}

h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  font-weight: var(--fw-h3);
  letter-spacing: var(--ls-h3);
}

p,
ul,
ol {
  margin: 0;
}

a {
  color: var(--color-link);
}

.container {
  width: min(var(--container-max), calc(100% - (var(--container-px) * 2)));
  margin-inline: auto;
}

.section {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-xl);
}

.section-head {
  margin-bottom: var(--space-lg);
}

.section-head--center {
  text-align: center;
}

.section-head p {
  margin-top: var(--space-xs);
  color: var(--color-text-secondary);
}

.section--hero {
  background: linear-gradient(180deg, #f6f5f7 0%, #f2f3f5 100%);
  padding-top: 56px;
  padding-bottom: 44px;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 560px);
  gap: 40px;
  align-items: center;
}

.hero-content p {
  max-width: 62ch;
  color: var(--color-text-secondary);
}

.hero-content p + p {
  margin-top: var(--space-sm);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.btn {
  height: 44px;
  padding-inline: 18px;
  border-radius: var(--radius-sm);
  border: var(--border-width) var(--border-style);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: var(--color-brand-primary);
  color: #fff;
  border-color: var(--color-brand-primary);
  box-shadow: 0 2px 6px var(--color-shadow-rgba);
}

.btn--primary:hover {
  background: var(--color-brand-primary-hover);
  border-color: var(--color-brand-primary-hover);
}

.btn--secondary {
  background: #fff;
  color: var(--color-text-primary);
  border-color: #d9dde3;
}

.btn--secondary:hover {
  background: var(--color-brand-secondary);
}

.check-list {
  list-style: none;
  margin-top: var(--space-lg);
  padding: 0;
  display: grid;
  gap: 12px;
}

.check-list li {
  position: relative;
  padding-left: 34px;
}

.check-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--color-success);
  background: rgba(145, 177, 150, 0.18);
}

.hero-image-card {
  margin: 0;
  border-radius: var(--radius-lg);
  border: var(--border-width) var(--border-style) var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  background: var(--color-surface);
}

.hero-image {
  aspect-ratio: 16/9;
  border-radius: calc(var(--radius-lg) - 4px);
  background: linear-gradient(145deg, #eaf0f8, #f8fafc);
  border: var(--border-width) var(--border-style) #dfe5ef;
  padding: var(--space-md);
}

.hero-image__bar {
  height: 16px;
  border-radius: 999px;
  width: 48%;
  background: #d7e1f2;
}

.hero-image__line {
  margin-top: var(--space-sm);
  height: 10px;
  border-radius: 999px;
  width: 100%;
  background: #e2e8f3;
}

.hero-image__line--short {
  width: 72%;
}

.hero-image__grid {
  margin-top: var(--space-md);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

.hero-image__grid span {
  display: block;
  height: 64px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #f5f8fd, #e8eef7);
  border: var(--border-width) var(--border-style) #dfe5ef;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.tab {
  height: 30px;
  padding-inline: 14px;
  border-radius: var(--radius-sm);
  border: var(--border-width) var(--border-style) var(--color-border);
  background: var(--color-tab-bg);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  background: var(--color-tab-active-bg);
  color: var(--color-tab-active-text);
  border-color: var(--color-tab-active-bg);
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.card {
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: var(--space-md);
}

.card h3 {
  min-height: 52px;
}

#demoTitle {
  min-height: 0;
  font-size: 20px;
  line-height: 28px;
}

.demo-subtitle {
  margin-top: 4px;
  margin-bottom: 18px;
  color: var(--color-text-secondary);
  font-size: 15px;
  line-height: 23px;
}

.codecard {
  margin-top: 10px;
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  background: #fff;
  padding: 12px;
}

.codecard p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 20px;
}

.codecard__label {
  color: var(--color-text-primary);
}

.codecard--result {
  background: #fbfcff;
}

.caption {
  margin-top: 10px;
  color: var(--color-text-secondary);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}

.immersion-tabs {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.immersion-tab {
  min-width: 46px;
  height: 30px;
  padding-inline: var(--space-sm);
  border-radius: var(--radius-sm);
  border: var(--border-width) var(--border-style) var(--color-border);
  background: var(--color-tab-bg);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
}

.immersion-tab--active {
  background: var(--color-tab-active-bg);
  color: var(--color-tab-active-text);
  border-color: var(--color-tab-active-bg);
}

.immersion-tab:focus-visible {
  outline: 2px solid rgba(37, 107, 186, 0.25);
  outline-offset: 2px;
}

.immersion-range {
  margin-top: var(--space-sm);
}

.immersion-range label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.immersion-range input[type="range"] {
  width: 100%;
  accent-color: var(--color-brand-primary);
}

.stacked-cards {
  margin-top: var(--space-sm);
  display: grid;
  gap: 8px;
}

.stacked-cards p {
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 10px;
  box-shadow: var(--shadow-sm);
}

.script-panel {
  margin-top: var(--space-sm);
  display: grid;
  gap: 10px;
}

.target-panel {
  margin-top: var(--space-sm);
  display: grid;
  gap: 10px;
}

.gloss-panel {
  margin-top: var(--space-sm);
  display: grid;
  gap: 10px;
}

.gloss-level-range label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.gloss-level-range input[type="range"] {
  width: 100%;
  accent-color: var(--color-brand-primary);
}

.gloss-level-scale {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-secondary);
}

.gloss-level-scale span {
  text-align: center;
  white-space: nowrap;
}

.target-word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.target-word-row {
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: var(--border-width) var(--border-style) var(--color-border);
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 6px 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.target-word-check {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--color-brand-primary);
}

.target-word-ru {
  font-size: 14px;
  color: var(--color-text-primary);
}

.target-word-arrow {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.target-word-en {
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--color-text-primary);
  justify-self: end;
}

/* Guardrail: Script Blend panel must never appear in Mix/Target/Gloss */
#demo_examples:has([data-mode="mix"].is-active) #scriptAlphabetPanel,
#demo_examples:has([data-mode="target"].is-active) #scriptAlphabetPanel,
#demo_examples:has([data-mode="gloss"].is-active) #scriptAlphabetPanel {
  display: none !important;
}

/* In Script mode show alphabet panel and hide immersion helper */
#demo_examples:has([data-mode="script"].is-active) #scriptAlphabetPanel {
  display: grid;
}

#demo_examples:has([data-mode="script"].is-active) #immersionPanel {
  display: none;
}

#demo_examples:has([data-mode="target"].is-active) #immersionPanel {
  display: none;
}

#demo_examples:has([data-mode="gloss"].is-active) #immersionPanel {
  display: none;
}

#demo_examples:has([data-mode="mix"].is-active) #targetWordsPanel,
#demo_examples:has([data-mode="gloss"].is-active) #targetWordsPanel,
#demo_examples:has([data-mode="script"].is-active) #targetWordsPanel {
  display: none !important;
}

#demo_examples:has([data-mode="target"].is-active) #targetWordsPanel {
  display: grid;
}

#demo_examples:has([data-mode="mix"].is-active) #glossLevelPanel,
#demo_examples:has([data-mode="target"].is-active) #glossLevelPanel,
#demo_examples:has([data-mode="script"].is-active) #glossLevelPanel {
  display: none !important;
}

#demo_examples:has([data-mode="gloss"].is-active) #glossLevelPanel {
  display: grid;
}

.script-panel__hint {
  font-size: 14px;
  color: var(--color-text-secondary);
}

.script-panel__note {
  font-size: 13px;
  line-height: 18px;
  color: var(--color-text-secondary);
}

.script-lang-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.script-lang-btn {
  height: 30px;
  padding-inline: 12px;
  border-radius: var(--radius-sm);
  border: var(--border-width) var(--border-style) var(--color-border);
  background: var(--color-tab-bg);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.script-lang-btn.is-active {
  background: var(--color-tab-active-bg);
  color: #fff;
  border-color: var(--color-tab-active-bg);
}

.script-blend-range {
  margin-top: 4px;
}

.script-blend-range label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.script-blend-range input[type="range"] {
  width: 100%;
  accent-color: var(--color-brand-primary);
}

.script-pronunciation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.script-pronunciation__row {
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: var(--border-width) var(--border-style) var(--color-border);
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 6px 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.script-pronunciation__row.is-selected {
  border-color: #c7d7ee;
  background: #f7fbff;
}

.script-pronunciation__check {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--color-brand-primary);
}

.script-pronunciation__letter {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  color: var(--color-text-primary);
}

.script-pronunciation__sound {
  font-size: 13px;
  color: var(--color-text-secondary);
  justify-self: end;
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.step-card {
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--color-surface);
  padding: 14px;
  min-height: 64px;
}

.step-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  margin-bottom: 8px;
  color: #fff;
  background: var(--color-tab-active-bg);
  font-weight: 700;
  font-size: 14px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.mode-card {
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  background: var(--color-surface);
  padding: var(--space-md);
}

.mode-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  margin-bottom: 10px;
  color: #fff;
  background: var(--color-tab-active-bg);
  font-size: 12px;
  font-weight: 700;
}

.mode-card p {
  margin-top: 4px;
  color: var(--color-text-secondary);
}

.audience-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.audience-card {
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--color-surface);
  padding: var(--space-md);
}

.icon-list {
  list-style: none;
  margin-top: var(--space-md);
  padding: 0;
  display: grid;
  gap: 10px;
}

.icon-list li {
  position: relative;
  padding-left: 30px;
}

.icon-list li::before {
  position: absolute;
  left: 0;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.icon-list--good li::before {
  content: "✓";
  color: var(--color-success);
  background: rgba(145, 177, 150, 0.18);
}

.icon-list--bad li::before {
  content: "×";
  color: var(--color-danger);
  background: rgba(214, 107, 99, 0.16);
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-list details {
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 12px 14px;
}

.faq-list summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list p {
  margin-top: 8px;
  color: var(--color-text-secondary);
}

.reveal {
  opacity: 1;
  transform: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 1024px) {
  :root {
    --fs-h1: 38px;
    --lh-h1: 48px;
    --fs-h2: 24px;
    --lh-h2: 32px;
  }

  .hero-layout {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .demo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  :root {
    --container-px: 16px;
    --fs-h1: 32px;
    --lh-h1: 40px;
    --fs-h2: 22px;
    --lh-h2: 30px;
    --fs-h3: 17px;
    --lh-h3: 24px;
  }

  .section {
    padding-top: var(--space-lg);
    padding-bottom: var(--space-lg);
  }

  .demo-grid,
  .step-grid,
  .mode-grid,
  .audience-grid {
    grid-template-columns: 1fr;
  }

  .script-pronunciation {
    grid-template-columns: 1fr;
  }

  .target-word-grid {
    grid-template-columns: 1fr;
  }

  .card h3 {
    min-height: 0;
  }

  #demoTitle {
    font-size: 19px;
    line-height: 27px;
  }

  .demo-subtitle {
    margin-top: 3px;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 21px;
  }
}

@media (max-width: 480px) {
  :root {
    --container-px: 14px;
    --fs-body: 15px;
    --lh-body: 24px;
    --fs-h1: 28px;
    --lh-h1: 36px;
    --fs-h2: 20px;
    --lh-h2: 28px;
  }

  .btn {
    width: 100%;
  }

  .cta-row {
    display: grid;
  }

  .script-pronunciation {
    grid-template-columns: 1fr;
  }
}
