:root {
  color-scheme: light;
  --page: #f2f5f3;
  --surface: #ffffff;
  --surface-subtle: #f6f8f7;
  --surface-strong: #e9efec;
  --ink: #202925;
  --muted: #586960;
  --line: #d5ddd9;
  --line-strong: #b9c7c1;
  --green: #216b5b;
  --green-dark: #174c41;
  --green-soft: #e6f2ee;
  --blue: #355f82;
  --blue-soft: #e8f0f6;
  --amber: #8b612f;
  --amber-soft: #fbf3e7;
  --danger: #a23f3f;
  --danger-soft: #fff0f0;
  --shadow: 0 8px 24px rgba(31, 52, 44, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.advanced-options > summary {
  display: list-item;
  cursor: pointer;
  color: var(--ink);
  padding-block: 4px;
}

.advanced-summary-copy {
  display: inline-grid;
  gap: 4px;
  vertical-align: middle;
  max-width: calc(100% - 22px);
}

.advanced-summary-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.advanced-content {
  margin-block-start: 18px;
}

.advanced-content > .field-hint {
  margin-block: 10px;
}

.stability-limits summary {
  cursor: pointer;
  color: var(--green);
  font-weight: 650;
}

.stability-option {
  padding-block: 12px;
  border-block-start: 1px solid var(--line);
}

.stability-option:first-of-type {
  padding-block-start: 0;
  border-block-start: 0;
}

.stability-option > .option-note {
  margin-block: 5px 8px;
  padding-inline-start: 30px;
}

.stability-limits {
  margin-inline-start: 30px;
  font-size: 12px;
}

.stability-limits > .field-hint {
  margin-block: 10px;
}

.stability-limits > .option-check {
  margin-block-start: 10px;
  font-size: 12px;
}

.growth-row {
  padding-block: 14px;
  border-block-start: 1px solid var(--line);
}

.growth-row > strong {
  display: block;
  margin-block-end: 10px;
  font-size: 13px;
}

.growth-family-title small {
  margin-inline-start: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.growth-row .bonus-pair-fields {
  margin-block: 10px;
}

.growth-row .option-check {
  font-size: 12px;
}

.growth-number {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.growth-number input {
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
}

.growth-number > span {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
}

.growth-range {
  font-size: 12px;
  color: var(--muted);
  margin-block: 8px 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.bonus-coverage {
  margin-block: 16px;
  color: var(--muted);
  font-size: 12px;
}

.bonus-coverage summary {
  cursor: pointer;
  font-weight: 400;
}

/* Keep result guidance in place when its current coverage becomes unavailable. */
.result-feedback { display: grid; margin-block: 16px; color: var(--muted); font-size: 12px; }
.result-feedback > * { grid-area: 1 / 1; align-self: start; margin: 0; }
.result-feedback > [hidden],
#planExplanationPrevious[hidden] { display: block !important; visibility: hidden; pointer-events: none; }
.result-feedback-note { color: var(--amber); line-height: 1.5; }

.coverage-range {
  margin-block: 12px 0;
  padding-block-start: 10px;
  border-block-start: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

html {
  background: var(--page);
  scroll-padding-block: 20px 160px;
}

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}

:target {
  scroll-margin-block: 20px;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 8px;
  inset-inline-start: 12px;
  padding: 12px 16px;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--green-dark);
  color: white;
}

.skip-link:focus {
  transform: translateY(0);
}

.workflow-nav {
  margin-bottom: 22px;
}

.workflow-nav ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.workflow-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.workflow-nav a:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.workflow-nav a > span:first-child {
  color: var(--green);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.review-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--green);
  font-size: 12px;
  font-weight: 650;
  text-underline-offset: 4px;
}

body {
  min-width: 0;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1400px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 4px 2px 0;
}

.brand-block {
  min-width: 0;
}

.maker-lockup {
  display: inline-grid;
  min-width: 0;
  grid-template-columns: 46px minmax(0, auto);
  align-items: center;
  gap: 10px;
  margin-top: 0;
}

.maker-monogram {
  display: grid;
  width: 46px;
  height: 38px;
  place-items: center;
  border: 1px solid #c8a66e;
  border-radius: 6px;
  background: var(--amber-soft);
  color: #72502a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.maker-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.maker-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
}

.maker-name {
  color: var(--amber);
  font-size: 14px;
  font-weight: 820;
  line-height: 1.25;
}

.maker-invite {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  white-space: normal;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1,
h2 {
  margin-bottom: 0;
  letter-spacing: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(26px, 2.6vw, 34px);
  font-weight: 780;
}

h2 {
  font-size: 20px;
  font-weight: 760;
}

.page-summary,
.panel-copy {
  max-width: 570px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.panel-copy {
  font-size: 13px;
}

.header-tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.language-picker {
  display: grid;
  min-width: 150px;
  gap: 5px;
}

.language-picker-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.language-picker-icon {
  flex: 0 0 auto;
}

.language-picker select {
  width: 100%;
  min-height: 44px;
  padding-block: 8px;
  padding-inline-start: 12px;
  padding-inline-end: 28px;
  background-color: var(--surface);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 500px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.controls {
  container-type: inline-size;
  container-name: march-setup;
  display: block;
  min-width: 0;
  padding: 22px;
  /* Redrawing/revealing setup content can move WebKit's chosen scroll anchor
     even when the controls keep their document positions. Leave page/results
     anchoring intact while keeping these interactive form edits stationary. */
  overflow-anchor: none;
}

.results {
  min-width: 0;
  padding: 22px;
}

.panel-header {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.controls-header {
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.controls-header > div { min-width: 0; }

.results-header {
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.results-header > div {
  flex: 1 1 20rem;
  min-width: 0;
}

.results-header .review-link {
  flex: 0 0 auto;
  min-height: 40px;
}

.panel-kicker {
  color: var(--muted);
  font-size: 11px;
}

.form-section {
  min-width: 0;
  margin: 0;
  padding: 24px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.leadership-section {
  padding-top: 24px;
}

.capacity-fields {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.custom-active-banner {
  display: flex;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--green-soft);
}

.custom-active-banner strong {
  display: block;
  color: var(--green-dark);
  font-size: 13px;
}

.custom-active-banner button {
  flex: 0 0 auto;
  max-width: 100%;
}

.custom-active-banner .custom-mode-exit {
  min-height: 44px;
  padding-inline: 14px;
  border-color: var(--green);
  background: var(--surface);
  color: var(--green-dark);
}

.custom-active-banner .custom-mode-exit:hover {
  border-color: var(--green-dark);
  background: var(--surface-subtle);
  color: var(--green-dark);
}

.custom-active-banner .custom-mode-exit:focus-visible {
  outline: 3px solid var(--green-dark);
  outline-offset: 2px;
}

.step-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 750;
}

.section-heading .step-heading {
  margin-bottom: 0;
}

.step-number {
  display: inline-grid;
  flex: 0 0 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.optional-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
}

.context-note {
  margin: 0 0 16px;
  padding-inline-start: 12px;
  border-inline-start: 2px solid var(--line-strong);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.disclosure-copy {
  overflow-wrap: anywhere;
  display: inline-grid;
  gap: 5px;
  max-width: calc(100% - 24px);
  margin-inline-start: 5px;
  vertical-align: middle;
}

.disclosure-copy strong {
  color: var(--ink);
  font-size: 13px;
}

.disclosure-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.bonus-overrides {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.bonus-overrides summary,
.profile-section summary {
  cursor: pointer;
}

.bonus-overrides[open] > summary {
  margin-bottom: 18px;
}

.custom-order-entry-copy {
  overflow-wrap: anywhere;
  display: inline-grid;
  gap: 3px;
  margin-inline-start: 4px;
  vertical-align: middle;
}

.custom-order-entry-copy strong {
  color: var(--ink);
  font-size: 13px;
}

.custom-order-entry-copy small {
  color: var(--muted);
  font-size: 12px;
}

.highest-tier-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tier-selection-card {
  min-width: 0;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-subtle);
  transition: background 120ms ease;
}

.tier-selection-card.custom {
  background: var(--blue-soft);
}

.tier-selection-actions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tier-selection-actions {
  justify-content: flex-start;
  margin-top: 8px;
  gap: 2px;
}

.tier-text-button {
  min-height: 40px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--green);
  font-weight: 760;
}

.tier-text-button:hover {
  background: rgba(255, 255, 255, 0.68);
}

.tier-text-button:focus-visible {
  outline: 3px solid var(--green-dark);
  outline-offset: 1px;
}

.custom-tier-panel {
  min-width: 0;
  margin-top: 14px;
}

.custom-tier-panel-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.custom-tier-section:last-child {
  padding-bottom: 0;
}

.section-heading {
  display: grid;
  width: 100%;
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  gap: 3px;
}

.section-heading > span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 780;
}

.section-heading > small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.field > span,
.selector-label,
.control-label {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.field-hint {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input,
select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--ink);
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.capacity-fields input {
  font-size: 18px;
  font-weight: 650;
}

input:hover,
select:hover {
  border-color: #8fa79d;
}

input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(33, 107, 91, 0.16);
  outline-offset: 0;
}

input:disabled {
  border-color: #dbe2de;
  background: #edf1ef;
  color: #78827e;
  opacity: 1;
}

.selector-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.selector-row + .selector-row {
  margin-top: 16px;
}

.selector-label {
  padding-top: 11px;
}

.tier-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.tier-grid.wide {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.tier-choice {
  min-width: 0;
}

.tier-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.tier-choice span {
  display: grid;
  min-width: 0;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.tier-choice span:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.tier-choice input:focus-visible + span {
  outline: 3px solid var(--green-dark);
  outline-offset: 2px;
}

.tier-choice input:checked + span {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
}

.bonus-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 12px;
}

.bonus-pair {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bonus-pair-header {
  display: flex;
  min-width: 0;
  min-height: 22px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.bonus-pair-title {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 780;
}

.bonus-tag {
  color: var(--blue);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.bonus-pair-fields {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compact input {
  min-height: 42px;
}

.option-check {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
}

.option-check input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: var(--green);
}

.option-check > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.inline-option {
  width: 100%;
  min-height: 36px;
  padding: 5px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--green-dark);
}

.option-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.option-list {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.custom-order-section {
  min-width: 0;
}

.custom-order-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 4px;
  scroll-margin-top: 16px;
  cursor: pointer;
  list-style: none;
}

.custom-order-section > summary::-webkit-details-marker {
  display: none;
}

.custom-order-section > summary:focus-visible {
  border-radius: 4px;
  outline: 3px solid var(--green-dark);
  outline-offset: 2px;
}

.custom-order-section > summary::before {
  content: "▸";
  color: var(--green);
  font-size: 14px;
}

.custom-order-section[open] > summary::before {
  transform: rotate(90deg);
}

.custom-order-section > summary .custom-order-entry-copy {
  min-width: 0;
  margin-inline-start: 0;
}

.custom-order-visibility {
  flex: 0 0 auto;
  margin-inline-start: auto;
  color: var(--green);
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.custom-order-section[open] .custom-order-show,
.custom-order-section:not([open]) .custom-order-hide {
  display: none;
}

.custom-order-body {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.custom-order-tools {
  display: flex;
  justify-content: flex-end;
}

.custom-order-stale {
  margin: 2px 0 8px;
  font-size: 12px;
  line-height: 1.45;
}

.custom-order-endpoint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.custom-pinned-blocks,
.custom-blocks {
  display: grid;
  min-width: 0;
  gap: 6px;
}

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

.custom-order-help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.custom-order-help summary {
  color: var(--green);
  cursor: pointer;
}

.custom-order-help p {
  margin: 8px 0 0;
}

.custom-block {
  display: grid;
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  margin: 0;
  padding: 7px 9px;
  grid-template-columns: 34px 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  transition:
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease,
    opacity 120ms ease;
}

.custom-block:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.custom-tile-copy {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 4px;
}

.custom-tile-code {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.custom-tile-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.custom-drag-handle {
  display: grid;
  width: 34px;
  min-height: 36px;
  place-items: center;
  padding: 0;
  border-radius: 5px;
  color: var(--muted);
  cursor: grab;
  font-size: 20px;
  letter-spacing: -5px;
  touch-action: none;
  user-select: none;
}

.custom-drag-handle:hover {
  background: var(--surface-strong);
  color: var(--green-dark);
}

.custom-drag-handle:active {
  cursor: grabbing;
}

.custom-rank-badge {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
}

.fixed-custom-block {
  grid-template-columns: 24px minmax(0, 1fr) 24px;
  border-color: #afc6bd;
  background: var(--green-soft);
}

.fixed-custom-block:hover {
  background: var(--green-soft);
}

.custom-lock {
  display: grid;
  place-items: center;
  font-size: 13px;
}

.custom-block.dragging {
  opacity: 0.48;
}

.custom-block.drag-over {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.custom-block-actions {
  display: flex;
  gap: 4px;
}

.ghost-button.compact-action {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 6px;
  background: var(--surface);
}

.ghost-button.compact-action:hover {
  background: var(--blue-soft);
}

.ghost-button.compact-action:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.compact-action-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

@media (pointer: coarse) {
  .custom-block {
    min-height: 62px;
    grid-template-columns: 36px 24px minmax(0, 1fr) auto;
    gap: 6px;
    padding-inline: 6px;
  }

  .custom-drag-handle {
    width: 36px;
    min-height: 44px;
  }

  .fixed-custom-block {
    grid-template-columns: 24px minmax(0, 1fr) 24px;
  }

  .ghost-button.compact-action {
    width: 44px;
    min-height: 44px;
  }
}

.option-item {
  display: grid;
  min-width: 0;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.option-item .option-check {
  min-height: 32px;
}

.option-item .option-note {
  padding-inline-start: 30px;
}

.profile-grid {
  display: grid;
  min-width: 0;
  gap: 12px;
  margin-top: 18px;
  /* Bound native text overflow, with outline room even without clip-margin support. */
  padding: 6px;
  overflow: clip;
  overflow-clip-margin: 6px;
}

.profile-note {
  margin: 12px 0 0;
}

.profile-actions .danger {
  border-color: transparent;
  background: transparent;
}

.profile-actions {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.primary-button,
.ghost-button,
.toggle-button {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 760;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.primary-button {
  width: 100%;
  overflow-wrap: anywhere;
  min-height: 48px;
  padding: 0 18px;
  background: var(--green);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--green-dark);
}

.ghost-button,
.toggle-button {
  min-width: 0;
  overflow-wrap: anywhere;
  min-height: 40px;
  padding: 0 12px;
  border-color: var(--line);
  background: var(--surface-subtle);
  color: var(--muted);
}

.ghost-button:hover,
.toggle-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.ghost-button:disabled,
.toggle-button:disabled {
  border-color: var(--line);
  background: #edf1ef;
  color: #929b97;
  cursor: not-allowed;
  transform: none;
}

.primary-button:active,
.ghost-button:active,
.toggle-button:active {
  transform: translateY(1px);
}

.ghost-button.danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.form-actions {
  display: grid;
  position: sticky;
  z-index: 3;
  bottom: max(12px, env(safe-area-inset-bottom));
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 3px 20px rgba(31, 52, 44, 0.12);
}

.calculation-state {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
}

.result-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.plan-state-row { flex: 0 0 100%; min-width: 0; }

.plan-state-badge,
.setting-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.4;
}

[data-tone="ready"],
.setting-badge[data-active="true"] {
  color: var(--green-dark);
}

.plan-state-badge[data-tone="ready"],
.setting-badge[data-active="true"] {
  background: var(--green-soft);
  border-color: #b8d6c9;
}

[data-tone="stale"] {
  color: var(--amber);
}

.plan-state-badge[data-tone="stale"] {
  background: var(--amber-soft);
  border-color: #e4cfb2;
}

[data-tone="error"] {
  color: var(--danger);
}

.plan-state-badge[data-tone="error"] {
  background: var(--danger-soft);
  border-color: #e9c4c4;
}

[data-tone="busy"] {
  color: var(--blue);
}

.primary-button:disabled {
  background: var(--surface-strong);
  color: var(--muted);
  cursor: wait;
  transform: none;
}

input:user-invalid {
  border-color: var(--danger);
  outline-color: var(--danger);
  background: var(--danger-soft);
}

.bonus-overrides > summary,
.profile-section > summary,
.advanced-options > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.bonus-overrides > summary::-webkit-details-marker,
.profile-section > summary::-webkit-details-marker,
.advanced-options > summary::-webkit-details-marker {
  display: none;
}

.bonus-overrides > summary::before,
.profile-section > summary::before,
.advanced-options > summary::before {
  content: "▸";
  flex: 0 0 auto;
  color: var(--green);
}

[dir="rtl"] .bonus-overrides > summary::before,
[dir="rtl"] .profile-section > summary::before,
[dir="rtl"] .advanced-options > summary::before {
  transform: scaleX(-1);
}

.bonus-overrides[open] > summary::before,
.profile-section[open] > summary::before,
.advanced-options[open] > summary::before {
  content: "▾";
}

.bonus-overrides .disclosure-copy,
.profile-section .disclosure-copy,
.advanced-summary-copy {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  margin-inline-start: 0;
}

/* Reserve every translated status size so changing mode cannot rewrap the title. */
.summary-badge-slot { display: inline-grid; flex: 0 0 auto; min-width: 0; max-width: 45%; }
.summary-badge-slot > .setting-badge { grid-area: 1 / 1; max-width: 100%; }
.summary-badge-sizer { visibility: hidden; pointer-events: none; }
@container march-setup (max-width: 360px) {
  .bonus-overrides > .special-bonus-summary { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .special-bonus-summary > .summary-badge-slot { grid-column: 2; justify-self: start; max-width: 100%; }
}

.option-item:has(input:checked):not(:has(input:disabled)) {
  border-color: #b8d6c9;
  background: var(--green-soft);
}

.option-item:has(input:disabled) .option-check {
  color: var(--muted);
  cursor: default;
}

.option-item:has(input:disabled) .option-note {
  display: none;
}

.view-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.result-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 14px;
}

.result-context,
.result-count {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.result-context {
  display: none;
  color: var(--ink);
  font-weight: 650;
}

.profile-empty {
  margin-top: 16px;
  margin-bottom: 0;
}

.count-cell {
  user-select: all;
  cursor: text;
}

.empty-row td {
  grid-column: 1 / -1;
  padding: 22px 14px;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}

.result-toolbar {
  min-width: 0;
  margin: 0 -22px;
  padding: 14px 22px;
  margin-bottom: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.result-controls {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-controls > .control-group:first-child {
  grid-column: 1 / -1;
}

.compact-control select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

@media (pointer: coarse) {
  .compact-control select {
    min-height: 44px;
  }
}

.control-group {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 6px;
}

.table-toggle {
  display: grid;
  min-width: 0;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-subtle);
}

.toggle-button {
  min-height: 40px;
  padding: 7px 9px;
  border-color: transparent;
  background: transparent;
  font-size: 12px;
  line-height: 1.15;
  white-space: normal;
}

.toggle-button.active {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 1px 3px rgba(31, 52, 44, 0.06);
}

.metrics {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metric {
  min-width: 0;
  padding: 11px 14px;
  background: var(--surface-subtle);
}

.metric span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: none;
  line-height: 1.5;
}

.metric strong {
  display: block;
  font-size: clamp(17px, 1.6vw, 23px);
  line-height: 1.3;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.messages {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #e4cfb2;
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  line-height: 1.6;
}

.messages.error {
  border-color: #e9c4c4;
  background: var(--danger-soft);
  color: var(--danger);
}

.messages p {
  margin: 0;
}

.messages p + p {
  margin-top: 6px;
}

.table-wrap {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

table[data-view="ordering"] {
  min-width: 620px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: none;
}

.count-heading {
  text-align: end;
}

td {
  color: #2b3732;
}

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

tbody tr:not(.group-row):hover {
  background: #f8faf9;
}

tbody tr[data-phase="monster"] {
  background: #fffaf2;
}

tbody tr[data-phase="tank"] {
  background: #edf5f2;
}

.group-row td {
  background: var(--surface-strong);
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 820;
  text-transform: uppercase;
}

.order-cell {
  width: 70px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stack-cell {
  width: 140px;
  color: var(--blue);
  font-weight: 800;
  white-space: nowrap;
}

.unit-cell {
  min-width: 180px;
}

.count-cell {
  width: 150px;
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  text-align: end;
  white-space: nowrap;
}

.unit-name {
  font-weight: 760;
  overflow-wrap: anywhere;
}

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

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(400px, 430px) minmax(0, 1fr);
  }

  .controls,
  .results {
    padding: 18px;
  }

  .result-toolbar {
    margin-right: -18px;
    margin-left: -18px;
    padding-right: 18px;
    padding-left: 18px;
  }

}

@media (max-width: 1100px) {
  .app-shell {
    width: min(840px, calc(100% - 24px));
    padding-top: 18px;
  }

  .workspace {
    display: block;
  }

  .controls {
    margin-bottom: 16px;
  }

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

@media (max-width: 700px) {
  .app-shell {
    width: calc(100% - 16px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 14px;
  }

  .header-tools {
    width: 100%;
    align-items: flex-end;
    justify-content: space-between;
  }

  .language-picker {
    width: min(220px, 62%);
    min-width: 0;
  }

  h1 {
    font-size: 28px;
  }

  .page-summary {
    font-size: 13px;
  }

  .bonus-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .controls,
  .results {
    padding: 14px;
  }

  .controls-header,
  .results-header {
    padding-bottom: 16px;
  }

  .form-section {
    padding: 18px 0;
  }

  .selector-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .capacity-fields {
    grid-template-columns: 1fr;
  }

  .workflow-nav ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-nav a {
    padding-inline: 12px;
  }

  input,
  select {
    font-size: 16px;
  }

  .form-actions {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 8px;
  }

  .form-actions .review-link {
    min-height: 36px;
  }

  .selector-label {
    padding-top: 0;
  }

  .tier-grid,
  .tier-grid.wide {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .result-toolbar {
    margin-right: -14px;
    margin-left: -14px;
    padding: 12px 14px;
  }

  .control-group {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .toggle-button {
    min-height: 42px;
    padding: 5px 6px;
    font-size: 11px;
  }

  .metrics {
    margin: 14px 0;
  }

  .metric {
    padding: 10px 12px;
  }

  .metric strong {
    font-size: 20px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  table,
  table[data-view="ordering"] {
    display: block;
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  tbody,
  tr {
    display: block;
  }

  tbody tr:not(.group-row) {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 12px;
    margin-bottom: 8px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface) !important;
  }

  tbody tr:not(.group-row):last-child {
    margin-bottom: 0;
  }

  td,
  .order-cell,
  .stack-cell,
  .unit-cell,
  .count-cell {
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    white-space: normal;
  }

  .order-cell {
    grid-column: 1;
    color: var(--muted);
    font-size: 11px;
  }

  .stack-cell {
    grid-column: 1;
    font-size: 14px;
  }

  .unit-cell {
    grid-column: 1;
    font-size: 13px;
    line-height: 1.35;
  }

  .count-cell {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    font-size: 18px;
    text-align: end;
    white-space: nowrap;
  }

  .count-cell::after {
    content: attr(data-label);
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
  }

  tbody tr[data-phase="tank"] {
    border-inline-start: 3px solid var(--green);
  }

  tbody tr[data-phase="monster"] {
    border-inline-start: 3px solid var(--amber);
  }

  .group-row td {
    display: block;
    margin: 14px 0 7px;
    padding: 0 2px;
    background: transparent;
  }
}

@media (max-width: 360px) {
  .app-shell {
    width: calc(100% - 12px);
  }

  h1 {
    font-size: 26px;
  }

  .maker-invite {
    white-space: normal;
  }

  .header-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .language-picker {
    width: 100%;
  }

  .controls,
  .results {
    padding: 12px;
  }

  .bonus-pair-fields {
    grid-template-columns: 1fr;
  }

  .highest-tier-grid {
    grid-template-columns: 1fr;
  }

  .profile-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-actions .danger {
    grid-column: 1 / -1;
  }

  .result-toolbar {
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .metric {
    padding: 10px;
  }

  .metric strong {
    font-size: 18px;
  }
}

@media (max-width: 700px) {
  .custom-active-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .custom-active-banner .custom-mode-exit {
    width: 100%;
  }
}

.release-version {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin: 0;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 24px;
  padding: 20px 2px 0;
  border-top: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body,
  html {
    background: white;
    font-size: 11px;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .controls,
  .header-tools,
  .workflow-nav,
  .result-toolbar,
  .review-link,
  .app-footer,
  .skip-link {
    display: none;
  }

  .result-context-bar button {
    display: none;
  }

  .result-context {
    display: block;
  }

  .workspace {
    display: block;
  }

  .results {
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  table,
  table[data-view="ordering"] {
    min-width: 0;
  }

  th {
    position: static;
  }

  tr,
  .metrics,
  .messages {
    break-inside: avoid;
  }
}
.battle-context { margin-block: 0 1.5rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.battle-context h3 { margin: 0 0 .65rem; font-size: .9rem; }
.battle-toggle { max-width: 30rem; }
.battle-toggle button { flex: 1; min-height: 44px; }
.battle-toggle small { display: inline; font-size: inherit; font-weight: 500; opacity: 0.85; }
.battle-context .context-note { margin-bottom: 0; }
.class-bonus-section, .class-growth-limits { margin-top: 1rem; }
.class-bonus-section summary, .class-growth-limits summary { cursor: pointer; font-weight: 600; }
.class-bonus-section[open] summary, .class-growth-limits[open] summary { margin-bottom: .75rem; }
.battle-result-note { margin: 0 1.25rem 1rem; padding: .75rem 1rem; border-radius: 8px; background: #eef5f2; color: #28564b; font-size: .85rem; }

/* Keep each family's base, target and resolved totals together. */
.bonus-component-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.target-bonus-pair {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.target-bonus-pair .option-note { margin: 0; }

.family-order-section { margin: 16px 0; }
/* One column per card: Epic shows three or four, PvP three. */
.family-order-cards { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.family-order-card { display: grid; justify-items: center; gap: 6px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: center; min-width: 0; }
.family-order-card strong { font-size: 12px; overflow-wrap: anywhere; }
.family-order-title { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; }
.family-order-number { display: grid; place-items: center; flex: 0 0 22px; height: 22px; border-radius: 50%; background: var(--green-soft); font-weight: 800; color: var(--green-dark); }
.family-order-card button { min-width: 38px; min-height: 38px; background: transparent; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.family-order-card button:disabled { opacity: .3; cursor: default; }

/* Make the chosen battle mode distinct from keyboard focus and hover. */
.battle-toggle .toggle-button.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.battle-toggle .toggle-button.active small { opacity: 1; }

/* Phone screens use a vertical hit order with comfortably sized controls. */
@media (max-width: 560px) {
  .family-order-cards { grid-auto-flow: row; grid-template-columns: 1fr; }
  .family-order-card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; justify-items: stretch; text-align: start; padding: 8px; }
  .family-order-title { justify-content: flex-start; }
  .family-order-card button { min-width: 44px; min-height: 44px;  }
}

/* Battle context and family summaries share the same visual language. */
.family-card-copy { display: grid; gap: 5px; min-width: 0; }
.family-position, .family-total { color: var(--muted); font-size: 11px; }
.family-total { min-block-size: 1lh; }
.family-total-unavailable { visibility: hidden; }
.family-tiers { font-size: 12px; overflow-wrap: anywhere; }
.family-warning { grid-column: 1 / -1; margin: 0; padding: 8px; background: var(--amber-soft); color: var(--amber); border-radius: 6px; font-size: 12px; }
.family-move-buttons { display: flex; gap: 4px; }
.family-move-buttons span { display: inline-block; }
[dir="rtl"] .family-move-buttons span { transform: scaleX(-1); }
#customizeTiersButton { margin-top: 10px; }
.custom-family-group { list-style: none; min-width: 0; }
.custom-family-group h4 { margin: 8px 0; color: var(--green-dark); }
.custom-family-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.custom-block-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.family-result-header th { position: static; background: var(--surface-strong); color: var(--green-dark); text-align: start; white-space: normal; font-size: 12px; }
.omitted-tiers { display: block; color: var(--amber); margin-top: 4px; }
@media (max-width: 767px) {
  .form-actions { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 8px; padding: 8px; }
  .form-actions .calculation-state { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .form-actions .primary-button { width: auto; min-height: 40px; flex: 0 0 auto; padding: 8px 10px; font-size: 12px; }
  .form-actions .review-link { display: none; }
  html { scroll-padding-bottom: 90px; }
  input, select, button { scroll-margin-block: 20px 100px; }
  /* Give the focused field all the available space when the keyboard is open. */
  .controls:has(input:focus, select:focus) .form-actions { position: static; }
}
@media (max-width: 560px) {
  .family-move-buttons span, [dir="rtl"] .family-move-buttons span { transform: rotate(90deg); }
  .family-order-card { min-height: 80px; }
}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --page:#101915; --surface:#19251f; --surface-subtle:#202e27; --surface-strong:#2b3d33; --ink:#e5eee8; --muted:#acbfb2; --line:#41554a; --line-strong:#678271; --green:#287c66; --green-dark:#9adfc3; --green-soft:#203f33; --blue:#a8cbe8; --blue-soft:#243b4c; --amber:#f0c78e; --amber-soft:#423522; --danger:#ffb3b3; --danger-soft:#442a2a; }
  input, select { background: var(--surface); color: var(--ink); }
  input:disabled, select:disabled, button:disabled { background: var(--surface-subtle); color: var(--muted); }
  tbody, td, th { color: var(--ink); }
  .primary-button:hover { background: #236b59; }
  .stability-limits summary, .workflow-nav a > span:first-child, .review-link,
  .eyebrow, .panel-kicker, .tier-text-button, .custom-order-visibility,
  .custom-order-help summary { color: var(--green-dark); }
  tbody tr:not(.group-row):hover { background: var(--surface-subtle); }
  tbody tr[data-phase="monster"] { background: var(--amber-soft); }
  tbody tr[data-phase="tank"], .battle-result-note { background: var(--green-soft); color: var(--ink); }
}

.family-order-card { align-content: start; }
.family-move-buttons { align-self: start; }

/* Compact setup: one place for each summary and ordering control. */
.workflow-nav ol { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tier-selection-card { display: flex; align-items: center; flex-wrap: wrap; gap: 0 6px; padding: 4px 0; border: 0; background: transparent; }
.tier-selection-card > strong { font-size: 12px; }
.tier-selection-actions { display: flex; align-items: center; margin: 0; gap: 4px; }
.tier-selection-actions::before { content: "·"; color: var(--muted); }
.tier-selection-actions .tier-text-button { padding-inline: 3px; font-size: 12px; }
.family-order-card button:disabled { visibility: hidden; }
.battle-heading { display: flex; align-items: baseline; gap: 8px; position: relative; }
.battle-info { flex: 1; min-width: 0; }
.battle-info summary { width: max-content; cursor: pointer; list-style: none; padding: 4px; border-radius: 4px; }
.battle-info summary::-webkit-details-marker { display: none; }
.battle-info p { margin: 8px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; }
#languageCode { display: none; }
@media (max-width: 767px) {
  .workflow-nav { max-width: 100%; overflow-x: auto; }
  .workflow-nav ol { display: flex; width: max-content; gap: 6px; padding: 3px; }
  .workflow-nav a { min-height: 36px; padding: 6px 8px; font-size: 11px; gap: 5px; white-space: nowrap; }
  .topbar { position: relative; display: block; }
  .brand-block h1 { margin-inline-end: 85px; font-size: 22px; }
  .header-tools { position: absolute; inset-inline-end: 0; top: 20px; width: 78px; }
  .language-picker { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; width: 78px; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
  .language-picker-label > span { display: none; }
  #languageCode { display: inline; font-size: 12px; font-weight: 700; }
  .language-picker select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
  .language-picker:focus-within { outline: 2px solid var(--green-dark); outline-offset: 2px; }
}

/* Compact ordering controls retain the same actions at every screen width. */
#customizeTiersButton { border: 1px solid var(--green-dark); color: var(--green-dark); background: var(--green-soft); }
.family-position { display: block; min-height: 1.4em; }
.engineer-tank-options { min-width: 0; margin: 12px 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.engineer-tank-options legend { color: var(--muted); font-size: 12px; padding-inline: 4px; }
.engineer-tank-options .option-list { gap: 8px; }
.custom-family-details > summary { padding-block: 10px; cursor: pointer; font-size: 13px; font-weight: 700; }
.custom-family-rows { gap: 4px; }
.custom-family-rows .custom-block { grid-template-columns: 16px 22px minmax(0, 1fr) auto; gap: 4px; min-height: 56px; padding: 6px; }
.custom-family-rows .custom-drag-handle { width: 16px; height: 40px; }
.custom-family-rows .custom-rank-badge { width: 22px; height: 22px; }
.custom-tile-copy { min-width: 0; }
.custom-tile-code, .custom-tile-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-block-actions { display: flex; gap: 2px; align-items: center; }
.custom-block-actions > .compact-action { width: 30px; min-width: 30px; height: 40px; padding: 4px; }
.custom-row-menu { position: relative; }
.custom-row-menu > summary { display: flex; align-items: center; justify-content: center; list-style: none; width: 28px; height: 40px; cursor: pointer; border-radius: 6px; border: 1px solid var(--line); }
.custom-row-menu > summary::-webkit-details-marker { display: none; }
.custom-row-menu-panel { position: absolute; inset-inline-end: 0; top: 100%; z-index: 5; width: 215px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: 0 4px 16px #0003; }
.custom-row-menu-panel .compact-action { display: block; width: 100%; min-height: 40px; height: auto; padding: 8px; text-align: start; white-space: normal; }
/* Linking reveals fields below the same header, without moving the card. */
#specialistBonusGroup,
#engineerBonusGroup { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px; }
:is(#specialistBonusGroup, #engineerBonusGroup) > .bonus-pair-header { flex: 0 0 auto; }
:is(#specialistBonusGroup, #engineerBonusGroup) > .inline-option { width: auto; flex: 1 1 180px; min-height: 32px; padding: 0; }
:is(#specialistBonusGroup, #engineerBonusGroup) > :is(.bonus-pair-fields, .family-target-bonuses) { flex: 0 0 100%; }
.bonus-linked .target-bonus-pair { border: 0; padding: 0; gap: 0; }
.stack-cell, .custom-tile-code { color: var(--ink); }

.custom-block-actions .compact-action:disabled { background: var(--surface-subtle); color: var(--muted); }

/* An unused Monster card still exposes the saved order controls. */
.family-order-unused { background: var(--surface-subtle); border-style: dashed; }
.family-order-unused .family-card-copy { color: var(--muted); }
.family-unused-note { margin: 0; color: var(--muted); font-size: 12px; }
.custom-row-menu-panel .compact-action:enabled { color: var(--green-dark); font-weight: 700; cursor: pointer; }
.custom-row-menu-panel .compact-action:disabled { color: var(--muted); font-weight: 400; cursor: not-allowed; background: var(--surface-subtle); }

/* Special troop shortcuts remain local to their base bonus cards. */
.special-bonus-action { border: 0; background: transparent; color: var(--blue); padding: 4px 0; font: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.research-option { align-items: flex-start; padding: 10px; border-radius: 6px; background: var(--surface-subtle); }
.research-option small { display: block; margin-top: 5px; font-size: 12px; font-weight: 400; color: var(--muted); }
.research-option > .option-note { margin: 6px 0; font-size: 12px; line-height: 1.5; }
.shortcut-help { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.shortcut-help > summary { min-height: 24px; cursor: pointer; color: var(--green-dark); }
.shortcut-help > p { margin: 8px 0 0; }
@media (pointer: coarse) { .shortcut-help > summary { padding-block: 13px; } }
.special-bonus-resolved { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.special-bonus-resolved > div { display: grid; min-width: 0; gap: 7px; }
.special-bonus-resolved span { display: block; font-size: 11px; font-weight: 800; color: var(--muted); }
.special-bonus-resolved output { display: flex; align-items: center; min-height: 42px; font-size: 20px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#monstersTargetSource { min-block-size: 2lh; }
@media (max-width: 360px) { .special-bonus-resolved { grid-template-columns: 1fr; } }
@media (pointer: coarse) { .special-bonus-action { min-height: 44px; } }

.bonus-total { border-top: 1px solid var(--line); padding-top: 10px; }
.bonus-total strong { font-size: 12px; }
.bonus-total p { margin: 5px 0 0; font-size: 14px; font-weight: 650; }
@container march-setup (max-width: 360px) { .bonus-total p { min-block-size: 2lh; } }
.target-bonus-pair > .special-bonus-action { text-align: start; justify-self: start; }

/* Size hit-order cards against the setup panel, including split desktop layouts. */
@container march-setup (min-width: 361px) and (max-width: 520px) {
  .family-order-cards { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.research-explanation { margin: 8px 0 0; padding-inline-start: 20px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.5; }
.research-explanation li + li { margin-top: 5px; }
.bonus-pair-header { flex-wrap: wrap; }
.setting-badge { max-width: 45%; white-space: normal; text-align: center; }

/* Recovery controls stay next to the setup or result they describe. */
.setup-notice,
.recovery-notice {
  padding: 0.85rem 1rem;
  margin-block: 0 1rem;
  border: 1px solid #cbded8;
  border-radius: 0.65rem;
  background: #f1f7f4;
  color: #254b41;
  line-height: 1.5;
}
.recovery-notice p { margin-block: 0 0.75rem; }
.recovery-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.recovery-confirm { display: flex; gap: 0.6rem; align-items: flex-start; margin-block: 1rem; }
.recovery-confirm input { flex: 0 0 20px; width: 20px; min-width: 20px; height: 20px; min-height: 20px; margin: 0.25rem 0 0; padding: 0; accent-color: var(--green); }
.recovery-confirm > span { min-width: 0; overflow-wrap: anywhere; }
.march-copy-actions { padding-block: 0.25rem 0.5rem; }
.march-copy-actions p { margin-block: 0.5rem 0; }
.request-recovery-actions { padding-inline: 1.25rem; }
.request-recovery-actions:has(button:not([hidden])) { padding-block: 0 1rem; }
#copyMarchDialog {
  width: min(38rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  border: 1px solid #cbded8;
  border-radius: 0.8rem;
  padding: 1.25rem;
  color: #20342e;
  background: #fff;
}
#copyMarchDialog::backdrop { background: rgb(0 0 0 / 35%); }
#copyMarchText { box-sizing: border-box; width: 100%; min-height: 12rem; margin-block: 0.75rem; resize: vertical; }
#planOriginBadge { white-space: normal; }
@media print {
  .recovery-notice, .march-copy-actions, .request-recovery-actions, #copyMarchDialog { display: none !important; }
}

/* Contextual help uses native disclosures for touch and keyboard access. */
.input-help { margin-block: 0.8rem; border-inline-start: 3px solid var(--line); padding-inline: 0.8rem; }
.input-help summary { cursor: pointer; color: var(--green-dark); font-size: 0.85rem; font-weight: 600; }
.input-help p { font-size: 0.85rem; line-height: 1.6; margin-block: 0.7rem; }
.input-help .worked-example { padding: 0.75rem; border-radius: 0.5rem; background: var(--surface-subtle); }
.monster-selection { margin-top: 0.7rem; }
#customizeTiersButton + .field-hint { margin-block: 0.6rem 1rem; }
.profile-transfer-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.7rem; margin-top: 1rem; }
#profileTransferStatus:empty { display: none; }
#profileNameHint, #profileTransferStatus { min-width: 0; overflow-wrap: anywhere; }
#undoNotice { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; width: 100%; margin: 0 0 0.4rem; padding: 0.45rem 0.6rem; border: 0; background: var(--green-soft); color: var(--ink); }
#undoNotice #undoMessage { min-width: 0; margin: 0; font-size: 0.8rem; overflow-wrap: anywhere; }
#undoNotice button { flex: 0 0 auto; }
@media (max-width: 767px) {
  .form-actions:has(#undoNotice:not([hidden])) { flex-wrap: wrap; }
  #undoNotice { flex: 0 0 100%; }
}
@media print { .input-help, .monster-selection, .profile-transfer-actions, #undoNotice { display: none !important; } }

.profile-tools { margin-top: 0.75rem; }
.profile-tools > summary { cursor: pointer; color: var(--green-dark); font-size: 0.85rem; }
.profile-actions:has(> button:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.profile-action-status { color: var(--green-dark); font-weight: 650; margin-block: 0.6rem; }
.monster-bonus-card { display: block; }
.monster-bonus-card > summary { cursor: pointer; justify-content: flex-start; list-style: none; }
.monster-bonus-card > summary::-webkit-details-marker { display: none; }
.monster-bonus-card > summary::before { content: "▸"; color: var(--green-dark); }
.monster-bonus-card[open] > summary::before { transform: rotate(90deg); }
[dir="rtl"] .monster-bonus-card:not([open]) > summary::before { transform: rotate(180deg); }
.monster-bonus-card > summary small { flex-basis: 100%; margin: 0; }
@media (pointer: coarse) { .monster-bonus-card > summary { min-height: 44px; } }
#monsterBonusFields { display: none; }
.monster-bonus-card[open] > #monsterBonusFields { display: grid; gap: 11px; margin-top: 11px; }
.input-guide-example { margin: 0.8rem 0; }
.input-guide-example figcaption { margin-bottom: 0.5rem; font-size: 0.75rem; color: var(--muted); }
.input-guide-comparison { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: 0.6rem; }
.input-guide-panel { min-width: 0; border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.7rem; background: var(--surface); font-size: 0.8rem; }
.input-guide-panel > strong { display: block; color: var(--green-dark); }
.input-guide-panel dl { margin-block: 0.6rem 0; }
.input-guide-panel dl > div { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.3rem 0.6rem; padding-block: 0.4rem; border-top: 1px solid var(--line); }
.input-guide-panel dt { flex: 1 1 7rem; }
.input-guide-panel dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.input-guide-panel mark { background: var(--green-soft); color: var(--ink); padding: 0.15rem; border-radius: 0.2rem; }
.input-guide-panel small { display: block; margin-top: 0.5rem; line-height: 1.5; }
.plan-explanation { margin-block: 0.8rem 1rem; }
.plan-explanation > summary { color: var(--green-dark); cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.plan-explanation p { font-size: 0.85rem; line-height: 1.6; margin-block: 0.7rem 0; }
@media print { .plan-explanation:not([open]), .profile-action-status { display: none !important; } }
