:root {
  --ux-copy-size: 1rem;
  --ux-copy-leading: 1.56;
  --ux-line-length: 68ch;
  --ux-small-size: .875rem;
  --ux-muted: #555d65;
  --ux-link: #684624;
  --ux-focus: #704016;
  --ux-focus-ring: #fff;
  --ux-control-edge: #73695f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ux-muted: #b7c2cb;
    --ux-link: #f0cea4;
    --ux-focus: #f7d4a8;
    --ux-focus-ring: #0e141a;
    --ux-control-edge: #9eaab5;
  }
}

:root[data-theme="light"], :root[data-ux-theme="light"] {
  --ux-muted: #555d65;
  --ux-link: #684624;
  --ux-focus: #704016;
  --ux-focus-ring: #fff;
  --ux-control-edge: #73695f;
}

:root[data-theme="dark"], :root[data-ux-theme="dark"] {
  --ux-muted: #b7c2cb;
  --ux-link: #f0cea4;
  --ux-focus: #f7d4a8;
  --ux-focus-ring: #0e141a;
  --ux-control-edge: #9eaab5;
}

/* Inherit the existing scale for hero text and strengthen the small and muted copy. */
main p:where(:not([class])),
main :where(.home-lab-tech-description, .re-proof, .dynamics-case-detail, .sl-note,
  .study-conclusion p, .project-context p, .product-description, .contact-hero p) {
  font-size: max(var(--ux-copy-size), 1em);
  line-height: var(--ux-copy-leading);
  max-inline-size: var(--ux-line-length);
}

.labs-shell .home-lab-tech-description {
  font-size: var(--ux-copy-size);
  line-height: var(--ux-copy-leading);
}

main :is(.home-lab-tech-description, .dynamics-case-detail, .sl-note, .re-proof, .study-conclusion p,
  .ai-question-hint, .support-field-note, .re-engine-copy figcaption, .project-context dd) {
  color: var(--ux-muted);
}

.labs-shell main figcaption,
.studio-marketing main figcaption,
main :is(.home-lab-tech-action, .re-stat small, .dp-readout small, .fsie-stats small) {
  font-size: max(var(--ux-small-size), 1em);
  line-height: 1.45;
}

:where(main, footer) :where(p, li, dd, figcaption) {
  overflow-wrap: break-word;
}

:where(main) :where(h1, h2, h3, h4) {
  overflow-wrap: break-word;
}

:where([id]) {
  scroll-margin-block-start: 1rem;
}

:where(a, button, input, select, textarea, summary, [tabindex], [contenteditable]):focus-visible {
  outline: 2px solid var(--ux-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px var(--ux-focus-ring);
}

[data-ux-scroll]:focus-visible {
  outline-offset: -2px;
}

.ux-skip {
  position: fixed;
  z-index: 10001;
  inset-block-start: .5rem;
  inset-inline-start: .5rem;
  padding: .65rem .85rem;
  background: var(--ux-focus-ring);
  color: var(--ux-focus);
}

.ux-skip:not(:focus) {
  position: absolute;
  clip-path: inset(50%);
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
}

.ux-lab-link {
  display: inline-flex;
  align-items: center;
  gap: .55em;
  min-block-size: 2rem;
  color: inherit;
  font-weight: inherit;
  text-decoration: underline;
  text-underline-offset: .22em;
  text-decoration-color: var(--ux-link);
}

.ux-lab-link span { color: var(--ux-link); }
.ux-study-links,
.ux-beta-links {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .9rem;
  margin: .75rem 0;
  padding: 0;
  list-style: none;
  min-inline-size: 0;
}

.ux-study-links li,
.ux-beta-links li { min-inline-size: 0; }
.ux-study-links a,
.ux-beta-links a,
.ux-legacy-studio {
  display: inline-block;
  padding-block: .4rem;
  line-height: 1.4;
  color: var(--ux-link);
  font-size: var(--ux-small-size);
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.re-engine-actions > .ux-study-links {
  inline-size: 100%;
  margin: 0;
  order: -1;
}
.ux-beta-links { margin-block: 1rem; }
.ux-beta-links a { font-size: var(--ux-copy-size); }
.ux-legacy-studio { margin-inline-start: .65rem; }

/* Apply horizontal scrolling only inside technical tables and code snippets. */
:where(.re-table-wrap, .ote-table, .fpre-table, .fsie-table, .sl-table-scroll, .dp-table, .pt-table,
  .table, .scroll, pre)[data-ux-scroll] {
  max-inline-size: 100%;
  overscroll-behavior-inline: contain;
}

:where(.labs-shell, .policy-shell, .studio-marketing, .studio-ai) :where(
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select, textarea) {
  border-color: var(--ux-control-edge);
}

@media (max-width: 768px), (pointer: coarse) {
  .ux-lab-link,
  .ux-study-links a,
  .ux-beta-links a,
  :is(.labs-shell,.studio-marketing,.studio-ai,.contacts-shell) :is(
    .language-switch button, .studio-menu > summary, .studio-menu-panel a, .button,
    .home-section-link, .ai-suggestions button, .presentation-reading-nav a) {
    min-block-size: 2.75rem;
  }

  .ux-study-links,
  .ux-beta-links { row-gap: 0; }
  .ux-study-links a,
  .ux-beta-links a { display: inline-flex; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  html,
  html :where(*, *::before, *::after) {
    scroll-behavior: auto !important;
  }
  .ux-lab-link, .ux-study-links a, .ux-beta-links a { transition: none; }
}

/* Keep existing graphics and labels when the available width shrinks. */
[data-ux-studio] .source-choices {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
[data-ux-studio] .source-choices button {
  min-inline-size: 0;
  white-space: normal;
}
[data-ux-studio] .source-choices button > span:first-child {
  flex: none;
}
[data-ux-studio] .header-right {
  min-inline-size: 0;
  flex-wrap: wrap;
}
[data-ux-studio] .connection {
  white-space: normal;
}
[data-ux-studio] h1 { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  [data-ux-studio] .source-choices {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  }
}
@media (max-width: 360px) {
  [data-ux-studio] body > header {
    min-block-size: 4.5rem;
    block-size: auto;
    padding: .6rem .8rem;
    gap: .45rem;
  }
  [data-ux-studio] body > header .brand { flex-shrink: 1; }
  [data-ux-studio] .header-right { justify-content: end; }
}
.concept-content > h2 {
  font: inherit;
  font-size: 1.28rem;
  line-height: 1.2;
  font-weight: 550;
  margin: 0;
}
.sl-readouts dd small {
  display: block;
  font-weight: 400;
}

.labs-shell :is(.labs-hero-bottom p, .home-research-intro p:not(.labs-eyebrow), .home-research-areas dd,
  .re-engine-copy p:not(.labs-eyebrow), .presentation-intro p:not(.labs-eyebrow)),
.studio-marketing :is(.product-info > p, .v2-care p:not(.eyebrow)),
.studio-ai :is(.ai-answer p, .ai-question p, textarea),
.contacts-shell :is(.contact-hero p:not(.eyebrow), .contact-card p),
[data-ux-studio] :is(.page-heading .muted, .onboarding p:not(.eyebrow)) {
  font-size: max(var(--ux-copy-size), 1em);
  line-height: var(--ux-copy-leading);
  max-inline-size: var(--ux-line-length);
}

:is(.labs-shell,.studio-marketing) main figure figcaption {
  font-size: var(--ux-small-size);
}
html[data-satinato="documento"] :is(th, td) {
  font-size: max(var(--ux-small-size), 1em);
}
html[data-satinato="documento"] .study-conclusion p {
  color: inherit;
}
html[data-satinato="documento"] .ux-report-data a {
  text-underline-offset: .2em;
}

[data-ux-studio] .onboarding > div,
[data-ux-studio] .onboarding .actions > *,
[data-ux-studio] aside nav button {
  min-inline-size: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
@media (max-width: 760px) {
  [data-ux-studio] aside nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  [data-ux-studio] aside nav button { justify-content: center; }
  [data-ux-studio] .onboarding { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 700px) {
  html[data-satinato="documento"] .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html[data-satinato="documento"] .stats > div {
    min-inline-size: 0;
    overflow-wrap: anywhere;
    padding-inline: clamp(.55rem, 3vw, 1.15rem);
  }
}

.ux-column-links {
  display: none;
}
@media (max-width: 760px) {
  .ux-column-links {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    margin-block: .4rem;
  }
  .ux-column-links a {
    display: inline-flex;
    align-items: center;
    min-block-size: 2rem;
    font-size: var(--ux-small-size);
    text-underline-offset: .2em;
  }
}

[data-ux-materials-report] .bar {
  grid-template-columns: minmax(3ch, 1fr) minmax(1.75rem, 2fr) max-content;
  align-items: center;
  gap: clamp(.3rem, 1vw, .9rem);
}
[data-ux-materials-report] .bar meter {
  min-inline-size: 0;
}
.web-v2 .product-art .image-label {
  inset-inline: .6rem;
  max-inline-size: calc(100% - 1.2rem);
  white-space: normal;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

/* A theme-matched fallback keeps the focus visible over transparent surfaces. */
html:where([data-satinato], [data-ux-studio]) :is(
  .ux-lab-link, .ux-study-links a, .ux-beta-links a, .ux-column-links a,
  .studio-menu > summary, .studio-menu-panel a, .appearance-control select,
  input:not([type="hidden"]), textarea, summary, [data-ux-scroll]
):focus-visible {
  outline: 2px solid var(--ux-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px var(--ux-focus-ring);
}
html [data-ux-scroll]:focus-visible { outline-offset: -3px; }

@media (forced-colors: active) {
  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline-color: Highlight;
  }
}

.studio-ai .ai-composer textarea,
.security-lab .sl-controls select,
.security-lab .sl-benchmark-form select {
  border-color: var(--ux-control-edge);
}

@media (max-width: 410px) {
  .web-v2 .product-art .image-label {
    display: inline-block;
    max-inline-size: calc(100% - 1.25rem);
    inline-size: fit-content;
    padding: .24rem .45rem;
    border-radius: .3rem;
    color: #f3f2ee;
    background: #151a20;
    font-size: .75rem;
  }
}

/* Match the dark palette on technical reports whose original sheet used fixed
   paper colours. The existing light and print renderings stay available. */
@media screen and (prefers-color-scheme: dark) {
  html[data-ux-paper-report] {
    color-scheme: dark;
    --ux-report-surface: #202831;
    --ux-report-divider: #65727c;
  }
  html[data-ux-paper-report] body {
    color: #f3f2ee;
    background-color: #101316;
  }
  html[data-ux-paper-report] a { color: #a8d4e1; }
  html[data-ux-paper-report] :is(th, pre, article, .stats) {
    background-color: var(--ux-report-surface);
  }
  html[data-ux-paper-report] :is(th, td, article, pre, footer, .stats) {
    border-color: var(--ux-report-divider);
  }
  html[data-ux-paper-report] :is(small, .muted, figcaption, .meta, .kind, .eyebrow, .stats span, footer) {
    color: #c3cbd3;
  }
  html[data-ux-paper-report] .notice { border-color: #caad88; }
}
