:root {
  color-scheme: light;
  font-family: "Aptos", "Segoe UI", sans-serif;
  background: #f3f5f2;
  color: #18201d;
  --ink: #18201d;
  --muted: #586660;
  --line: #d7ddd7;
  --panel: #ffffff;
  --panel-soft: #f8faf7;
  --control: #ffffff;
  --control-hover: #f6f8f5;
  --page-bg: #f3f5f2;
  --grid-line: rgba(24, 32, 29, 0.035);
  --header-bg: rgba(243, 245, 242, 0.93);
  --accent: #256b52;
  --accent-dark: #164c3a;
  --steel: #40566f;
  --blue: #2d639b;
  --amber: #b76f1f;
  --red: #b84035;
  --brand-border: #b7c4bc;
  --subtle-border: #c9d1ca;
  --secondary-hover-border: #b8c2bb;
  --model-bg: #f9fbfa;
  --model-cube-bg: rgba(255, 255, 255, 0.68);
  --model-cube-shadow: rgba(37, 107, 82, 0.12);
  --model-grid-line: rgba(64, 86, 111, 0.09);
  --model-accent-wash: rgba(37, 107, 82, 0.1);
  --live-dot-glow: rgba(37, 107, 82, 0.18);
  --active-shadow: 0 4px 12px rgba(28, 39, 34, 0.08);
  --row-hover: #f4f7f3;
  --badge-queued-bg: #fff4df;
  --badge-rendering-bg: #e8f0fa;
  --badge-complete-bg: #e6f2ec;
  --badge-failed-bg: #fae8e6;
  --online-bg: #e8f3ec;
  --online-border: #b7d5c5;
  --offline-bg: #fae8e6;
  --offline-border: #e7c5c1;
  --drop-border: #9aaaa0;
  --shadow: 0 20px 55px rgba(28, 39, 34, 0.08);
  --accent-wash: rgba(37, 107, 82, 0.1);
  --on-accent: #ffffff;
  --on-red: #ffffff; /* text on a --red fill — light red is dark enough for white (5.5:1) */
  --amber-strong: #8a5210; /* AA-passing amber for small badge text on light washes */
  /* Radius scale — theme-independent, defined once here and inherited everywhere.
     sm = controls/inputs/buttons/chips · md = panels/cards · lg = feature cards/modals · pill */
  --radius-sm: 7px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  /* Spacing scale (4px base step) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  /* Motion grammar (the reduced-motion block already neutralizes these). */
  --dur-fast: 0.12s;
  --dur: 0.16s;
  --dur-slow: 0.25s;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    background: #0d1110;
    color: #eef5f1;
    --ink: #eef5f1;
    --muted: #a7b7af;
    --line: #26312d;
    --panel: #151b19;
    --panel-soft: #111715;
    --control: #101614;
    --control-hover: #1b2421;
    --page-bg: #0d1110;
    --grid-line: rgba(93, 194, 151, 0.07);
    --header-bg: rgba(13, 17, 16, 0.92);
    --accent: #48c995;
    --accent-dark: #2da978;
    --steel: #86a4c8;
    --blue: #6ba8e5;
    --amber: #e3a84c;
    --red: #ef776b;
    --brand-border: #33433d;
    --subtle-border: #2d3a35;
    --secondary-hover-border: #40524b;
    --model-bg: #0f1514;
    --model-cube-bg: rgba(72, 201, 149, 0.09);
    --model-cube-shadow: rgba(72, 201, 149, 0.16);
    --model-grid-line: rgba(107, 168, 229, 0.12);
    --model-accent-wash: rgba(72, 201, 149, 0.16);
    --live-dot-glow: rgba(72, 201, 149, 0.22);
    --active-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    --row-hover: #1a231f;
    --badge-queued-bg: rgba(227, 168, 76, 0.14);
    --badge-rendering-bg: rgba(107, 168, 229, 0.14);
    --badge-complete-bg: rgba(72, 201, 149, 0.14);
    --badge-failed-bg: rgba(239, 119, 107, 0.14);
    --online-bg: rgba(72, 201, 149, 0.13);
    --online-border: rgba(72, 201, 149, 0.38);
    --offline-bg: rgba(239, 119, 107, 0.13);
    --offline-border: rgba(239, 119, 107, 0.36);
    --drop-border: #52665e;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
    --accent-wash: rgba(72, 201, 149, 0.14);
    --on-accent: #06231a;
    --on-red: #06231a; /* dark ink on the lighter dark-theme red (6:1) */
    --amber-strong: #e3a84c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  background: #0d1110;
  color: #eef5f1;
  --ink: #eef5f1;
  --muted: #a7b7af;
  --line: #26312d;
  --panel: #151b19;
  --panel-soft: #111715;
  --control: #101614;
  --control-hover: #1b2421;
  --page-bg: #0d1110;
  --grid-line: rgba(93, 194, 151, 0.07);
  --header-bg: rgba(13, 17, 16, 0.92);
  --accent: #48c995;
  --accent-dark: #2da978;
  --steel: #86a4c8;
  --blue: #6ba8e5;
  --amber: #e3a84c;
  --red: #ef776b;
  --brand-border: #33433d;
  --subtle-border: #2d3a35;
  --secondary-hover-border: #40524b;
  --model-bg: #0f1514;
  --model-cube-bg: rgba(72, 201, 149, 0.09);
  --model-cube-shadow: rgba(72, 201, 149, 0.16);
  --model-grid-line: rgba(107, 168, 229, 0.12);
  --model-accent-wash: rgba(72, 201, 149, 0.16);
  --live-dot-glow: rgba(72, 201, 149, 0.22);
  --active-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  --row-hover: #1a231f;
  --badge-queued-bg: rgba(227, 168, 76, 0.14);
  --badge-rendering-bg: rgba(107, 168, 229, 0.14);
  --badge-complete-bg: rgba(72, 201, 149, 0.14);
  --badge-failed-bg: rgba(239, 119, 107, 0.14);
  --online-bg: rgba(72, 201, 149, 0.13);
  --online-border: rgba(72, 201, 149, 0.38);
  --offline-bg: rgba(239, 119, 107, 0.13);
  --offline-border: rgba(239, 119, 107, 0.36);
  --drop-border: #52665e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  --accent-wash: rgba(72, 201, 149, 0.14);
  --on-accent: #06231a;
  --on-red: #06231a; /* dark ink on the lighter dark-theme red (6:1) */
  --amber-strong: #e3a84c;
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    var(--page-bg);
  background-size: 34px 34px;
  color: var(--ink);
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--control);
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  padding: 12px;
  resize: vertical;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 44px;
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  min-height: 74px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
}

.brand,
.top-nav a {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 850;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0;
  box-shadow: 0 2px 8px var(--model-cube-shadow);
}

.top-nav,
.header-actions,
.hero-actions,
.button-row,
.heading-actions,
.panel-tools,
.theme-control,
.segmented-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-nav {
  justify-content: center;
}

.top-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.top-nav a:hover {
  color: var(--ink);
}

.user-chip,
.backend-chip {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.theme-control {
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.theme-control select {
  width: auto;
  min-height: 38px;
  padding: 0 30px 0 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.backend-chip.online {
  border-color: var(--online-border);
  background: var(--online-bg);
  color: var(--accent);
}

.backend-chip.offline {
  border-color: var(--offline-border);
  background: var(--offline-bg);
  color: var(--red);
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0 16px;
  font-weight: 850;
}

.primary-button {
  background: var(--accent);
  color: var(--on-accent);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-button:disabled,
.ghost-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--ink);
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled) {
  border-color: var(--secondary-hover-border);
  background: var(--control-hover);
}

.link-button {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 850;
}

.full-width {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  align-items: center;
  gap: 54px;
  min-height: calc(100vh - 138px);
  padding: 56px 7vw 34px;
}

.hero-copy {
  max-width: 720px;
}

.hero-copy h1 {
  font-size: clamp(2.4rem, 9vw, 82px);
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.hero-copy p {
  max-width: 620px;
  font-size: 19px;
}

.ops-panel,
.workflow-strip article,
.auth-card,
.side-rail,
.workspace-panel,
.result-card,
.log-panel,
.output-panel,
.timeline-panel,
.settings-grid article,
.detail-info-grid article,
.stat-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.ops-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.ops-header {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px var(--live-dot-glow);
}

.model-preview {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  border: 1px solid var(--subtle-border);
  border-radius: 7px;
  background:
    linear-gradient(135deg, var(--model-accent-wash), transparent 46%),
    linear-gradient(90deg, var(--model-grid-line) 1px, transparent 1px),
    linear-gradient(var(--model-grid-line) 1px, transparent 1px),
    var(--model-bg);
  background-size: auto, 26px 26px, 26px 26px, auto;
}

.model-cube {
  position: absolute;
  top: 78px;
  left: 50%;
  width: 116px;
  height: 116px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: linear-gradient(135deg, var(--model-cube-bg), transparent 70%);
  box-shadow: 20px 20px 0 var(--model-cube-shadow);
}

.model-axis {
  position: absolute;
  background: var(--accent);
}

.x-axis {
  right: 34px;
  bottom: 38px;
  width: 90px;
  height: 2px;
}

.y-axis {
  right: 34px;
  bottom: 38px;
  width: 2px;
  height: 90px;
}

.ops-metrics {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr;
  gap: 12px;
}

.ops-metrics div,
.rail-stat,
.stat-grid article {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.ops-metrics span,
.rail-stat span,
.stat-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.ops-metrics strong,
.rail-stat strong,
.stat-grid strong {
  color: var(--ink);
  font-size: 18px;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 0 7vw 68px;
}

.workflow-strip article {
  min-height: 190px;
  padding: 24px;
}

.workflow-strip span {
  color: var(--accent);
  font-size: 28px;
  font-weight: 900;
  opacity: 0.4;
}

.auth-view {
  display: none;
  min-height: calc(100vh - 74px);
  padding: 54px 20px;
  place-items: center;
}

.auth-view.active {
  display: grid;
}

.auth-card {
  display: grid;
  gap: 16px;
  width: min(100%, 420px);
  padding: 30px;
}

.form-note {
  margin: 0;
  font-size: 13px;
}

/* Signup captcha (Cloudflare Turnstile): collapse the slot entirely when no key is
   configured so it doesn't add a phantom gap in the auth card. */
.signup-captcha:empty {
  display: none;
}

.dashboard-view {
  padding: 34px 4vw 72px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  max-width: 1280px;
  margin: 0 auto;
}

.single-panel {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1080px;
}

.side-rail,
.workspace-panel {
  padding: 22px;
}

.side-rail {
  position: sticky;
  top: 96px;
  align-self: start;
  display: grid;
  gap: 14px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.page-heading h1,
.auth-card h1,
.job-summary h1 {
  font-size: 40px;
}

.segmented-control {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.segmented-control button {
  min-height: 34px;
  padding: 0 13px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.segmented-control button.active {
  background: var(--control);
  color: var(--ink);
  box-shadow: var(--active-shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.table-panel {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: var(--panel);
}

th,
td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: var(--row-hover);
}

/* Folder group headers in the dashboard table (📁 marks the group without
   relying on color). Not clickable — they're labels, not renders. */
tbody tr.folder-row {
  cursor: default;
}

tbody tr.folder-row:hover {
  background: transparent;
}

tbody tr.folder-row td {
  padding-top: 14px;
  padding-bottom: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
  border-bottom: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.project-name {
  display: grid;
  gap: 3px;
}

.project-name strong {
  color: var(--ink);
}

.project-name span {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.badge.queued {
  background: var(--badge-queued-bg);
  color: var(--amber-strong);
}

.badge.rendering,
.badge.processing {
  background: var(--badge-rendering-bg);
  color: var(--blue);
}

.badge.complete {
  background: var(--badge-complete-bg);
  color: var(--accent);
}

.badge.failed {
  background: var(--badge-failed-bg);
  color: var(--red);
}

/* G1: cancelled = a deliberate stop, not an error — neutral gray, and the label
   text itself ("Cancelled") carries the state (colorblind-safe, never hue-only). */
.badge.cancelled {
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  color: var(--muted);
}

/* The cancel action reads as a warning-tier control: outlined red, filled on hover. */
.cancel-job-button {
  border-color: var(--red);
  color: var(--red);
}
.cancel-job-button:hover:not(:disabled) {
  background: var(--red);
  color: var(--on-red);
}

.back-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.upload-layout {
  display: grid;
  gap: 18px;
}

.drop-zone {
  place-items: center;
  min-height: 210px;
  padding: 28px;
  border: 1px dashed var(--drop-border);
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--model-grid-line) 1px, transparent 1px),
    linear-gradient(var(--model-grid-line) 1px, transparent 1px),
    var(--model-bg);
  background-size: 24px 24px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--accent);
}

/* The real file input is visually hidden, so keyboard + screen-magnifier users had no
   focus indicator on the primary upload control. Light up the whole drop-zone on focus. */
.drop-zone:focus-within {
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 3px var(--accent-wash);
  outline: none;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone span {
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
}

.drop-zone strong {
  color: var(--accent);
}

.drop-zone small {
  color: var(--muted);
}

.form-grid,
.detail-grid,
.detail-info-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.detail-grid {
  align-items: stretch;
  margin-bottom: 18px;
}

.secondary-detail-grid {
  align-items: start;
  margin-top: 18px;
  margin-bottom: 0;
}

.detail-info-grid {
  grid-template-columns: 0.8fr 1fr 1.6fr;
  margin-bottom: 18px;
}

.detail-info-grid article {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.detail-info-grid span,
.file-row span,
.log-entry time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-info-grid strong {
  color: var(--ink);
  line-height: 1.4;
}

.job-summary,
.result-card,
.log-panel,
.output-panel {
  padding: 22px;
}

.job-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--model-accent-wash), transparent 50%),
    var(--panel);
}

.result-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

/* (removed dead .render-preview-img — superseded by .result-preview) */

.compact-label {
  gap: 6px;
  font-size: 12px;
}

.action-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.secondary-detail-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.panel-tools {
  justify-content: end;
  flex-wrap: wrap;
}

.refresh-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.compact-segments button {
  min-height: 30px;
  padding: 0 10px;
}

.log-list,
.output-list {
  display: grid;
  gap: 10px;
}

.log-entry,
.file-row {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.log-entry {
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 10px;
}

.log-entry::before {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.log-entry.error::before {
  background: var(--red);
}

.log-entry.warning::before {
  background: var(--amber);
}

.log-entry p,
.file-row p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.file-row button {
  justify-self: start;
  min-height: 34px;
  margin-top: 4px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.file-row button:hover {
  border-color: var(--secondary-hover-border);
  background: var(--control-hover);
}

.empty-state {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--drop-border);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
}

.timeline-panel {
  display: grid;
  gap: 0;
  margin-bottom: 18px;
  padding: 6px 20px;
}

.timeline-step {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 14px;
  padding: 18px 0;
}

.timeline-step:not(:last-child)::before {
  position: absolute;
  top: 42px;
  left: 10px;
  width: 2px;
  height: calc(100% - 18px);
  background: var(--line);
  content: "";
}

.timeline-step > span {
  z-index: 1;
  width: 22px;
  height: 22px;
  border: 2px solid var(--brand-border);
  border-radius: 999px;
  background: var(--control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.timeline-step.complete > span,
.timeline-step.active > span {
  border-color: var(--accent);
  background: var(--accent);
}

.timeline-step.failed-step > span {
  border-color: var(--red);
  background: var(--red);
}

/* Colorblind-safe: never state-by-hue alone. Done dots carry a ✓ and failed dots
   an ✕ so green-vs-red never has to be told apart by color. (Active pulses below.) */
.timeline-step.complete > span::after {
  content: "✓";
  color: var(--on-accent);
}
.timeline-step.failed-step > span::after {
  content: "✕";
  color: var(--on-red);
}

/* The active step is styled the same as completed ones — give the CURRENT stage a soft
   pulsing halo so "what's happening right now" is obvious at a glance during a render. */
.timeline-step.active > span {
  animation: stepPulse 1.9s ease-out infinite;
}
@keyframes stepPulse {
  0% { box-shadow: 0 0 0 0 var(--accent-wash); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .timeline-step.active > span { animation: none; } }

.timeline-step strong {
  display: block;
  margin-bottom: 3px;
}

.timeline-step p {
  margin: 0;
}

.settings-grid article {
  padding: 22px;
}

@media (max-width: 940px) {
  .site-header {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px 20px;
  }

  .top-nav,
  .header-actions {
    justify-content: start;
    flex-wrap: wrap;
  }

  .hero,
  .app-shell,
  .detail-grid {
    /* minmax(0, 1fr), not 1fr: a plain 1fr track has min-width=auto (=min-content),
       so a wide child (the data table) blows the column out past the viewport and
       drags the whole layout into horizontal scroll. minmax(0,…) lets the column
       shrink so .table-panel's own overflow-x:auto handles the scrolling. */
    grid-template-columns: minmax(0, 1fr);
  }

  .side-rail {
    position: static;
  }

  .hero {
    min-height: auto;
    padding: 44px 20px;
  }

  .workflow-strip,
  .stat-grid,
  .form-grid,
  .detail-info-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .workflow-strip {
    padding: 0 20px 44px;
  }

  .dashboard-view {
    padding: 24px 20px 44px;
  }
}

@media (max-width: 560px) {
  .hero-actions,
  .button-row,
  .heading-actions,
  .panel-heading,
  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions button,
  .button-row button {
    width: 100%;
  }

  .page-heading h1,
  .auth-card h1,
  .job-summary h1 {
    font-size: 32px;
  }
}

/* Render output preview (Phase 6) */
.result-preview {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

/* Render settings (Phase 2: three-tier presets / overrides / custom) */
.settings-card {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.settings-card legend {
  padding: 0 8px;
  color: var(--steel);
  font-size: 13px;
  font-weight: 900;
}

.settings-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.settings-mode label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

/* Override the global `input { width: 100% }` so radios stay small circles. */
.settings-mode input[type="radio"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

.settings-fields select:disabled,
.settings-fields input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Dashboard gallery + pagination (M1 — consumer core) */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.gallery-grid .empty-row {
  grid-column: 1 / -1;
}
.gallery-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--panel-soft);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.gallery-thumb {
  aspect-ratio: 4 / 3;
  background-size: cover;
  background-position: center;
  background-color: var(--model-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-meta {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gallery-meta strong {
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-meta span {
  font-size: 0.78rem;
  color: var(--muted);
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}
.pagination:empty {
  display: none;
}
.page-info {
  font-size: 0.85rem;
  color: var(--muted);
}
.empty-row {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

/* Notification bell (M1 — consumer core) */
.notif-wrap { position: relative; }
.notif-bell {
  position: relative;
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.notif-bell:hover { background: var(--control-hover); }
.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--red);
  color: var(--on-red);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  /* On phones a fixed 320px dropdown anchored right:0 runs off the left edge.
     Cap it to the viewport so it always stays on-screen. */
  max-width: calc(100vw - 32px);
  max-height: 380px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 6px;
}
.notif-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.notif-item:hover { background: var(--row-hover); }
.notif-item.unread { background: var(--accent-wash); }
.notif-item strong { font-size: 0.85rem; }
.notif-item span { font-size: 0.78rem; color: var(--muted); }
.notif-item time { font-size: 0.7rem; color: var(--muted); }
.notif-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* M2 — engagement depth (feedback, onboarding, upload progress, drag-drop) */
.feedback-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.feedback-row > span:first-child { font-size: 0.85rem; color: var(--muted); }
.feedback-btn {
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.feedback-btn:hover { background: var(--control-hover); }
.feedback-btn.active { border-color: var(--accent); background: var(--accent-wash); }
.onboarding-banner {
  border: 1px solid var(--accent);
  background: var(--accent-wash);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 18px;
}
.onboarding-banner h2 { margin: 0 0 6px; }
.onboarding-banner p { margin: 0 0 12px; color: var(--muted); }
.upload-progress { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.new-folder-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.new-folder-row input { flex: 1 1 180px; min-width: 160px; }
.new-folder-row .action-status { flex-basis: 100%; }
.progress-bar { width: 100%; height: 8px; background: var(--model-bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }
.progress-label { font-size: 0.8rem; color: var(--muted); }
.drop-zone.dragging { border-color: var(--accent); background: var(--accent-wash); }

/* M7 — soft render-time expectation note */
.render-time-note { margin-top: 8px; font-size: 0.82rem; color: var(--amber); }

/* M5 — saved render presets */
.saved-presets { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.saved-presets-title { font-size: 0.74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.saved-preset-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.saved-preset-empty { font-size: 0.82rem; color: var(--muted); }
.saved-preset-chip { display: inline-flex; align-items: center; background: var(--control); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.saved-preset-apply { background: none; border: none; color: var(--ink); padding: 5px 4px 5px 12px; font-size: 0.82rem; cursor: pointer; }
.saved-preset-apply:hover { color: var(--accent); }
.saved-preset-del { background: none; border: none; color: var(--muted); padding: 5px 10px 5px 6px; font-size: 1rem; line-height: 1; cursor: pointer; }
.saved-preset-del:hover { color: var(--red); }
.saved-preset-save { display: flex; gap: 8px; }
.saved-preset-save input { flex: 1; }
#savedPresetStatus.error { color: var(--red); }

/* M5 — project tags + search */
.dashboard-search { margin-bottom: 14px; }
.dashboard-search input { width: 100%; max-width: 440px; }
.tag-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag-chip { display: inline-block; background: var(--panel-soft); color: var(--accent); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 0.7rem; font-weight: 600; }
.detail-tags { margin: 4px 0 8px; }
.detail-tags-head span { font-size: 0.74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-tags .tag-chips { margin: 6px 0 8px; }
.tag-empty { font-size: 0.82rem; color: var(--muted); }
.detail-tags-edit { display: flex; gap: 8px; }
.detail-tags-edit input { flex: 1; }
#detailTagStatus.error { color: var(--red); }

/* M2 — SSE live progress */
.live-progress { margin: 6px 0 10px; font-size: 0.85rem; color: var(--accent); font-weight: 600; animation: livePulse 1.4s ease-in-out infinite; }
/* Click-to-zoom lightbox for a finished render */
.img-lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(5,8,7,0.92); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.img-lightbox img { max-width: 96vw; max-height: 94vh; border-radius: 8px; box-shadow: 0 24px 80px rgba(0,0,0,0.6); }
/* iOS zooms the page when a focused input's font-size is < 16px — pin a floor on phones */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }
}
/* Self-serve delete (destructive, understated until hovered) */
.text-danger-button { background: transparent; border: 1px solid transparent; color: var(--muted); font-size: 0.85rem; padding: 8px; border-radius: var(--radius-md); cursor: pointer; margin-top: 6px; }
.text-danger-button:hover { color: #ef776b; border-color: #ef776b44; background: #ef776b11; }

/* Settings danger zone (delete account). The ⚠ in the legend + border carry the
   "danger" signal alongside color (colorblind-safe: never hue alone). */
.danger-card { border-color: var(--red); }
.danger-card legend { color: var(--red); font-weight: 700; }
.danger-button {
  background: var(--red);
  color: var(--on-red);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
.danger-button:hover { filter: brightness(1.08); }
.danger-button:disabled { opacity: 0.6; cursor: not-allowed; }
/* Classroom invite link + QR */
.class-invite { display: flex; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; align-items: center; }
.class-invite input { flex: 1; min-width: 220px; padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--model-bg); color: var(--accent); font: 0.85rem monospace; }

/* Assignments (teacher posts → students turn in → X of N board) */
.assignment-context { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 14px; border: 1px solid var(--accent); border-radius: var(--radius-md); background: var(--model-bg); font-weight: 600; }
.asg-list { display: flex; flex-direction: column; gap: 10px; }
.asg-row { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 14px; background: var(--model-bg); }
.asg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.asg-actions { margin-top: 8px; align-items: center; }
.asg-actions select { max-width: 260px; }
.asg-board { margin-top: 10px; }
.asg-create { display: grid; gap: 8px; margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius-md); }
.asg-create label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Live render progress fill: a slow travelling sheen over the accent bar so an in-progress
   render reads as actively working, not stalled — reassurance during an expensive render. */
#liveProgressFill {
  background-image: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.22) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: progressSheen 1.6s linear infinite;
}
@keyframes progressSheen { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
@media (prefers-reduced-motion: reduce) { #liveProgressFill { animation: none; } }

/* M3 — settings recommendation */
.recommend-row { display: flex; align-items: flex-end; gap: 10px; margin: 10px 0 4px; flex-wrap: wrap; }
.recommend-purpose { display: flex; flex-direction: column; font-size: 0.8rem; gap: 4px; }
#recommendRationale { color: var(--accent); }

/* M5 — accessibility pass: visible keyboard focus + respect reduced-motion */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* M5 — mobile polish: keep the settings grid + heading actions from overflowing on phones */
@media (max-width: 560px) {
  .settings-fields { grid-template-columns: 1fr; }
  .heading-actions { flex-wrap: wrap; gap: 8px; }
  .saved-preset-save, .detail-tags-edit, .recommend-row { flex-wrap: wrap; }
  .dashboard-search input { max-width: 100%; }

  /* On phones the bell sits mid-row, so a right:0 dropdown anchored to the small
     .notif-wrap runs off the left edge. Anchor it to the header instead and span
     the viewport so it stays on-screen. (Must come AFTER the base .notif rules in
     source order — media queries don't add specificity.) */
  .notif-wrap { position: static; }
  .notif-dropdown {
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
  }
}

/* ==========================================================================
   Previously-undefined utility classes. These were referenced in index.html /
   script.js but had no rule, so they rendered as default (un-muted, full-size)
   text — the single biggest source of the "lots of small holes" feeling.
   ========================================================================== */

/* The standard secondary-text class — by far the most widely-used missing rule
   (Classes view, re-render note, visibility note, every classroom JS string). */
.muted-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Inline "(optional)" label qualifier. */
.field-hint {
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
}

/* Helper text under an input (e.g. the Discord webhook hint). Resets the bold
   weight the parent <label> would otherwise force onto the <small>. */
.field-help {
  display: block;
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

/* "Tweak & re-render" <details> wrapper + summary. */
.rerender-tweak {
  margin: var(--space-1) 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}
.rerender-tweak > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  color: var(--ink);
}
.rerender-tweak[open] > summary {
  margin-bottom: 8px;
}

.saved-presets-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

/* Inline code — classroom join codes and the like. */
code {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-soft);
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.9em;
}

/* Classroom list + detail. */
.class-list {
  display: grid;
  gap: var(--space-2);
}
.class-list-heading {
  margin-top: var(--space-5);
}
#classJoinCode {
  text-transform: uppercase;
}
.class-detail {
  margin-top: var(--space-5);
}
.class-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}
.class-row strong {
  color: var(--ink);
}
.class-detail h3 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 15px;
}
.class-detail ul {
  margin: 0 0 var(--space-2);
  padding-left: 18px;
  color: var(--ink);
}
.class-detail li {
  margin: 2px 0;
}

/* Class submissions table — overrides the global table{min-width:820px} that
   would otherwise overflow the classroom panel (it has no scroll wrapper). */
.mini-table {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.mini-table th,
.mini-table td {
  padding: 8px 12px;
  font-size: 13px;
}

/* Gallery thumbnail states (JS adds .placeholder before load, .loaded after). */
.gallery-thumb.placeholder {
  background: var(--model-bg);
}
.gallery-thumb {
  transition: opacity var(--dur-slow) var(--ease);
}
.gallery-thumb:not(.loaded) {
  opacity: 0.65;
}
.gallery-thumb.loaded {
  opacity: 1;
  background-color: transparent;
}

/* ==========================================================================
   Accessibility utilities — screen-reader-only text + skip link.
   ========================================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 850;
  text-decoration: none;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
}

/* Current-page indicator in the top nav (set by showView). */
.top-nav a.active {
  position: relative;
  color: var(--ink);
}
.top-nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* ==========================================================================
   Form feedback — focus ring, placeholder, red error variant, drop-zone states.
   ========================================================================== */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
.action-status.error,
.form-note.error,
#uploadPreflight.error,
#recommendRationale.error {
  color: var(--red);
}
.drop-zone.drop-error {
  border-color: var(--red);
}
.drop-zone.drop-error strong {
  color: var(--red);
}
.drop-zone.has-file {
  border-style: solid;
  border-color: var(--accent);
}

/* Checkboxes/radios must not stretch to the global input width. */
input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--accent);
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-grow {
  flex: 1;
  min-width: 0;
}

/* Visibility / license rows (detail view) — tokenized, no inline opacity. */
.visibility-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.visibility-row label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* Result-card control grouping (Primary / Share & re-render / Delivery). */
.result-more {
  margin-top: var(--space-1);
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.result-more > summary {
  padding: 4px 0;
  cursor: pointer;
  font-weight: 850;
  color: var(--ink);
}
.result-more[open] > summary {
  margin-bottom: 8px;
}

/* Operator/staff admin zone demarcation. Hidden by default (defense-in-depth):
   applyRoleVisibility() reveals it ONLY for a confirmed signed-in operator, so a
   logged-out visitor can never flash the staff controls. */
#operatorActions {
  display: none;
  position: relative;
  padding: 14px 12px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}
#operatorActions::before {
  content: "Staff tools";
  position: absolute;
  top: -9px;
  left: 12px;
  padding: 0 6px;
  background: var(--panel);
  font-size: 11px;
  font-weight: 850;
  color: var(--muted);
}

/* Long-content overflow guards (file names, pasted notes, share URLs). */
#detailName,
.job-summary h1,
.project-name strong,
.project-name span,
.detail-info-grid strong,
.action-status {
  overflow-wrap: anywhere;
}

/* Loading skeleton shimmer (reduced-motion block neutralizes the animation). */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--panel-soft);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--row-hover), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* ==========================================================================
   Motion layer — transitions, press states, and tasteful entrance animations.
   The prefers-reduced-motion block above neutralizes all of these.
   ========================================================================== */
.primary-button,
.secondary-button,
.ghost-button,
.link-button,
.compact-button,
.file-row button,
.notif-bell,
.feedback-btn,
.saved-preset-apply,
.saved-preset-del,
.segmented-control button {
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.top-nav a {
  transition: color var(--dur) var(--ease);
}
tbody tr {
  transition: background-color var(--dur) var(--ease);
}
.drop-zone {
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.ghost-button:active:not(:disabled),
.compact-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

@keyframes liveDotPulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px var(--live-dot-glow);
  }
  50% {
    box-shadow: 0 0 0 8px transparent;
  }
}
.live-dot {
  animation: liveDotPulse 1.8s ease-in-out infinite;
}
@keyframes viewIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.view.active,
.auth-view.active {
  animation: viewIn 0.16s ease both;
}
@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.notif-dropdown:not([hidden]) {
  animation: dropIn var(--dur) ease both;
}
.timeline-step > span {
  transition: background-color var(--dur-slow) var(--ease), border-color var(--dur-slow) var(--ease),
    box-shadow var(--dur-slow) var(--ease);
}

/* ==========================================================================
   Mobile refinements (extend / complement the existing 940px + 560px blocks).
   ========================================================================== */
@media (max-width: 940px) {
  .top-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 14px;
  }
  .user-chip {
    display: none;
  }
  .theme-control span {
    display: none;
  }
  .header-actions {
    justify-content: space-between;
    width: 100%;
  }
  /* Full-bleed notification dropdown from the header-collapse breakpoint down. */
  .notif-wrap {
    position: static;
  }
  .notif-dropdown {
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
  }
}

@media (max-width: 760px) {
  .detail-grid,
  .detail-info-grid,
  .secondary-detail-grid {
    grid-template-columns: 1fr;
  }
  .page-heading {
    flex-direction: column;
    align-items: stretch;
  }
  .heading-actions {
    flex-wrap: wrap;
    width: 100%;
    gap: 14px;
  }
  /* Keep the first column visible as a scroll anchor in the wide data table. */
  .table-panel th:first-child,
  .table-panel td:first-child {
    position: sticky;
    left: 0;
    background: var(--panel);
    z-index: 1;
  }
  /* Keep the pinned first column in sync with the row hover/tap tint. */
  .table-panel tbody tr:hover td:first-child,
  .table-panel tbody tr:focus-visible td:first-child {
    background: var(--row-hover);
  }
}

@media (max-width: 560px) {
  .segmented-control button,
  .compact-button,
  .file-row button {
    min-height: 40px;
  }
  .compact-segments button {
    min-height: 36px;
  }
  .notif-bell {
    padding: 9px 12px;
  }
  .saved-preset-apply,
  .saved-preset-del {
    padding-top: 9px;
    padding-bottom: 9px;
  }
  .visibility-row {
    flex-direction: column;
    align-items: stretch;
  }
  .visibility-row label {
    white-space: normal;
  }
  .drop-zone {
    min-height: 160px;
    padding: 20px;
  }
  .drop-zone span {
    font-size: 17px;
  }
  .side-rail p {
    display: none;
  }
}

/* ==========================================================================
   Component classes introduced by the markup pass (hero trust row, footer,
   main focus target, grouped detail controls).
   ========================================================================== */
.accent-word {
  color: var(--accent);
}
.hero-trust {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.hero-trust li {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.hero-trust li::before {
  content: "✓";
  color: var(--accent);
  font-weight: 900;
}
.hero-sample {
  margin: 14px 0 0;
  font-size: 14px;
}
.hero-sample a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 20px;
  max-width: 1100px;
  margin: 24px auto 40px;
  padding: 18px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.site-footer strong {
  color: var(--ink);
}
.site-footer a {
  padding: 6px 4px;
  color: var(--accent);
  text-decoration: none;
}

#mainContent {
  scroll-margin-top: 84px;
}
#mainContent:focus {
  outline: none;
}

.rerender-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.result-more > *:not(summary) {
  margin-top: 10px;
}

/* ---- AI render copilot (per-render chat) ----
   Speaker is marked by a TEXT label + alignment (not color alone). */
.ai-chat-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  background: var(--panel);
}
.ai-chat-privacy { max-width: 260px; text-align: right; }
.ai-chat-messages {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}
.ai-chat-empty { font-size: 0.85rem; color: var(--muted); }
.ai-chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--model-bg);
}
.ai-chat-msg .who {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.ai-chat-msg p { margin: 0; font-size: 0.9rem; line-height: 1.45; white-space: pre-wrap; }
.ai-chat-msg.from-user { align-self: flex-end; border-style: dashed; }
.ai-chat-msg.from-ai { align-self: flex-start; }
.ai-chat-msg.chat-error p { color: var(--amber); }
.ai-chat-form { display: flex; gap: 8px; }
.ai-chat-form input { flex: 1; min-width: 0; }
