:root {
  color-scheme: light dark;
  --thm-font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --thm-font-heading: var(--thm-font-body);
  --thm-bg: #f6f7f9;
  --thm-surface: #ffffff;
  --thm-surface-soft: #eef1f5;
  --thm-text: #171a21;
  --thm-muted: #626a78;
  --thm-border: #d9dee7;
  --thm-accent: #3659d9;
  --thm-on-accent: #ffffff;
  --thm-accent-strong: #2744b5;
  --thm-focus: #5272eb;
  --thm-danger: #b42318;
  --thm-gutter: clamp(1rem, 4vw, 2rem);
  --thm-container-narrow: 60rem;
  --thm-container-standard: 75rem;
  --thm-container-wide: 97.5rem;
  --thm-container: var(--thm-container-standard);
  --thm-section-density: 1;
  --thm-anchor-offset: 1.5rem;
  --thm-readable: 46rem;
  --thm-radius: 0.75rem;
  --thm-shadow: 0 1px 2px rgb(15 23 42 / 0.07), 0 8px 28px rgb(15 23 42 / 0.05);
  --thm-shadow-hover: 0 2px 4px rgb(15 23 42 / 0.08), 0 14px 36px rgb(15 23 42 / 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-thm-appearance="light"]) {
    --thm-bg: #101217;
    --thm-surface: #181b22;
    --thm-surface-soft: #20242d;
    --thm-text: #f0f2f6;
    --thm-muted: #abb2c0;
    --thm-border: #343a46;
    --thm-accent: #8ca2ff;
  --thm-on-accent: #171a21;
    --thm-accent-strong: #b4c1ff;
    --thm-focus: #a8b7ff;
    --thm-danger: #ff9d96;
    --thm-shadow: 0 1px 2px rgb(0 0 0 / 0.24), 0 8px 28px rgb(0 0 0 / 0.2);
    --thm-shadow-hover: 0 2px 4px rgb(0 0 0 / 0.28), 0 14px 36px rgb(0 0 0 / 0.26);
  }
}


/* M5: semantic theme context only; no client-side appearance engine. */
:root[data-thm-appearance="light"] { color-scheme: light; }
:root[data-thm-appearance="dark"] {
  color-scheme: dark;
  --thm-bg: #101217;
  --thm-surface: #181b22;
  --thm-surface-soft: #20242d;
  --thm-text: #f0f2f6;
  --thm-muted: #abb2c0;
  --thm-border: #343a46;
  --thm-accent: #8ca2ff;
  --thm-on-accent: #171a21;
  --thm-accent-strong: #b4c1ff;
  --thm-focus: #a8b7ff;
  --thm-danger: #ff9d96;
  --thm-shadow: 0 1px 2px rgb(0 0 0 / 0.24), 0 8px 28px rgb(0 0 0 / 0.2);
  --thm-shadow-hover: 0 2px 4px rgb(0 0 0 / 0.28), 0 14px 36px rgb(0 0 0 / 0.26);
}

/* Curated accents: invalid/missing keys keep the semantic default palette. */
:root[data-thm-accent="violet"] {
  --thm-accent: #6d28d9;
  --thm-accent-strong: #5b21b6;
  --thm-focus: #6d28d9;
}
:root[data-thm-accent="teal"] {
  --thm-accent: #0f766e;
  --thm-accent-strong: #115e59;
  --thm-focus: #0f766e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-thm-appearance="light"])[data-thm-accent="violet"] {
    --thm-accent: #c4b5fd;
    --thm-accent-strong: #ddd6fe;
    --thm-focus: #c4b5fd;
  }
  :root:not([data-thm-appearance="light"])[data-thm-accent="teal"] {
    --thm-accent: #5eead4;
    --thm-accent-strong: #99f6e4;
    --thm-focus: #5eead4;
  }
}
:root[data-thm-appearance="dark"][data-thm-accent="violet"] {
  --thm-accent: #c4b5fd;
  --thm-accent-strong: #ddd6fe;
  --thm-focus: #c4b5fd;
}
:root[data-thm-appearance="dark"][data-thm-accent="teal"] {
  --thm-accent: #5eead4;
  --thm-accent-strong: #99f6e4;
  --thm-focus: #5eead4;
}

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

html {
  min-width: 20rem;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--thm-bg);
  color: var(--thm-text);
  font-family: var(--thm-font-body);
  font-size: 1rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

.thm-page {
  display: flex;
  flex-direction: column;
}

a {
  color: var(--thm-accent);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--thm-accent-strong);
}

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

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
input,
select,
textarea {
  border: 1px solid var(--thm-border);
  border-radius: calc(var(--thm-radius) * 0.75);
  background: var(--thm-surface);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
}

button,
.button {
  min-height: 2.5rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

:focus-visible {
  outline: 3px solid var(--thm-focus);
  outline-offset: 3px;
}

.thm-container {
  width: min(100% - (2 * var(--thm-gutter)), var(--thm-container));
  margin-inline: auto;
}

.thm-container-narrow {
  --thm-container: var(--thm-container-narrow);
}

.thm-container-standard {
  --thm-container: var(--thm-container-standard);
}

.thm-container-wide {
  --thm-container: var(--thm-container-wide);
}

.thm-skip-link {
  position: fixed;
  z-index: 100;
  inset: 0 auto auto 0;
  padding: 0.75rem 1rem;
  transform: translateY(-150%);
  border-radius: 0 0 var(--thm-radius) 0;
  background: var(--thm-text);
  color: var(--thm-bg);
  font-weight: 700;
}

.thm-skip-link:focus {
  transform: translateY(0);
}

.thm-header {
  border-bottom: 1px solid var(--thm-border);
  background: color-mix(in srgb, var(--thm-surface) 94%, transparent);
}

.thm-header__inner {
  display: flex;
  min-height: 4.5rem;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.thm-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--thm-text);
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
}

.thm-brand__mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: calc(var(--thm-radius) * 0.7);
  background: var(--thm-accent);
  color: var(--thm-bg);
  font-size: 1.05rem;
  font-weight: 800;
}

.thm-brand__logo {
  width: auto;
  max-width: min(12rem, 45vw);
  max-height: 2.5rem;
}

.thm-nav ul {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.thm-nav a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: calc(var(--thm-radius) * 0.7);
  color: var(--thm-muted);
  font-weight: 650;
  text-decoration: none;
}

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

.thm-nav a[aria-current="page"] {
  box-shadow: inset 0 -2px 0 var(--thm-accent);
}

.thm-nav-toggle {
  display: none;
  align-items: center;
  gap: 0.55rem;
  background: var(--thm-surface);
}

.thm-nav-toggle__icon,
.thm-nav-toggle__icon::before,
.thm-nav-toggle__icon::after {
  width: 1.1rem;
  height: 2px;
  background: currentColor;
}

.thm-nav-toggle__icon {
  position: relative;
}

.thm-nav-toggle__icon::before,
.thm-nav-toggle__icon::after {
  position: absolute;
  left: 0;
  content: "";
}

.thm-nav-toggle__icon::before {
  top: -0.35rem;
}

.thm-nav-toggle__icon::after {
  top: 0.35rem;
}

.thm-main {
  flex: 1 0 auto;
  outline: none;
}

.thm-content-shell {
  padding-block: clamp(2.25rem, 7vw, 5rem);
}

.thm-prose {
  max-width: var(--thm-readable);
}

.thm-prose > :first-child,
.thm-page-heading > :first-child {
  margin-top: 0;
}

.thm-prose > :last-child {
  margin-bottom: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--thm-text);
  font-family: var(--thm-font-heading);
  line-height: 1.18;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.75rem);
}

h2 {
  font-size: clamp(1.55rem, 4vw, 2.4rem);
}

.thm-page-heading {
  margin-bottom: 2rem;
}

.thm-page-heading p,
.thm-muted {
  color: var(--thm-muted);
}

.thm-article-list,
.thm-feed {
  display: grid;
  gap: 1rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.thm-card,
.thm-feed-card {
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--thm-border);
  border-radius: var(--thm-radius);
  background: var(--thm-surface);
  box-shadow: var(--thm-shadow);
}

.thm-card :is(h2, h3),
.thm-feed-card :is(h2, h3) {
  margin-top: 0;
}

.thm-footer {
  flex: none;
  padding-block: 1.5rem;
  border-top: 1px solid var(--thm-border);
  color: var(--thm-muted);
  font-size: 0.92rem;
}

.thm-footer p {
  margin: 0;
}

.thm-error__code {
  margin: 0;
  color: var(--thm-muted);
  font-size: clamp(3rem, 12vw, 7rem);
  font-weight: 800;
  line-height: 1;
}

/* Public Contract v0.1 defaults: unlayered plugin values take precedence.
   Root scope avoids overriding inherited explicit Design Kit values. */
@layer thematis-bridge {
  :root {
    --grvst-page-gutter: var(--thm-gutter);
    --grvst-container-narrow: var(--thm-container-narrow);
    --grvst-container-standard: var(--thm-container-standard);
    --grvst-container-wide: var(--thm-container-wide);
    --grvst-container-max: var(--thm-container);
    --grvst-section-container-max: var(--grvst-container-max);
    --grvst-readable-width: var(--thm-readable);
    --grvst-space: var(--thm-section-density);
    --grvst-radius: var(--thm-radius);
    --grvst-card-shadow: var(--thm-shadow);
    --grvst-card-shadow-hover: var(--thm-shadow-hover);
    --grvst-body: var(--thm-font-body);
    --grvst-head: var(--thm-font-heading);
    --grvst-accent: var(--thm-accent);
    --grvst-on-accent: var(--thm-on-accent);
    --grvst-page: var(--thm-bg);
    --grvst-surface: var(--thm-surface);
    --grvst-surface-soft: var(--thm-surface-soft);
    --grvst-text: var(--thm-text);
    --grvst-muted: var(--thm-muted);
    --grvst-border: var(--thm-border);
  }

  /* Explicit section width is a public per-section choice, not a global default.
     Leave container-max to root/Design Kit; component rules can override this layer. */
  :where(.grvst[data-grvst-width="narrow"]) {
    --grvst-section-container-max: var(--grvst-container-narrow);
  }
  :where(.grvst[data-grvst-width="standard"]) {
    --grvst-section-container-max: var(--grvst-container-standard);
  }
  :where(.grvst[data-grvst-width="wide"]) {
    --grvst-section-container-max: var(--grvst-container-wide);
  }
  :where(.grvst[data-grvst-width="full"]) {
    --grvst-section-container-max: 100%;
  }
}

/* Root-resolved bridge defaults need the same native shell width context as body.
   This does not change M4 page layout selection or plugin component width choices. */
:root[data-thm-width="narrow"] { --thm-container: var(--thm-container-narrow); }
:root[data-thm-width="standard"] { --thm-container: var(--thm-container-standard); }
:root[data-thm-width="wide"] { --thm-container: var(--thm-container-wide); }

/* Non-sticky shell: leave breathing room at native fragment destinations.
   Page Jump owns its interaction; Thematis neither renames IDs nor intercepts links. */
.grvst-section[id] {
  scroll-margin-block-start: var(--thm-anchor-offset);
}

@media (max-width: 47.5rem) {
  .thm-header__inner {
    position: relative;
    flex-wrap: wrap;
    padding-block: 0.75rem;
  }

  .thm-js .thm-nav-toggle {
    display: inline-flex;
  }

  .thm-nav {
    flex-basis: 100%;
  }

  .thm-js .thm-nav:not(.is-open) {
    display: none;
  }

  .thm-nav ul {
    align-items: stretch;
    flex-direction: column;
    padding-bottom: 0.5rem;
  }

  .thm-nav a {
    padding: 0.7rem 0.8rem;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* M3 Navigation Foundation: one native tree, separate links and disclosure controls. */
.thm-nav__item{position:relative}
.thm-nav__row{display:flex;align-items:center}
.thm-nav__group{padding:.55rem .75rem;color:var(--thm-muted)}
.thm-nav__expand{display:none;border:1px solid var(--thm-border);border-radius:var(--thm-radius);background:var(--thm-surface);color:var(--thm-text);padding:.4rem .6rem;cursor:pointer;min-width:2.25rem;min-height:2.25rem}
.thm-js .thm-nav__expand{display:block}
.thm-nav__expand[aria-expanded="true"] span{display:inline-block;transform:rotate(180deg)}
.thm-nav .thm-nav__submenu{display:block;min-width:12rem;padding:.35rem;border:1px solid var(--thm-border);border-radius:var(--thm-radius);background:var(--thm-surface)}
.thm-nav__submenu[hidden]{display:none!important}
.thm-nav .thm-nav__submenu a{white-space:normal;overflow-wrap:anywhere}
.thm-nav__submenu .thm-nav__row{justify-content:space-between}
.thm-nav .is-ancestor>.thm-nav__row>.thm-nav__link{color:var(--thm-text);text-decoration:underline;text-underline-offset:.25em}
@media (min-width:47.501rem){
 .thm-js .thm-nav>.thm-nav__list>.thm-nav__item>.thm-nav__submenu{position:absolute;top:100%;right:0;width:16rem;max-width:calc(100vw - 2rem);z-index:20;box-shadow:0 .5rem 1rem rgb(0 0 0 / .12)}
 .thm-nav__submenu .thm-nav__submenu{margin:.25rem 0 .25rem .75rem;min-width:0}
 .thm-nav>.thm-nav__list{flex-wrap:wrap}
}
@media (max-width:47.5rem){
 .thm-nav__row{width:100%;justify-content:space-between}
 .thm-nav__link{flex:1;min-width:0;overflow-wrap:anywhere}
 .thm-nav .thm-nav__submenu{min-width:0;margin-left:.75rem;border:0;border-left:1px solid var(--thm-border);border-radius:0}
}

/* M4 Layout Patterns: theme shell only; plugin-owned section widths are untouched. */
.thm-layout{flex:1;min-width:0}
.thm-layout>.thm-main{min-width:0}
.thm-layout--sidebar-left,.thm-layout--sidebar-right{display:grid;gap:var(--thm-gutter);align-items:start}
.thm-layout--sidebar-left{grid-template-columns:minmax(12rem,18rem) minmax(0,1fr)}
.thm-layout--sidebar-right{grid-template-columns:minmax(0,1fr) minmax(12rem,18rem)}
.thm-layout--sidebar-left>.thm-main>.thm-container,.thm-layout--sidebar-right>.thm-main>.thm-container{width:100%;max-width:none;padding-inline:0}
.thm-layout__aside{min-width:0;margin-block:2rem;padding:1.25rem;border:1px solid var(--thm-border);border-radius:var(--thm-radius);background:var(--thm-surface);color:var(--thm-text);overflow-wrap:anywhere}
.thm-layout__aside h2{margin-top:0}
@media (max-width:60rem){
 .thm-layout--sidebar-left,.thm-layout--sidebar-right{grid-template-columns:minmax(0,1fr)}
 .thm-layout__aside{margin-block:1rem}
}

/* M5 shell-only presentation. Main/aside/layout/component rules stay untouched. */
:root[data-thm-density="compact"] .thm-header__inner {
  min-height: 4rem;
  gap: 1rem;
}
:root[data-thm-density="compact"] .thm-nav a {
  padding: 0.45rem 0.65rem;
  min-height: 2.25rem;
}
:root[data-thm-density="compact"] .thm-footer { padding-block: 1rem; }
:root[data-thm-surface="subtle"] .thm-header,
:root[data-thm-surface="subtle"] .thm-footer {
  background: var(--thm-surface-soft);
  border-color: var(--thm-border);
}
/* Site Identity: bounded native media and wrapping text, no header pattern change. */
.thm-brand{min-width:0;max-width:100%;flex-shrink:1}
.thm-brand__identity{display:flex;flex-direction:column;min-width:0;overflow-wrap:anywhere}
.thm-brand__tagline{font-size:.8rem;font-weight:400;line-height:1.4;color:var(--thm-muted)}
.thm-brand__mark{flex-shrink:0}
.thm-brand__logo{object-fit:contain;min-width:0;flex-shrink:1}
.thm-brand__logo--dark{display:none}
@media(prefers-color-scheme:dark){
 :root:not([data-thm-appearance="light"]) .thm-brand__logo--light{display:none}
 :root:not([data-thm-appearance="light"]) .thm-brand__logo--dark{display:block}
}
:root[data-thm-appearance="dark"] .thm-brand__logo--light{display:none}
:root[data-thm-appearance="dark"] .thm-brand__logo--dark{display:block}
@media(max-width:47.5rem){.thm-brand{flex-basis:100%}.thm-brand__logo{max-width:min(8rem,35vw);max-height:2.25rem}}

/* 0.9.1 fixed Site Shell: column order equals DOM order; no layout JS. */
.thm-header-columns.thm-nav{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem;align-items:center;width:100%;min-width:0}
.thm-shell-column{min-width:0;overflow-wrap:anywhere}
.thm-header-columns>[data-thm-column="1"]{grid-column:1}
.thm-header-columns>[data-thm-column="2"]{grid-column:2}
.thm-header-columns>[data-thm-column="3"]{grid-column:3}
.thm-header .thm-brand{display:inline-flex;padding:0;color:var(--thm-text);background:transparent}
.thm-header--centered .thm-shell-column{text-align:center}
.thm-header--centered .thm-shell-nav>.thm-nav__list{justify-content:center}
.thm-header--compact .thm-header__inner{padding-block:.5rem;min-height:3.5rem}
.thm-shell-nav{min-width:0}
.thm-shell-nav>.thm-nav__list{flex-wrap:wrap}
.thm-nav__link,.thm-nav__group{overflow-wrap:anywhere}
.thm-sidebar-nav ul{margin:0;padding:0;list-style:none}
.thm-sidebar-nav .thm-nav__list{display:block}
.thm-sidebar-nav .thm-nav__submenu{position:static;display:block;box-shadow:none;border:0;padding-left:1rem;background:transparent}
.thm-sidebar-nav .thm-nav__row{min-width:0}
.thm-sidebar-nav a{display:block;min-height:2.25rem;padding:.5rem;overflow-wrap:anywhere}
.thm-sidebar-nav .is-ancestor>.thm-nav__row>.thm-nav__link{text-decoration:underline}
@media(min-width:47.501rem){
 .thm-js .thm-shell-nav>.thm-nav__list>.thm-nav__item>.thm-nav__submenu{position:absolute;top:100%;right:0;width:16rem;max-width:calc(100vw - 2rem);z-index:20;box-shadow:0 .5rem 1rem rgb(0 0 0 / .12)}
}
.thm-footer__inner{display:block;min-width:0}
.thm-footer-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1.5rem;align-items:start}
.thm-footer-grid>[data-thm-column="1"]{grid-column:1}
.thm-footer-grid>[data-thm-column="2"]{grid-column:2}
.thm-footer-grid>[data-thm-column="3"]{grid-column:3}
.thm-footer .thm-shell-column h2{font-size:1rem;margin:0 0 .75rem}
.thm-footer .thm-shell-column p{margin:.25rem 0}
.thm-footer ul{margin:0;padding:0;list-style:none}
.thm-footer a{display:inline-block;min-height:2.25rem;padding-block:.5rem;overflow-wrap:anywhere;max-width:100%}
.thm-footer .thm-brand{display:inline-flex;padding-block:0}
.thm-footer .thm-nav__row{display:block}
.thm-footer .thm-nav__submenu{position:static;padding-left:1rem;min-width:0}
.thm-footer-social,.thm-footer-legal>ul{display:flex;flex-wrap:wrap;gap:.25rem 1rem}
.thm-footer-address{white-space:pre-line}
.thm-footer-bottom{display:flex;flex-wrap:wrap;gap:.75rem 2rem;align-items:center;margin-top:1rem;border-top:1px solid var(--thm-border);padding-top:1rem;min-width:0}
.thm-footer-legal,.thm-footer-copyright{min-width:0;overflow-wrap:anywhere}
.thm-footer-copyright{margin:0}
@media(max-width:60rem){
 .thm-header-columns.thm-nav,.thm-footer-grid{grid-template-columns:minmax(0,1fr)}
 .thm-header-columns>[data-thm-column],.thm-footer-grid>[data-thm-column]{grid-column:auto}
}
@media(max-width:47.5rem){
 .thm-js .thm-header-columns.thm-nav:not(.is-open){display:grid}
 .thm-js .thm-header-columns:not(.is-open) .thm-shell-nav{display:none}
 .thm-header-columns .thm-shell-nav{width:100%}
 .thm-footer-bottom{align-items:stretch;flex-direction:column}
}

/* 0.10.0 Native Grav Page presentation: no shell or component overrides. */
.thm-article,.thm-native-list>li{min-width:0;overflow-wrap:anywhere}
.thm-native-list{list-style:none;padding:0;display:grid;gap:1.5rem}
.thm-native-taxonomy,.thm-native-translations ul{display:flex;flex-wrap:wrap;gap:.5rem 1rem;list-style:none;padding:0}
.thm-native-taxonomy a,.thm-native-translations a{display:inline-block;min-height:2.25rem;padding:.25rem 0}
.thm-native-translations [aria-current]{font-weight:700;text-decoration:underline}
.thm-article-media{margin:1.5rem 0;max-width:100%}
.thm-article-media img{display:block;max-width:100%;height:auto}
.thm-article-media figcaption{margin-top:.5rem;color:var(--thm-muted);overflow-wrap:anywhere}
.thm-native-translations{margin-top:1.5rem}

/* C1 Native Sticky Header: measured progressive enhancement, native fragments.
   No-JS/unsupported measurement keeps the existing non-sticky shell. */
@media (width > 60rem) {
  :root[data-thm-header-sticky="true"].thm-sticky-ready {
    scroll-padding-block-start: calc(var(--thm-sticky-height) + var(--thm-anchor-offset));
  }
  :root[data-thm-header-sticky="true"].thm-sticky-ready .thm-header {
    position: sticky;
    top: 0;
    z-index: 40;
  }
}
