/* Scene overlays (visual v3, 11 Nov 2026).
   The 3D view stays readable: the story card is a compact chip that opens on
   demand and the planning legend is a single-line strip that expands on hover
   or keyboard focus. No information is removed; it is one click/hover away. */

.studio-app .production-story-overlay,
.production-story-overlay {
  top: 12px;
  left: 12px;
  width: auto;
  max-width: min(440px, calc(100% - 120px));
  padding: 0;
  border-radius: 999px;
  border-left-width: 1px;
  background: rgba(6, 31, 24, 0.78);
  box-shadow: 0 6px 18px rgba(3, 20, 15, 0.18);
  pointer-events: auto;
}

.three-planning-view.is-active + .production-story-overlay {
  display: block;
}

.production-story-overlay .story-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  background: transparent;
  color: #89dfc1;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.production-story-overlay .story-toggle span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-size: inherit;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.production-story-overlay .story-toggle i {
  display: inline-grid;
  flex: 0 0 22px;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-style: normal;
  font-weight: 800;
}

.production-story-overlay .story-toggle:focus-visible {
  outline: 2px solid #f0c24b;
  outline-offset: 2px;
}

/* Collapsed detail stays rendered (clipped) so innerText-based checks still
   read the headline and evidence. */
.production-story-overlay .story-detail {
  display: grid;
  gap: 3px;
  max-height: 0;
  overflow: hidden;
  padding: 0 14px;
  opacity: 0;
  transition: max-height 0.18s ease, opacity 0.18s ease, padding 0.18s ease;
}

.production-story-overlay.is-expanded {
  border-radius: 14px;
  background: rgba(6, 31, 24, 0.9);
}

.production-story-overlay.is-expanded .story-detail {
  max-height: 220px;
  padding: 0 14px 10px;
  opacity: 1;
}

.production-story-overlay .story-detail strong {
  color: #ffffff;
  font-size: 12px;
  line-height: 1.3;
}

.production-story-overlay .story-detail small {
  color: rgba(255, 255, 255, 0.66);
  font-size: 11px;
  line-height: 1.3;
}

.studio-app .three-planning-legend,
.three-planning-legend {
  bottom: 10px;
  left: 10px;
  max-width: min(520px, calc(100% - 140px));
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(5, 28, 22, 0.62);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;   /* whole phrases only (app.js setPlanningLegend): never an ellipsis mid-phrase */
  pointer-events: auto;
  cursor: help;
}

.three-planning-legend .legend-full { display: none; }

.three-planning-legend:hover,
.three-planning-legend:focus-visible {
  max-width: min(680px, calc(100% - 24px));
  border-radius: 10px;
  background: rgba(5, 28, 22, 0.9);
  white-space: normal;
  outline: none;
}

.three-planning-legend:hover .legend-short,
.three-planning-legend:focus-visible .legend-short { display: none; }

.three-planning-legend:hover .legend-full,
.three-planning-legend:focus-visible .legend-full { display: inline; }

@media (prefers-reduced-motion: reduce) {
  .production-story-overlay .story-detail {
    transition: none;
  }
}

@media (max-width: 700px) {
  .studio-app .production-story-overlay,
  .production-story-overlay {
    max-width: calc(100% - 70px);
  }

  .studio-app .three-planning-legend,
  .three-planning-legend {
    max-width: calc(100% - 20px);
  }
}

/* Layout editor (phase 1): toolbar over the 3D view, warnings, rotation marker. */
.layout-edit-bar {
  position: absolute;
  z-index: 35;
  top: 12px;
  right: 64px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(5, 28, 22, 0.72);
  backdrop-filter: blur(8px);
}

.layout-edit-bar[hidden] {
  display: none !important;
}

.layout-edit-bar .compact-button {
  min-height: 26px;
  padding: 0 9px;
  font-size: 11px;
}

.layout-edit-bar .compact-button:disabled,
.layout-edit-row .compact-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Signal red is reserved for the bottleneck marker and pill: layout warnings are amber-outlined with an icon. */
.layout-warning-chip {
  padding: 3px 8px;
  border: 1px solid #e0b04a;
  border-radius: 999px;
  background: rgba(5, 28, 22, 0.55);
  color: #f6d98a;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  cursor: help;
}
.layout-warning-chip::before { content: "\26A0\FE0E"; margin-right: 4px; font-weight: 400; }

.layout-edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.layout-edit-warnings-title {
  margin: 10px 0 4px;
  font-size: 13px;
}

.layout-edit-warnings {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.layout-edit-warnings li {
  padding: 5px 8px;
  border-left: 3px solid #c4271c;
  border-radius: 4px;
  background: rgba(196, 39, 28, 0.08);
}

.layout-edit-warnings li.is-clear {
  border-left-color: #0d7a64;
  background: rgba(13, 122, 100, 0.08);
}

.scene-object.has-layout-warning {
  outline: 2px solid #d2261b;
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(210, 38, 27, 0.18);
}

.scene-object[data-mobility="fixed"]:not([data-type="building"]) {
  cursor: not-allowed;
}

.scene-object-heading {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid #173f34;
  transform: translate(-50%, -50%) rotate(var(--heading, 0deg)) translateY(14px);
  pointer-events: none;
}

.three-planning-view canvas.is-dragging-layout {
  cursor: grabbing;
}

@media (max-width: 700px) {
  .layout-edit-bar {
    top: auto;
    right: 10px;
    bottom: 44px;
  }
}

/* ------------------------------------------------------------------ operation chain panels (mining/agri) */
.chain-decision-panel[hidden],
.chain-inputs-panel[hidden] { display: none !important; }
#chainDecisionPanel { order: 5; }
#chainInputsPanel { order: 5; }
body[data-template="mining-operation"] { --sector-accent: #e3914f; --sector-accent-soft: rgba(227,145,79,.16); --sector-surface: #3b2f24; }
body[data-template="agri-operation"] { --sector-accent: #6fae5a; --sector-accent-soft: rgba(111,174,90,.15); --sector-surface: #22351d; }
body[data-chain="true"] .replay-timeline,
body[data-chain="true"] .advisor-action-grid,
body[data-chain="true"] #missionCompareOptions { display: none !important; }

.chain-decision-panel, .chain-inputs-panel { margin-top: 12px; overflow: hidden; }
.chain-decision-panel h2, .chain-inputs-panel h2 { margin: 0 0 4px; font-size: 19px; }
.chain-decision-panel h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chain-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.chain-pack-status:empty { display: none; }
.chain-pack-status { margin: -6px 0 10px; font-size: 13px; color: var(--muted); }

.chain-verdict { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 14px; }
.chain-verdict > div { min-width: 0; padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: #f8faf8; }
.chain-verdict span, .chain-risk span, .chain-recommendation > span { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chain-verdict strong { display: block; margin-top: 4px; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.chain-verdict small { display: block; margin-top: 3px; color: var(--muted); }
.chain-verdict.tone-risk > div:first-child { background: var(--risk-bg); border-color: var(--risk-line); }
.chain-verdict.tone-good > div:first-child { background: var(--good-bg); border-color: var(--good-line); }

.chain-decision-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chain-block { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.chain-block-options { grid-column: 1 / -1; }

.chain-stage-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.chain-stage-bar-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: 13px; }
.chain-stage-bar-head span { color: var(--muted); font-size: 12px; }
.chain-binding-chip { font-style: normal; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--warn); padding: 1px 6px; border-radius: 999px; margin-left: 4px; vertical-align: middle; }
.chain-bar-track { position: relative; height: 12px; margin-top: 4px; border-radius: 999px; background: #edf1ee; }
.chain-bar-capacity { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }
.chain-stage-bar.is-short .chain-bar-capacity { background: var(--accent-2); }
.chain-stage-bar.is-binding .chain-bar-capacity { background: var(--warn); }
.chain-stage-bar.is-binding .chain-bar-track { box-shadow: 0 0 0 2px rgba(194, 59, 34, .25); }
.chain-bar-demand { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1px; background: var(--ink); border-radius: 2px; }
.chain-legend { margin: 8px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chain-legend-cap { display: inline-block; width: 18px; height: 8px; border-radius: 999px; background: var(--accent); }
.chain-legend-demand { display: inline-block; width: 3px; height: 12px; background: var(--ink); margin-left: 8px; }

.chain-plan { margin: 0 0 8px; padding-left: 22px; display: grid; gap: 8px; }
.chain-plan li strong { display: block; }
.chain-plan li span, .chain-plan li small { display: block; font-size: 12px; color: var(--muted); }
.chain-plan-summary { margin: 0 0 10px; font-weight: 700; font-size: 13px; }
.chain-risk { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chain-risk > div { padding: 8px 10px; border-radius: 8px; background: #f6f8f6; border: 1px solid var(--line); }
.chain-risk strong { display: block; font-size: 20px; }
.chain-risk small { color: var(--muted); font-size: 12px; }
.chain-risk p { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }
.chain-decision-panel .tone-risk { color: var(--warn); }
.chain-decision-panel .tone-good { color: var(--good); }
.chain-decision-panel .tone-watch { color: #9a6a12; }
.chain-decision-panel .chain-verdict.tone-risk, .chain-decision-panel .chain-verdict.tone-good { color: inherit; }

.chain-table-wrap { overflow-x: auto; max-width: 100%; }
.chain-options { width: 100%; border-collapse: collapse; font-size: 13px; }
.chain-options th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.chain-options td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.chain-options td small { display: block; color: var(--muted); font-size: 11px; }
.chain-options tr.is-top td:first-child { font-weight: 800; }
.chain-decision-panel .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chain-blend { margin-bottom: 12px; padding: 10px; border-radius: 8px; background: var(--sector-accent-soft, #f3efe6); }
.chain-blend strong { font-size: 18px; }
.chain-blend p { margin: 4px 0; font-size: 13px; }
.chain-blend small { color: var(--muted); font-size: 12px; }
.chain-products { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.chain-products li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; }
.chain-products small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }

.chain-tornado { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 12px; }
.chain-tornado-track { position: relative; height: 10px; margin: 3px 0 2px; background: linear-gradient(90deg, transparent calc(50% - 1px), #9aa8a0 calc(50% - 1px), #9aa8a0 calc(50% + 1px), transparent calc(50% + 1px)), #f1f4f1; border-radius: 4px; }
.chain-tornado-track i { position: absolute; top: 0; bottom: 0; }
.chain-tornado-track i.down { background: var(--warn); border-radius: 4px 0 0 4px; }
.chain-tornado-track i.up { background: var(--accent); border-radius: 0 4px 4px 0; }
.chain-tornado small { color: var(--muted); }
.chain-assumed { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 3px; }

.chain-recommendation { margin-top: 12px; padding: 12px 14px; border-left: 4px solid var(--sector-accent, var(--accent)); background: #f8faf8; border-radius: 0 8px 8px 0; }
.chain-recommendation p { margin: 4px 0 0; font-weight: 700; line-height: 1.45; }

.chain-input-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.chain-stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.chain-stage-inputs { min-width: 0; margin: 0; padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 6px; }
.chain-stage-inputs legend { padding: 0 4px; font-weight: 800; font-size: 13px; }
.chain-input { display: grid; gap: 3px; min-width: 0; font-size: 12px; color: var(--muted); }
.chain-input > span { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chain-input input { width: 100%; min-width: 0; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 14px; color: var(--ink); background: #fff; }
.chain-input input[aria-invalid="true"] { border-color: var(--warn); }
.chain-prov { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; border: 1px solid transparent; }
.chain-prov-actual { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.chain-prov-surveyed { background: #e8f1fb; color: #164f83; border-color: #a9c4e3; }
.chain-prov-calibrated { background: var(--watch-bg); color: #8a6212; border-color: var(--watch-line); }
.chain-prov-assumed { background: var(--risk-bg); color: var(--warn); border-color: var(--risk-line); }
.chain-note { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

@media (max-width: 900px) {
  .chain-verdict { grid-template-columns: 1fr; }
  .chain-decision-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .chain-decision-panel .section-heading, .chain-inputs-panel .section-heading { flex-direction: column; }
  .chain-heading-actions { justify-content: flex-start; }
  .chain-risk { grid-template-columns: 1fr; }
  .chain-options thead { display: none; }
  .chain-options, .chain-options tbody, .chain-options tr, .chain-options td { display: block; width: 100%; box-sizing: border-box; }
  .chain-options tr { padding: 6px 0; border-bottom: 1px solid var(--line); }
  .chain-options td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 10px; }
  .chain-options td::before { content: attr(data-label); color: var(--muted); font-size: 11px; text-transform: uppercase; }
  .chain-options td:first-child { display: block; }
  .chain-options td:first-child::before { content: none; }
  .chain-stage-grid, .chain-input-grid { grid-template-columns: 1fr; }
}

/* Layout editor stage 2: walls, individual rows and doors, heat map, option A/B compare. */
.layout-edit-bar {
  flex-wrap: wrap;
  justify-content: flex-end;
  /* Leave room for the scene's status chip at top left: the buttons wrap onto a second row instead. */
  max-width: max(300px, calc(100% - 540px));
}

.layout-edit-bar .compact-button[aria-pressed="true"],
.layout-option-row .compact-button[aria-pressed="true"] {
  background: #f0c24b;
  border-color: #f0c24b;
  color: #10241e;
}

.layout-edit-bar [hidden],
.layout-edit-row [hidden] {
  display: none !important;
}

.layout-counts-note,
.layout-option-status {
  margin: 2px 0 0;
  color: #4b5d56;
  font-size: 12px;
  line-height: 1.4;
}

.layout-counts-note:empty,
.layout-option-status:empty {
  display: none;
}

.scene-object.is-wall {
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: #4f5b57;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
  min-width: 3px;
  min-height: 3px;
}

.scene-object.is-wall::before,
.scene-object.is-wall span,
.scene-object.is-wall small,
.scene-object.is-wall::after,
.scene-object.is-compact::before,
.scene-object.is-compact small,
.scene-object.is-compact::after {
  display: none;
}

.scene-object.is-compact {
  padding: 0 4px;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.1;
  white-space: nowrap;
}

.scene-object.is-compact span {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
}

.scene-object.is-wall.is-selected {
  background: #c2701a;
  box-shadow: 0 0 0 3px rgba(240, 194, 75, 0.75);
}

.scene-object.is-wall.has-layout-warning {
  background: #b3261e;
}

.scene-object.has-heat {
  background: color-mix(in srgb, var(--heat-colour) 34%, #ffffff);
  border-color: var(--heat-colour);
  box-shadow: inset 0 0 0 2px var(--heat-colour);
}

.scene-object.has-no-heat {
  background: repeating-linear-gradient(135deg, #f3f5f4 0 6px, #e1e6e3 6px 12px);
}

.scene-preview.is-heat-on .scene-object small,
.scene-object.is-compact .scene-heat-badge {
  display: none;
}

.scene-heat-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--heat-colour);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.layout-heat-legend {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(23, 32, 29, 0.14);
  border-radius: 8px;
  background: #ffffff;
  color: #17201d;
  font-size: 12px;
  line-height: 1.35;
}

.layout-heat-legend[hidden] {
  display: none !important;
}

.layout-heat-legend ul {
  display: grid;
  gap: 3px;
  margin: 5px 0;
  padding: 0;
  list-style: none;
}

.layout-heat-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.layout-heat-legend i {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.layout-heat-legend i.is-no-data {
  background: repeating-linear-gradient(135deg, #f3f5f4 0 3px, #c9d1cd 3px 6px);
  border: 1px solid #b7c1bc;
}

.layout-heat-legend small {
  display: block;
  color: #3f514a;
  font-size: 11px;   /* footnote at the 11 px floor (round 3, P11) */
  line-height: 1.35;
}

.layout-heat-legend .layout-heat-reason {
  margin: 0;
  color: #4b5d56;
}

.layout-heat-legend.is-overlay {
  position: absolute;
  z-index: 34;
  right: 12px;
  bottom: 48px;
  max-width: 280px;
  margin: 0;
  box-shadow: 0 10px 24px rgba(5, 28, 22, 0.22);
}

.layout-compare-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #17201d;
  box-shadow: 0 30px 80px rgba(5, 28, 22, 0.35);
}

.layout-compare-dialog::backdrop {
  background: rgba(5, 28, 22, 0.55);
}

.layout-compare-inner {
  display: grid;
  gap: 12px;
  padding: 18px 20px;
}

.layout-compare-inner header h2 {
  margin: 0;
  font-size: 18px;
}

.layout-compare-inner header p,
.layout-compare-note,
.layout-compare-key {
  margin: 4px 0 0;
  color: #4b5d56;
  font-size: 12px;
}

.layout-compare-note.is-warning {
  padding: 6px 9px;
  border-left: 3px solid #d97842;
  border-radius: 4px;
  background: rgba(217, 120, 66, 0.1);
  color: #5c3a1e;
}

.layout-compare-table-wrap {
  overflow-x: auto;
}

.layout-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.layout-compare-table th,
.layout-compare-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e3e8e5;
  text-align: right;
  white-space: nowrap;
}

.layout-compare-table th[scope="row"],
.layout-compare-table thead th:first-child {
  text-align: left;
  white-space: normal;
}

.layout-compare-table thead th {
  color: #4b5d56;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.layout-compare-table tr[data-verdict="better"] .layout-compare-delta,
.layout-compare-key .is-better {
  color: #0b6b4f;
  font-weight: 800;
}

.layout-compare-table tr[data-verdict="worse"] .layout-compare-delta,
.layout-compare-key .is-worse {
  color: #b3261e;
  font-weight: 800;
}

.layout-compare-table tr[data-verdict="better"] {
  background: rgba(31, 154, 114, 0.08);
}

.layout-compare-table tr[data-verdict="worse"] {
  background: rgba(198, 42, 31, 0.07);
}

.layout-compare-inner h3 {
  margin: 4px 0 0;
  font-size: 14px;
}

.layout-compare-changes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.layout-compare-changes-group h4 {
  margin: 0 0 4px;
  font-size: 12px;
}

.layout-compare-changes-group ul {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
}

.layout-compare-inner footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 700px) {
  .layout-edit-bar {
    left: 10px;
    max-width: none;
  }

  .layout-heat-legend.is-overlay {
    left: 10px;
    right: 10px;
    bottom: auto;
    top: 10px;
    max-width: none;
  }

  .layout-compare-inner {
    padding: 14px;
  }
}

/* ------------------------------------------------------------------ polish-1
   Headline finding card, compact meeting controls, readable KPI values. */
.studio-app .topbar { min-height: 0; padding: 10px 14px; align-items: center; gap: 14px; }
.studio-app .topbar h1 { font-size: clamp(19px, 1.7vw, 24px); margin-bottom: 0; }
.studio-app .topbar p { max-width: 62ch; }
.studio-app .presentation-toolbar { flex-wrap: nowrap; gap: 5px; }
.studio-app .presentation-toolbar button {
  flex: 0 0 auto;
  width: auto;
  min-height: 30px;
  padding: 5px 9px;
  font-size: 10.5px;
  white-space: nowrap;
}
.studio-app #presentationStatus {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.studio-app .topbar .run-status { white-space: nowrap; }

.studio-headline {
  order: 1;
  display: grid;
  gap: 10px;
  margin: 0 0 8px;
  padding: 13px 15px 12px;
  border: 1px solid rgba(13, 81, 67, 0.16);
  border-left: 4px solid var(--sector-accent, #0d5143);
  border-radius: 12px;
  background: linear-gradient(115deg, var(--sector-accent-soft, #e9f5f1), #ffffff 46%);
  color: #10251f;
}
.studio-headline[hidden] { display: none; }
.studio-headline .headline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.9fr) minmax(0, 1.35fr);
  gap: 14px;
}
.studio-headline .headline-cell { display: grid; align-content: start; gap: 4px; min-width: 0; }
.studio-headline .headline-cell + .headline-cell { padding-left: 14px; border-left: 1px solid rgba(13, 81, 67, 0.14); }
.studio-headline .headline-cell > span {
  color: var(--sector-accent, #0d5143);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.studio-headline .headline-cell strong { font-size: 15px; line-height: 1.32; font-weight: 750; letter-spacing: -0.01em; }
.studio-headline .headline-cell p { margin: 0; font-size: 13px; line-height: 1.42; }
.studio-headline .headline-cell.is-fix p { font-weight: 700; color: #0b3f33; }
.studio-headline .headline-cell small { color: #4a5f58; font-size: 11.5px; line-height: 1.35; }
.studio-headline .headline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.studio-headline .headline-chip {
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid rgba(13, 81, 67, 0.28);
  border-radius: 999px;
  background: #ffffff;
  color: #0d5143;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}
.studio-headline .headline-chip:hover { background: #eef7f3; }
.studio-headline .headline-chip:focus-visible,
.studio-headline .headline-cta:focus-visible { outline: 3px solid #f0c24b; outline-offset: 2px; }
.studio-headline .headline-cta {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
  min-height: 34px;
  padding: 7px 14px;
  border-radius: 9px;
  background: #a2501d;   /* white text >= 4.5:1 (5.7:1); the old #c8692f was 3.8:1 */
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.studio-headline .headline-cta small { font-size: 11px; font-weight: 650; opacity: 1; }
.studio-headline .headline-cta:hover { background: #8a4417; }
.studio-headline .headline-status { margin: 0; min-height: 0; color: #0d5143; font-size: 12px; font-weight: 650; }
.studio-headline .headline-status:empty { display: none; }

/* Long stage names ("Crusher (high grade)") wrap instead of truncating. */
.studio-app .main-simulation-card .kpi-card strong { white-space: normal; overflow-wrap: anywhere; line-height: 1.15; }

body.is-presentation .studio-headline,
.studio-app.is-presentation .studio-headline { margin-bottom: 14px; }

@media (max-width: 1100px) {
  .studio-headline .headline-grid { grid-template-columns: 1fr 1fr; }
  .studio-headline .headline-cell.is-fix { grid-column: 1 / -1; padding-left: 0; border-left: 0; padding-top: 8px; border-top: 1px solid rgba(13, 81, 67, 0.14); }
}
@media (max-width: 900px) {
  .studio-app .presentation-toolbar { display: none; }
}
@media (max-width: 700px) {
  .studio-headline { padding: 11px 12px; }
  .studio-headline .headline-grid { grid-template-columns: 1fr; gap: 8px; }
  .studio-headline .headline-cell + .headline-cell { padding-left: 0; border-left: 0; padding-top: 8px; border-top: 1px solid rgba(13, 81, 67, 0.14); }
  .studio-headline .headline-cell strong { font-size: 14px; }
  .studio-headline .headline-cta { margin-left: 0; width: 100%; justify-content: center; flex-wrap: wrap; }
}
.studio-app .topbar > div:first-child { flex: 1 1 260px; min-width: 0; }
.studio-app .topbar .run-status { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.studio-app .main-simulation-card .kpi-card em { white-space: normal; }

/* Provenance tags on chain inputs (physics branch: illustrative -> directional -> calibrated -> validated).
   Text + border style carry the level, not colour alone; no signal red (reserved for the bottleneck).
   All text/background pairs >= 4.5:1. */
.chain-prov-illustrative,
.chain-prov-directional,
.chain-prov-calibrated,
.chain-prov-validated {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
}
.chain-prov-illustrative { color: #4b5754; background: #eef1f0; border-style: dashed; }
.chain-prov-illustrative::before { content: "\25CB"; }            /* hollow circle: not measured */
.chain-prov-directional { color: #1d4f7a; background: #e8f0f8; border-style: dashed; }
.chain-prov-directional::before { content: "\25D0"; }             /* half circle */
.chain-prov-calibrated { color: #0b5f4e; background: #e3f2ed; }
.chain-prov-calibrated::before { content: "\25D5"; }
.chain-prov-validated { color: #ffffff; background: #0d6b57; border-color: #0d6b57; }
.chain-prov-validated::before { content: "\25CF"; }               /* filled circle: validated */

/* ------------------------------------------------------------------ visual baseline v2 (13 Nov 2026)
   Bottleneck pill anchored to the marker, one-line data credit above the status strip, a real
   metric scale bar, no truncated headline chip, and phone overlays that leave the stage visible. */
.scene-bottleneck-pill {
  position: absolute;
  z-index: 6;
  max-width: min(320px, calc(100% - 16px));
  padding: 4px 10px;
  border-radius: 999px;
  background: #c23b22;          /* signal red: reserved for the bottleneck marker */
  color: #ffffff;               /* 5.5:1 */
  font: 800 12px/1.3 system-ui, sans-serif;
  white-space: normal;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}
.scene-bottleneck-pill[hidden] { display: none; }

/* Key-equipment chips: a glyph + label anchored above a machine that projects too small to recognise
   (scene3d_renderer.js placeKeyChips; minimum 24 px desktop, 18 px phone). Dark ink, never signal red. */
.scene-key-chips { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.scene-key-chip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 3px;
  border-radius: 999px;
  background: rgba(16, 36, 30, 0.9);
  color: #ffffff;               /* 14:1 */
  font: 700 11px/1.25 system-ui, sans-serif;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}
.scene-key-chip[hidden] { display: none; }
.scene-key-chip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom: 0;
  border-top-color: rgba(16, 36, 30, 0.9);
}
.scene-key-glyph {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f0c24b;
}
.scene-key-glyph svg { width: 12px; height: 10px; fill: #10241e; }

.scene-data-credit {
  position: absolute;
  z-index: 5;
  left: 10px;
  bottom: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 180px);
  margin: 0;
  border: 0;
  border-radius: 999px;
  padding: 2px 4px 2px 9px;
  background: rgba(16, 24, 22, 0.78);
  color: #f4f7f4;
  font: 600 10.5px/1.4 system-ui, sans-serif;
  text-align: left;
  white-space: nowrap;
  min-height: 0;
  height: auto;
  width: auto;
  box-shadow: none;
  cursor: pointer;
}
.scene-data-credit span { overflow: hidden; text-overflow: clip; }
.scene-data-credit i {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-style: normal;
  font-weight: 800;
}
.scene-data-credit[aria-expanded="true"] { white-space: normal; border-radius: 10px; max-width: min(560px, calc(100% - 20px)); }
.scene-data-credit:focus-visible { outline: 2px solid #f0c24b; outline-offset: 2px; }
.scene-data-credit[hidden] { display: none; }

.studio-app .scene-scale,
.scene-scale {
  right: 12px;
  bottom: 10px;
  min-width: 0;
  padding: 3px 8px 4px;
  border-radius: 8px;
  background: rgba(16, 24, 22, 0.72);
  color: #f4f7f4;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
}
.scene-scale i { width: 60px; max-width: 160px; }
.scene-compass i { border-bottom-color: #f0c24b; }

/* the story chip shows the whole bottleneck line (wraps to two lines, never "3 tr...") */
.production-story-overlay .story-toggle span {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.3;
}

@media (max-width: 700px) {
  /* keep the bottleneck chip on the scene on phones (it used to drop below the canvas) */
  .studio-app .production-story-overlay,
  .production-story-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    width: auto;
    max-width: calc(100% - 76px);
    margin-top: 0;
    padding: 0;
  }
  .three-planning-view.is-active + .production-story-overlay { display: block; }
  /* edit tools wrap under the chip (no hidden scroll row: every button and the warnings stay on screen);
     the layout warnings chip comes first so it is never pushed out of view */
  .layout-edit-bar {
    top: 52px;
    bottom: auto;
    left: 8px;
    right: 8px;
    max-width: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    overflow: visible;
  }
  .layout-edit-bar .compact-button { flex: 0 0 auto; padding: 0 7px; white-space: nowrap; }
  .layout-edit-bar .layout-warning-chip { order: -1; }
  .scene-data-credit { bottom: 36px; max-width: calc(100% - 20px); }
  .scene-scale { bottom: 8px; right: 8px; }
  .scene-render-badge { display: none !important; }
}

/* Round 3 (P12 / P22): on phones the layout tools fold behind one "Tools" button beside the compass, so the
   toolbar covers a corner instead of two or three rows of the frame; the button carries the warning count. */
.layout-edit-bar .layout-more-toggle { display: none; }
@media (max-width: 700px) {
  .layout-edit-bar .layout-more-toggle { display: inline-flex; align-items: center; order: -2; }
  .layout-edit-bar:not(.is-expanded) {
    top: 56px;
    left: auto;
    right: 8px;
    padding: 3px;
    gap: 0;
  }
  .layout-edit-bar:not(.is-expanded) > :not(.layout-more-toggle) { display: none !important; }
  .layout-edit-bar .layout-more-toggle.has-warnings { border-color: #e0b04a; color: #f6d98a; }
}

/* Round 5 (R5-4): plain-words physics alerts, amber (signal red is reserved for the bottleneck). */
.scene-alert-chip {
  position: absolute;
  z-index: 31;
  max-width: min(380px, calc(100% - 16px));
  padding: 3px 9px;
  border: 1px solid #e0b04a;
  border-radius: 10px;
  background: rgba(5, 28, 22, 0.86);
  color: #f6d98a;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;   /* wraps to two lines: never cut mid-phrase */
  pointer-events: auto;
}
.scene-alert-chip[hidden] { display: none; }
.production-story-overlay .story-alert {
  margin: 4px 0 0;
  padding: 3px 9px;
  border: 1px solid #e0b04a;
  border-radius: 8px;
  background: rgba(5, 28, 22, 0.86);
  color: #f6d98a;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.3;
}
.production-story-overlay .story-alert-short { display: none; }
@media (max-width: 700px) {
  /* one short line on phones: the scene chrome stays within its budget */
  .production-story-overlay .story-alert-long { display: none; }
  .production-story-overlay .story-alert-short { display: inline; }
}
