/*=============================================================================
  LEarn2arn — main stylesheet
   Themes: windows (light) | macos (purple-led #9933CC / secondary #3366cc) | linux (#213342 / #182742 + green)
   Primary buttons (.btn-primary / --btn-primary-*):
     windows → #2142ff | macos → Linux green #3fb950 | linux → macOS purple #9933CC
   Layout utilities (Step 1+): .layout-vertical-stack | .layout-inline-wrap | .layout-row-or-column
   Page shell (Step 2): .site-shell uses grid rows — header | breadcrumb | main | footer
   Content column (Step 3): .hero-inner shares width/padding with .section-inner
   Home hero (Step 4): index.html uses .section-inner + .layout-vertical-stack on .hero-inner
   Tool + register pages (Step 5): .section-inner / card shells use .layout-vertical-stack
   Tool panels (Step 6): .tool-panel + modifiers; @container rules in tool CSS
   One source of truth: .tool-card, .field, .field-input, .form-hint, .action-row, .tool-mode-tab in main.css
  ============================================================================= */

@layer reset, tokens, themes, layout, components, utilities;

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

:root {
  --font-display: "Sora", "Segoe UI", sans-serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 6.375rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.25rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4.5rem;
  --max-w: 81rem;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ----- Windows: light ----- */
[data-theme="windows"] {
  --bg: #f4f7f6;
  --bg-elevated: #ffffff;
  --bg-muted: #e8efed;
  --surface: #ffffff;
  --orange: #ffbb00;
  --highlight-bg: #ffe8cc;
  --highlight-fg: #7a3e00;
  --highlight-border: #ffc285;
  --text: #14201e;
  --text-secondary: #3d524d;
  --text-muted: #6b7f79;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d8f3ef;
  --accent-contrast: #ffffff;
  --btn-primary-bg: #2142ff;
  --btn-primary-bg-hover: #1835cc;
  --btn-primary-fg: #ffffff;
  --border: #d5e0dc;
  --border-strong: #b7c9c3;
  --header-bg: rgba(255, 255, 255, 0.86);
  --hero-glow-a: #9fd8cf;
  --hero-glow-b: #f0e6c8;
  --hero-glow-c: #c5ddd8;
  --shadow: 0 12px 40px rgba(20, 32, 30, 0.08);
  --pattern: rgba(15, 118, 110, 0.05);
  color-scheme: light;
}

/* ----- macOS: purple-led (#9933CC) with secondary blue (#3366cc) ----- */
[data-theme="macos"] {
  --macos-blue: #3366cc;
  --macos-purple: #9933cc;
  --macos-blue-rgb: 51, 102, 204;
  --macos-purple-rgb: 153, 51, 204;
  --bg: #1a0a2e;
  --bg-elevated: #3d1560;
  --bg-muted: #280c40;
  --surface: #341052;
  --orange: #ffbb00;
  --highlight-bg: #5c4528;
  --highlight-fg: #ffe8b0;
  --highlight-border: #a67c2a;
  --text: #f7eefc;
  --text-secondary: #e0c2f2;
  --text-muted: #c49adb;
  --accent: var(--macos-purple);
  --accent-strong: #7a29a3;
  --accent-soft: #4a1868;
  --accent-contrast: #ffffff;
  --btn-primary-bg: #3fb950;
  --btn-primary-bg-hover: #2ea043;
  --btn-primary-fg: #0d1117;
  --border: #5a3080;
  --border-strong: #8040a8;
  --header-bg: #280c40;
  --hero-glow-a: rgba(var(--macos-purple-rgb), 0.78);
  --hero-glow-b: rgba(var(--macos-blue-rgb), 0.22);
  --hero-glow-c: #2a0d45;
  --shadow: 0 18px 50px rgba(26, 10, 46, 0.55), 0 0 0 1px rgba(var(--macos-purple-rgb), 0.16);
  --pattern: rgba(var(--macos-purple-rgb), 0.1);
  color-scheme: dark;
}

[data-theme="macos"] body {
  background-color: #1a0a2e;
  background-image:
    radial-gradient(ellipse 72% 56% at 44% 46%, rgba(var(--macos-purple-rgb), 0.72), transparent 64%),
    radial-gradient(ellipse 48% 40% at 68% 34%, rgba(var(--macos-blue-rgb), 0.2), transparent 55%),
    radial-gradient(ellipse 90% 70% at 50% 100%, rgba(42, 13, 69, 0.95), transparent 72%),
    linear-gradient(160deg, #140824 0%, #2a0d45 34%, #4d1a6b 66%, #1a0a2e 100%);
}

[data-theme="macos"] .site-header {
  background: var(--header-bg);
  border-bottom-color: var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

[data-theme="macos"] .theme-switcher {
  background: var(--bg-muted);
  border-color: var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="macos"] .theme-btn.is-active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 4px 14px rgba(26, 10, 46, 0.4);
}

[data-theme="macos"] .nav-submenu,
[data-theme="macos"] .menu-toggle,
[data-theme="macos"] .site-footer {
  background: linear-gradient(160deg, var(--bg-elevated), var(--bg-muted));
  border-color: var(--border);
}

[data-theme="macos"] .section-about-us {
  background: radial-gradient(ellipse 55% 70% at 50% 100%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 72%);
}

[data-theme="macos"] .btn-ghost {
  background: color-mix(in srgb, var(--surface) 88%, var(--bg-muted));
  border-color: color-mix(in srgb, var(--macos-blue) 55%, var(--border));
}

[data-theme="macos"] .btn-ghost:hover {
  background: var(--accent-soft);
  border-color: var(--macos-purple);
}

[data-theme="macos"] .nav-link.is-active,
[data-theme="macos"] .nav-submenu-link.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

[data-theme="macos"] .site-shell.is-nav-open .site-nav {
  background: var(--header-bg);
  border-bottom-color: var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

[data-theme="macos"] ::selection {
  background: rgba(var(--macos-purple-rgb), 0.5);
  color: #ffffff;
}

/* ----- Linux: #213342 / #182742 slate mix, green accents preserved ----- */
[data-theme="linux"] {
  --linux-slate: #213342;
  --linux-navy: #182742;
  --linux-slate-rgb: 33, 51, 66;
  --linux-navy-rgb: 24, 39, 66;
  --bg: var(--linux-navy);
  --bg-elevated: var(--linux-slate);
  --bg-muted: #1c2d3c;
  --surface: #1e3140;
  --orange: #ffbb00;
  --highlight-bg: rgba(255, 187, 0, 0.2);
  --highlight-fg: #ffe8b0;
  --highlight-border: rgba(255, 187, 0, 0.38);
  --text: #e8eef3;
  --text-secondary: #b7c5d0;
  --text-muted: #8a9bab;
  --accent: #3fb950;
  --accent-strong: #2ea043;
  --accent-soft: rgba(63, 185, 80, 0.16);
  --accent-contrast: #0d1117;
  --btn-primary-bg: #9933cc;
  --btn-primary-bg-hover: #7a29a3;
  --btn-primary-fg: #ffffff;
  --border: rgba(120, 150, 175, 0.28);
  --border-strong: rgba(120, 150, 175, 0.42);
  --header-bg: rgba(var(--linux-navy-rgb), 0.92);
  --hero-glow-a: rgba(var(--linux-slate-rgb), 0.95);
  --hero-glow-b: rgba(63, 185, 80, 0.18);
  --hero-glow-c: var(--linux-slate);
  --shadow: 0 16px 48px rgba(10, 16, 28, 0.5);
  --pattern: rgba(var(--linux-slate-rgb), 0.35);
  color-scheme: dark;
}

[data-theme="linux"] body {
  background-color: var(--linux-navy);
  background-image:
    radial-gradient(ellipse 70% 50% at 12% -8%, rgba(var(--linux-slate-rgb), 0.95), transparent 55%),
    radial-gradient(ellipse 55% 42% at 88% 0%, rgba(var(--linux-navy-rgb), 0.9), transparent 52%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(var(--linux-slate-rgb), 0.55), transparent 70%),
    linear-gradient(165deg, var(--linux-navy) 0%, #1a2c3c 42%, var(--linux-slate) 72%, var(--linux-navy) 100%);
}

[data-theme="linux"] .site-header {
  background: var(--header-bg);
  border-bottom-color: var(--border);
}

[data-theme="linux"] .theme-switcher {
  background: rgba(var(--linux-slate-rgb), 0.65);
  border-color: var(--border);
}

[data-theme="linux"] .theme-btn.is-active {
  background: var(--linux-slate);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(10, 16, 28, 0.35);
}

[data-theme="linux"] .nav-submenu,
[data-theme="linux"] .menu-toggle,
[data-theme="linux"] .site-footer {
  background: linear-gradient(160deg, var(--linux-slate), var(--linux-navy));
  border-color: var(--border);
}

[data-theme="linux"] .section-about-us {
  background: radial-gradient(ellipse 50% 80% at 50% 100%, rgba(63, 185, 80, 0.12), transparent 70%);
}

[data-theme="linux"] .site-shell.is-nav-open .site-nav {
  background: rgba(var(--linux-navy-rgb), 0.96);
  border-bottom-color: var(--border);
}

[data-theme="linux"] ::selection {
  background: rgba(63, 185, 80, 0.35);
  color: #ffffff;
}

html {
  scroll-behavior: smooth;
  min-height: 100%;
  background-color: var(--bg);
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, var(--hero-glow-a), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, var(--hero-glow-b), transparent 50%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 92%, var(--hero-glow-c)) 0%, var(--bg) 42%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  background-position: center top;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

/* Avoid iOS / small-screen fixed-bg glitches; still no tiling on long pages */
@media (max-width: 900px) {
  body {
    background-attachment: scroll;
    background-size: 100% 100%;
  }
}

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

a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Progressive emphasis: weight + size step up together */
.strong,
.stronger,
.strongest {
  display: inline-block;
  font-family: var(--font-display);
  line-height: 1.25;
}

.strong {
  font-weight: 700;
  font-size: 1.2em;
}

.stronger {
  font-weight: 800;
  font-size: 1.5em;
}

.strongest {
  font-weight: 900;
  font-size: 1.8em;
}

/* Alignment utilities — usable on headings, paragraphs, divs, etc. */
.centered {
  text-align: center;
  justify-content: center;
}

.justified {
  text-align: justify;
  text-justify: inter-word;
  justify-content: space-between;
}

/* Hide any element from display */
.hidden {
  display: none !important;
}

/* Inline text highlight — use on span/em/strong or wrap phrases inside p, h1–h6, etc. */
.highlight {
  display: inline;
  padding: 0.1em 0.3em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--highlight-border);
  background: var(--highlight-bg);
  color: var(--highlight-fg);
  font-weight: inherit;
  font-style: inherit;
  line-height: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.highlight *,
p .highlight,
h1 .highlight,
h2 .highlight,
h3 .highlight,
h4 .highlight,
h5 .highlight,
h6 .highlight,
span.highlight,
em.highlight,
strong.highlight,
mark.highlight {
  color: inherit;
}

/* Site-wide callouts: reminder (info), warning, high-alert */
.friendly-reminder,
.friendly-warning,
.high-alert {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  border-left-width: 0.35rem;
  font-weight: 500;
  font-size: 0.98rem;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

.friendly-reminder {
  border-color: #8fd49a;
  border-left-color: #2f9e44;
  background: linear-gradient(135deg, #e8f8ec 0%, #d4f0db 100%);
  color: #14532d;
}

.friendly-warning {
  border-color: #f0b4b4;
  border-left-color: #d94848;
  background: linear-gradient(135deg, #fff1f1 0%, #ffd6d6 100%);
  color: #7f1d1d;
}

.high-alert {
  border-color: #e03131;
  border-left-color: #c92a2a;
  background: linear-gradient(135deg, #ffe3e3 0%, #ffc9c9 100%);
  color: #5c0000;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(201, 42, 42, 0.22);
}

[data-theme="macos"] .friendly-reminder {
  border-color: rgba(63, 185, 80, 0.55);
  border-left-color: #3fb950;
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.28) 0%, rgba(63, 185, 80, 0.14) 100%);
  color: #d8ffe0;
}

[data-theme="macos"] .friendly-warning {
  border-color: rgba(255, 120, 120, 0.55);
  border-left-color: #ff6b6b;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.28) 0%, rgba(255, 107, 107, 0.14) 100%);
  color: #ffe0e0;
}

[data-theme="macos"] .high-alert {
  border-color: #ff6b6b;
  border-left-color: #fa5252;
  background: linear-gradient(135deg, rgba(250, 82, 82, 0.4) 0%, rgba(250, 82, 82, 0.2) 100%);
  color: #fff0f0;
}

[data-theme="linux"] .friendly-reminder {
  border-color: rgba(63, 185, 80, 0.55);
  border-left-color: #3fb950;
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.24) 0%, rgba(63, 185, 80, 0.12) 100%);
  color: #d8ffe0;
}

[data-theme="linux"] .friendly-warning {
  border-color: rgba(255, 120, 120, 0.5);
  border-left-color: #ff8787;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.24) 0%, rgba(255, 107, 107, 0.12) 100%);
  color: #ffe0e0;
}

[data-theme="linux"] .high-alert {
  border-color: #ff6b6b;
  border-left-color: #fa5252;
  background: linear-gradient(135deg, rgba(250, 82, 82, 0.35) 0%, rgba(250, 82, 82, 0.18) 100%);
  color: #fff0f0;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -4rem;
  z-index: 1000;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: var(--space-2);
}

/* Page shell: header | breadcrumb (when present) | main | footer */
.site-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  max-width: 100%;
  overflow-x: clip;
}

.site-main {
  grid-row: 3;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ----- Header ----- */
.site-header {
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.header-inner {
  max-width: var(--max-w);
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: 2.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 1.125rem;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 3.75rem;
  height: 3.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #0000fe;
}

.brand-mark__logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}

.site-header .brand-name {
  font-size: 1.575rem;
}

.brand-full {
  font-size: 0.63rem;
  color: var(--text-muted);
  font-weight: 500;
}

.site-header .brand-full {
  font-size: 0.972rem;
}

/* ----- Breadcrumb (injected by site-chrome.js) ----- */
.site-breadcrumb {
  grid-row: 2;
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0;
  /*border-left: 0.28rem solid var(--btn-primary-bg); */

}

/* Theme-contrasting strip — readable at a glance */
[data-theme="windows"] .site-breadcrumb {
  background: linear-gradient(90deg, #dce4ff 0%, #e8eeff 55%, #f0f3ff 100%);
  border-bottom-color: color-mix(in srgb, #2142ff 28%, var(--border));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

[data-theme="macos"] .site-breadcrumb {
  background: linear-gradient(90deg, var(--bg-muted) 0%, var(--surface) 55%, var(--bg-elevated) 100%);
  border-bottom-color: var(--border-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="linux"] .site-breadcrumb {
  background: linear-gradient(
    90deg,
    rgba(63, 185, 80, 0.14) 0%,
    #243848 50%,
    #1c2f42 100%
  );
  border-bottom-color: rgba(63, 185, 80, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.site-breadcrumb-inner {
  padding-top: 0;
  padding-bottom: 0;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.35;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.breadcrumb-sep {
  display: inline-flex;
  align-items: center;
  padding: 0 0.35rem;
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}

.breadcrumb-emoji {
  margin-right: 0.28rem;
  font-size: 0.95em;
  line-height: 1;
}

.breadcrumb-link,
.breadcrumb-parent,
.breadcrumb-current {
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: 100%;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.25rem;
}

.breadcrumb-link:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 65%, transparent);
}

.breadcrumb-parent {
  color: var(--text-secondary);
  cursor: default;
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 700;
}

.breadcrumb-link span,
.breadcrumb-parent span,
.breadcrumb-current span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .site-breadcrumb {
    padding: 0.55rem 0;
  }

  .breadcrumb-list {
    font-size: 0.82rem;
    justify-content: center;
  }
}

.site-nav {
  display: none;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.275rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 1.425rem;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.875rem;
  font-size: 1.5rem;
  line-height: 1;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.525rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.nav-caret {
  width: 0.6rem;
  height: 0.6rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.2s var(--ease);
  opacity: 0.75;
}

.nav-dropdown.is-open .nav-caret {
  transform: rotate(225deg) translateY(-1px);
}

.nav-submenu {
  list-style: none;
  margin: 0;
  padding: 0.6rem;
  min-width: 18.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.nav-submenu[hidden] {
  display: none !important;
}

.nav-submenu-link {
  display: flex;
  align-items: center;
  gap: 0.675rem;
  padding: 0.825rem 1.125rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 1.38rem;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.nav-submenu-link:hover,
.nav-submenu-link.is-active {
  color: var(--text);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
}

/* Mobile-only theme block inside burger nav (shown in max-width query) */
.nav-theme {
  display: none;
}

.theme-switcher {
  display: inline-flex;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  gap: 0.2rem;
  flex-shrink: 0;
}

.theme-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0.35rem;
  border-radius: calc(var(--radius-md) - 0.15rem);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.theme-btn__icon {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
  object-fit: contain;
  opacity: 0.62;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.theme-btn[data-theme="linux"] .theme-btn__icon {
  width: 1.5rem;
  height: 1.5rem;
}

.theme-btn:hover {
  color: var(--text);
}

.theme-btn:hover .theme-btn__icon {
  opacity: 0.9;
  transform: scale(1.06);
}

.theme-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.theme-btn.is-active .theme-btn__icon {
  opacity: 1;
  transform: scale(1.08);
}

.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.42rem;
  width: 3.75rem;
  height: 3.75rem;
  padding: 0.825rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.menu-toggle-bar {
  display: block;
  height: 3px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}

.site-shell.is-nav-open .menu-toggle-bar:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.site-shell.is-nav-open .menu-toggle-bar:nth-child(2) {
  opacity: 0;
}

.site-shell.is-nav-open .menu-toggle-bar:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

/* ----- Shared tool pages ----- */
.tool-page {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  padding: var(--space-5) 0 var(--space-6);
  overflow-x: clip;
  box-sizing: border-box;
  min-height: 100%;
}

.tool-kicker {
  display: inline-block;
  margin-bottom: var(--space-1);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4vw, 2.75rem);
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.tool-hero.layout-vertical-stack h1 {
  margin-bottom: 0;
}

.tool-lead {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* ----- Shared tool panel + form primitives (one source of truth) ----- */
.tool-panel {
  container-type: inline-size;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.tool-panel--stack {
  display: grid;
  gap: var(--space-3);
}

.tool-panel--probability-calculator {
  container-name: probability-calculator;
}

.tool-panel--bip39 {
  container-name: bip39;
}

.tool-panel--seed-generator {
  container-name: seed-generator;
}

.tool-panel--random-selection {
  container-name: random-selection;
}

.tool-panel--other-utilities {
  container-name: other-utilities;
}

.tool-card {
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow-x: auto;
}

[data-theme="macos"] .tool-card {
  background: var(--surface);
}

[data-theme="linux"] .tool-card {
  background: linear-gradient(160deg, #213342, #182742);
}

.field,
.field-row {
  display: grid;
  gap: 0.4rem;
  margin-bottom: var(--space-2);
}

.field label,
.field-row label,
.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.card-title {
  font-size: 1.2rem;
  margin: 0;
}

.form-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-2);
  line-height: 1.45;
}

.field-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}

.field-input::placeholder {
  color: var(--text-muted);
}

.field-input:focus {
  outline: none;
  border-color: var(--btn-primary-bg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-primary-bg) 35%, transparent);
}

textarea.field-input {
  resize: vertical;
  line-height: 1.45;
}

.action-row,
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.hero-actions {
  justify-content: center;
}

/* Tool mode switcher (tab pills) — e.g. Probability Calculator modes */
.tool-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
}

.tool-mode-tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition:
    background-color 0.2s var(--ease),
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.tool-mode-tab:hover {
  background: color-mix(in srgb, var(--accent-soft) 65%, var(--bg-muted));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--text);
}

.tool-mode-tab.is-active {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--btn-primary-bg) 28%, transparent);
}

.tool-mode-tab.is-active:hover {
  background: var(--btn-primary-bg-hover);
  border-color: var(--btn-primary-bg-hover);
  color: var(--btn-primary-fg);
}

/* ----- Main / Hero ----- */
.site-shell:has(.site-main--reader) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.site-shell:has(.site-main--reader) .site-footer {
  display: none;
}

.site-main--reader {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 0;
  overflow: hidden;
}

.site-main--reader .ebook-reader {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.hero {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - var(--header-h));
  display: grid;
  align-items: center;
  overflow: hidden;
}

.hero-atmosphere {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, transparent 55%, var(--bg) 100%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 22px,
      var(--pattern) 22px,
      var(--pattern) 23px
    );
  pointer-events: none;
}

/* Shared content column — hero + sections (+ breadcrumb via .section-inner) */
.section-inner,
.hero-inner {
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding-inline: var(--space-3);
  box-sizing: border-box;
  min-width: 0;
}

.hero-inner {
  padding-block: var(--space-6);
  animation: hero-rise 0.9s var(--ease) both;
}

/* Stack gap replaces per-block margins when home hero uses .layout-vertical-stack */
.hero-inner.layout-vertical-stack > .section-kicker,
.hero-inner.layout-vertical-stack > .hero-brand,
.hero-inner.layout-vertical-stack > .hero-tagline,
.hero-inner.layout-vertical-stack > .hero-support {
  margin-bottom: 0;
}

.hero .section-kicker {
  display: inline-block;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  animation: fade-up 0.7s var(--ease) 0.1s both;
}

.hero-brand {
  font-family: var(--font-display);
  /* 60% of previous clamp(1.08rem, 5.4vw, 3.9rem) — further −40% */
  font-size: clamp(0.65rem, 3.24vw, 2.34rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.055em;
  margin-bottom: var(--space-2);
  animation: fade-up 0.8s var(--ease) 0.18s both;
}

.hero-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  animation: fade-up 0.8s var(--ease) 0.28s both;
}

.hero-support {
  color: var(--text-secondary);
  font-size: 1.4rem;
  margin-bottom: var(--space-4);
  animation: fade-up 0.8s var(--ease) 0.36s both;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  animation: fade-up 0.8s var(--ease) 0.44s both;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

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

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: transparent;
}

.btn-primary:hover {
  background: var(--btn-primary-bg-hover);
  color: var(--btn-primary-fg);
}

.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

.btn-primary:disabled:not(.is-loading),
.btn-primary[disabled]:not(.is-loading) {
  background: color-mix(in srgb, var(--btn-primary-bg) 32%, var(--bg-muted));
  color: color-mix(in srgb, var(--btn-primary-fg) 60%, var(--text-muted));
  opacity: 0.62;
  box-shadow: none;
}

.btn-primary:disabled:not(.is-loading):hover,
.btn-primary[disabled]:not(.is-loading):hover {
  background: color-mix(in srgb, var(--btn-primary-bg) 32%, var(--bg-muted));
  transform: none;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ----- Sections ----- */
.section {
  padding: var(--space-6) 0;
  border-top: 1px solid var(--border);
}

/* Fill #main-content height; center contents when shorter than the viewport */
.site-main > .section {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  min-height: 100%;
}

.site-main > .section > .section-inner {
  width: 100%;
  margin-block: auto;
}

.section-inner--center {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
}

.section-head {
  max-width: 36rem;
  margin-bottom: var(--space-4);
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: var(--space-2);
}

.section-lead {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.section-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.placeholder-card-list {
  list-style: none;
  width: min(100%, 28rem);
  display: grid;
  gap: 0.65rem;
  margin: 0.5rem 0 0;
  padding: 0;
  text-align: left;
}

.placeholder-card-list li {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.placeholder-page-actions {
  margin-top: 1.25rem;
}

/* ----- Footer ----- */
.site-footer {
  grid-row: 4;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: var(--space-4) 0;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.footer-copy {
  display: inline-block;
  line-height: 1.45;
}

.footer-tag {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 400;
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.55rem;
  margin-top: 0.27rem;
}

.footer-legal__link {
  color: var(--text-muted);
  font-size: 0.54rem;
  font-weight: 700;
  text-decoration: none;
  transition: color var(--transition-fast, 160ms ease);
}

.footer-legal__link:hover,
.footer-legal__link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.footer-legal__sep {
  color: var(--text-muted);
  font-size: 0.83rem;
  opacity: 0.7;
}

/* ----- Legal / policy document pages ----- */
.legal-doc {
  max-width: min(100%, 46rem);
  margin-inline: auto;
  text-align: left;
}

.legal-doc .section-lead {
  margin-bottom: var(--space-3);
}

.legal-doc__meta {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.legal-doc h3 {
  margin: var(--space-3) 0 var(--space-1);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.legal-doc p,
.legal-doc li {
  color: var(--text-secondary);
  line-height: 1.55;
}

.legal-doc p {
  margin: 0 0 var(--space-2);
}

.legal-doc ul {
  margin: 0 0 var(--space-2);
  padding-left: 1.25rem;
}

.legal-doc li {
  margin-bottom: 0.35rem;
}

/* ----- Motion ----- */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hero-rise {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----- Responsive ----- */
@media (min-width: 768px) {
  .site-nav {
    display: flex;
  }

  .menu-toggle {
    display: none;
  }

  .header-actions {
    margin-left: 0;
  }

  .theme-switcher--nav,
  .nav-theme {
    display: none !important;
  }

  .nav-submenu {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    z-index: 120;
  }
}

@media (max-width: 767px) {
  .section-inner,
  .hero-inner {
    padding-inline: var(--space-2);
  }

  /* Site-wide: all .btn are 80% of their parent on small screens */
  .btn {
    width: 80%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .hero-actions,
  .action-row {
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  .header-actions {
    gap: 0.65rem;
    flex-shrink: 0;
  }

  /* Free header space: themes live in the burger panel */
  .theme-switcher--header {
    display: none !important;
  }

  .brand-full {
    display: block;
  }

  .menu-toggle {
    flex-shrink: 0;
  }

  .nav-theme {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.55rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
  }

  .nav-theme__label {
    margin: 0;
    padding: 0 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .theme-switcher--nav {
    display: inline-flex;
    width: 100%;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 0.35rem;
    gap: 0.25rem;
  }

  .theme-switcher--nav .theme-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 2.6rem;
    padding: 0.4rem;
  }

  .theme-switcher--nav .theme-btn__icon {
    width: 1.35rem;
    height: 1.35rem;
  }

  .theme-switcher--nav .theme-btn[data-theme="linux"] .theme-btn__icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .site-shell.is-nav-open .site-nav {
    display: flex;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-2);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    gap: 0.15rem;
  }

  .nav-dropdown {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .nav-dropdown-toggle,
  .nav-link {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
  }

  .nav-submenu {
    position: static;
    box-shadow: none;
    border-color: var(--border);
    background: var(--bg-muted);
    margin: 0 0 0.25rem;
  }

  .site-header {
    position: sticky;
  }

  .header-inner {
    position: relative;
  }
}

/* =============================================================================
   Modular layout utilities (composition patterns)
   Opt-in only — existing pages unchanged until these classes are added in HTML.
   ============================================================================= */
@layer layout {
  /**
   * .layout-vertical-stack — vertical flow with even spacing between children.
   * Use: hero copy blocks, form fields, card body sections.
   */
  .layout-vertical-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--layout-stack-gap, var(--space-3));
  }

  /**
   * .layout-inline-wrap — horizontal row that wraps; keeps items aligned in a cluster.
   * Use: nav pills, tag lists, icon + label groups (not primary button rows — use .hero-actions).
   */
  .layout-inline-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--layout-inline-wrap-gap, var(--space-2));
  }

  /**
   * .layout-row-or-column — side-by-side when wide, stacks when narrow (Switcher pattern).
   * Use: two-column promo blocks, label + control pairs on tool pages.
   */
  .layout-row-or-column {
    display: flex;
    flex-wrap: wrap;
    gap: var(--layout-row-or-column-gap, var(--space-2));
  }

  .layout-row-or-column > * {
    flex-grow: 1;
    flex-basis: calc((var(--layout-row-or-column-threshold, 30rem) - 100%) * 999);
    min-width: 0;
  }
}
