@layer components {
  .resolution-workspace {
    margin-top: 24px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--paper-deep);
    box-shadow: var(--shadow);
    overflow: clip;
  }

  .boundary-only-workspace {
    border-color: var(--line);
    background: var(--surface-strong);
    box-shadow: none;
  }

  .boundary-only-workspace .resolution-workspace-header h3 {
    font-size: clamp(21px, 2.8vw, 28px);
  }

  .boundary-only-workspace .resolution-step > summary {
    min-height: 58px;
  }

  .resolution-workspace-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: clamp(20px, 3vw, 30px);
    border-bottom: 1px solid var(--line-strong);
  }

  .resolution-workspace-header h3 {
    margin-top: 5px;
    font-size: clamp(24px, 3.2vw, 34px);
    letter-spacing: -0.035em;
  }

  .resolution-workspace-header p:not(.eyebrow) {
    max-width: 720px;
    margin-top: 8px;
    color: var(--ink-soft);
    font-size: 14px;
  }

  .resolution-branch {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    white-space: nowrap;
  }

  .resolution-steps {
    display: grid;
    gap: 1px;
    background: var(--line-strong);
  }

  .resolution-step {
    background: var(--surface);
  }

  .resolution-step > summary {
    display: grid;
    grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1fr) auto;
    min-height: 64px;
    align-items: center;
    gap: 22px;
    padding: 12px clamp(18px, 3vw, 28px);
    cursor: pointer;
    list-style: none;
  }

  .resolution-step > summary::-webkit-details-marker { display: none; }
  .resolution-step > summary::after {
    content: "+";
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent-dark);
    font-family: var(--mono);
    font-size: 16px;
  }
  .resolution-step[open] > summary::after { content: "−"; }

  .resolution-step > summary:hover {
    background: var(--surface-strong);
  }

  .resolution-step[open] > summary {
    border-bottom: 1px solid var(--line);
    background: var(--surface-strong);
  }

  .support-step > summary {
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
  }
  .support-step > summary::after {
    border-color: var(--accent);
    background: var(--surface);
  }

  .support-step-embedded {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    overflow: clip;
  }

  .support-step-heading {
    padding: 18px clamp(18px, 3vw, 26px) 16px;
    border-bottom: 1px solid var(--line);
    background: var(--accent-soft);
  }

  .support-step-heading h3 {
    margin-top: 4px;
    font-size: clamp(20px, 2.6vw, 27px);
    letter-spacing: -0.028em;
  }

  .support-step-heading > p:not(.eyebrow) {
    max-width: 760px;
    margin-top: 6px;
    color: var(--ink-soft);
    font-size: 12px;
  }

  .support-step-embedded > .resolution-step-body {
    padding: clamp(18px, 3vw, 26px);
  }

  .resolution-summary-title {
    color: var(--ink);
    font-size: 15px;
    font-weight: 760;
  }

  .resolution-summary-copy {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
  }

  .resolution-step-body {
    padding: clamp(18px, 3vw, 28px);
  }

  .resolution-explainer {
    max-width: 820px;
    color: var(--ink-soft);
    font-size: 13px;
  }

  .resolution-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
  }

  .resolution-fields label {
    display: grid;
    min-width: 0;
    gap: 7px;
  }

  .resolution-fields label:last-child {
    grid-column: 1 / -1;
  }

  .resolution-fields label > span,
  .resolution-local-note .resolution-note-head span {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 720;
  }

  .resolution-fields label > small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
  }

  .resolution-fields select,
  .resolution-fields textarea,
  .resolution-action-controls select,
  .resolution-action-controls textarea,
  .resolution-local-note textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    color: var(--ink);
    font-size: 13px;
  }

  .resolution-fields textarea,
  .resolution-action-controls textarea,
  .resolution-local-note textarea {
    resize: vertical;
    line-height: 1.5;
  }

  .resolution-fields select:focus,
  .resolution-fields textarea:focus,
  .resolution-action-controls select:focus,
  .resolution-action-controls textarea:focus,
  .resolution-local-note textarea:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(21, 86, 240, 0.15);
  }

  .boundary-preview {
    max-height: 220px;
    margin-top: 16px;
    padding: 13px 14px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.55;
    white-space: pre-wrap;
  }

  .resolution-inline-status {
    min-height: 22px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
  }

  .resolution-inline-status[data-kind="success"] {
    color: var(--accent-dark);
  }

  .resolution-inline-status[data-kind="error"] {
    color: var(--danger);
  }

  .resolution-step-body > .primary-button {
    min-height: 48px;
    margin-top: 10px;
  }

  .resolution-action-ledger {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    list-style: none;
  }

  .resolution-action-ledger > li {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) minmax(210px, 0.42fr);
    align-items: start;
    gap: 14px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
  }

  .resolution-action-ledger > li.resolution-empty {
    display: block;
    color: var(--muted);
    font-size: 13px;
  }

  .resolution-action-number {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent-dark);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
  }

  .resolution-action-copy h4 {
    font-size: 14px;
  }

  .resolution-action-copy p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.48;
  }

  .resolution-action-controls {
    display: grid;
    gap: 7px;
  }

  .resolution-action-controls textarea {
    min-height: 76px;
  }

  .verification-fields .new-failure-field {
    grid-column: 1 / -1;
  }

  .resolution-comparison-mount {
    margin-top: 16px;
  }

  .resolution-comparison {
    padding: 17px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
  }

  .resolution-comparison.comparison-resolved,
  .resolution-comparison.comparison-moved-downstream {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .resolution-comparison.comparison-moved-upstream,
  .resolution-comparison.comparison-still-partial {
    border-color: var(--warning);
    background: var(--warning-soft);
  }

  .resolution-comparison-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  .resolution-comparison-head h4 {
    margin-top: 4px;
    font-size: 20px;
  }

  .resolution-status {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 4px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 10px;
    white-space: nowrap;
  }

  .resolution-comparison-copy {
    margin-top: 12px;
    color: var(--ink-soft);
    font-size: 14px;
  }

  .resolution-delta,
  .support-pack-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin: 14px 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--line);
  }

  .resolution-delta div,
  .support-pack-summary div {
    min-width: 0;
    padding: 11px;
    background: var(--surface);
  }

  .resolution-delta dt,
  .support-pack-summary dt {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .resolution-delta dd,
  .support-pack-summary dd {
    margin-top: 4px;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 12px;
    font-weight: 680;
  }

  .resolution-local-note {
    display: grid;
    gap: 8px;
    margin-top: 18px;
  }

  .resolution-note-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .resolution-note-head small {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
  }

  .resolution-local-note textarea {
    min-height: 96px;
  }

  .resolution-export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 14px;
  }

  .resolution-export-actions .primary-button,
  .resolution-export-actions .secondary-button {
    min-height: 48px;
  }

  .resolution-clear {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    margin-top: 9px;
  }

  .resolution-privacy {
    padding: 14px clamp(18px, 3vw, 28px);
    border-top: 1px solid var(--line-strong);
    background: var(--paper-deep);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
  }

  .p12-import-banner {
    max-width: 900px;
  }

  .first-screen-boundary-builder {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper);
  }

  .first-screen-boundary-builder > summary {
    display: grid;
    grid-template-columns: minmax(210px, 0.46fr) minmax(0, 1fr) auto auto;
    min-height: 48px;
    align-items: center;
    gap: 14px;
    padding: 9px 12px;
    list-style: none;
    cursor: pointer;
  }

  .first-screen-boundary-builder > summary .resolution-summary-title {
    grid-column: 1;
  }

  .first-screen-boundary-builder > summary .resolution-summary-copy {
    grid-column: 2;
  }

  .first-screen-boundary-badge {
    grid-column: 3;
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .first-screen-boundary-builder > summary::-webkit-details-marker {
    display: none;
  }

  .first-screen-boundary-builder > summary::after {
    content: "+";
    grid-column: 4;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent-dark);
    font-family: var(--mono);
    font-size: 15px;
  }

  .first-screen-boundary-builder[open] > summary::after {
    content: "−";
  }

  .first-screen-boundary-builder[open] > summary {
    border-bottom: 1px solid var(--line);
    background: var(--surface-strong);
  }

  .first-screen-boundary-body {
    padding: 15px;
  }

  .first-screen-boundary-intro {
    max-width: 820px;
    color: var(--ink-soft);
    font-size: 12px;
  }

  .first-screen-boundary-order {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin-top: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--line);
    list-style: none;
  }

  .first-screen-boundary-order li {
    min-width: 0;
    padding: 10px 11px;
    background: var(--surface-strong);
  }

  .first-screen-boundary-order strong,
  .first-screen-boundary-order span {
    display: block;
  }

  .first-screen-boundary-order strong {
    color: var(--ink);
    font-size: 11px;
  }

  .first-screen-boundary-order span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
  }

  .first-screen-boundary-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
  }

  .first-screen-boundary-fields label {
    display: grid;
    min-width: 0;
    gap: 6px;
  }

  .first-screen-boundary-fields label:last-child {
    grid-column: 1 / -1;
  }

  .first-screen-boundary-fields label > span {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 720;
  }

  .first-screen-boundary-fields label > small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
  }

  .first-screen-boundary-fields select,
  .first-screen-boundary-fields textarea {
    width: 100%;
    min-height: 44px;
    padding: 9px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    color: var(--ink);
    font-size: 13px;
  }

  .first-screen-boundary-fields textarea {
    min-height: 78px;
    resize: vertical;
    line-height: 1.45;
  }

  .first-screen-boundary-preview {
    max-height: 176px;
    margin-top: 13px;
    padding: 11px 12px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
  }

  .first-screen-boundary-status {
    min-height: 21px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 11px;
  }

  .first-screen-boundary-status[data-kind="success"] {
    color: var(--accent-dark);
  }

  .first-screen-boundary-status[data-kind="error"] {
    color: var(--danger);
  }

  .first-screen-boundary-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-top: 8px;
  }

  .first-screen-boundary-actions .secondary-button {
    min-height: 46px;
  }
}

@layer components {
  .same-task-comparison {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper);
  }
  .same-task-comparison > summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 48px;
    align-items: center;
    gap: 6px 16px;
    padding: 10px 12px;
    cursor: pointer;
    list-style: none;
  }
  .same-task-comparison > summary::-webkit-details-marker { display: none; }
  .same-task-comparison > summary strong { font-size: 13px; }
  .same-task-comparison > summary span { color: var(--muted); font-size: 11px; }
  .same-task-comparison[open] > summary { border-bottom: 1px solid var(--line); }
  .comparison-body { min-width: 0; padding: 16px; }
  .comparison-setups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
  .comparison-setups > p { flex-basis: 100%; color: var(--muted); font-size: 12px; }
  .comparison-setups button { min-height: 44px; font-size: 12px; }
  .comparison-checkpoint-guide { margin-top: 9px; color: var(--ink-soft); font-size: 13px; }
  .comparison-checkpoint-guide > summary { min-height: 44px; padding: 12px 0; cursor: pointer; }
  .comparison-checkpoint-guide > div { padding: 12px; border-left: 2px solid var(--line-strong); }
  .comparison-checkpoint-guide p + p { margin-top: 8px; }
  .comparison-next-action { min-height: 44px; margin: 10px 0; }
  .comparison-limits { color: var(--ink-soft); border-left: 2px solid var(--line-strong); }
  .comparison-limits:empty { display: none; }
  .comparison-body > p, .comparison-conditions > p {
    color: var(--ink-soft); font-size: 13px; line-height: 1.5;
  }
  .comparison-shared, .comparison-pair, .comparison-fields {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  }
  .comparison-shared, .comparison-pair { margin-top: 16px; }
  .comparison-side { min-width: 0; margin: 0; padding: 13px; border: 1px solid var(--line-strong); }
  .comparison-side legend { padding: 0 6px; color: var(--accent-dark); font-size: 12px; font-weight: 700; }
  .comparison-body label { display: grid; min-width: 0; gap: 6px; }
  .comparison-body label > span { color: var(--ink-soft); font-size: 12px; font-weight: 650; }
  .comparison-body input, .comparison-body select, .comparison-body textarea {
    width: 100%; min-width: 0; min-height: 44px; padding: 9px 10px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); font-size: 14px;
  }
  .comparison-side label:nth-last-child(-n + 2) { grid-column: 1 / -1; }
  .comparison-body textarea { min-height: 90px; resize: vertical; }
  .comparison-conditions { margin-top: 16px; border-block: 1px solid var(--line); }
  .comparison-conditions > summary { min-height: 48px; padding: 13px 0; font-size: 13px; cursor: pointer; }
  .comparison-conditions > p { margin-bottom: 12px; }
  .comparison-conditions > .comparison-fields { padding-bottom: 14px; }
  .comparison-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
  .comparison-actions button { min-height: 44px; }
  .comparison-status { margin-top: 12px; min-height: 20px; font-size: 13px; color: var(--ink-soft); }
  .comparison-output { margin-top: 15px; padding-top: 16px; border-top: 1px solid var(--line-strong); }
  .comparison-output h3 { font-size: 19px; }
  .comparison-output > p { margin-top: 9px; font-size: 13px; }
  .comparison-output > ul { margin: 10px 0; padding-left: 20px; font-size: 12px; }
  .comparison-next { padding: 12px; background: var(--accent-soft); border-left: 2px solid var(--accent); }
  .comparison-note {
    max-height: 300px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
    margin-top: 12px; padding: 13px; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink-soft); font-family: var(--mono); font-size: 12px; line-height: 1.55;
  }
  .comparison-limit { color: var(--muted); }
}

@media (max-width: 680px) {
  .same-task-comparison > summary { grid-template-columns: 1fr; }
  .comparison-body { padding: 12px; }
  .comparison-shared, .comparison-pair { grid-template-columns: 1fr; }
  .comparison-actions, .comparison-setups { flex-direction: column; }
  .comparison-actions button, .comparison-setups button { width: 100%; }
  .comparison-body input, .comparison-body select, .comparison-body textarea { font-size: 16px; }
}
@media (max-width: 390px) {
  .comparison-fields { grid-template-columns: 1fr; }
  .comparison-side label:nth-last-child(-n + 2) { grid-column: auto; }
}

@media (max-width: 780px) {
  .resolution-workspace-header,
  .resolution-comparison-head {
    flex-direction: column;
  }

  .resolution-step > summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    min-height: 72px;
  }

  .resolution-summary-copy { grid-column: 1 / -1; }

  .resolution-fields,
  .resolution-delta,
  .support-pack-summary {
    grid-template-columns: 1fr;
  }

  .resolution-fields label:last-child,
  .verification-fields .new-failure-field {
    grid-column: auto;
  }

  .resolution-action-ledger > li {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .resolution-action-controls {
    grid-column: 2;
  }

  .resolution-export-actions {
    flex-direction: column;
  }

  .resolution-export-actions .primary-button,
  .resolution-export-actions .secondary-button {
    width: 100%;
  }

  .first-screen-boundary-builder > summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
    min-height: 52px;
  }

  .first-screen-boundary-builder > summary .resolution-summary-title {
    grid-column: 1;
    grid-row: 1;
  }

  .first-screen-boundary-builder > summary::after {
    grid-column: 2;
    grid-row: 1;
  }

  .first-screen-boundary-builder > summary .resolution-summary-copy {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .first-screen-boundary-badge {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: start;
    margin-top: 3px;
  }

  .first-screen-boundary-order {
    grid-template-columns: 1fr;
  }

  .first-screen-boundary-fields {
    grid-template-columns: 1fr;
  }

  .first-screen-boundary-fields label:last-child {
    grid-column: auto;
  }

  .first-screen-boundary-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .first-screen-boundary-actions .secondary-button,
  .first-screen-boundary-actions .text-action {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .resolution-workspace {
    border-radius: 12px;
  }

  .resolution-workspace-header,
  .resolution-step-body {
    padding-right: 15px;
    padding-left: 15px;
  }

  .resolution-action-ledger > li {
    grid-template-columns: 1fr;
  }

  .resolution-action-number,
  .resolution-action-copy,
  .resolution-action-controls {
    grid-column: 1;
  }

  .resolution-action-controls select,
  .resolution-action-controls textarea,
  .resolution-fields select,
  .resolution-fields textarea,
  .resolution-local-note textarea {
    font-size: 16px;
  }
}

@media print {
  .resolution-workspace,
  .p12-import-banner {
    display: none !important;
  }
}
