/*
 * Workspace layer: "White City: Sun & Shade".
 * Plaster panels, indigo ink, one sun. Layout rules first, then the skin.
 * Loaded after the inline shell, workspace.css and identity.css.
 * The sun sits up-left, so every hand-written cast shadow offsets down-right (+x).
 */

/* ── Shell structure (moved from the retired inline "product shell") ── */
#login-view { position: relative; overflow: hidden; padding: 24px; }
.login-card { position: relative; z-index: 1; max-width: none; }
.login-logo { display: block; width: 56px; height: 56px; margin: 0 0 22px; border-radius: 12px; }
.top-bar-title { position: relative; display: flex; align-items: center; gap: 11px; text-align: right; }
.brand-logo { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 8px; }
.top-bar-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  position: relative; display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center;
  border: 1px solid var(--border-medium); border-radius: var(--radius-md);
  color: var(--text-secondary); background: transparent; cursor: pointer;
  transition: color var(--dur-ui) ease, border-color var(--dur-ui) ease, background-color var(--dur-ui) ease;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--border-accent); background: var(--brand-soft); }
.theme-icon-light, .theme-icon-dark { position: absolute; display: grid; place-items: center; transition: opacity .18s var(--ease-out), transform .18s var(--ease-out); }
.theme-icon-light svg, .theme-icon-dark svg { width: 18px; height: 18px; }
.theme-icon-dark { opacity: 0; transform: rotate(-60deg) scale(.7); }
.theme-light .theme-icon-light { opacity: 0; transform: rotate(60deg) scale(.7); }
.theme-light .theme-icon-dark { opacity: 1; transform: none; }

/* ── Task layout: persistent navigation, working sheet, run activity ── */
.top-bar, .theme-light .top-bar {
  min-height: 68px; padding: 10px 24px 18px;
  border: 0; box-shadow: none;
  /* Ribbon band as the header's bottom edge: a thick ink rule, then a thin sun rule. */
  background:
    linear-gradient(var(--ribbon-ink) 0 0) left calc(100% - 4px) / 100% 3px no-repeat,
    linear-gradient(var(--sun) 0 0) left bottom / 100% 1px no-repeat,
    var(--bg-primary);
}
.top-bar-title { color: var(--text-primary); font: 700 1.15rem/1 var(--font-sans); letter-spacing: -.01em; direction: ltr; }
.top-bar-info { flex: 1; justify-content: flex-start; padding-inline: 24px; gap: 10px; }
.top-bar-info span { color: var(--text-muted); font-size: .78rem; }
.top-bar-info .sep { color: var(--border-medium); }
.top-bar-actions .btn { min-height: 40px; }
.top-bar .btn-ghost { color: var(--text-secondary); border: 1px solid var(--border-medium); background: transparent; }
.top-bar .btn-ghost:hover { color: var(--text-primary); border-color: var(--border-accent); background: var(--brand-soft); }

.workspace-shell { grid-template-columns: 196px minmax(0, 1fr); }

/* Navigation rail: a vertical "thermometer window". The destinations form one
   narrow glazed strip: stacked panes separated by ribbon rules inside a slim
   mullion frame. The active floor's pane is sunlit, with a lit sun edge on the
   side that faces the content. */
.workspace-nav { position: relative; padding: 28px 16px 16px; gap: 0; border-left: 0; background: var(--bg-secondary); }
.workspace-nav button {
  position: relative; min-height: 50px; margin-top: -1px; padding: 12px 14px;
  border: 1px solid var(--border-medium); border-inline-start-width: 3px; border-radius: 0;
  color: var(--text-secondary); background: var(--bg-primary);
  font: 500 .88rem var(--font-sans);
  transition: background-color var(--dur-ui) ease, color var(--dur-ui) ease, box-shadow var(--dur-ui) ease;
}
.workspace-nav button:hover { z-index: 1; color: var(--text-primary); background: var(--bg-card); box-shadow: 2px 3px 8px rgb(var(--cast-rgb) / 14%); }
.workspace-nav button.active, .theme-light .workspace-nav button.active {
  z-index: 1; color: var(--text-primary); background: var(--brand-soft); font-weight: 600;
  box-shadow: inset -2px 0 0 var(--sun);
}
.workspace-nav button:focus-visible { z-index: 2; outline: 2px solid var(--focus-ring); outline-offset: -4px; }
.workspace-nav-icon { color: currentColor; }
.workspace-nav-icon svg { width: 20px; height: 20px; }
.workspace-nav button.active .workspace-nav-icon { color: var(--sun-text); }
.workspace-nav-footer { margin-top: auto; padding: 22px 12px 0; border-top: 1px solid var(--border-subtle); color: var(--text-muted); font-size: .75rem; }
.workspace-nav-footer a { color: var(--text-secondary); display: inline-block; padding-block: 8px; }
.workspace-nav-footer p { line-height: 1.7; }

.main-layout { grid-template-columns: minmax(0, 1fr) 288px; }
.form-panel { padding: 32px 36px; }
.form-inner { --form-gutter: 0px; background: transparent; padding: 0; border: 0; border-radius: 0; box-shadow: none; max-width: 1040px; }
.run-intro { padding-bottom: 26px; }
.run-intro h2, .workspace-head h2, .project-detail-title h2 {
  color: var(--text-primary); font-family: var(--font-display); font-weight: 700;
  font-size: 2.1rem; line-height: 1.15; letter-spacing: -.02em;
}
.run-intro p { color: var(--text-secondary); font-size: .92rem; line-height: 1.7; margin-top: 8px; max-width: 52ch; }

/* The main working panel: plaster with a sun-cast shadow and the one balcony corner
   (top-left, the corner away from the rail). */
.run-fields-grid {
  background: var(--bg-card); padding: 26px; gap: 28px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-lg);
  border-top-left-radius: var(--radius-balcony);
  box-shadow: var(--shadow-md);
}
.form-section-heading { border: 0; margin: 0 0 18px; padding: 0; }
.form-section-heading h3 { color: var(--text-primary); font: 700 1rem/1.3 var(--font-display); letter-spacing: -.005em; }
.form-section-heading small { color: var(--text-muted); font-size: .78rem; }
.form-inner > .form-section-heading { margin: 34px 0 16px; padding-top: 18px; border-top: 1px solid var(--border-subtle); }
.form-inner .field-label, label.field-label { font-size: .8rem; margin-bottom: 7px; color: var(--text-secondary); font-weight: 500; }
.field-label.required::after, .required::after { color: var(--error); }

/* Inputs: recessed plaster, ink focus. */
.input-field, .select-field, .form-inner .input-field, .form-inner .select-field {
  background: var(--bg-primary); border: 1px solid var(--border-medium); color: var(--text-primary);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-ui) ease, box-shadow var(--dur-ui) ease, background-color var(--dur-ui) ease;
}
.form-inner .input-field, .form-inner .select-field { min-height: 44px; padding: 10px 12px; }
.input-field:hover, .select-field:hover { border-color: var(--text-muted); }
.input-field:focus, .select-field:focus, .form-inner .input-field:focus, .form-inner .select-field:focus {
  background: var(--bg-card); border-color: var(--text-primary); box-shadow: 0 0 0 3px var(--brand-soft); outline: none;
}
.input-field::placeholder { color: var(--text-muted); opacity: 1; }
.input-field[readonly], .select-field:disabled, .form-inner .input-field[readonly] { color: var(--text-muted); background: var(--bg-secondary); cursor: not-allowed; }
.input-field[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-soft); }
.select-field option { background: var(--bg-card); color: var(--text-primary); }
.city-dropdown, .project-dropdown, .address-dropdown { background: var(--bg-card); border-color: var(--border-medium); }
.city-option, .project-option, .address-option { color: var(--text-primary); }
.city-option:hover, .city-option.highlighted, .project-option:hover, .project-option.highlighted, .address-option:hover, .address-option.highlighted { background: var(--brand-soft); }
.city-option.selected, .project-option.selected, .address-option.selected { color: var(--sun-text); font-weight: 600; }
.section-label { position: relative; margin: 22px 0 12px; color: var(--text-primary); font: 700 .92rem var(--font-display); letter-spacing: 0; text-transform: none; }

/* Upload target: dashed plaster that turns into a sunlit patch. */
.file-upload-zone, .form-inner .file-upload-zone {
  background: var(--bg-primary); min-height: 164px; padding: 22px;
  border: 1px dashed var(--border-medium); border-radius: var(--radius-md); box-shadow: none;
}
.form-inner .file-upload-zone:hover, .form-inner .file-upload-zone:focus-within, .file-upload-zone:hover, .file-upload-zone.drag-over {
  border-color: var(--border-accent); background: var(--brand-soft);
}
.file-upload-zone:focus-within { box-shadow: 0 0 0 3px var(--brand-soft); }
.form-inner .drop-icon, .drop-icon { color: var(--text-secondary); opacity: 1; }
.form-inner .drop-text, .drop-text { color: var(--text-primary); font-size: .88rem; }
.form-inner .drop-text small, .drop-text small { color: var(--text-muted); font-size: .78rem; letter-spacing: .04em; }
.drop-text-hover { color: var(--sun-text); }
.file-upload-zone:has(.has-file) { border-style: solid; border-color: var(--border-accent); background: var(--brand-soft); }
.form-inner .file-name.has-file, .file-name.has-file { font-size: 1.02rem; font-weight: 600; color: var(--text-primary); }
.drop-replace { display: none; color: var(--text-secondary); font-size: .78rem; text-align: center; }
.file-upload-zone:has(.has-file) .drop-replace { display: block; }
.file-upload-zone:has(.has-file) .drop-text { display: none; }
.file-selection-tools { font-variant-numeric: tabular-nums; }
.file-selection-tools .btn { border-color: transparent; color: var(--text-muted); padding-inline: 4px; background: transparent; }
.file-selection-tools .btn:hover { color: var(--error); background: transparent; }

/* Switch cards */
.form-inner .defaults-switch-card, label.defaults-switch-card { background: var(--bg-card); border-color: var(--border-subtle); }
.form-inner .defaults-switch-copy strong { font-size: .86rem; font-weight: 600; }
.defaults-switch-track { background: var(--bg-secondary); box-shadow: inset 0 0 0 1px var(--border-medium); }
.defaults-switch-track::after { background: var(--text-muted); box-shadow: 1px 1px 2px rgb(var(--cast-rgb) / 25%); }
.defaults-checkbox:checked + .defaults-switch-card { border-color: var(--border-accent); background: var(--brand-soft); }
.defaults-checkbox:checked + .defaults-switch-card .defaults-switch-track { background: var(--sun); box-shadow: none; }
.defaults-checkbox:checked + .defaults-switch-card .defaults-switch-track::after { background: var(--sun-ink); }
.defaults-checkbox:focus-visible + .defaults-switch-card { border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--brand-soft); }
.defaults-option:hover { border-color: var(--border-accent); transform: none; }
.defaults-option:has(input:checked) { border-color: var(--border-accent); background: var(--brand-soft); }
.defaults-option input, .glare-address-section label > input[type="checkbox"], .review-share-run input, .review-share-toggle input, .project-run-compare input, .project-compare-difference-toggle input { accent-color: var(--sun-strong); }
.run-notes-disclosure { margin-top: 14px; }
.run-notes-disclosure summary { color: var(--text-secondary); }

/* Submit bar */
.run-submit-bar { margin-top: 22px; padding: 18px 0; border-radius: 0; border-top: 1px solid var(--border-subtle); background: var(--bg-primary); box-shadow: none; gap: 12px; }
.form-inner #submit-btn { min-height: 46px; min-width: 164px; font-size: .95rem; }
.form-inner #submit-btn:disabled { opacity: 1; color: var(--text-muted); background: var(--bg-secondary); border: 1px solid var(--border-subtle); }
.submit-readiness { font-size: .8rem; max-width: 65ch; color: var(--text-secondary); }
.submit-readiness[data-ready="true"] { color: var(--success); }

/* Buttons that the shared identity doesn't cover */
.btn:disabled { opacity: .45; }
.btn-primary:hover:not(:disabled) { transform: none; }
.btn-secondary { color: var(--text-primary); border: 1px solid var(--border-medium); background: transparent; }
.btn-secondary:hover:not(:disabled) { background: var(--brand-soft); color: var(--text-primary); border-color: var(--border-accent); transform: none; }
.btn-ghost { color: var(--text-secondary); border: 1px solid var(--border-medium); background: transparent; }
.btn-ghost:hover { color: var(--text-primary); background: var(--brand-soft); border-color: var(--border-accent); }
.btn-sm { border-radius: var(--radius-sm); transition: background-color var(--dur-ui) ease, border-color var(--dur-ui) ease, color var(--dur-ui) ease, transform var(--dur-press) var(--ease-out); }
.btn-sm:active:not(:disabled) { transform: scale(.97); }
.btn-sm.btn-primary { border: 1px solid transparent; }
.btn-danger { color: var(--error); border: 1px solid var(--border-medium); background: transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--error); background: var(--error-soft); }
.error-text { color: var(--error); }
.skip-link { background: var(--sun); color: var(--sun-ink); }

/* ── Run activity: a printed log with a ribbon progress bar ── */
.queue-panel, .theme-light .queue-panel { color: var(--text-primary); background: var(--bg-secondary); border-color: var(--border-subtle); border-right: 1px solid var(--border-subtle); }
.queue-header { padding: 30px 20px 18px; border-bottom: 1px solid var(--border-subtle); }
.queue-header-title { color: var(--text-primary); font: 700 .98rem var(--font-display); }
.queue-count { border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-subtle); font: 600 .75rem var(--font-sans); font-variant-numeric: tabular-nums; }
.queue-panel .btn-ghost { color: var(--text-secondary); border-color: var(--border-medium); background: transparent; }
.queue-panel .btn-ghost:hover { color: var(--text-primary); background: var(--brand-soft); }
.queue-empty { text-align: center; padding: 56px 12px; gap: 12px; color: var(--text-muted); }
.queue-empty-icon { background: transparent; color: var(--text-muted); border: 0; }
.queue-empty strong { font-size: .88rem; color: var(--text-primary); font-weight: 600; }
.queue-empty > span:last-child { font-size: .8rem; }
.queue-item { color: var(--text-primary); background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.queue-item:hover { border-color: var(--border-medium); background: var(--bg-card); }
.queue-running, .queue-item.queue-running { border-color: var(--border-accent); background: var(--bg-card); }
.queue-filename { color: var(--text-primary); font-weight: 600; }
.queue-status, .queue-message { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.queue-item.queue-running .queue-status { color: var(--sun-text); font-weight: 600; }
.queue-completed .queue-status { color: var(--success); }
.queue-failed .queue-status { color: var(--error); }
.queue-icon { display: inline-grid; place-items: center; color: var(--text-muted); }
.queue-item.queue-running .queue-icon { animation: none; color: var(--sun-text); }
.queue-completed .queue-icon { color: var(--success); }
.queue-failed .queue-icon { color: var(--error); }

/* The ribbon progress: an ink rule on a plaster track, led by a small sun. */
.queue-progress, .queue-item.queue-running .queue-progress { position: relative; height: 3px; margin-top: 12px; overflow: visible; border-radius: 0; background: var(--border-subtle); }
.queue-progress-fill, .queue-progress-fill.active {
  position: relative; height: 100%; border-radius: 0;
  background: var(--text-primary); animation: none;
  transition: width .6s var(--ease-out);
}
.queue-progress-fill::after {
  /* The sun leads the fill (RTL: the fill grows leftward). */
  content: ''; position: absolute; top: 50%; left: -5px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--sun); transform: translateY(-50%);
  box-shadow: 0 0 0 3px var(--bg-card);
}
.queue-progress-fill::before {
  content: ''; position: absolute; top: 50%; left: -5px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--sun); transform: translateY(-50%);
  animation: sun-breathe 2.4s var(--ease-out) infinite;
}
@keyframes sun-breathe {
  0% { opacity: .55; transform: translateY(-50%) scale(1); }
  100% { opacity: 0; transform: translateY(-50%) scale(2.6); }
}

/* Progress phases print as log lines. */
.progress-phases { flex-direction: column; gap: 1px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.phase, .phase.completed, .phase.active {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 3px 0; border-radius: 0; background: transparent;
  text-align: start; font-size: .78rem; white-space: normal;
}
.phase { color: var(--text-muted); }
.phase::before { content: ''; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--border-medium); }
.phase.completed { color: var(--text-secondary); }
.phase.completed::before { display: none; }
.phase.completed svg { color: var(--success); width: 12px; height: 12px; flex: 0 0 12px; }
.phase.active { color: var(--sun-text); font-weight: 600; }
.phase.active::before { border-color: transparent; background: var(--sun); }
.queue-message { margin-top: 10px; }
.queue-waiting { color: var(--text-muted) !important; font-style: normal; }
.loader-dots span { display: inline-block; width: 4px; height: 4px; background: currentColor; border-radius: 50%; }
.phase svg { width: 12px; height: 12px; }

/* Queue actions and confirmations */
.queue-status { display: inline-flex; align-items: center; gap: 8px; }
.queue-grade .workspace-grade { min-width: 34px; height: 24px; padding-inline: 6px; border-radius: var(--radius-sm); font-size: .8rem; }
.queue-actions .queue-cancel { color: var(--text-secondary); border: 1px solid var(--border-medium); background: transparent; }
.queue-actions .queue-cancel:hover { color: var(--error); border-color: var(--error); background: transparent; }
.queue-confirm { grid-column: 1 / -1; display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-primary); }
.queue-confirm p { margin: 0; color: var(--text-primary); font-size: .85rem; line-height: 1.6; overflow-wrap: anywhere; }
.queue-confirm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.queue-confirm .queue-danger { border: 1px solid var(--error); color: var(--bg-card); background: var(--error); font-weight: 600; }
.queue-confirm .queue-danger:hover:not(:disabled) { filter: brightness(1.08); }
.queue-confirm .btn-ghost { color: var(--text-primary); }
.queue-item .queue-error { color: var(--error); }

/* ── Projects ── */
.projects-workspace { padding: 34px 36px 48px; }
.workspace-head { margin-bottom: 28px; }
.workspace-head h2 { padding: 0; }
.workspace-head h2::before, .workspace-stat::before { display: none; }
.workspace-head p { font-size: .92rem; color: var(--text-secondary); }
.workspace-toolbar { justify-content: space-between; }
.workspace-mode-toggle { background: var(--bg-secondary); padding: 3px; border-color: var(--border-subtle); }
.workspace-mode-toggle button { color: var(--text-secondary); font-weight: 500; transition: background-color var(--dur-ui) ease, color var(--dur-ui) ease; }
.workspace-mode-toggle button.active, .theme-light .workspace-mode-toggle button.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); font-weight: 600; }
.workspace-export { border: 1px solid var(--border-medium); color: var(--text-primary); background: transparent; }

/* Statistics: one plaster strip; each figure ruled with a dimension line. */
.workspace-stats { gap: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-card); overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.workspace-stat { border: 0; border-radius: 0; background: transparent; padding: 22px 24px; box-shadow: none; }
.workspace-stat + .workspace-stat { border-inline-start: 1px solid var(--border-subtle); }
.workspace-stat span { display: block; color: var(--text-muted); font-size: .8rem; }
.workspace-stat strong {
  display: inline-block; margin-top: 10px; padding: 0 2px 7px;
  color: var(--text-primary); font: 600 2rem/1.1 var(--font-sans); font-variant-numeric: tabular-nums;
  background:
    linear-gradient(var(--border-medium) 0 0) left bottom / 100% 1px no-repeat,
    linear-gradient(var(--border-medium) 0 0) left bottom / 1px 7px no-repeat,
    linear-gradient(var(--border-medium) 0 0) right bottom / 1px 7px no-repeat;
}
.workspace-filters { padding: 20px; background: var(--bg-card); box-shadow: none; border-color: var(--border-subtle); }
.workspace-filter label { color: var(--text-secondary); font-weight: 500; }
.workspace-filter input, .workspace-filter select { background: var(--bg-primary); border-color: var(--border-medium); }
.workspace-filter input:focus, .workspace-filter select:focus { border-color: var(--text-primary); box-shadow: 0 0 0 3px var(--brand-soft); }
.workspace-results { box-shadow: none; border-color: var(--border-subtle); }
.workspace-table th { padding: 13px 16px; font-weight: 500; color: var(--text-muted); background: var(--bg-card); border-bottom: 1px solid var(--border-medium); font-size: .76rem; }
.workspace-table td { padding: 17px 16px; font-size: .86rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.workspace-table tr[data-workspace-run]:hover, .workspace-table tr[data-workspace-project-id]:hover { background: var(--bg-card-hover); }
.workspace-name { color: var(--text-primary); }
.workspace-card { border: 1px solid var(--border-subtle); box-shadow: var(--shadow-sm); }
.workspace-card dd { font-variant-numeric: tabular-nums; }
.workspace-empty { padding-block: 64px; }
.workspace-count { background: var(--bg-secondary); color: var(--text-secondary); font: 600 .75rem var(--font-sans); font-variant-numeric: tabular-nums; }
.workspace-icon-action { width: 40px; height: 40px; flex-basis: 40px; background: transparent; border-color: var(--border-medium); color: var(--text-secondary); border-radius: var(--radius-md); }
.workspace-icon-action:hover { border-color: var(--border-accent); color: var(--text-primary); background: var(--brand-soft); }
.project-folder-icon { color: var(--text-secondary); background: var(--bg-secondary); border: 1px solid var(--border-subtle); }
.project-folder-icon svg, .queue-icon svg { width: 20px; height: 20px; }
.workspace-toolbar-actions { gap: 8px; }
.workspace-toolbar-actions .btn { min-height: 40px; padding: 8px 16px; font-size: .85rem; }
.workspace-filter-actions #workspace-clear { border-color: transparent; color: var(--text-muted); }
.workspace-pager { font-variant-numeric: tabular-nums; }

/* Project detail */
.project-detail-header { padding: 22px 24px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); border-top-left-radius: var(--radius-balcony); background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-cast, var(--shadow-md)); }
.project-detail-title h2 { font-size: 1.8rem; }
.project-detail-back { color: var(--text-secondary); font-weight: 500; }
.project-detail-back:hover { color: var(--text-primary); }
.project-overview > div { box-shadow: none; }
.project-overview b { font-variant-numeric: tabular-nums; }
.project-runs-panel { box-shadow: var(--shadow-sm); }
.project-runs-head h3 { font-family: var(--font-display); font-weight: 700; }
.project-run-filters, .project-run-table-head { background: var(--bg-secondary); }
.project-run-compare { background: var(--bg-secondary); }
.project-run-row:hover { background: var(--bg-card-hover); }
.project-run-actions .btn-sm { background: transparent; border-color: var(--border-medium); color: var(--text-secondary); }
.project-run-actions .btn-sm:hover { border-color: var(--border-accent); color: var(--text-primary); background: var(--brand-soft); }
.project-review-panel { box-shadow: var(--shadow-sm); }

/* ── Dialogs ── */
.workspace-run-modal, .diagnostic-modal { background: rgb(var(--cast-rgb) / 52%); backdrop-filter: none; }
.workspace-run-dialog, .diagnostic-dialog { border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); background: var(--bg-card); box-shadow: var(--shadow-xl); }
.workspace-run-head, .project-detail-header, .diagnostic-header { color: var(--text-primary); }
.workspace-run-head, .diagnostic-header { background: var(--bg-card); border-bottom: 1px solid var(--border-subtle); }
.workspace-run-head h2, .workspace-run-head h3, .diagnostic-header h2, .review-share-dialog .workspace-run-head h2 {
  color: var(--text-primary); font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em;
}
.workspace-run-close, .diagnostic-close {
  display: grid; place-items: center; min-width: 40px; min-height: 40px;
  border: 1px solid var(--border-medium); border-radius: var(--radius-md);
  color: var(--text-secondary); background: transparent; font-size: 1.3rem; line-height: 1;
  transition: border-color var(--dur-ui) ease, background-color var(--dur-ui) ease, color var(--dur-ui) ease;
}
.workspace-run-close:hover, .diagnostic-close:hover { color: var(--text-primary); border-color: var(--border-accent); background: var(--brand-soft); }
.workspace-run-body { background: var(--bg-primary); }
.workspace-run-dialog.defaults-dialog { width: min(780px, calc(100% - 32px)); }
.defaults-modal-body { background: var(--bg-card); }
.workspace-run-section { border: 0; border-top: 1px solid var(--border-subtle); border-radius: 0; padding: 22px; }
.workspace-run-section h3 { font-family: var(--font-display); font-weight: 700; }
.workspace-run-note { border: 1px solid var(--border-subtle); }
.workspace-detail { border-inline-end-width: 1px; box-shadow: none; background: var(--bg-card); }
.workspace-detail b { font-variant-numeric: tabular-nums; }
.workspace-pdf-actions .btn { min-height: 40px; }
.workspace-run-head .btn-danger { margin-inline-start: 16px; }
.workspace-summary-kpi { box-shadow: none; }
.workspace-summary-kpi strong { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-primary); }
.workspace-energy-hero { box-shadow: var(--shadow-cast, var(--shadow-md)); border-top-left-radius: var(--radius-balcony); }
.workspace-energy-hero-copy h3 { color: var(--text-primary); font-family: var(--font-display); font-weight: 700; }
.workspace-energy-hero-grade .workspace-grade { border-radius: var(--radius-md); box-shadow: 3px 5px 10px rgb(var(--cast-rgb) / 22%); }
.workspace-section-count { color: var(--text-secondary); background: var(--bg-secondary); }
.workspace-collapsible-section > summary::after, .workspace-pdf-group > summary::after, .project-compare-collapsible > summary::after, .project-compare-layers summary::after { color: var(--text-muted); }
.workspace-component-card header small { color: var(--text-secondary); }
.workspace-pdf-card { background: var(--bg-card); }
.workspace-pdf-group { background: var(--bg-card); }
.diagnostic-section h3 { color: var(--text-primary); }
.diagnostic-kind-temporary { color: var(--sun-text); }
.diagnostic-raw { color: var(--text-secondary); background: var(--bg-secondary); border-color: var(--border-subtle); }
.project-compare-run-rating strong, .project-compare-delta { color: var(--text-primary); }
.project-compare-run-card.is-baseline { border-color: var(--border-accent); box-shadow: inset 0 0 0 1px var(--border-accent); }
.project-compare-baseline-badge, .project-compare-inline-baseline, .project-apartment-run-count, .project-compare-layer-number { color: var(--sun-text) !important; background: var(--brand-soft); }
.project-compare-difference-label { color: var(--sun-text); border-color: var(--border-accent); }
.project-compare-table td.is-different, .project-apartment-grade.is-different, .project-apartment-metric.is-different { border-color: var(--border-accent); background: var(--brand-soft); }
.hebrew-calendar-days button.selected { color: var(--sun-ink); background: var(--sun); }
.hebrew-calendar-days button.today { box-shadow: inset 0 0 0 1px var(--text-primary); }
.hebrew-calendar { box-shadow: var(--shadow-xl); }

/* ── Sign-in: a plaster card under the sun ── */
#login-view {
  background:
    linear-gradient(var(--ribbon-ink) 0 0) top / 100% 10px no-repeat,
    linear-gradient(var(--sun) 0 0) 0 13px / 100% 3px no-repeat,
    var(--bg-primary);
}
#login-view::before {
  /* The sun's path: the upper half of one wide ellipse, a single arc across the sky. */
  display: block; content: ''; position: absolute;
  left: -20vw; top: 14vh; width: 140vw; height: 110vh;
  border: 1px solid var(--sun); border-radius: 50%;
  clip-path: inset(0 0 50% 0);
  background: none; mask-image: none; pointer-events: none; opacity: .85;
}
#login-view::after {
  /* The sun sits on that arc in the afternoon (125° along the ellipse). */
  content: ''; position: absolute; left: calc(9.8vw - 24px); top: calc(24vh - 24px);
  width: 48px; height: 48px; border-radius: 50%; background: var(--sun); pointer-events: none;
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--sun) 16%, transparent);
}
.login-card {
  width: min(440px, 100%); padding: 44px 40px 36px;
  color: var(--text-secondary); background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); border-top-left-radius: var(--radius-balcony);
  box-shadow: var(--shadow-cast, var(--shadow-md)); animation: none;
}
.login-card::before, .login-card::after { display: none; }
.login-card h1 {
  color: var(--text-primary); text-align: right; direction: ltr; unicode-bidi: isolate;
  font: 700 2.3rem/1.05 var(--font-sans); letter-spacing: -.02em;
}
.login-card .subtitle { color: var(--text-muted); margin-top: 8px; text-align: start; font-weight: 500; }
.login-card .description { margin-top: 30px; line-height: 1.7; color: var(--text-secondary); text-align: start; }
.key-row { margin-top: 16px; }
.key-input {
  background: var(--bg-primary); border: 1px solid var(--border-medium); color: var(--text-primary);
  border-radius: var(--radius-md); font-variant-numeric: tabular-nums; letter-spacing: .12em;
}
.key-input:focus { background: var(--bg-card); border-color: var(--text-primary); box-shadow: 0 0 0 3px var(--brand-soft); }
.key-sep, .hint { color: var(--text-muted); }
.login-card .hint { text-align: start; }
.login-card #login-btn { min-height: 48px; font-size: 1rem; }
.login-footer { margin-top: 24px; text-align: start; font-size: .82rem; }
.login-footer a { color: var(--text-secondary); }
.login-footer a:hover { color: var(--text-primary); }

@media (min-width: 1025px) { .form-panel { scroll-padding-block: 24px 120px; } }
/* Below this width, the navigation rail leaves too little room for all columns. */
@media (max-width: 1240px) {
  .workspace-results { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .workspace-table-wrap { display: none; }
  .workspace-cards { display: block; }
}
@media (min-width: 1600px) { .main-layout { grid-template-columns: minmax(0, 1fr) 320px; } .form-panel { padding: 42px 52px; } }
@media (max-width: 1250px) { .workspace-shell { grid-template-columns: 168px minmax(0, 1fr); } .main-layout { grid-template-columns: minmax(0, 1fr) 248px; } .form-panel { padding: 24px; } .top-bar-info { padding-inline: 8px; } }
@media (max-width: 1024px) { .main-layout { grid-template-columns: minmax(0, 1fr); } .queue-panel { border-top: 1px solid var(--border-subtle); border-right: 0; } .queue-empty { padding: 28px 12px; } .run-submit-bar { position: static; } .top-bar-info { display: none; } .form-panel { padding: 24px 18px; } }
@media (max-width: 720px) {
  .top-bar { padding: 10px 16px 18px; min-height: 64px; }
  .workspace-shell { grid-template-columns: minmax(0, 1fr); }
  .workspace-nav { padding: 8px 12px; gap: 6px; border-bottom: 1px solid var(--border-subtle); }
    .workspace-nav button { min-height: 44px; font-size: .8rem; padding: 8px; }
  .workspace-nav-footer { display: none; }
  .form-panel, .projects-workspace { padding: 24px 16px; }
  .run-intro { padding-bottom: 20px; }
  .run-intro h2, .workspace-head h2 { font-size: 1.65rem; }
  .run-fields-grid { padding: 18px; gap: 22px; border-top-left-radius: 20px; }
  .form-inner .input-field, .form-inner .select-field { font-size: 16px; }
  .workspace-stat { padding: 16px 10px; }
  .workspace-stat strong { font-size: 1.5rem; }
  .workspace-stat span { font-size: .75rem; }
  .workspace-filters { padding: 16px; }
  .login-card { padding: 34px 22px 28px; }
  .login-card h1 { font-size: 2rem; }
  /* Phones: a flatter, higher arc so the sun sits in open sky above the card. */
  #login-view::before { top: 4vh; height: 60vh; }
  #login-view::after { width: 36px; height: 36px; left: calc(9.8vw - 18px); top: calc(9.4vh - 18px); }
  .queue-panel:has(.queue-empty) { flex-direction: column; align-items: stretch; }
  .queue-panel:has(.queue-empty) .queue-header { padding: 16px 20px 0; }
  .queue-panel:has(.queue-empty) .queue-body { padding: 12px 20px 20px; }
  .queue-panel:has(.queue-empty) .queue-empty { display: grid; justify-items: start; gap: 4px; }
}
@media (max-width: 500px) { .top-bar-title { font-size: 1rem; } }
@container run-form (max-width: 639px) { .run-model-section { border-top: 1px solid var(--border-subtle); padding-top: 22px; } }

/* Open suggestion lists sit above the sticky submit bar; the bar stays low in the stack. */
.run-submit-bar { z-index: 2; }
.city-search-wrap:has(.open), .project-search-wrap:has(.open), .address-search-wrap:has(.open) { z-index: 30; }
.city-dropdown, .project-dropdown, .address-dropdown { max-height: 264px; box-shadow: var(--shadow-md); }
@media (min-width: 1025px) { .form-panel { padding-bottom: 0; } }

/* Shared utilities and corrected control states. */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.workspace-run-head .btn-ghost { color: var(--text-primary); border-color: var(--border-medium); background: transparent; }
.workspace-run-head .btn-ghost:hover { color: var(--text-primary); border-color: var(--border-accent); background: var(--brand-soft); }
.defaults-edit { min-height: 36px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-primary); font: 600 .8rem var(--font-sans); text-decoration: underline; text-decoration-color: var(--sun); text-decoration-thickness: 2px; text-underline-offset: .3em; }
.defaults-edit:hover { background: var(--brand-soft); }

/* Glare study: subordinate disclosures, readable help, product upload zones. */
.glare-address-section { background: var(--bg-primary); border-color: var(--border-subtle); }
.glare-address-section summary { font: 500 .88rem/1.5 var(--font-sans); color: var(--text-primary); }
.glare-address-section details { margin-top: 4px; border-top: 1px solid var(--border-subtle); }
.glare-address-section details[open] > summary { margin-bottom: 8px; }
.glare-address-section p.defaults-selection-summary { margin: 4px 0 16px; }
.glare-address-section .field-group > .defaults-selection-summary { display: block; margin-top: 4px; }
.glare-address-section label:has(> input[type="checkbox"]) { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding-block: 10px; color: var(--text-primary); font-size: .85rem; line-height: 1.5; cursor: pointer; }
.glare-address-section label > input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 2px; }
/* Reflective surroundings picker: an optional checklist of nearby map buildings. */
.glare-context-picker { min-width: 0; margin: 4px 0 18px; padding: 12px 16px 4px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-card); }
.glare-context-picker legend { padding-inline: 6px; color: var(--text-primary); font: 500 .88rem/1.5 var(--font-sans); }
.glare-context-optional { margin-inline-start: 6px; color: var(--text-muted); font-size: .75rem; font-weight: 400; }
.glare-address-section .glare-context-picker p.defaults-selection-summary { margin: 2px 0 12px; }
.glare-context-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.glare-address-section .glare-context-load { min-height: 44px; padding: 8px 16px; border: 1px solid var(--border-medium); border-radius: var(--radius-md); color: var(--text-primary); background: transparent; font-size: .85rem; }
.glare-address-section .glare-context-load:hover:not(:disabled) { border-color: var(--border-accent); color: var(--text-primary); background: var(--brand-soft); }
.glare-address-section .glare-context-load:disabled { color: var(--text-muted); border-color: var(--border-subtle); cursor: not-allowed; }
.glare-context-load[aria-busy="true"] { cursor: progress; }
.glare-context-load:focus-visible, .glare-context-item input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.glare-context-count { color: var(--text-secondary); font-size: .8rem; font-variant-numeric: tabular-nums; }
.glare-address-section .glare-context-picker p.glare-context-status { margin: 10px 0 12px; }
.glare-context-list { max-height: min(24rem, 60vh); margin: 0 0 12px; padding: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; border-top: 1px solid var(--border-subtle); }
.glare-context-item { border-bottom: 1px solid var(--border-subtle); }
.glare-context-item:last-child { border-bottom: 0; }
.glare-context-item .glare-context-check { padding-inline: 4px; }
.glare-context-item:has(input:checked) { background: var(--brand-soft); }
.glare-context-text { display: grid; gap: 2px; min-width: 0; }
.glare-context-name { color: var(--text-primary); font-weight: 500; overflow-wrap: anywhere; }
.glare-context-meta { color: var(--text-secondary); font-size: .78rem; font-variant-numeric: tabular-nums; }
.glare-context-parcel { display: grid; grid-template-columns: repeat(2, minmax(0, 11rem)); gap: 10px; padding-block: 0 12px; padding-inline: 32px 4px; }
.glare-context-parcel[hidden] { display: none; }
.glare-address-section .glare-context-parcel .field-group { margin: 0; }
.glare-context-parcel .field-label { font-size: .78rem; }
.glare-context-parcel .input-field { min-height: 44px; }
.form-inner .file-upload-zone.file-upload-compact { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 56px; padding: 10px 14px; text-align: start; }
.file-upload-compact .drop-icon { flex-shrink: 0; }
.file-upload-compact .file-name { margin: 0; }
#reference-upload-section .section-label { margin: 18px 0 10px; font-size: .9rem; }
.glare-address-section a { color: var(--text-primary); text-decoration-color: var(--sun); }

/* Projects: open control inside each row and card, empty project state. */
.workspace-project-open { font: inherit; }
.workspace-project-open:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: var(--radius-sm); }
.project-runs-empty { display: grid; justify-items: center; gap: 8px; }
.project-runs-empty p { margin: 0 0 8px; }

@media (max-width: 720px) {
  .theme-toggle { width: 44px; height: 44px; flex-basis: 44px; }
  .top-bar-actions .btn, .workspace-create, .defaults-edit, .workspace-toolbar-actions .btn, .workspace-mode-toggle button { min-height: 44px; }
  .workspace-icon-action, .project-run-actions .workspace-icon-action { width: 44px; height: 44px; flex: 0 0 44px; }
}
#project-action-error:empty { display: none; }
/* Numeric summaries use Heebo tabular numerals; mono stays for codes and filenames. */
.workspace-count, .workspace-section-count, .workspace-grade, .workspace-validation-summary > span b,
.project-compare-run-rating strong, .project-apartment-metric strong, .form-section-heading > span { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }

/* Review room sharing and guest comments in the project detail. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; border: 0; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.project-review-panel { padding: 18px 22px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-card); }
.project-review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.project-review-head h3 { color: var(--text-primary); font: 700 1rem var(--font-display); }
.project-review-count { padding: 2px 10px; border: 1px solid var(--border-medium); border-radius: 999px; color: var(--text-secondary); font-size: .75rem; font-variant-numeric: tabular-nums; }
.project-review-count.has-open { border-color: var(--border-accent); background: var(--brand-soft); color: var(--sun-text); }
.project-review-panel .error-text { text-align: start; min-height: 0; }
.project-review-panel .error-text:empty { display: none; }
.project-review-list { display: grid; margin: 8px 0 0; padding: 0; list-style: none; }
.project-review-thread { display: grid; gap: 6px; padding: 12px 0; }
.project-review-thread + .project-review-thread { border-top: 1px solid var(--border-subtle); }
.project-review-thread-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.project-review-author { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-review-thread-head time { color: var(--text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.project-review-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-primary); }
.project-review-bar:empty { display: none; }
.project-review-bar-copy { display: grid; gap: 2px; }
.project-review-bar-copy b { color: var(--text-primary); font-size: .86rem; font-weight: 600; }
.project-review-bar-copy small { color: var(--text-secondary); font-size: .78rem; }
.project-review-bar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-review-bar-actions .btn-sm, .project-review-actions .btn-sm { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding-inline: 14px; border-radius: var(--radius-md); font-size: .8rem; text-decoration: none; }
.project-review-open { border: 1px solid transparent; background: var(--sun); color: var(--sun-ink); font-weight: 600; }
.project-review-open:hover { background: var(--sun-strong); }
.project-review-copy, .project-review-open-thread { border: 1px solid var(--border-medium); background: transparent; color: var(--text-secondary); }
.project-review-copy:hover, .project-review-open-thread:hover { border-color: var(--border-accent); background: var(--brand-soft); color: var(--text-primary); }
.project-review-copy-status { color: var(--text-secondary); font-size: .76rem; }
.project-review-copy-status:empty { display: none; }
.project-review-context { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; color: var(--text-muted); font-size: .76rem; }
.project-review-context b { color: var(--text-secondary); font-weight: 500; }
.project-review-surface { padding: 1px 6px; border-radius: 5px; background: var(--bg-primary); color: var(--text-secondary); font: .72rem var(--font-mono); direction: ltr; }
.project-review-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-review-thread-head b { color: var(--text-primary); font-size: .85rem; font-weight: 600; }
.project-review-tag { padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--sun-text); font-size: .7rem; font-weight: 600; }
.project-review-tag.is-resolved { border: 1px solid var(--border-medium); background: transparent; color: var(--text-secondary); }
.project-review-body { max-width: 75ch; color: var(--text-primary); font-size: .9rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; text-align: right; unicode-bidi: plaintext; }
.project-review-thread.is-resolved .project-review-body { color: var(--text-secondary); }
.project-review-reply { text-align: right; unicode-bidi: plaintext; max-width: 75ch; padding-inline-start: 12px; border-inline-start: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.project-review-reply b { color: var(--text-primary); font-weight: 500; }
.project-review-thread-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.project-review-thread-foot small { color: var(--text-muted); font-size: .75rem; }
.project-review-status, .review-share-links .btn-sm { min-height: 40px; border: 1px solid var(--border-medium); background: transparent; color: var(--text-secondary); transition: background-color .16s, border-color .16s, color .16s; }
.project-review-status:hover:not(:disabled), .review-share-links .btn-sm:hover:not(:disabled) { border-color: var(--border-accent); background: var(--brand-soft); color: var(--text-primary); }
.project-review-empty { margin-top: 10px; color: var(--text-muted); font-size: .82rem; }
.project-review-resolved { margin-top: 8px; border-top: 1px solid var(--border-subtle); }
.project-review-resolved summary { display: flex; align-items: center; min-height: 44px; color: var(--text-secondary); font-size: .82rem; cursor: pointer; }

.review-share-dialog { width: min(640px, calc(100vw - 32px)); margin: auto; max-height: calc(100dvh - 48px); padding: 0; overflow: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-xl); }
.review-share-dialog::backdrop { background: rgb(var(--cast-rgb) / 52%); }
.review-share-dialog .workspace-run-head { background: var(--bg-card); }
.review-share-dialog .workspace-run-head h2 { font-size: 1.2rem; }
.review-share-body { display: grid; gap: 20px; padding: 20px 24px 24px; direction: rtl; }
.review-share-intro { max-width: 60ch; color: var(--text-secondary); font-size: .88rem; line-height: 1.6; }
#review-share-form { display: grid; gap: 16px; justify-items: start; }
.review-share-runs-field { width: 100%; margin: 0; padding: 0; border: 0; }
.review-share-runs-field legend { padding: 0; color: var(--text-primary); font-size: .9rem; font-weight: 600; }
.review-share-hint { margin: 2px 0 10px; color: var(--text-muted); font-size: .76rem; }
.review-share-runs { display: grid; max-height: 280px; overflow: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.review-share-run { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; cursor: pointer; transition: background-color .16s; }
.review-share-run + .review-share-run { border-top: 1px solid var(--border-subtle); }
.review-share-run:hover { background: var(--bg-card-hover); }
.review-share-run.is-checked { background: var(--brand-soft); }
.review-share-run:has(input:disabled) { cursor: not-allowed; opacity: .6; }
.review-share-run input { width: 18px; height: 18px; margin: 0; }
.review-share-run-name { display: grid; min-width: 0; }
.review-share-run-name b { overflow: hidden; color: var(--text-primary); font-size: .86rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.review-share-run-name small { color: var(--text-muted); font-size: .74rem; }
.review-share-baseline { padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--sun-text); font-size: .7rem; font-weight: 600; }
.review-share-options { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; width: 100%; }
.review-share-field { display: grid; gap: 6px; }
.review-share-field label { color: var(--text-secondary); font-size: .8rem; font-weight: 500; }
.review-share-field select { min-width: 160px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); font: inherit; font-size: .88rem; }
.review-share-toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.review-share-toggle input { width: 18px; height: 18px; margin: 0; }
.review-share-toggle span { display: grid; }
.review-share-toggle strong { color: var(--text-primary); font-size: .86rem; font-weight: 500; }
.review-share-toggle small { color: var(--text-muted); font-size: .74rem; }
#review-share-form .error-text { margin: 0; min-height: 0; text-align: start; }
#review-share-form .error-text:empty { display: none; }
#review-share-create { min-height: 44px; }
.review-share-result { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--border-accent); border-radius: var(--radius-lg); background: var(--brand-soft); }
.review-share-result > label { color: var(--text-primary); font-size: .86rem; font-weight: 600; }
.review-share-url-row { display: flex; gap: 8px; }
.review-share-url-row input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary); font: .84rem var(--font-mono); }
.review-share-url-row .btn { min-height: 44px; }
.review-share-once { color: var(--text-secondary); font-size: .78rem; }
.review-share-status { min-height: 0; color: var(--success); font-size: .8rem; }
.review-share-status:empty { display: none; }
.review-share-open { width: max-content; padding-block: 8px; color: var(--text-primary); font-size: .86rem; font-weight: 600; text-decoration: underline; text-decoration-color: var(--sun); text-decoration-thickness: 2px; }
.review-share-links-section h3 { color: var(--text-primary); font: 700 .95rem var(--font-display); }
.review-share-links-section h3:focus { outline: none; }
.review-share-links { display: grid; margin: 8px 0 0; padding: 0; list-style: none; }
.review-link { display: grid; gap: 4px; padding: 12px 0; }
.review-link + .review-link { border-top: 1px solid var(--border-subtle); }
.review-link-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.review-link-main b { color: var(--text-primary); font-size: .84rem; font-weight: 500; }
.review-link-state { padding: 1px 8px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: .72rem; font-weight: 600; }
.review-link.is-expired .review-link-state, .review-link.is-revoked .review-link-state { border: 1px solid var(--border-medium); background: transparent; color: var(--text-secondary); }
.review-link small { color: var(--text-muted); font-size: .75rem; }
.review-link > .btn-sm { justify-self: start; margin-top: 4px; }
.review-link-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border-medium); border-radius: var(--radius-md); }
.review-link-confirm p { flex-basis: 100%; color: var(--text-primary); font-size: .82rem; }
.review-share-links .review-link-danger { border-color: var(--error); color: var(--error); }
.review-share-links .review-link-danger:hover:not(:disabled) { border-color: var(--error); background: var(--error-soft); color: var(--error); }
.review-link-empty { padding: 12px 0; color: var(--text-muted); font-size: .82rem; }
@media (max-width: 720px) {
  .project-review-panel { padding: 16px; }
  .project-review-status, .review-share-links .btn-sm { min-height: 44px; }
  .review-share-body { padding: 16px; }
  .review-share-run { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .review-share-run .workspace-grade { display: none; }
  .review-share-url-row { flex-direction: column; }
  .review-share-field select { font-size: 16px; }
}

/* ══ Workspace layout: task column, run sheet, one continuous ribbon ══════════
   The brand sits at the top of the rail; the top bar carries only context.
   Both are 64px with the ribbon on their bottom edge, so the band runs unbroken
   across the screen. */
.workspace-shell { grid-template-columns: 208px minmax(0, 1fr); }
.workspace-content { min-height: 0; }
.workspace-nav { padding: 0 16px 16px; gap: 0; }
.workspace-brand {
  height: 64px; flex: 0 0 64px; margin: 0 -16px 28px; padding: 0 20px 10px;
  background:
    linear-gradient(var(--ribbon-ink) 0 0) left calc(100% - 4px) / 100% 3px no-repeat,
    linear-gradient(var(--sun) 0 0) left bottom / 100% 1px no-repeat,
    var(--bg-secondary);
}
.workspace-brand-title { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--text-primary); font: 700 1.12rem/1 var(--font-sans); letter-spacing: -.01em; direction: ltr; }
.workspace-brand-title .brand-logo { width: 30px; height: 30px; border-radius: 7px; }
.workspace-nav-live { flex: none; width: 8px; height: 8px; margin-inline-start: auto; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 3px var(--brand-soft); }
.workspace-nav button.active .workspace-nav-live { box-shadow: 0 0 0 3px var(--bg-card); }
.top-bar, .theme-light .top-bar { height: 64px; min-height: 64px; padding: 0 28px 8px; flex-wrap: nowrap; }
.top-bar-info { padding-inline: 0; min-width: 0; overflow: hidden; white-space: nowrap; }

/* Run workspace: form column + activity column (run sheet above the queue). */
.main-layout { grid-template-columns: minmax(0, 1fr) 344px; }
.form-panel { padding: 32px 40px 56px; }
.form-inner { max-width: 800px; }
.run-intro { padding-bottom: 22px; }

/* One continuous plaster sheet, divided into steps in the order the work happens. */
/* Each step casts the same hard shadow; the next step covers the seam, so the sheet reads as one slab. */
.run-step { padding: 24px 28px; border: 1px solid var(--border-subtle); border-top-width: 0; background: var(--bg-card); box-shadow: var(--shadow-cast, var(--shadow-md)); }
.run-intro + .run-step { border-top-width: 1px; border-top-left-radius: var(--radius-balcony); border-top-right-radius: var(--radius-lg); }
.run-step:last-child { border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }
.run-step .form-section-heading, .form-inner .run-step > .form-section-heading { margin: 0 0 16px; padding: 0; border: 0; }
.run-step .form-section-heading h3 { font-size: 1.05rem; }
.run-step-run .field-group { margin-bottom: 0; }

/* The model leads: a wide, generous drop target that collapses to a file row. */
.run-step-model .file-upload-zone, .form-inner .run-step-model .file-upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 208px; padding: 32px 24px; text-align: center;
}
.run-step-model .drop-icon svg { width: 38px; height: 38px; }
.form-inner .run-step-model .drop-text { font-size: 1rem; font-weight: 600; }
.form-inner .run-step-model .drop-text small { display: block; margin: 6px 0 0; font-weight: 400; }
.run-step-model .file-upload-zone:has(.has-file) {
  flex-direction: row; justify-content: flex-start; gap: 12px;
  min-height: 64px; padding: 12px 18px; text-align: start;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.run-step-model .file-upload-zone:has(.has-file) .drop-icon svg { width: 24px; height: 24px; }
.run-step-model .file-upload-zone:has(.has-file) .drop-replace { display: none; }
.form-inner .run-step-model .file-name.has-file { font-size: 1.05rem; text-align: start; }
.file-selection-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0; padding: 4px 6px 4px 18px;
  border: 1px solid var(--border-accent); border-top: 0; border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--bg-card); color: var(--text-secondary); font-size: .8rem;
}
.file-selection-actions { display: flex; gap: 4px; }
.file-selection-tools .btn { min-height: 36px; padding: 6px 12px; border: 1px solid transparent; color: var(--text-secondary); background: transparent; font-size: .82rem; }
.file-selection-tools .btn:hover { color: var(--text-primary); background: var(--brand-soft); }
.file-selection-tools .btn:last-child:hover { color: var(--error); background: var(--error-soft); }
#reference-upload-section .section-label { margin-top: 20px; }

/* Project: pick an existing one (shown as a compact row) or fill in a new one. */
.run-step-project[data-project-selected="true"] #project-picker-row,
.run-step-project[data-project-selected="true"] .project-identity-row { display: none; }
.project-selected { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border-accent); border-radius: var(--radius-md); background: var(--brand-soft); }
.project-selected[hidden] { display: none; }
.project-selected .project-folder-icon { background: var(--bg-card); }
.project-selected-copy { display: grid; flex: 1; min-width: 0; gap: 2px; }
.project-selected-copy strong { overflow: hidden; color: var(--text-primary); font-size: 1rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.project-selected-copy small { color: var(--text-secondary); font-size: .8rem; font-variant-numeric: tabular-nums; }
.project-selected .btn { min-height: 40px; padding: 8px 16px; background: var(--bg-card); }
#project-picker-row { margin-bottom: 4px; }

/* ── Activity column ── */
.queue-panel { display: flex; flex-direction: column; min-height: 0; }
.queue-header { padding: 18px 20px 10px; border-bottom: 0; }
.queue-header-title { font-size: .95rem; }
.queue-body { padding: 4px 18px 20px; }
.queue-empty { display: grid; justify-items: start; gap: 4px; padding: 4px 2px 8px; text-align: start; }
.queue-empty-icon { display: none; }
.queue-empty strong { font-size: .85rem; }
.queue-empty > span:last-child { max-width: none; font-size: .78rem; line-height: 1.6; }

/* The run sheet reads like a drawing title block: ink frame, ruled cells, one action. */
.run-sheet {
  flex: none; margin: 20px 18px 6px; overflow: hidden;
  border: 1.5px solid var(--text-primary); border-radius: var(--radius-sm);
  background: var(--bg-card); box-shadow: var(--shadow-md);
}
.run-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1.5px solid var(--text-primary); }
.run-sheet-head h2 { color: var(--text-primary); font: 700 1.02rem/1.2 var(--font-display); }
.run-sheet-state { padding: 2px 9px; border-radius: 999px; background: var(--bg-secondary); color: var(--text-secondary); font-size: .74rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.run-sheet[data-ready="true"] .run-sheet-state { background: var(--success-soft); color: var(--success); }
.run-sheet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.run-sheet-cell { min-width: 0; padding: 7px 14px 8px; border-bottom: 1px solid var(--border-medium); }
.run-sheet-cell-wide { grid-column: 1 / -1; }
.run-sheet-cell:nth-child(4), .run-sheet-cell:nth-child(6) { border-inline-start: 1px solid var(--border-medium); }
.run-sheet-cell dt { color: var(--text-muted); font-size: .68rem; line-height: 1.4; }
.run-sheet-cell dd { margin: 1px 0 0; overflow: hidden; color: var(--text-primary); font-size: .86rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.run-sheet-cell dd[dir="ltr"] { text-align: right; }
.run-sheet-missing { padding: 11px 14px 6px; border-bottom: 1px solid var(--border-medium); }
.run-sheet-missing[hidden] { display: none; }
.run-sheet-missing-title { margin: 0 0 4px; color: var(--text-muted); font-size: .72rem; }
.run-sheet-checklist { display: grid; margin: 0; padding: 0; list-style: none; }
.run-sheet-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 32px; padding: 3px 0;
  border: 0; background: none; color: var(--text-primary); font: 500 .85rem var(--font-sans); text-align: start; cursor: pointer;
}
.run-sheet-item::before { content: ''; flex: 0 0 10px; width: 10px; height: 10px; border: 1.5px solid var(--border-medium); border-radius: 2px; }
.run-sheet-item:hover { color: var(--sun-text); text-decoration: underline; text-decoration-color: var(--sun); text-underline-offset: .3em; }
.run-sheet-item:hover::before { border-color: var(--sun-strong); }
.run-sheet-action { display: grid; gap: 8px; padding: 14px; }
.run-sheet-action .submit-readiness { margin: 0; color: var(--success); font-size: .8rem; line-height: 1.5; }
.run-sheet[data-ready="false"] .run-sheet-action .submit-readiness { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.run-sheet-action .error-text { margin: 0; min-height: 0; text-align: start; }
.run-sheet-action .error-text:empty { display: none; }
.run-sheet #submit-btn { width: 100%; min-height: 48px; margin: 0; font-size: .98rem; }
.run-sheet #submit-btn:disabled { opacity: 1; color: var(--text-muted); background: var(--bg-secondary); border: 1px solid var(--border-subtle); }
.run-sheet-shortcut { margin: 0; color: var(--text-muted); font-size: .72rem; text-align: center; }
.run-sheet-shortcut kbd { padding: 0 5px; border: 1px solid var(--border-medium); border-bottom-width: 2px; border-radius: 4px; color: var(--text-secondary); font: 600 .68rem var(--font-sans); }

@media (max-width: 1250px) {
  .workspace-shell { grid-template-columns: 176px minmax(0, 1fr); }
  .main-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .form-panel { padding: 28px 24px 48px; }
  .run-step { padding: 22px 22px; }
}

/* Narrow: the queue drops below the form and the sheet becomes a sticky action bar. */
@media (max-width: 1024px) {
  .main-layout { display: block; padding-bottom: 88px; }
  .queue-panel { border-top: 1px solid var(--border-subtle); border-inline-start: 0; }
  .run-sheet {
    position: fixed; z-index: 40; inset-inline: 0; bottom: 0; margin: 0;
    display: flex; align-items: center;
    border: 0; border-top: 1px solid var(--border-medium); border-radius: 0;
    box-shadow: 0 -8px 20px rgb(var(--cast-rgb) / 12%);
  }
  .run-sheet-head, .run-sheet-grid, .run-sheet-missing, .run-sheet-shortcut { display: none; }
  .run-sheet-action { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; width: 100%; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .run-sheet-action .submit-readiness,
  .run-sheet[data-ready="false"] .run-sheet-action .submit-readiness {
    position: static; width: auto; height: auto; overflow: hidden; clip-path: none; white-space: normal;
    flex: 1 1 0; min-width: 0; color: var(--text-secondary); font-size: .78rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }
  .run-sheet[data-ready="true"] .run-sheet-action .submit-readiness { color: var(--success); }
  .run-sheet-action .error-text { order: -1; flex-basis: 100%; }
  .run-sheet #submit-btn { width: auto; min-width: 150px; flex: none; }
  .form-panel { padding: 24px 18px 32px; }
}
@media (max-width: 720px) {
  .workspace-shell { grid-template-columns: minmax(0, 1fr); }
  .workspace-nav { padding: 6px 10px; gap: 4px; align-items: center; }
  /* Collapsed rail: plain tabs, the active one underlined by the sun. */
  .workspace-nav button { margin: 0; border: 0; border-radius: var(--radius-md); background: transparent; box-shadow: none; }
  .workspace-nav button:hover { box-shadow: none; }
  .workspace-nav button.active, .theme-light .workspace-nav button.active { box-shadow: inset 0 -2px 0 var(--sun); }
  .workspace-brand { height: auto; flex: none; margin: 0; padding: 0 2px 0 6px; background: none; }
  .workspace-brand-title { font-size: 0; }
  .workspace-brand-title .brand-logo { width: 28px; height: 28px; }
  .workspace-nav-live { position: absolute; top: 8px; left: 8px; margin: 0; }
  .top-bar, .theme-light .top-bar { height: 56px; min-height: 56px; padding: 0 16px 8px; justify-content: flex-end; }
  .form-panel { padding: 20px 14px 28px; }
  .run-step { padding: 18px 16px; }
  .run-intro + .run-step { border-top-left-radius: 20px; }
  .run-step-model .file-upload-zone, .form-inner .run-step-model .file-upload-zone { min-height: 168px; padding: 24px 16px; }
  .run-sheet #submit-btn { min-width: 128px; }
}

/* ── Projects: headline row with figures, then one command row ── */
.workspace-head { align-items: flex-end; flex-wrap: wrap; gap: 16px 28px; margin-bottom: 22px; }
.workspace-head-copy { flex: 1 1 320px; }
.workspace-head .workspace-stats, .workspace-head .workspace-stats:empty {
  display: flex; gap: 28px; margin: 0; padding: 0; overflow: visible;
  border: 0; border-radius: 0; background: none; box-shadow: none;
}
.workspace-head .workspace-stat { padding: 0; }
.workspace-head .workspace-stat + .workspace-stat { border-inline-start: 0; }
.workspace-head .workspace-stat span { font-size: .72rem; }
.workspace-head .workspace-stat strong { margin-top: 4px; font-size: 1.55rem; }
.workspace-toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin: 0; padding: 14px 16px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--bg-card);
}
.workspace-toolbar .workspace-filters {
  display: flex; flex: 1 1 520px; align-items: flex-end; gap: 8px; min-width: 0; margin: 0; padding: 0;
  border: 0; border-radius: 0; background: none; box-shadow: none;
}
.workspace-toolbar .workspace-filter { flex: 1 1 110px; min-width: 0; }
.workspace-toolbar .workspace-filter-search { flex: 2.2 1 200px; }
.workspace-toolbar .workspace-filter label { margin-bottom: 4px; font-size: .72rem; }
.workspace-toolbar .workspace-filter input, .workspace-toolbar .workspace-filter select { min-height: 40px; padding: 7px 10px; }
.workspace-toolbar .workspace-filter-actions .btn { min-height: 40px; padding-inline: 10px; }
.workspace-toolbar .workspace-mode-toggle { flex: none; }
.workspace-toolbar-actions { flex: none; margin-inline-start: auto; }
.workspace-results { border-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.workspace-project-actions { gap: 6px; }
.workspace-project-run { min-height: 36px; padding: 6px 12px; border: 1px solid var(--border-medium); background: transparent; color: var(--text-primary); font-weight: 600; }
.workspace-project-run:hover { border-color: var(--border-accent); background: var(--brand-soft); }
.workspace-table td:nth-child(2) .workspace-grade { min-width: 40px; height: 30px; }
.workspace-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.workspace-card-grade .workspace-grade { min-width: 44px; height: 34px; font-size: .95rem; }
.workspace-card dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workspace-empty { display: grid; justify-items: center; gap: 4px; padding: 56px 20px; }
.workspace-empty strong { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }
@media (max-width: 1240px) {
  .workspace-toolbar { border-radius: var(--radius-lg); margin-bottom: 14px; }
}
@media (max-width: 720px) {
  .workspace-head .workspace-stats { gap: 20px; }
  .workspace-toolbar .workspace-filters { flex-wrap: wrap; flex-basis: 100%; }
  .workspace-toolbar .workspace-filter-search { flex-basis: 100%; }
  .workspace-toolbar .workspace-filter input, .workspace-toolbar .workspace-filter select { min-height: 44px; }
  .workspace-toolbar .workspace-mode-toggle { flex: 1 1 100%; }
  .workspace-toolbar-actions { flex: 1 1 100%; display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
  .workspace-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Run detail: the result first, then the reports, then the inputs title block ── */
.workspace-run-body > .workspace-run-summary + *, .workspace-run-body > .workspace-run-section { margin-top: 18px; }
.workspace-run-summary { display: grid; gap: 14px; }
.workspace-energy-hero { padding: 22px 24px; }
.workspace-energy-hero-main, .workspace-energy-hero.is-plain .workspace-energy-hero-main {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.25fr) auto; align-items: center; gap: 22px;
}
.workspace-energy-hero.is-plain .workspace-energy-hero-main { grid-template-columns: minmax(0, 1fr) auto; }
.workspace-energy-hero.is-plain > .workspace-run-hero-actions { display: flex; justify-content: flex-start; }
.workspace-energy-hero-grade .workspace-grade { min-width: 96px; height: 96px; font-size: 2.8rem; }
.workspace-energy-hero-copy h3 { font-size: 1.12rem; }
.workspace-energy-hero-copy strong { font-size: .95rem; font-weight: 600; }
.workspace-energy-hero .workspace-summary-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding-inline-start: 18px; border-inline-start: 1px solid var(--border-subtle); }
.workspace-energy-hero.is-plain .workspace-summary-kpis { padding-inline-start: 0; border: 0; }
.workspace-energy-hero .workspace-summary-kpi { padding: 2px 10px; border: 0; background: none; text-align: start; }
.workspace-energy-hero .workspace-summary-kpi strong { font-size: 1.45rem; }
.workspace-energy-hero .workspace-summary-kpi span { margin-top: 4px; font-size: .72rem; white-space: normal; }
.workspace-run-hero-actions { display: grid; gap: 8px; min-width: 168px; }
.workspace-run-hero-actions .btn { min-height: 44px; }
.workspace-run-summary > .workspace-grade-distribution { margin: 0; padding: 18px 20px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-card); }
.workspace-run-summary > .workspace-validation-summary { box-shadow: none; }
.workspace-pdf-subtitle { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--text-primary); font: 700 .9rem/1.3 var(--font-display); }
.workspace-pdf-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.workspace-pdf-group { margin-top: 12px; }
.workspace-pdf-group > .workspace-pdf-list { padding: 10px; }
.workspace-pdf-card { min-height: 54px; padding: 8px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-card); }
.workspace-pdf-card:hover { background: var(--bg-card-hover); border-color: var(--border-medium); }
@media (max-width: 720px) { .workspace-pdf-list { grid-template-columns: minmax(0, 1fr); } }
.workspace-pdf-card > strong { font-size: .9rem; font-weight: 500; }
.workspace-pdf-icon { color: var(--text-secondary); background: var(--bg-secondary); font: 700 .66rem var(--font-sans); }
/* Inputs and metadata close the sheet as a drawing title block. */
.workspace-run-details .workspace-detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; overflow: hidden;
  border: 1.5px solid var(--text-primary); border-radius: var(--radius-sm); background: var(--bg-card);
}
.workspace-run-details .workspace-detail {
  margin: -1px -1px 0 0; padding: 9px 14px 10px; border: 0; border-radius: 0; background: transparent;
  border-top: 1px solid var(--border-medium); border-right: 1px solid var(--border-medium);
}
.workspace-run-details .workspace-detail span { margin-bottom: 3px; font-size: .7rem; }
.workspace-run-details .workspace-detail b { font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 1024px) {
  .workspace-energy-hero-main, .workspace-energy-hero.is-plain .workspace-energy-hero-main { grid-template-columns: auto minmax(0, 1fr); }
  .workspace-energy-hero .workspace-summary-kpis, .workspace-run-hero-actions { grid-column: 1 / -1; }
  .workspace-energy-hero .workspace-summary-kpis { padding: 14px 0 0; border: 0; border-top: 1px solid var(--border-subtle); }
  .workspace-run-hero-actions { display: flex; flex-wrap: wrap; }
  .workspace-run-hero-actions .btn { flex: 1 1 160px; }
  .workspace-run-details .workspace-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  .workspace-energy-hero-grade .workspace-grade { min-width: 68px; height: 68px; font-size: 2rem; }
  .workspace-energy-hero .workspace-summary-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace-energy-hero .workspace-summary-kpi { padding-inline: 4px; }
  .workspace-energy-hero .workspace-summary-kpi strong { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .queue-progress-fill::before { animation: none; opacity: 0; }
}

/* WCAG 2.4.11: at these widths the run sheet is a fixed bottom bar, so scrolled-to
   and focused fields keep clear of it. */
@media (max-width: 1024px) {
  html, .form-panel, .main-content { scroll-padding-bottom: 140px; }
}
@media (min-width: 721px) and (max-width: 1024px) {
  .workspace-nav { padding-bottom: 120px; }
}

/* Legal links: accessibility statement, privacy and terms stay one click away. */
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; font-size: .78rem; }
.legal-links a { color: var(--text-muted); text-decoration: underline; text-decoration-color: var(--border-medium); min-height: 24px; display: inline-flex; align-items: center; }
.legal-links a:hover { color: var(--text-primary); }

/* The sign-in screen stands alone: no workspace chrome (run sheet bar, shell) behind or over it. */
body:has(#login-view.active) #form-view,
body:has(#login-view.active) .run-sheet { display: none !important; }

/* Grade distribution: a visible trough, filled in each row's own grade colour,
   so every bar reads as a share of the whole. */
.workspace-grade-distribution-bar {
  height: 10px; background: var(--bg-secondary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border-medium) 55%, transparent);
}
/* Bars read in the marketing palette; the grade badge beside each row carries the official colour. */
.workspace-grade-distribution-bar i { background: var(--shade); }

/* ── Queue: one compact row per run so about ten fit under the run sheet ── */
#queue-list { display: grid; align-content: start; gap: 6px; }
.queue-item { padding: 8px 10px; border-radius: var(--radius-md); }
.queue-item-header { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; min-height: 30px; }
.queue-item-header .queue-filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.queue-item-header .queue-status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: .74rem; }
.queue-item-header .queue-status .workspace-grade { min-width: 26px; height: 20px; font-size: .68rem; border-radius: 4px; }
.queue-item-header .queue-actions { display: inline-flex; gap: 4px; margin: 0; }
.queue-icon { display: grid; place-items: center; width: 18px; height: 18px; }
.queue-icon svg { width: 18px; height: 18px; }
.queue-icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium); background: var(--bg-card); color: var(--text-primary); cursor: pointer;
  transition: background-color var(--dur-ui) ease, border-color var(--dur-ui) ease;
}
.queue-icon-btn svg { width: 16px; height: 16px; }
.queue-icon-btn:hover { background: var(--brand-soft); border-color: var(--border-accent); }
.queue-icon-btn.is-primary { background: var(--sun); border-color: transparent; color: var(--sun-ink); }
.queue-icon-btn.is-primary:hover { background: var(--sun-strong); }
.queue-icon-btn.queue-cancel:hover { color: var(--error); border-color: var(--error); background: var(--error-soft); }
.queue-progress-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 6px; }
.queue-progress-row .queue-progress { margin: 0; }
.queue-phase { font-size: .72rem; font-weight: 600; color: var(--sun-text); white-space: nowrap; }
.queue-item .queue-message { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.queue-item .queue-error { margin-top: 6px; font-size: .76rem; }
.queue-item .progress-phases { display: none; }
.queue-gear { color: var(--sun-text); transform-origin: 50% 50%; animation: queue-gear-turn 2.4s linear infinite; }
@keyframes queue-gear-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .queue-gear { animation: none; } }
/* The run sheet reads as a compact title block. */
.run-sheet .run-sheet-cell { padding-block: 5px 6px; }
.queue-item { margin: 0; }
.queue-item .queue-item-header .queue-actions { grid-column: auto; flex-wrap: nowrap; padding-top: 0; }
.queue-item .queue-item-header .queue-actions:has(.queue-confirm) { grid-column: 1 / -1; flex-wrap: wrap; }
.queue-item .queue-error { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Missing fields read as a row of chips, not a tall list; the summary grid shows
   once everything is filled, as the last check before adding to the queue. */
.run-sheet[data-ready="false"] .run-sheet-grid { display: none; }
.run-sheet .run-sheet-checklist { display: flex; flex-wrap: wrap; gap: 6px; }
.run-sheet .run-sheet-checklist li { margin: 0; }
.run-sheet .run-sheet-checklist button { min-height: 28px; padding: 3px 10px; border: 1px solid var(--border-medium); border-radius: 999px; background: var(--bg-card); font-size: .78rem; }
.run-sheet .run-sheet-checklist button:hover { border-color: var(--border-accent); background: var(--brand-soft); }
.queue-item { padding: 5px 8px; }
.queue-item .queue-item-header { min-height: 28px; gap: 6px; }
.queue-icon-btn { width: 28px; height: 28px; }
.queue-panel .queue-header { padding-block: 8px; }
.run-sheet .run-sheet-shortcut { display: none; }
#queue-list { gap: 5px; }
.queue-item .queue-error { margin-top: 2px; font-size: .74rem; }

/* ── Loading: one turning gear and a short status line ── */
.app-loading { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 120px; padding: 24px; color: var(--text-secondary); font-size: .9rem; font-weight: 500; }
.app-loading .queue-gear { width: 22px; height: 22px; flex: none; }
.review-link-empty .app-loading, #project-detail-runs .app-loading { min-height: 64px; justify-content: flex-start; padding: 12px 0; }
.btn.is-busy, button.is-busy { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: progress; }
.btn.is-busy .queue-gear, button.is-busy .queue-gear { width: 16px; height: 16px; color: currentColor; }
.workspace-pdf-dialog { position: relative; }
.workspace-pdf-loading { position: absolute; inset: 64px 0 0; display: none; place-items: center; background: var(--bg-card); z-index: 1; }
.workspace-pdf-modal[data-loading="true"] .workspace-pdf-loading { display: grid; }
.workspace-results[aria-busy="true"]::before { content: ""; display: block; height: 3px; margin-bottom: 8px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--sun), transparent) 0 0 / 40% 100% no-repeat var(--bg-secondary); animation: results-busy 1.1s linear infinite; }
@keyframes results-busy { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) { .workspace-results[aria-busy="true"]::before { animation: none; background: var(--sun); } }

/* Rail footer: one aligned column; the legal links sit together under the help link. */
.workspace-nav-footer { display: grid; gap: 10px; justify-items: start; text-align: start; padding: 16px 14px 6px; }
.workspace-nav-footer p { margin: 0; line-height: 1.5; }
.workspace-nav-footer > a { display: inline-flex; align-items: center; min-height: 24px; padding: 0; font-weight: 600; }
.workspace-nav-footer .legal-links { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 2px 12px; margin: 0; padding-top: 10px; border-top: 1px solid var(--border-subtle); width: 100%; }
.workspace-nav-footer .legal-links a { display: inline-flex; align-items: center; min-height: 24px; padding: 0; font-size: .74rem; }
/* On phones the rail becomes a tab bar; the footer stays out of it. */
@media (max-width: 720px) { .workspace-nav-footer { display: none; } }
/* Run name and city share the first row; they stack with a gap on narrow forms. */
.run-name-row { gap: 16px; }
.run-name-row > .field-group:first-child { flex: 1.4; }
@media (max-width: 720px) { .run-name-row { flex-direction: column; gap: 14px; } }
/* Accessibility control clears the fixed submit bar on phones. */
@media (max-width: 720px) { .a11y-fab { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); } .a11y-panel { bottom: calc(144px + env(safe-area-inset-bottom, 0px)); } }

/* ══ Phones, tablets and touch ═══════════════════════════════════════════════
   One pass that keeps every screen inside the viewport, lets tables reflow,
   turns dialogs into sheets on phones and gives touch a 44px target. */

/* Landscape phones with a notch: content stays inside the safe area. */
body { padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px); }
#login-view, #form-view { min-height: 100vh; min-height: 100dvh; }

/* Queue rows never grow past their column (a long error line is nowrap). */
#queue-list { grid-template-columns: minmax(0, 1fr); }
.queue-item { min-width: 0; }

/* Filenames and identifiers wrap, or ellipsize from their own start edge. */
.workspace-sub, .review-share-run-name small, .queue-confirm p, .workspace-name,
.project-detail-title h2, .project-selected-copy small, .diagnostic-run-context { overflow-wrap: anywhere; }
.project-compare-run-identity > span[dir] { text-align: start; }
.queue-item .queue-error, .queue-item .queue-message { unicode-bidi: plaintext; text-align: start; }

/* Project runs: the table needs about 980px; below that each run is a card. */
.project-runs-panel { container: project-runs / inline-size; }
@container project-runs (max-width: 980px) {
  .project-run-table-head { display: none; }
  .project-run-entry, .project-run-entry.no-compare { grid-template-columns: auto minmax(0, 1fr); padding-inline: 0 16px; }
  .project-run-entry.no-compare { grid-template-columns: minmax(0, 1fr); padding-inline: 16px; }
  .project-run-compare { min-width: 48px; }
  .project-run-row { grid-template-columns: minmax(0, 1fr) auto auto auto; column-gap: 14px; }
  .project-run-row > .project-run-meta:nth-child(3) { display: none; }
  .project-run-row > .project-run-meta:nth-child(2) { color: var(--text-muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .project-run-actions { grid-column: 1 / -1; flex-wrap: wrap; justify-content: flex-start; padding: 0 0 12px; }
  .project-run-entry:has(.project-run-compare) .project-run-actions { grid-column: 2; }
}
@container project-runs (max-width: 560px) {
  .project-run-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .project-run-row > .project-run-meta { display: none; }
  .project-run-actions .btn-sm { flex: 1 1 0; }
  .project-run-actions .workspace-icon-action { flex: 0 0 auto; }
}
@container project-runs (max-width: 780px) {
  .project-run-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-run-filter-search { grid-column: 1 / -1; }
  .project-run-filter-actions { align-self: end; }
}

/* Projects toolbar: filters wrap instead of squeezing the date fields. */
.workspace-toolbar .workspace-filters { flex-wrap: wrap; }
.workspace-toolbar .workspace-filter { flex: 1 1 130px; }
.workspace-toolbar .workspace-filter-search { flex: 2 1 220px; }

/* The Hebrew calendar never runs past a narrow screen. */
.hebrew-calendar { max-width: calc(100vw - 24px); }

/* Tablet and phone: the run sheet is a fixed bar, so the page and the
   accessibility control keep clear of it (and of the home indicator). */
@media (max-width: 1024px) {
  .main-layout { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .run-sheet-action { padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
  body:has(#form-view.active):has(#run-workspace:not(.workspace-hidden)) .a11y-fab { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  body:has(#form-view.active):has(#run-workspace:not(.workspace-hidden)) .a11y-panel { bottom: calc(144px + env(safe-area-inset-bottom, 0px)); }
}

/* Touch screens: 16px fields (no zoom on focus) and 44px targets. */
@media (max-width: 720px), (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea,
  .form-inner .input-field, .form-inner .select-field, .workspace-filter input, .workspace-filter select,
  .review-share-field select, .key-input, .input-field, .select-field, .workspace-note-editor textarea { font-size: 16px; }
  .btn, .btn-sm, .queue-panel .btn-sm, .defaults-edit, .file-selection-tools .btn, .workspace-row-action, .workspace-project-run,
  .project-detail-back, .project-review-status, .review-share-links .btn-sm, .glare-address-section .glare-context-load { min-height: 44px; }
  .workspace-run-close, .diagnostic-close { min-width: 44px; min-height: 44px; }
  .queue-icon-btn, .workspace-icon-action, .project-run-actions .workspace-icon-action { width: 44px; height: 44px; flex: 0 0 44px; }
  .queue-icon-btn svg { width: 18px; height: 18px; }
  .queue-item .queue-item-header { min-height: 44px; }
  .model-check, .glare-address-section label:has(> input[type="checkbox"]) { min-height: 44px; align-items: center; }
  .model-disclosure summary, .study-setup > summary, #optional-model-tools > summary, .run-notes-disclosure summary,
  .glare-address-section summary, .diagnostic-section > summary, .project-review-resolved summary { min-height: 44px; padding-block: 11px; }
  summary.workspace-run-section-head { min-height: 44px; }
  .hebrew-calendar-head { grid-template-columns: 44px 1fr 44px; }
  .hebrew-calendar-head button { width: 44px; height: 44px; }
  .hebrew-calendar-days button { min-height: 44px; }
  .hebrew-calendar-actions button { min-height: 44px; }
  .legal-links a, .workspace-nav-footer .legal-links a { min-height: 44px; }
  .project-run-compare { min-width: 48px; }
}

@media (max-width: 720px) {
  /* Dialogs become sheets that rise from the bottom edge. */
  .workspace-run-modal:not(.workspace-pdf-modal) { padding: 12px 0 0; place-items: end stretch; }
  .workspace-run-modal:not(.workspace-pdf-modal) > .workspace-run-dialog {
    width: 100%; max-width: none !important; max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px));
    border-bottom: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .diagnostic-modal { padding: 12px 0 0; align-items: flex-end; }
  .diagnostic-dialog { width: 100%; max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px)); border-bottom: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .review-share-dialog { width: 100%; max-width: 100%; margin: auto 0 0; max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px)); border-bottom: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .workspace-run-head, .diagnostic-header { padding: 14px 16px; gap: 12px; }
  .workspace-run-head h2, .diagnostic-header h2 { font-size: 1.1rem; }
  .workspace-pdf-modal { padding: 0; }
  .workspace-pdf-dialog { width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .workspace-pdf-head { padding: 10px 12px; }
  /* Defaults sheet: confirm and cancel stay in reach while the list scrolls. */
  .defaults-modal-actions {
    position: sticky; bottom: 0; z-index: 2; margin: 0 -16px -20px; padding: 12px 16px 16px;
    border-top: 1px solid var(--border-subtle); background: var(--bg-card);
  }
  .defaults-modal-actions .btn { flex: 1 1 0; }
  .defaults-modal-tools { flex-wrap: wrap; }

  /* Projects head: the copy keeps its natural height when the head stacks. */
  .workspace-head-copy { flex: 0 1 auto; }
  .workspace-toolbar-actions { align-self: stretch; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }

  /* Project detail: a shorter title, the primary action on its own row, compact facts. */
  .project-detail-header { padding: 18px 16px; }
  .project-detail-title { align-items: flex-start; }
  .project-detail-title h2 { font-size: 1.35rem; line-height: 1.25; }
  .project-detail-actions { width: 100%; }
  .project-detail-actions .btn { flex: 1 1 0; min-width: max-content; }
  .project-detail-actions .btn-primary { flex-basis: 100%; }
  .project-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .project-overview > div { padding: 12px 14px; }
  .project-overview b { margin-top: 4px; }
  .project-runs-head { padding: 14px 16px; }
  .project-run-filters { padding: 12px 16px; }

  .hebrew-calendar { width: min(340px, calc(100vw - 24px)); }
}

/* The smallest phones: tabs stack the icon over the label so all three fit. */
@media (max-width: 400px) {
  .workspace-nav { padding-inline: 6px; gap: 2px; }
  .workspace-nav button { flex-direction: column; gap: 2px; min-height: 48px; padding: 4px 4px 6px; font-size: .72rem; line-height: 1.2; }
  .workspace-nav-live { top: 4px; left: 4px; }
}
