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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--color-text);
  background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
}

/* Shell */

.shell {
  display: flex;
  min-height: 100vh;
}

/* The sidebar stays in view while long pages scroll. */
.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  width: var(--sidebar-width);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px 18px;
  background: var(--color-surface-sunken);
}

/* Mark and wordmark as in assets/brand/logo.svg: "dental" in navy,
   "clarity" and the mark in dental blue, the same on every screen. */
.wordmark {
  display: flex;
  align-items: center;
  gap: 0.3em;
  padding: 0 6px 26px;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--logo-ink);
}

.logo-mark {
  flex: none;
  width: 1.3em;
  height: 1.3em;
  fill: var(--color-primary);
}

.wordmark-accent {
  color: var(--color-primary);
}

.nav-link {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text-strong);
  font-size: var(--text-md);
  transition:
    background-color var(--dur-base) var(--ease-standard),
    color var(--dur-base) var(--ease-standard),
    transform var(--dur-fast) var(--ease-standard);
}

.nav-link svg {
  flex: none;
  stroke: var(--color-text-muted);
  transition: stroke var(--dur-base) var(--ease-standard);
}

.nav-link:hover {
  background: var(--color-border-faint);
}

.nav-link:active {
  transform: scale(var(--press-scale));
}

.nav-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link[aria-current="page"] {
  /* Same blue as .button.primary: white text needs 4.5:1, which #2a7dd1 misses. */
  background: #1f72c4;
  color: #ffffff;
  font-weight: 600;
}

.nav-link[aria-current="page"] svg {
  stroke: #ffffff;
}

.sidebar-spacer {
  flex: 1;
}

.demo-badge {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px dashed #c9d2de;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--color-text-subtle);
}

.demo-badge strong {
  color: var(--color-text-strong);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-page) var(--space-page);
  outline: none;
  view-transition-name: staff-main;
}

/* Page content fills the column up to a per-screen maximum, centered, so
   wide monitors get wider tables instead of empty gutters. Screens built
   around one card use the narrower maximum. */
.main > * {
  width: 100%;
  max-width: var(--page-max, var(--staff-max));
  margin-inline: auto;
}

.main:has(.patient-card),
.main:has(.settings-card) {
  --page-max: var(--staff-narrow-max);
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -64px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #1f72c4;
  color: #ffffff;
  font-weight: 600;
  transition: top var(--dur-fast) var(--ease-standard);
}

.skip-link:focus {
  top: 12px;
}

.topbar {
  height: 72px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sync-pill {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.sync-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
}

/* Status cards */

.status-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-gap);
}

.status-card {
  min-height: 78px;
  padding: 16px 16px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.status-card h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
}

.status-card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.status-card.ready { background: var(--status-ready-bg); border-color: var(--status-ready-border); color: var(--status-ready-fg); }
.status-card.generating { background: var(--status-generating-bg); border-color: var(--status-generating-border); color: var(--status-generating-fg); }
.status-card.changed { background: var(--status-changed-bg); border-color: var(--status-changed-border); color: var(--status-changed-fg); }
.status-card.review { background: var(--status-review-bg); border-color: var(--status-review-border); color: var(--status-review-fg); }

/* Section header */

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: var(--space-section) auto 14px;
}

.section-head h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-head p {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* Data table */

.table {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  font-size: var(--text-sm);
}

.table th {
  height: 38px;
  padding: 0 12px;
  background: var(--color-surface-sunken);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
}

.table td {
  height: var(--row-height);
  padding: 0 12px;
  border-top: 1px solid var(--color-border-faint);
  transition: background-color var(--dur-fast) var(--ease-standard);
}

.table tbody tr:hover td {
  background: #fafbfc;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.table .pill {
  animation: dc-fade-in var(--dur-base) var(--ease-standard);
}

.table th:first-child,
.table td:first-child {
  padding-left: 18px;
}

.table .num {
  font-variant-numeric: tabular-nums;
}

.table .name {
  font-weight: 600;
}

.table .action {
  color: var(--color-primary-strong);
  font-weight: 600;
  white-space: nowrap;
}

.table .num {
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.pill.not-started { background: var(--color-border-faint); color: var(--color-text-muted); }
.pill.ready { background: var(--status-ready-bg); color: var(--status-ready-fg); }
.pill.generating { background: var(--status-generating-bg); color: var(--status-generating-fg); }
.pill.changed { background: var(--status-changed-bg); color: var(--status-changed-fg); }
.pill.review { background: var(--status-review-bg); color: var(--status-review-fg); }

/* Notices */

.notice {
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
}

.notice.error {
  border-color: var(--status-review-border);
  background: var(--status-review-bg);
  color: var(--status-review-fg);
}

/* A failed sign-out, shown above the page it left in place. */
.shell-error {
  margin-top: var(--space-page);
}

/* Reduced motion: the tokens already remove movement (see tokens.css);
   progress bars jump instead of sliding. */
@media (prefers-reduced-motion: reduce) {
  .progress-fill {
    transition: none;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Sign-in, setup and lock screens */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--color-surface-sunken);
}

.auth-card {
  width: 100%;
  max-width: clamp(420px, 12vw + 266px, 520px);
  padding: clamp(28px, 0.8vw + 18px, 40px);
  animation: dc-scale-in var(--dur-slow) var(--ease-emphasized) backwards;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.auth-card .wordmark {
  padding: 0 0 20px;
}

.auth-card h1 {
  margin: 0;
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
}

.auth-subtitle,
.auth-text,
.auth-note {
  margin: 6px 0 20px;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text-muted);
}

.auth-note {
  margin: 18px 0 0;
  color: var(--color-text-subtle);
}

/* Lock screen: the main action, then sign-out with its confirmation. */
.lock-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lock-body .auth-text {
  margin: 0 0 8px;
}

.lock-body > .button,
.lock-body > a.button {
  justify-content: center;
}

.lock-sign-out {
  align-self: center;
}

.lock-confirm {
  margin-top: 4px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--status-review-bg);
  color: var(--status-review-fg);
  font-size: var(--text-sm);
  line-height: 1.45;
  animation: dc-rise-in var(--dur-base) var(--ease-emphasized) backwards;
}

.lock-confirm-text {
  margin: 0 0 10px;
}

.lock-confirm-actions {
  display: flex;
  gap: 8px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-strong);
}

.field input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #868e9c;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 400;
  color: var(--color-text);
  transition:
    border-color var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-base) var(--ease-standard);
}

.field input:focus-visible {
  box-shadow: 0 0 0 4px var(--color-primary-soft);
}

.field input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
  border-color: var(--color-primary);
}

.field small {
  font-weight: 400;
  color: var(--color-text-subtle);
}

.form-error {
  animation: dc-rise-in var(--dur-base) var(--ease-emphasized) backwards;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--status-review-bg);
  color: var(--status-review-fg);
  font-size: var(--text-sm);
}

.button {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font: inherit;
  font-weight: 600;
  color: var(--color-text-strong);
  cursor: pointer;
  transition:
    background-color var(--dur-base) var(--ease-standard),
    border-color var(--dur-base) var(--ease-standard),
    color var(--dur-base) var(--ease-standard),
    box-shadow var(--dur-base) var(--ease-standard),
    opacity var(--dur-base) var(--ease-standard),
    transform var(--dur-fast) var(--ease-standard);
}

.button:hover:not(:disabled, [aria-disabled="true"]) {
  background: var(--color-surface-sunken);
  border-color: #b8c0cc;
}

.button:active:not(:disabled, [aria-disabled="true"]) {
  transform: scale(var(--press-scale));
}

.button.primary {
  border-color: #1f72c4;
  background: #1f72c4;
  color: #ffffff;
}

.button.primary:hover:not(:disabled, [aria-disabled="true"]) {
  border-color: #1a65b0;
  background: #1a65b0;
  box-shadow: 0 2px 8px rgba(31, 114, 196, 0.25);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.nav-button {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* Links styled as buttons */

a.button {
  display: inline-flex;
  align-items: center;
}

.table .name a:hover,
.table .action a:hover,
.breadcrumb a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--color-text-subtle);
}

/* Patient directory */

/* The Open link column fits its link; the spare width goes to the name. */
.directory th:last-child,
.directory td.action {
  width: 1%;
  padding-right: 18px;
  text-align: right;
}

.directory th:first-child {
  width: 26%;
}

.search-field {
  position: relative;
  max-width: 560px;
  margin-bottom: 18px;
}

.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  stroke: var(--color-text-muted);
  pointer-events: none;
}

.search-field input {
  transition:
    border-color var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-base) var(--ease-standard);
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 1px solid #868e9c;
  border-radius: 10px;
  font: inherit;
  color: var(--color-text);
}

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

.search-field input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-soft);
}

/* Narrow items line up with the left edge of the centered page column. */
.search-field,
.settings-card {
  margin-left: max(0px, (100% - var(--page-max, var(--staff-max))) / 2);
  margin-right: auto;
}

/* Patient page */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-md);
  color: var(--color-text-subtle);
}

.breadcrumb [aria-current="page"] {
  font-weight: 600;
  color: var(--color-text);
}

.crumb-sep {
  color: var(--color-text-faint);
}

.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
}

.patient-head {
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.patient-id {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  background: var(--color-primary-tint);
  color: var(--color-primary-strong);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.patient-name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.patient-meta {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

.plan-chip,
.plan-select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid #868e9c;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
}

.plan-chip {
  border-color: var(--color-border-input);
}

.plan-select select {
  height: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--color-text);
}

.plan-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.plan-table th,
.plan-table td {
  padding: 0 6px;
  text-align: left;
}

.plan-table th:first-child,
.plan-table td:first-child {
  padding-left: 22px;
}

.plan-table th:last-child,
.plan-table td:last-child {
  padding-right: 22px;
}

.plan-table thead th {
  height: 38px;
  background: var(--color-surface-sunken);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Phase, tooth, code, description, fee, patient estimate (mockup 2b). */
.plan-table th:nth-child(1) { width: 78px; }
.plan-table th:nth-child(2) { width: 72px; }
.plan-table th:nth-child(3) { width: 82px; }
.plan-table th:nth-child(5) { width: 108px; }
.plan-table th:nth-child(6) { width: 130px; }

.plan-table tbody td {
  height: var(--row-height);
  border-top: 1px solid var(--color-border-faint);
}

.patient-card .plan-table {
  animation: dc-fade-in var(--dur-base) var(--ease-standard);
}

.plan-table .amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.plan-table .estimate {
  font-weight: 600;
}

.plan-table .tooth {
  font-weight: 600;
}

.plan-table .surfaces {
  margin-left: 6px;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.plan-table .none {
  color: var(--color-text-faint);
}

.plan-table .code {
  color: var(--color-text-muted);
}

.plan-table .desc {
  padding-top: 6px;
  padding-bottom: 6px;
}

.plan-table .our-name {
  display: block;
}

.plan-table .pms-desc {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.plan-table .unknown {
  font-weight: 400;
  color: var(--color-text-muted);
}

.plan-table tfoot th,
.plan-table tfoot td {
  height: 48px;
  border-top: 1px solid var(--color-border);
  font-weight: 700;
}

.card-foot {
  padding: 14px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.foot-note {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

/* Settings */

.settings-card {
  max-width: 640px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.settings-values {
  margin: 0;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  font-size: var(--text-sm);
}

.settings-values dt {
  font-weight: 600;
  color: var(--color-text-strong);
}

.settings-values dd {
  margin: 0;
}

.color-row {
  display: flex;
  gap: 10px;
}

.field input.color-picker {
  width: 52px;
  padding: 4px;
  cursor: pointer;
}

.field input.hex-input {
  width: 140px;
  text-transform: uppercase;
}

.contrast {
  margin: -6px 0 0;
  font-size: var(--text-sm);
}

.contrast.pass {
  color: var(--status-ready-fg);
}

.contrast.fail {
  color: var(--status-review-fg);
}

.brand-preview {
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.brand-preview figcaption {
  padding: 8px 14px;
  background: var(--color-surface-sunken);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

.preview-bar {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
}

.preview-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.preview-name {
  font-size: 17px;
  font-weight: 700;
}

.preview-body {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.preview-tooth {
  width: 18px;
  height: 22px;
  border-radius: 8px 8px 10px 10px;
  border: 1.5px solid rgba(16, 24, 40, 0.35);
}

.saved {
  font-size: var(--text-sm);
  color: var(--status-ready-fg);
}

/* Full-width sub-pages: create presentation (2b) and preview (2c) */

.subpage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-surface-sunken);
}

.subbar {
  min-height: 68px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--space-page);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.subbar-wordmark {
  padding: 0;
  margin-right: 18px;
  font-size: 17px;
  border-radius: var(--radius-sm);
}

.subbar .breadcrumb a:hover {
  text-decoration: underline;
}

.subpage-body {
  flex: 1;
  width: 100%;
  max-width: calc(var(--staff-max) + 2 * var(--space-page));
  margin-inline: auto;
  padding: 24px var(--space-page);
}

.subpage {
  outline: none;
}

.create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(360px, 9vw + 285px, 480px);
  gap: var(--space-6);
  align-items: start;
}

/* The settings column stays in view next to a long plan. */
.create-side {
  position: sticky;
  top: 24px;
}

.create-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-panel {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.setting-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.setting-help {
  margin: -6px 0 0;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--color-text-subtle);
}

.select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--color-border-input);
  border-radius: 8px;
  background: var(--color-surface);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.select:disabled {
  opacity: 0.6;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: var(--text-sm);
}

.segment {
  height: 28px;
  padding: 0 11px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition:
    background-color var(--dur-base) var(--ease-standard),
    color var(--dur-base) var(--ease-standard);
}

.segment:hover:not(.selected):not(:has(input:disabled)) {
  background: var(--color-border-faint);
}

.segment.selected {
  background: #1f72c4;
  color: #ffffff;
  font-weight: 600;
}

.segment:has(input:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.segment:has(input:disabled) {
  cursor: default;
  opacity: 0.7;
}

.create-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.create-button {
  width: 100%;
  height: 42px;
}

/* Generation progress (2b) */

.progress-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.progress-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.progress-time {
  min-width: 5ch;
  text-align: right;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: #eef1f5;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-primary);
  transition:
    width var(--dur-slow) var(--ease-standard),
    background-color var(--dur-base) var(--ease-standard);
}

.progress-fill.failed {
  background: var(--status-review-fg);
}

.progress-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.stage-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: var(--text-md);
}

.stage-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* A row is redrawn when its stage changes, so its state settles in. */
.stage-state {
  animation: dc-rise-in var(--dur-base) var(--ease-emphasized) backwards;
}

.stage-row.passed .stage-icon,
.stage-row.held .stage-icon,
.stage-row.failed .stage-icon {
  animation: dc-pop var(--dur-slow) var(--ease-emphasized) backwards;
}

.stage-row.active .stage-dot {
  animation: dc-pulse 1.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .stage-row .stage-icon,
  .stage-row.active .stage-dot {
    animation: none;
  }
}

.stage-icon {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.stage-label {
  flex: 1;
  min-width: 0;
}

.stage-state {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.stage-row.queued .stage-icon {
  border: 2px solid var(--color-border-input);
}

.stage-row.queued .stage-label {
  color: var(--color-text-subtle);
}

.stage-row.active .stage-icon {
  border: 2px solid var(--color-primary);
}

.stage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
}

.stage-row.active .stage-label {
  font-weight: 600;
}

.stage-row.active .stage-state {
  color: var(--color-primary-strong);
}

.stage-row.passed .stage-icon {
  background: var(--color-primary);
  color: #ffffff;
}

.stage-row.held .stage-icon,
.stage-row.failed .stage-icon {
  background: var(--status-review-bg);
  border: 1px solid var(--status-review-border);
  color: var(--status-review-fg);
}

.stage-row.held .stage-state,
.stage-row.failed .stage-state {
  color: var(--status-review-fg);
  font-weight: 600;
}

.progress-foot {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--color-border-faint);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-text-subtle);
}

.running-body {
  display: flex;
  justify-content: center;
}

.running-body .progress-card {
  width: 100%;
  max-width: clamp(480px, 12vw + 330px, 640px);
  animation: dc-scale-in var(--dur-slow) var(--ease-emphasized) backwards;
}

/* Presentation preview (2c) */

.editor-bar {
  padding: 0 20px 0 24px;
  gap: 14px;
}

.back-button {
  transition: background-color var(--dur-base) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  stroke: var(--color-text-muted);
}

.back-button:hover {
  background: var(--color-surface-sunken);
}

.back-button:active {
  transform: scale(0.94);
}

.editor-name {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.editor-meta {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.version-chip {
  height: 32px;
  margin-left: 8px;
  padding: 0 10px;
  border: 1px solid var(--color-border-input);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
}

.editor-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
}

.button.text {
  border-color: transparent;
  background: none;
  padding: 0 12px;
}

.button.small {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
}

.button[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.present-button {
  height: 42px;
  margin-left: 6px;
  padding: 0 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: var(--text-lg);
  font-weight: 700;
}

.play {
  width: 0;
  height: 0;
  border-left: 9px solid #ffffff;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

/* Side panels grow on wide screens; the canvas keeps a reading width. */
.editor-grid {
  flex: 1;
  min-height: 0;
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns:
    clamp(240px, 12vw + 86px, 320px)
    minmax(0, 1fr)
    clamp(300px, 9.4vw + 180px, 420px);
  background: var(--color-surface);
}

.section-rail {
  padding: 18px 12px;
  overflow-y: auto;
  background: var(--color-surface-sunken);
}

.rail-label {
  margin: 0;
  padding: 0 10px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-subtle);
}

.rail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail-group {
  padding: 12px 10px 4px;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.rail-item {
  transition:
    background-color var(--dur-base) var(--ease-standard),
    color var(--dur-base) var(--ease-standard);
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: var(--text-md);
  color: var(--color-text-strong);
  text-align: left;
  cursor: pointer;
}

.rail-item.indent {
  padding-left: 18px;
}

.rail-item.spaced {
  margin-top: 8px;
}

.rail-item:hover {
  background: var(--color-border-faint);
}

.rail-item[aria-current="true"] {
  background: #1f72c4;
  color: #ffffff;
  font-weight: 600;
}

.rail-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-mark {
  flex: none;
  font-size: var(--text-sm);
}

.rail-mark.ready {
  color: var(--color-primary);
}

.rail-mark.review,
.rail-mark.failed {
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--status-review-bg);
  color: var(--status-review-fg);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-mark.auto {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.rail-item[aria-current="true"] .rail-mark.ready,
.rail-item[aria-current="true"] .rail-mark.auto {
  color: #ffffff;
}

.editor-canvas {
  padding: 26px clamp(24px, 1.6vw + 12px, 48px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-canvas > * {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  flex: none;
}

/* Generated and edited text keeps a comfortable line length. */
.block-body,
.block-textarea,
.question-list {
  max-width: 76ch;
}

.pane-head .eyebrow {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.pane-title {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.locked-strip {
  margin: 0;
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  font-size: var(--text-sm);
}

.locked-cell {
  padding: 9px 16px;
  border-right: 1px solid var(--color-border-faint);
}

.locked-cell dt {
  font-size: 12px;
  color: var(--color-text-subtle);
}

.locked-cell dd {
  margin: 0;
}

.locked-cell .none,
.locked-cell .surfaces {
  color: var(--color-text-subtle);
}

.locked-cell .surfaces {
  margin-left: 4px;
  font-size: var(--text-xs);
}

.locked-source {
  margin-left: auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  stroke: var(--color-text-muted);
}

.held-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 9px;
  border-left: 3px solid;
  font-size: var(--text-sm);
  line-height: 1.45;
}

.held-note.review,
.held-note.failed {
  background: var(--status-review-bg);
  border-color: var(--status-review-fg);
  color: var(--status-review-fg);
}

.block-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition:
    border-color var(--dur-base) var(--ease-standard),
    box-shadow var(--dur-base) var(--ease-standard);
}

.block-card:hover:not(.editing) {
  border-color: #d3d9e1;
}

.block-card.unconfirmed {
  border-style: dashed;
  border-color: var(--color-border-input);
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.block-title {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
}

.prov-pill {
  flex: none;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.prov-pill.neutral { background: #f2f4f7; color: var(--color-text-muted); }
.prov-pill.ready { background: var(--status-ready-bg); color: var(--status-ready-fg); }
.prov-pill.changed { background: var(--status-changed-bg); color: var(--status-changed-fg); }

.block-body {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--color-text-strong);
  white-space: pre-line;
}

.block-confirm {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.block-hint {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.question-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--color-text-strong);
}

.costs-table th:nth-child(1) { width: 64px; }
.costs-table th:nth-child(2) { width: 64px; }
.costs-table th:nth-child(3) { width: 76px; }
.costs-table th:nth-child(4) { width: auto; }
.costs-table th:nth-child(5) { width: 96px; }
.costs-table th:nth-child(6) { width: 112px; }
.costs-table th:nth-child(7) { width: 104px; }

.costs-table thead th {
  border-top: 0;
}

.cost-caveat {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text-muted);
}

.checks-rail {
  padding: 22px 20px;
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rail-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--color-text-strong);
}

.check-row {
  display: flex;
  gap: 9px;
}

.check-mark {
  color: var(--color-primary);
  font-weight: 700;
}

.check-callout {
  padding: 10px 12px;
  border-radius: 9px;
  display: flex;
  gap: 9px;
  font-size: var(--text-sm);
  line-height: 1.45;
}

.check-callout.review,
.check-callout.failed {
  background: var(--status-review-bg);
  color: var(--status-review-fg);
}

.callout-mark {
  font-weight: 700;
}

.callout-lead {
  margin: 0;
  font-weight: 600;
}

.reason-list {
  margin: 4px 0 0;
  padding-left: 16px;
}

.rail-divider {
  height: 1px;
  background: var(--color-border-faint);
}

.detail-list {
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  font-size: var(--text-xs);
}

.detail-list dt {
  color: var(--color-text-subtle);
}

.detail-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: break-word;
  color: var(--color-text-strong);
}

/* Model ids and prompt hashes get the full rail width under their label
   and stay on one line. On a very narrow rail they end in an ellipsis;
   the title holds the whole value. */
.detail-list dt.stacked,
.detail-list dd.mono {
  grid-column: 1 / -1;
}

.detail-list dd.mono {
  margin-top: -4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Presentations list */

.empty-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.empty-state p {
  margin: 0;
}

/* Editor: editing, revert, confirm and Present (M5) */

.editor-bar {
  position: relative;
}

.present-error {
  animation: dc-scale-in var(--dur-base) var(--ease-emphasized) backwards;
  transform-origin: top right;
  position: absolute;
  top: calc(100% + 8px);
  right: 20px;
  z-index: 5;
  max-width: 360px;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--status-review-bg);
  color: var(--status-review-fg);
  font-size: var(--text-sm);
  line-height: 1.45;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.held-note .held-lead {
  margin: 0;
  font-weight: 600;
}

.held-note .reason-list {
  margin-top: 4px;
}

/* Actions on a held section: release, write again, and why release waits. */
.held-actions {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.held-actions:empty {
  display: none;
}

.held-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.held-hint {
  margin: 0;
  font-size: var(--text-xs);
}

.release-blockers .held-lead {
  font-weight: 600;
}

.release-confirm,
.rewrite-progress {
  animation: dc-rise-in var(--dur-base) var(--ease-emphasized) backwards;
}

.release-confirm {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-strong);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

/* Focus lands on these only when the control that held it went away, so
   they read as a place in the page, not as something to press. */
.pane-title:focus,
.rewrite-progress:focus {
  outline: none;
}

.release-confirm-text {
  margin: 0 0 10px;
  font-weight: 600;
}

.rewrite-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.rewrite-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
  animation: dc-pulse 1.2s ease-in-out infinite;
}

/* Each stage change redraws the label, so it settles in. */
.rewrite-stage {
  animation: dc-fade-in var(--dur-base) var(--ease-standard) backwards;
}

.rail-mark.rewriting {
  animation: dc-pulse 1.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .rewrite-dot,
  .rail-mark.rewriting {
    animation: none;
  }
}

.block-card.editing {
  border: 2px solid var(--color-primary);
  padding: 15px 17px;
  box-shadow: 0 0 0 4px var(--color-primary-soft);
}

.block-card:focus {
  outline: none;
}

.block-textarea {
  animation: dc-fade-in var(--dur-base) var(--ease-standard);
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border: 1px solid #868e9c;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--color-text);
  resize: vertical;
}

.block-textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
  border-color: var(--color-primary);
}

.block-edit-hints {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.block-edit-hints .block-hint,
.block-card > .block-hint {
  margin: 0;
}

.block-hint.demo-note {
  color: var(--status-changed-fg);
}

.block-edit-actions,
.block-links {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 2px;
}

.block-edit-actions {
  gap: 8px;
}

.link-button {
  transition: color var(--dur-fast) var(--ease-standard), opacity var(--dur-base) var(--ease-standard);
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary-strong);
  cursor: pointer;
}

.link-button:hover:not(:disabled) {
  text-decoration: underline;
}

.link-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.change-status:empty {
  display: none;
}

.change-status > * {
  animation: dc-rise-in var(--dur-base) var(--ease-emphasized) backwards;
}

.check-callout.changed {
  background: var(--status-changed-bg);
  color: var(--color-text-strong);
}

.check-callout.changed .callout-mark {
  color: var(--status-changed-fg);
}

.callout-outcome {
  margin: 6px 0 0;
}

/* Settings on wide screens: the form and its live preview side by side. */
@media (min-width: 1360px) {
  .settings-card {
    max-width: 1120px;
  }

  .settings-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
    gap: 16px 32px;
    align-items: start;
  }

  .settings-form > * {
    grid-column: 1;
  }

  .settings-form > .brand-preview {
    grid-column: 2;
    grid-row: 1 / span 4;
    position: sticky;
    top: 24px;
  }
}

.preview-bar,
.preview-tooth {
  transition: background-color var(--dur-base) var(--ease-standard);
}

/* Skeletons */

.skeleton-table {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.sk-row {
  height: var(--row-height);
  padding: 0 12px 0 18px;
  display: grid;
  grid-template-columns: 0.5fr 1.3fr 0.4fr 1.5fr 0.6fr 0.7fr 1fr 0.4fr;
  align-items: center;
  gap: 24px;
  border-top: 1px solid var(--color-border-faint);
}

.sk-row.sk-head {
  height: 38px;
  border-top: 0;
  background: var(--color-surface-sunken);
}

.sk-head .sk-bar {
  height: 8px;
  width: 60%;
}

.sk-row .sk-bar:nth-child(3n + 1) {
  width: 70%;
}

.sk-row .sk-bar:nth-child(3n + 2) {
  width: 88%;
}

.sk-row .sk-bar:nth-child(3n) {
  width: 52%;
}

.sk-card {
  min-height: 78px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sk-title {
  width: 55%;
  height: 16px;
}

.sk-line {
  width: 35%;
}

.skeleton-card {
  padding: 20px 22px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sk-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sk-avatar {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  background: #eef1f5;
}

.sk-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sk-stack .sk-title {
  width: min(240px, 60%);
}

.sk-stack .sk-line {
  width: min(320px, 80%);
}

.sk-lines {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sk-text:nth-child(odd) {
  width: 92%;
}

.sk-text:nth-child(even) {
  width: 74%;
}

.sk-text:last-child {
  width: 46%;
}

.auth-skeleton {
  width: 100%;
  max-width: clamp(420px, 12vw + 266px, 520px);
}

.editor-skeleton .editor-canvas > .skeleton-card {
  max-width: 1040px;
}

/* Route transitions (view transitions). The sidebar stays put while the
   page column cross-fades with a short rise; going back reverses it. */
::view-transition-old(staff-main) {
  animation: var(--dur-fast) var(--ease-exit) both dc-vt-out-up;
}

::view-transition-new(staff-main) {
  animation: var(--dur-slow) var(--ease-emphasized) 40ms both dc-vt-in-up;
}

.router-back::view-transition-old(staff-main) {
  animation-name: dc-vt-out-down;
}

.router-back::view-transition-new(staff-main) {
  animation-name: dc-vt-in-down;
}

/* Editor section switches animate only the canvas and the checks. */
.vt-section .editor-canvas {
  view-transition-name: editor-canvas;
}

.vt-section .checks-rail {
  view-transition-name: editor-checks;
}

::view-transition-old(editor-canvas) {
  animation: var(--dur-fast) var(--ease-exit) both dc-vt-out-up;
}

::view-transition-new(editor-canvas) {
  animation: var(--dur-slow) var(--ease-emphasized) 30ms both dc-vt-in-up;
}

/* A section that changes state in place (released, or written again)
   cross-fades without moving, since the reader stays on the same section. */
.vt-state .editor-canvas {
  view-transition-name: editor-state;
}

.vt-state .section-rail {
  view-transition-name: editor-rail;
}

.vt-state .checks-rail {
  view-transition-name: editor-checks;
}

::view-transition-old(editor-state) {
  animation: var(--dur-fast) var(--ease-exit) both dc-fade-out;
}

::view-transition-new(editor-state) {
  animation: var(--dur-base) var(--ease-standard) both dc-fade-in;
}

/* Without view transitions, new page content rises in on its own. */
@supports not (view-transition-name: none) {
  .main > *,
  .subpage > * {
    animation: dc-rise-in var(--dur-slow) var(--ease-emphasized) backwards;
  }
}

/* Collapsed sidebar below 1180 px: icons only, names as tooltips and for
   screen readers. Pills grow to 44 px for touch. */
@media (max-width: 1179px) {
  .sidebar {
    width: 68px;
    padding: 18px 12px;
    align-items: center;
  }

  .wordmark {
    padding: 0 0 22px;
  }

  .sidebar .wordmark-text {
    display: none;
  }

  .nav-link {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .nav-label,
  .demo-full {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .demo-badge {
    padding: 6px 4px;
    text-align: center;
  }
}

.demo-short {
  display: none;
}

@media (max-width: 1179px) {
  .demo-short {
    display: inline;
    font-weight: 600;
  }
}

/* Tablet widths: stack the two-column screens, let the editor scroll as
   one page with the checks under the canvas. */
@media (max-width: 1100px) {
  .status-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table {
    min-width: 680px;
  }

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

  .create-side {
    position: static;
    order: -1;
  }

  .editor-bar {
    flex-wrap: wrap;
    padding-block: 12px;
    row-gap: 10px;
  }

  .editor-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .editor-grid {
    height: auto;
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .section-rail {
    grid-row: span 2;
  }

  .editor-canvas {
    overflow: visible;
  }

  .checks-rail {
    grid-column: 2;
    border-left: 0;
    border-top: 1px solid var(--color-border);
    overflow: visible;
  }

  .locked-strip {
    flex-wrap: wrap;
  }
}

/* Analytics */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-gap);
}

.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-card h2 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}

.stat-card .stat-value {
  margin: 4px 0 0;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--space-gap);
  margin-top: var(--space-section);
}

.analytics-panel {
  padding: 20px 22px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel-head h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.panel-head p {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

.panel-empty {
  margin: 18px 0 4px;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

.analytics-sample {
  margin: 0 0 var(--space-gap);
  padding: 12px 16px;
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-lg);
  background: var(--color-primary-soft);
  font-size: var(--text-sm);
  color: var(--color-primary-strong);
}

/* Time by screen: name, bar and share on one line, the detail under the
   bar. The list fills the panel so it lines up with the Generation panel. */
.screen-bars {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  flex: 1;
  display: grid;
  align-content: space-between;
  row-gap: 12px;
}

.screen-bar {
  display: grid;
  grid-template-columns: minmax(84px, 7.5rem) minmax(0, 1fr) 3.25rem;
  column-gap: 14px;
  row-gap: 3px;
  align-items: center;
  font-size: var(--text-sm);
}

.screen-bar-name {
  font-weight: 600;
  color: var(--color-text-strong);
}

.screen-bar-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  box-shadow: inset 0 0 0 1px var(--color-border);
  overflow: hidden;
}

.screen-bar-fill {
  min-width: 4px;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  transition: width var(--dur-base) var(--ease-standard);
}

.screen-bar-share {
  text-align: right;
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.screen-bar-detail {
  grid-column: 2 / -1;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .screen-bar-fill {
    transition: none;
  }
}

/* Generation figures in four labelled groups, two to a row, so the
   longer groups sit on the first row and the short ones line up below. */
.gen-groups {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 28px;
}

@media (max-width: 640px) {
  .gen-groups {
    grid-template-columns: minmax(0, 1fr);
  }
}

.gen-group h3 {
  margin: 0 0 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

.gen-facts {
  margin: 0;
}

.gen-facts > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--color-border-faint);
  font-size: var(--text-sm);
}

.gen-facts > div:last-child {
  border-bottom: 0;
}

.gen-facts dt {
  color: var(--color-text-muted);
}

.gen-facts dd {
  margin: 0;
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sample-tag {
  height: 20px;
  margin-left: 4px;
  padding: 0 7px;
  vertical-align: 1px;
}

@media (max-width: 1179px) {
  .stat-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

.analytics-footnote {
  margin: 18px 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.preview-logo.has-image {
  padding: 2px;
  background: #ffffff;
  object-fit: contain;
}

/* Logo field in Settings */
.logo-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-frame {
  width: 96px;
  height: 64px;
  flex: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-current {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-empty {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-subtle);
}

.logo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-weight: 400;
}

.logo-chosen {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--text-sm);
}

/* First-launch setup wizard (UI_SPEC 5.8): stepper on the left, one step
   at a time on the right, Back and Continue in the footer. */
.wizard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--color-surface);
}

.wizard[hidden] {
  display: none;
}

.wizard-steps {
  padding: 28px 20px;
  background: var(--color-surface-sunken);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-steps .wordmark {
  padding: 0;
}

.wizard-title {
  margin: 0;
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
}

.wizard-main {
  padding: 40px 32px;
  display: flex;
  justify-content: center;
}

.wizard-form {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 16px;
  outline: none;
}

.wizard-step .auth-text {
  margin: 0;
}

.wizard-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.wizard-inline-actions {
  justify-content: flex-start;
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-row {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--text-sm);
}

.check-row.ok {
  background: var(--status-ready-bg);
  color: var(--status-ready-fg);
}

.check-row.warn {
  background: var(--status-changed-bg);
  color: var(--status-changed-fg);
}

.check-title {
  font-weight: 600;
}

.ack-list {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ack-list legend {
  margin-bottom: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
}

.ack {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: var(--text-sm);
  line-height: 1.45;
}

.ack input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: none;
}

@media (max-width: 760px) {
  .wizard {
    grid-template-columns: 1fr;
  }

  .wizard-main {
    padding: 24px 16px;
  }
}

/* Version banners and history (UI_SPEC 5.5) */

.version-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) var(--space-page) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.version-banner p { margin: 0; flex: 1 1 320px; }
.version-banner.changed { background: var(--status-changed-bg); border-color: var(--status-changed-border); color: var(--status-changed-fg); }
.version-banner.review { background: var(--status-review-bg); border-color: var(--status-review-border); color: var(--status-review-fg); }

.version-changes {
  flex-basis: 100%;
  margin: 0;
  padding-left: var(--space-5);
  font-size: 13px;
}

.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: min(400px, 100vw);
  overflow-y: auto;
  padding: var(--space-5);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -12px 0 32px rgb(16 24 40 / 0.12);
}

.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.history-top h2 { margin: 0; font-size: 17px; }

.history-list { list-style: none; margin: 0; padding: 0; }

.history-entry {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.history-head, .history-marks, .history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.history-head { justify-content: space-between; }
