/*
 * OPSY Experience System
 * Form follows function: quiet surfaces, explicit state, one clear next action.
 *
 * Token architecture:
 *   1. primitive values
 *   2. semantic roles
 *   3. component contracts
 *
 * This stylesheet extends appweb/styles.css while preserving its public class
 * names. It contains no network-loaded assets so governed and participant
 * surfaces remain usable offline.
 */

/* ---------- 1. Primitive tokens ---------- */
:root {
  color-scheme: light dark;

  /* The Rose of Venus (brand/logo/opsy-rose-of-venus-mark.svg), redrawn with
     UI-weight strokes so the five orbits survive 20-28px rendering. Used as a
     mask so every mark inherits currentColor in both themes. */
  --opsy-rose-mark: url("/appweb/brand-rose-mask.svg");

  --opsy-ink-950: #111a16;
  --opsy-ink-900: #17231d;
  --opsy-ink-800: #23342b;
  --opsy-ink-700: #344a3f;
  --opsy-ink-600: #4b6156;
  --opsy-ink-500: #66796f;
  --opsy-ink-300: #b7c3bc;
  --opsy-ink-200: #d9e1dc;
  --opsy-ink-100: #e9eeeb;
  --opsy-ink-050: #f5f7f5;
  --opsy-white: #ffffff;

  --opsy-green-900: #063d2d;
  --opsy-green-800: #07523c;
  --opsy-green-700: #0b6b4f;
  --opsy-green-600: #13805f;
  --opsy-green-200: #a9ddc8;
  --opsy-green-100: #d9f0e7;
  --opsy-green-050: #edf8f4;

  --opsy-blue-800: #243c62;
  --opsy-blue-700: #315481;
  --opsy-blue-100: #dce8f5;
  --opsy-blue-050: #eff5fb;

  --opsy-amber-800: #71450b;
  --opsy-amber-700: #8b5b12;
  --opsy-amber-100: #f4e2b7;
  --opsy-amber-050: #fff8e8;
  --opsy-focus-contrast: #ffbf47;

  --opsy-red-800: #7e233d;
  --opsy-red-700: #a12c4d;
  --opsy-red-100: #f3ced9;
  --opsy-red-050: #fff0f4;

  --opsy-space-0: 0;
  --opsy-space-1: 0.25rem;
  --opsy-space-2: 0.5rem;
  --opsy-space-3: 0.75rem;
  --opsy-space-4: 1rem;
  --opsy-space-5: 1.25rem;
  --opsy-space-6: 1.5rem;
  --opsy-space-8: 2rem;
  --opsy-space-10: 2.5rem;
  --opsy-space-12: 3rem;
  --opsy-space-16: 4rem;

  --opsy-radius-sm: 0.375rem;
  --opsy-radius-md: 0.625rem;
  --opsy-radius-lg: 0.875rem;
  --opsy-radius-xl: 1.125rem;
  --opsy-radius-pill: 999px;

  --opsy-font-sans: "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --opsy-font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --opsy-text-xs: 0.75rem;
  --opsy-text-sm: 0.875rem;
  --opsy-text-md: 1rem;
  --opsy-text-lg: 1.125rem;
  --opsy-text-xl: clamp(1.35rem, 1.18rem + 0.7vw, 1.7rem);
  --opsy-text-2xl: clamp(1.75rem, 1.4rem + 1.25vw, 2.35rem);

  --opsy-shadow-1: 0 1px 2px rgb(17 26 22 / 0.06);
  --opsy-shadow-2: 0 10px 30px rgb(17 26 22 / 0.09);
  --opsy-motion-fast: 140ms;
  --opsy-motion-base: 200ms;
  --opsy-ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- 2. Semantic tokens ---------- */
:root,
:root[data-theme="light"] {
  --surface-canvas: var(--opsy-ink-050);
  --surface-primary: var(--opsy-white);
  --surface-secondary: #f0f4f1;
  --surface-raised: var(--opsy-white);
  --surface-inverse: var(--opsy-ink-900);

  --text-primary: var(--opsy-ink-950);
  --text-secondary: var(--opsy-ink-700);
  --text-tertiary: var(--opsy-ink-600);
  --text-inverse: var(--opsy-white);

  --border-default: var(--opsy-ink-200);
  --border-subtle: var(--opsy-ink-100);
  --border-strong: var(--opsy-ink-300);

  --action-primary: var(--opsy-green-700);
  --action-primary-hover: var(--opsy-green-800);
  --action-primary-active: var(--opsy-green-900);
  --action-primary-soft: var(--opsy-green-050);
  --action-secondary: var(--opsy-blue-700);
  --focus-ring: #0b6b4f;

  --state-info: var(--opsy-blue-700);
  --state-info-soft: var(--opsy-blue-050);
  --state-success: #1d714d;
  --state-success-soft: var(--opsy-green-050);
  --state-warning: var(--opsy-amber-700);
  --state-warning-soft: var(--opsy-amber-050);
  --state-danger: var(--opsy-red-700);
  --state-danger-soft: var(--opsy-red-050);

  --scrim: rgb(8 18 13 / 0.56);
}

:root[data-theme="dark"] {
  --surface-canvas: #0f1612;
  --surface-primary: #161f1a;
  --surface-secondary: #1d2822;
  --surface-raised: #202c25;
  --surface-inverse: #eef4f0;

  --text-primary: #f2f6f3;
  --text-secondary: #c5d0ca;
  --text-tertiary: #9eada4;
  --text-inverse: #082319;

  --border-default: #3c4d44;
  --border-subtle: #2b3931;
  --border-strong: #56675e;

  --action-primary: #72d6aa;
  --action-primary-hover: #8de2bd;
  --action-primary-active: #a7ebce;
  --action-primary-soft: #17382a;
  --action-secondary: #8db5e3;
  --focus-ring: #8de2bd;

  --state-info: #9cc4ef;
  --state-info-soft: #192c42;
  --state-success: #83d5ac;
  --state-success-soft: #17382a;
  --state-warning: #efc66c;
  --state-warning-soft: #382b16;
  --state-danger: #f09ab2;
  --state-danger-soft: #3e1c27;

  --scrim: rgb(0 0 0 / 0.68);
  --opsy-shadow-1: 0 1px 2px rgb(0 0 0 / 0.28);
  --opsy-shadow-2: 0 14px 38px rgb(0 0 0 / 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-canvas: #0f1612;
    --surface-primary: #161f1a;
    --surface-secondary: #1d2822;
    --surface-raised: #202c25;
    --surface-inverse: #eef4f0;
    --text-primary: #f2f6f3;
    --text-secondary: #c5d0ca;
    --text-tertiary: #9eada4;
    --text-inverse: #082319;
    --border-default: #3c4d44;
    --border-subtle: #2b3931;
    --border-strong: #56675e;
    --action-primary: #72d6aa;
    --action-primary-hover: #8de2bd;
    --action-primary-active: #a7ebce;
    --action-primary-soft: #17382a;
    --action-secondary: #8db5e3;
    --focus-ring: #8de2bd;
    --state-info: #9cc4ef;
    --state-info-soft: #192c42;
    --state-success: #83d5ac;
    --state-success-soft: #17382a;
    --state-warning: #efc66c;
    --state-warning-soft: #382b16;
    --state-danger: #f09ab2;
    --state-danger-soft: #3e1c27;
    --scrim: rgb(0 0 0 / 0.68);
  }
}

/*
 * Compatibility mapping for existing interviewer and MVP pages. New surfaces
 * should prefer semantic names, while old classes remain visually coherent.
 */
:root {
  --font-display: var(--opsy-font-sans);
  --font-body: var(--opsy-font-sans);
  --font-mono: var(--opsy-font-mono);
  --color-bg: var(--surface-canvas);
  --color-surface: var(--surface-primary);
  --color-surface-2: var(--surface-secondary);
  --color-divider: var(--border-subtle);
  --color-border: var(--border-default);
  --color-text: var(--text-primary);
  --color-text-muted: var(--text-secondary);
  --color-text-faint: var(--text-tertiary);
  --color-text-inverse: var(--text-inverse);
  --color-primary: var(--action-primary);
  --color-primary-hover: var(--action-primary-hover);
  --color-primary-active: var(--action-primary-active);
  --color-primary-light: var(--action-primary-soft);
  --color-secondary: var(--action-secondary);
  --color-secondary-light: var(--state-info-soft);
  --color-gold: var(--state-warning);
  --color-gold-light: var(--state-warning-soft);
  --color-success: var(--state-success);
  --color-warning: var(--state-warning);
  --color-error: var(--state-danger);
  --shadow-sm: var(--opsy-shadow-1);
  --shadow-md: var(--opsy-shadow-2);
  --shadow-lg: var(--opsy-shadow-2);
  --transition: var(--opsy-motion-base) var(--opsy-ease);
}

/* ---------- 3. Global and component contracts ---------- */
html {
  background: var(--surface-canvas);
  scroll-behavior: smooth;
}

body {
  background: var(--surface-canvas);
  color: var(--text-primary);
  font-family: var(--opsy-font-sans);
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  color: var(--text-primary);
  font-family: var(--opsy-font-sans);
  font-weight: 680;
  letter-spacing: -0.018em;
}

h1 {
  font-size: var(--opsy-text-2xl);
}

h2 {
  font-size: var(--opsy-text-xl);
}

h3 {
  font-size: var(--opsy-text-lg);
}

p,
li,
dd {
  max-width: 72ch;
}

a {
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.08em;
}

button,
a,
input,
textarea,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"],
.btn,
.iconbtn,
input:not([type="hidden"]),
select {
  min-height: 44px;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--opsy-radius-sm);
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: var(--opsy-space-3);
  left: var(--opsy-space-3);
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: var(--opsy-space-2) var(--opsy-space-4);
  border-radius: var(--opsy-radius-md);
  background: var(--surface-inverse);
  color: var(--text-inverse);
  font-weight: 700;
  transform: translateY(-180%);
  transition: transform var(--opsy-motion-fast) var(--opsy-ease);
}

.skip-link:focus {
  transform: translateY(0);
}

.experience-shell {
  width: min(100%, 90rem);
  min-height: 100dvh;
  margin-inline: auto;
}

.experience-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: var(--opsy-space-3);
  padding:
    calc(var(--opsy-space-2) + env(safe-area-inset-top))
    clamp(var(--opsy-space-4), 2.5vw, var(--opsy-space-8))
    var(--opsy-space-2);
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-canvas) 92%, transparent);
  backdrop-filter: blur(14px);
}

.experience-brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: var(--opsy-space-2);
  color: var(--text-primary);
  font-weight: 750;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.experience-mark {
  display: inline-block;
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--action-primary);
  background: currentColor;
  -webkit-mask: var(--opsy-rose-mark) center / contain no-repeat;
  mask: var(--opsy-rose-mark) center / contain no-repeat;
  font-size: 0;
}

/* Rose inside a chat avatar: inherit the avatar's inverse text colour. */
.msg .av .experience-mark {
  width: 20px;
  height: 20px;
  color: inherit;
}

.experience-nav {
  display: flex;
  align-items: center;
  gap: var(--opsy-space-1);
}

.experience-nav a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0 var(--opsy-space-3);
  border-radius: var(--opsy-radius-md);
  color: var(--text-secondary);
  font-size: var(--opsy-text-sm);
  font-weight: 620;
  text-decoration: none;
}

.experience-nav a:hover,
.experience-nav a[aria-current="page"] {
  background: var(--surface-secondary);
  color: var(--text-primary);
}

.experience-main {
  padding:
    clamp(var(--opsy-space-5), 3vw, var(--opsy-space-10))
    clamp(var(--opsy-space-4), 3vw, var(--opsy-space-8))
    calc(var(--opsy-space-12) + env(safe-area-inset-bottom));
}

.page-heading {
  display: grid;
  gap: var(--opsy-space-2);
  margin-bottom: var(--opsy-space-6);
}

.eyebrow {
  color: var(--text-tertiary);
  font-size: var(--opsy-text-xs);
  font-weight: 750;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.page-lede {
  color: var(--text-secondary);
  font-size: var(--opsy-text-md);
}

.lifecycle-note {
  max-width: none;
}

.cluster {
  display: flex;
  align-items: center;
  gap: var(--opsy-space-2);
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: var(--opsy-space-4);
}

.stack-sm {
  display: grid;
  gap: var(--opsy-space-2);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(17rem, 0.7fr);
  gap: var(--opsy-space-6);
  align-items: start;
}

.surface,
.panel,
.card {
  border: 1px solid var(--border-default);
  border-radius: var(--opsy-radius-lg);
  background: var(--surface-primary);
  box-shadow: var(--opsy-shadow-1);
}

.surface {
  padding: clamp(var(--opsy-space-4), 2vw, var(--opsy-space-6));
}

.surface-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--opsy-space-3);
  margin-bottom: var(--opsy-space-4);
}

.surface-header p {
  margin-top: var(--opsy-space-1);
  color: var(--text-secondary);
  font-size: var(--opsy-text-sm);
}

.btn,
.button {
  min-height: 44px;
  border-radius: var(--opsy-radius-md);
  padding: 0.65rem 1rem;
  font-weight: 700;
  line-height: 1.2;
  transition:
    background-color var(--opsy-motion-fast) var(--opsy-ease),
    border-color var(--opsy-motion-fast) var(--opsy-ease),
    color var(--opsy-motion-fast) var(--opsy-ease),
    box-shadow var(--opsy-motion-fast) var(--opsy-ease);
}

.btn-primary,
.button-primary {
  border: 1px solid var(--action-primary);
  background: var(--action-primary);
  color: var(--text-inverse);
  box-shadow: none;
}

.btn-primary:hover,
.button-primary:hover {
  border-color: var(--action-primary-hover);
  background: var(--action-primary-hover);
}

.btn-primary:active,
.button-primary:active {
  border-color: var(--action-primary-active);
  background: var(--action-primary-active);
  transform: none;
}

.btn-secondary,
.button-secondary,
.btn-ghost {
  border: 1px solid var(--border-default);
  background: var(--surface-primary);
  color: var(--text-primary);
}

.btn-secondary:hover,
.button-secondary:hover,
.btn-ghost:hover {
  border-color: var(--border-strong);
  background: var(--surface-secondary);
}

.button-danger {
  border: 1px solid var(--state-danger);
  background: var(--state-danger);
  color: var(--opsy-white);
}

.btn[disabled],
.button[disabled],
button[disabled],
[aria-disabled="true"] {
  cursor: not-allowed;
  filter: saturate(0.55);
  opacity: 0.52;
}

.status,
.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-default);
  border-radius: var(--opsy-radius-pill);
  background: var(--surface-secondary);
  color: var(--text-secondary);
  font-size: var(--opsy-text-xs);
  font-weight: 750;
  letter-spacing: 0.025em;
  line-height: 1;
  padding: 0.35rem 0.65rem;
  text-transform: none;
}

.status::before {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-success,
.pill.ok {
  border-color: color-mix(in srgb, var(--state-success) 32%, var(--border-default));
  background: var(--state-success-soft);
  color: var(--state-success);
}

.status-warning,
.pill.warn {
  border-color: color-mix(in srgb, var(--state-warning) 32%, var(--border-default));
  background: var(--state-warning-soft);
  color: var(--state-warning);
}

.status-danger,
.pill.err {
  border-color: color-mix(in srgb, var(--state-danger) 32%, var(--border-default));
  background: var(--state-danger-soft);
  color: var(--state-danger);
}

.status-info {
  border-color: color-mix(in srgb, var(--state-info) 32%, var(--border-default));
  background: var(--state-info-soft);
  color: var(--state-info);
}

.alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--opsy-space-3);
  padding: var(--opsy-space-4);
  border: 1px solid var(--border-default);
  border-left-width: 4px;
  border-radius: var(--opsy-radius-md);
  background: var(--surface-primary);
}

.alert::before {
  width: 0.625rem;
  height: 0.625rem;
  margin-top: 0.4rem;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.alert-info {
  border-left-color: var(--state-info);
  background: var(--state-info-soft);
  color: var(--state-info);
}

.alert-success {
  border-left-color: var(--state-success);
  background: var(--state-success-soft);
  color: var(--state-success);
}

.alert-warning {
  border-left-color: var(--state-warning);
  background: var(--state-warning-soft);
  color: var(--state-warning);
}

.alert-danger {
  border-left-color: var(--state-danger);
  background: var(--state-danger-soft);
  color: var(--state-danger);
}

.alert-body {
  color: var(--text-primary);
}

.alert-body strong {
  display: block;
  margin-bottom: var(--opsy-space-1);
}

.alert-body p {
  color: var(--text-secondary);
  font-size: var(--opsy-text-sm);
}

.field {
  display: grid;
  gap: var(--opsy-space-2);
}

.field label,
.field-label {
  color: var(--text-primary);
  font-size: var(--opsy-text-sm);
  font-weight: 700;
}

.field-hint,
.field-error {
  font-size: var(--opsy-text-xs);
}

.field-hint {
  color: var(--text-tertiary);
}

.field-error {
  color: var(--state-danger);
}

.field input,
.field textarea,
.field select,
input.input,
textarea.input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border-default);
  border-radius: var(--opsy-radius-md);
  background: var(--surface-primary);
  color: var(--text-primary);
  padding: 0.7rem 0.8rem;
}

.field textarea,
textarea.input {
  min-height: 7rem;
  resize: vertical;
}

.field input:hover,
.field textarea:hover,
.field select:hover,
input.input:hover,
textarea.input:hover {
  border-color: var(--border-strong);
}

.field input:focus,
.field textarea:focus,
.field select:focus,
input.input:focus,
textarea.input:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 18%, transparent);
  outline: none;
}

.field [aria-invalid="true"] {
  border-color: var(--state-danger);
}

.next-action {
  display: grid;
  gap: var(--opsy-space-4);
  padding: var(--opsy-space-5);
  border: 1px solid color-mix(in srgb, var(--action-primary) 32%, var(--border-default));
  border-radius: var(--opsy-radius-lg);
  background: var(--action-primary-soft);
}

.next-action-copy {
  display: grid;
  gap: var(--opsy-space-1);
}

.next-action-copy p {
  color: var(--text-secondary);
  font-size: var(--opsy-text-sm);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: var(--opsy-space-3);
}

.stat {
  padding: var(--opsy-space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--opsy-radius-md);
  background: var(--surface-secondary);
}

.stat dt {
  color: var(--text-tertiary);
  font-size: var(--opsy-text-xs);
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.stat dd {
  margin-top: var(--opsy-space-1);
  color: var(--text-primary);
  font-size: 1.45rem;
  font-weight: 730;
  font-variant-numeric: tabular-nums;
}

:is(ol, ul).lifecycle {
  display: grid;
  grid-template-columns: repeat(5, minmax(7rem, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

:is(ol, ul).lifecycle li {
  position: relative;
  display: grid;
  gap: var(--opsy-space-1);
  min-height: 62px;
  padding: var(--opsy-space-2) var(--opsy-space-3) var(--opsy-space-2) 1.7rem;
  border-top: 2px solid var(--border-default);
  color: var(--text-tertiary);
  font-size: var(--opsy-text-xs);
}

:is(ol, ul).lifecycle li::before {
  position: absolute;
  top: -0.45rem;
  left: 0;
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid var(--surface-primary);
  border-radius: 50%;
  background: var(--border-strong);
  box-shadow: 0 0 0 1px var(--border-default);
  content: "";
}

:is(ol, ul).lifecycle li strong {
  color: var(--text-secondary);
  font-size: var(--opsy-text-sm);
}

:is(ol, ul).lifecycle li[data-complete="true"],
:is(ol, ul).lifecycle li[aria-current="step"] {
  border-color: var(--action-primary);
}

:is(ol, ul).lifecycle li[data-complete="true"]::before,
:is(ol, ul).lifecycle li[aria-current="step"]::before {
  background: var(--action-primary);
}

:is(ol, ul).lifecycle li[aria-current="step"] strong {
  color: var(--text-primary);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--opsy-radius-lg);
  background: var(--surface-primary);
}

.data-table,
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--opsy-text-sm);
}

.data-table th,
.data-table td,
table th,
table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}

.data-table th,
table th {
  background: var(--surface-secondary);
  color: var(--text-secondary);
  font-size: var(--opsy-text-xs);
  font-weight: 760;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.data-table tbody tr:hover,
table tbody tr:hover {
  background: color-mix(in srgb, var(--action-primary-soft) 55%, transparent);
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: var(--opsy-space-3);
  padding: clamp(var(--opsy-space-6), 5vw, var(--opsy-space-10));
  border: 1px dashed var(--border-strong);
  border-radius: var(--opsy-radius-lg);
  background: var(--surface-primary);
}

.empty-state p {
  color: var(--text-secondary);
}

.skeleton {
  overflow: hidden;
  min-height: 0.85rem;
  border-radius: var(--opsy-radius-sm);
  background:
    linear-gradient(
      100deg,
      transparent 30%,
      color-mix(in srgb, var(--surface-raised) 65%, transparent) 50%,
      transparent 70%
    ),
    var(--surface-secondary);
  background-size: 200% 100%;
  animation: opsy-skeleton 1.4s linear infinite;
}

@keyframes opsy-skeleton {
  to {
    background-position-x: -200%;
  }
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: opsy-spin 0.7s linear infinite;
}

@keyframes opsy-spin {
  to {
    transform: rotate(1turn);
  }
}

.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* UX Lab environmental controls also work on any embedded scenario. */
.ux-large-text {
  font-size: 118%;
}

.ux-high-contrast {
  --border-default: var(--text-secondary);
  --border-subtle: color-mix(in srgb, var(--text-secondary) 68%, transparent);
  --border-strong: var(--text-primary);
  --focus-ring: var(--opsy-focus-contrast);
}

.ux-reduced-motion *,
.ux-reduced-motion *::before,
.ux-reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Existing shell refinements */
.topbar,
.editor-bar {
  border-bottom-color: var(--border-subtle);
  background: color-mix(in srgb, var(--surface-canvas) 94%, transparent);
}

.brand {
  font-family: var(--opsy-font-sans);
  font-weight: 750;
  letter-spacing: -0.025em;
}

.chat {
  scrollbar-gutter: stable;
}

.bubble {
  border-color: var(--border-default);
  border-radius: var(--opsy-radius-lg);
  background: var(--surface-primary);
}

.dock {
  background: var(--surface-canvas);
}

@media (max-width: 58rem) {
  .split {
    grid-template-columns: 1fr;
  }

  .experience-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .experience-nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: var(--opsy-space-1);
  }

  :is(ol, ul).lifecycle {
    grid-template-columns: 1fr;
    gap: 0;
    border-left: 2px solid var(--border-default);
  }

  :is(ol, ul).lifecycle li {
    min-height: 50px;
    border-top: 0;
    padding: 0 var(--opsy-space-3) var(--opsy-space-4) var(--opsy-space-5);
  }

  :is(ol, ul).lifecycle li::before {
    top: 0.2rem;
    left: -0.45rem;
  }

  :is(ol, ul).lifecycle li[data-complete="true"],
  :is(ol, ul).lifecycle li[aria-current="step"] {
    border-color: var(--action-primary);
  }
}

@media (max-width: 42rem) {
  .experience-main {
    padding-inline: var(--opsy-space-4);
  }

  .surface-header {
    flex-direction: column;
  }

  .surface-header > .cluster,
  .next-action > .cluster {
    width: 100%;
  }

  .surface-header .btn,
  .surface-header .button,
  .next-action .btn,
  .next-action .button {
    flex: 1;
  }

  .table-responsive-stack table,
  .table-responsive-stack thead,
  .table-responsive-stack tbody,
  .table-responsive-stack tr,
  .table-responsive-stack th,
  .table-responsive-stack td {
    display: block;
  }

  .table-responsive-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table-responsive-stack tr {
    padding: var(--opsy-space-4);
    border-bottom: 1px solid var(--border-default);
  }

  .table-responsive-stack td {
    display: grid;
    grid-template-columns: minmax(7rem, 0.7fr) minmax(0, 1fr);
    gap: var(--opsy-space-3);
    padding: var(--opsy-space-2) 0;
    border: 0;
  }

  .table-responsive-stack td::before {
    color: var(--text-tertiary);
    content: attr(data-label);
    font-size: var(--opsy-text-xs);
    font-weight: 750;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .status::before,
  .alert::before,
  .lifecycle li::before {
    border: 1px solid ButtonText;
  }

  .btn,
  .button,
  .field input,
  .field textarea,
  .field select {
    forced-color-adjust: auto;
  }
}

/* ---------- Literature citations (shared: builder + participant chat) ---------- */
.literature-sources {
  display: block;
  color: var(--text-tertiary);
  font-size: var(--opsy-text-xs);
  line-height: 1.6;
}

.literature-sources .literature-heading { font-weight: 700; }
.literature-sources .literature-source { display: block; }
.literature-sources .literature-source a { color: var(--action-primary); }
.literature-sources .literature-more summary { cursor: pointer; font-weight: 700; }
