:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --text: #17222d;
  --muted: #5d6d7b;
  --line: #d5dee6;
  --brand: #075e54;
  --brand-strong: #034b43;
  --brand-soft: #dff3ee;
  --accent: #d47a1f;
  --danger: #a4262c;
  --danger-soft: #fff0f0;
  --warn-soft: #fff6df;
  --info-soft: #eaf2ff;
  --shadow: 0 12px 32px rgba(29, 45, 59, .08);
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

[data-theme="dark"] {
  --bg: #0f171c;
  --surface: #172229;
  --surface-2: #202e36;
  --text: #eef5f4;
  --muted: #aebdc4;
  --line: #34454e;
  --brand: #70d5c2;
  --brand-strong: #a0eadc;
  --brand-soft: #183b36;
  --accent: #f1a556;
  --danger: #ff9a9f;
  --danger-soft: #3c2427;
  --warn-soft: #3a321e;
  --info-soft: #1e3045;
  --shadow: 0 14px 36px rgba(0, 0, 0, .26);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 280px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  overflow-wrap: anywhere;
}
button, select, input, textarea { font: inherit; }
button, select { min-height: 44px; }
button { cursor: pointer; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.skip-link:focus { top: 12px; }

.topbar, main, footer { width: min(1440px, calc(100% - 32px)); margin-inline: auto; }
.topbar { display: flex; justify-content: space-between; gap: 32px; align-items: flex-start; padding: 42px 4px 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1.08; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: clamp(1.35rem, 2vw, 1.8rem); letter-spacing: -.02em; }
h3 { font-size: 1.04rem; margin-bottom: 10px; }
.eyebrow, .step-label { color: var(--brand); font-size: .73rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.eyebrow { margin-bottom: 10px; }
.step-label { margin-bottom: 3px; }
.lede { color: var(--muted); max-width: 720px; margin-bottom: 0; font-size: 1.05rem; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.status-pill, .count-badge, .updated { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: .82rem; white-space: nowrap; }
.icon-button, .button { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 9px 14px; font-weight: 700; }
.icon-button:hover, .button:hover { border-color: var(--brand); color: var(--brand); }
.button.primary { color: #fff; border-color: var(--brand-strong); background: var(--brand-strong); }
[data-theme="dark"] .button.primary { color: #071b18; }
.button.ghost { background: transparent; }
.danger-text { color: var(--danger); }

main { display: grid; gap: 22px; }
[hidden] { display: none !important; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(18px, 2.2vw, 30px); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-heading.compact { margin-bottom: 10px; }
.hint { margin: 0 0 18px; color: var(--muted); font-size: .9rem; }
.control-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: .83rem; font-weight: 700; }
select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px 36px 9px 11px; background: var(--surface-2); color: var(--text); }
input, textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: var(--surface-2); color: var(--text); }
textarea { resize: vertical; min-height: 68px; }
.context-advice { margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.advice-card { border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 12px; background: var(--brand-soft); font-size: .88rem; }
.advice-card.warning { border-color: var(--accent); background: var(--warn-soft); }
.advice-card.risk { border-color: var(--danger); background: var(--danger-soft); }
.advice-card strong { display: block; margin-bottom: 2px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 22px; }
.service-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.service-card { position: relative; display: grid; min-width: 0; min-height: 142px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); text-align: left; color: var(--text); }
.service-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.service-card.selected { border: 2px solid var(--brand); padding: 15px; background: var(--brand-soft); }
.service-card .selected-marker { position: absolute; right: 10px; top: 10px; display: none; border-radius: 999px; padding: 2px 8px; background: var(--brand-strong); color: #fff; font-size: .69rem; font-weight: 800; }
[data-theme="dark"] .service-card .selected-marker { color: #071b18; }
.service-card.selected .selected-marker { display: inline-block; }
.service-icon { font-family: var(--mono); font-size: .72rem; color: var(--brand); font-weight: 800; letter-spacing: .04em; }
.service-name { align-self: end; margin-top: 16px; font-weight: 800; font-size: 1rem; }
.service-card small { color: var(--muted); }
.view-detail { position: absolute; right: 9px; bottom: 9px; z-index: 2; min-height: 32px; border: 0; background: transparent; color: var(--brand); font-weight: 800; font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; }

.architecture-panel { align-self: start; }
.architecture-flow { display: grid; gap: 14px; min-height: 160px; padding: 10px 0 18px; }
.flow-group { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.data-flow-group { background: var(--surface-2); }
.template-path-flow-group { border-color: var(--accent); background: var(--warn-soft); }
.service-flow-group { border-color: var(--brand); background: var(--brand-soft); }
.flow-group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; color: var(--text); }
.flow-group-heading strong { font-size: .84rem; }
.flow-group-heading small { color: var(--muted); font-size: .72rem; text-align: right; }
.flow-row { display: flex; align-items: center; align-content: flex-start; flex-wrap: wrap; gap: 8px; }
.flow-stage + .flow-stage { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.flow-stage-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.flow-node { max-width: 180px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--surface); font-weight: 750; font-size: .86rem; }
.flow-node.data-flow { border-color: #b8c9d7; background: var(--info-soft); }
.flow-node.template-flow { border-color: var(--accent); background: var(--surface); }
.flow-node.service-flow { border-color: var(--brand); background: var(--surface); }
.sortable-flow-node { display: inline-grid; gap: 8px; min-width: 150px; max-width: 220px; }
.flow-order-actions { display: flex; gap: 6px; }
.flow-order-actions button { min-width: 34px; min-height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--brand); cursor: pointer; font-weight: 900; }
.flow-order-actions button:hover:not(:disabled), .flow-order-actions button:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.flow-order-actions button:disabled { opacity: .35; cursor: not-allowed; }
.inferred-flow-row { align-items: stretch; }
.capability-empty { grid-column: 1 / -1; }
.flow-empty { margin: 0; color: var(--muted); font-size: .8rem; }
.flow-arrow { color: var(--muted); font-family: var(--mono); font-weight: 800; }
.empty-state { width: 100%; border: 1px dashed var(--line); border-radius: 12px; padding: 24px; color: var(--muted); text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--brand); }
.legend-dot.runtime { background: var(--accent); }
.legend-dot.managed { background: var(--muted); }
.legend-dot.data-flow { background: #7b9bb2; }
.legend-dot.service-flow { background: var(--brand); }

.detail-select-label { width: min(320px, 100%); }
.tab-list { display: flex; gap: 6px; padding: 5px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: thin; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.tab-list button { flex: 0 0 auto; border: 0; border-radius: 8px; padding: 9px 13px; background: transparent; color: var(--muted); font-weight: 800; }
.tab-list button[aria-selected="true"] { background: var(--surface); color: var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,.08); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.detail-content { min-height: 280px; }
.detail-intro { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.info-card, .role-card, .permission-card, .sa-card { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface-2); }
.info-card p:last-child, .role-card p:last-child, .permission-card p:last-child { margin-bottom: 0; }
.key-value { display: grid; grid-template-columns: minmax(110px, .35fr) 1fr; gap: 9px 16px; margin: 0; }
.key-value dt { color: var(--muted); font-weight: 750; }
.key-value dd { margin: 0; }
.docs-link { display: inline-flex; margin-top: 15px; font-weight: 800; }
.role-grid, .permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.role-card header, .permission-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
code, .code { font-family: var(--mono); overflow-wrap: anywhere; word-break: break-word; }
.role-name, .permission-name { font-family: var(--mono); color: var(--text); font-size: .88rem; font-weight: 800; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.badge { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; color: var(--muted); background: var(--surface); font-size: .71rem; font-weight: 800; }
.badge.required::before { content: "✓ "; }
.badge.conditional::before { content: "? "; }
.badge.risk-high, .badge.risk-critical { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.badge.risk-high::before { content: "⚠ 高風險 · "; }
.badge.risk-critical::before { content: "⛔ 極高風險 · "; }
.badge.risk-medium::before { content: "△ 中風險 · "; }
.badge.risk-low::before { content: "低風險 · "; }
.scope-note { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--muted); font-size: .84rem; }
.group-heading { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.group-heading::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.warning-box { margin: 0 0 18px; padding: 14px 16px; border: 1px solid var(--danger); border-left-width: 5px; border-radius: 10px; background: var(--danger-soft); }
.warning-box strong { color: var(--danger); }
.notice-box { margin: 0 0 18px; padding: 14px 16px; border-left: 5px solid var(--accent); border-radius: 10px; background: var(--warn-soft); }
.check-list, .question-list { display: grid; gap: 8px; padding: 0; list-style: none; }
.check-list li, .question-list li { position: relative; padding: 11px 12px 11px 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.check-list li::before { content: "□"; position: absolute; left: 13px; color: var(--brand); font-weight: 800; }
.question-list { counter-reset: question; }
.question-list li { counter-increment: question; }
.question-list li::before { content: counter(question, decimal-leading-zero); position: absolute; left: 10px; color: var(--brand); font-family: var(--mono); font-weight: 800; }

.action-bar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 20px; }
.summary-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.summary-block { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 17px; background: var(--surface-2); }
.summary-block h3 { display: flex; justify-content: space-between; gap: 8px; }
.summary-block .block-count { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.summary-block ul { margin: 0; padding-left: 20px; }
.summary-block li + li { margin-top: 6px; }
.summary-block.full { grid-column: 1 / -1; }
.summary-block.high-risk { border-color: var(--danger); background: var(--danger-soft); }
.empty-summary { grid-column: 1 / -1; padding: 40px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; color: var(--muted); }

.button.small { min-height: 34px; padding: 6px 10px; font-size: .78rem; }
.subsection-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.subsection-heading h3 { margin-bottom: 0; }
.capability-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.capability-group { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.capability-group h3 { margin-bottom: 8px; color: var(--brand); font-size: .86rem; }
.capability-check { display: flex; grid-template-columns: none; align-items: flex-start; gap: 9px; padding: 7px 0; color: var(--text); font-size: .82rem; font-weight: 650; }
.capability-check input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); }
.capability-group.high-risk { border-color: var(--danger); background: var(--danger-soft); }
.capability-group.customer { border-color: var(--accent); background: var(--warn-soft); }

.quick-model-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 24px; }
.quick-principal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quick-principal-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-left: 5px solid var(--muted); border-radius: 12px; background: var(--surface-2); }
.quick-principal-card.needed { border-left-color: var(--brand); }
.quick-principal-card.not-needed { opacity: .7; }
.quick-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.quick-card-heading h4 { margin: 2px 0 0; font-size: 1.08rem; }
.quick-card-kicker { color: var(--muted); font-size: .7rem; font-weight: 800; }
.need-badge { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; color: var(--muted); font-size: .68rem; font-weight: 800; }
.need-badge.needed { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.quick-principal-card > p { margin: 12px 0; color: var(--muted); font-size: .82rem; }
.quick-principal-card > small { display: block; margin-top: 10px; color: var(--muted); }
.compact-role-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.compact-role-list li { min-width: 0; }
.compact-role-list code { display: block; padding: 5px 7px; border-radius: 6px; background: var(--surface); font-size: .72rem; }
.compact-binding-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.compact-binding-list li { min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.binding-role-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.binding-role-line .binding-role-details { flex: 1 1 auto; min-width: 0; }
.binding-role-line code { min-width: 0; font-size: .73rem; font-weight: 800; }
.binding-target { display: block; margin-top: 5px; color: var(--brand); font-size: .71rem; font-weight: 800; }
.compact-binding-list small { display: block; margin-top: 5px; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.binding-role-details { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.binding-role-details > summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; padding: 8px 9px; color: var(--text); cursor: pointer; list-style-position: inside; }
.binding-role-details > summary::-webkit-details-marker { display: none; }
.binding-role-details > summary::marker { content: ""; }
.binding-role-details > summary::before { content: "▸"; flex: 0 0 auto; color: var(--brand); font-weight: 900; }
.binding-role-details[open] > summary::before { content: "▾"; }
.binding-role-details > summary:hover, .binding-role-details > summary:focus-visible { color: var(--brand); background: var(--brand-soft); outline: none; }
.binding-role-details[open] > summary { border-bottom: 1px solid var(--line); color: var(--brand); background: var(--brand-soft); }
.binding-role-details > summary code { flex: 1 1 auto; min-width: 0; font-size: .74rem; font-weight: 850; }
.role-detail-hint { flex: 0 0 auto; color: var(--brand); font-size: .65rem; font-weight: 850; white-space: nowrap; }
.binding-role-detail-panel { min-width: 0; padding: 11px; background: var(--surface-2); }
.binding-role-title { display: block; color: var(--text); font-size: .82rem; }
.binding-role-detail-panel > p { margin: 6px 0 10px; color: var(--muted); font-size: .76rem; line-height: 1.55; }
.role-detail-meta { display: grid; grid-template-columns: minmax(128px, .48fr) minmax(0, 1fr); gap: 8px 10px; margin: 0; font-size: .72rem; }
.role-detail-meta dt { color: var(--muted); font-weight: 800; }
.role-detail-meta dd { min-width: 0; margin: 0; color: var(--text); }
.role-permission-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.role-permission-list li { min-width: 0; padding: 0; border: 0; background: transparent; }
.role-permission-list code { font-size: .69rem; }
.role-detail-empty { color: var(--muted); font-style: italic; }
.role-docs-link { display: inline-flex; margin-top: 10px; font-size: .72rem; font-weight: 850; }
.binding-role-details.compact .binding-role-detail-panel { padding: 9px; }
.binding-role-details.compact .role-detail-meta { grid-template-columns: 1fr; gap: 3px; }
.binding-role-details.compact .role-detail-meta dd + dt { margin-top: 6px; }
.quick-empty { font-style: italic; }
.source-route-grid { display: grid; gap: 10px; }
.empty-route-note { margin: 0; padding: 16px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); background: var(--surface-2); font-size: .84rem; }
.source-route-card { grid-template-columns: minmax(130px, .8fr) minmax(180px, 1.2fr); align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.source-route-card span { min-width: 0; color: var(--text); }
.source-route-card strong, .source-route-card small { display: block; }
.source-route-card small { margin-top: 3px; color: var(--muted); font-weight: 500; }
.service-scope-heading { margin-top: 20px; }
.quick-resource-plan { display: flex; flex-wrap: wrap; gap: 8px; }
.service-scope-chip { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 10px; border: 1px solid var(--brand); border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .78rem; font-weight: 800; }

.entity-columns { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(0, 1.35fr); gap: 20px; }
.entity-editor { display: grid; gap: 10px; }
.entity-card { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.entity-card.unresolved { border-left: 5px solid var(--accent); }
.entity-card.complete { border-left: 5px solid var(--brand); }
.entity-card-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.entity-card-header strong { font-size: .9rem; }
.entity-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.resource-editor .entity-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.entity-fields label { font-size: .72rem; }
.remove-entity { min-height: 30px; border: 0; background: transparent; color: var(--danger); font-weight: 800; }

.project-architecture { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.architecture-node { min-width: 0; padding: 12px; border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: 10px; background: var(--surface-2); }
.architecture-node.unresolved { border-top-color: var(--accent); }
.architecture-node .node-type { display: block; color: var(--muted); font: 700 .68rem var(--mono); text-transform: uppercase; }
.architecture-node strong { display: block; margin: 5px 0; font-size: .88rem; }
.architecture-node small { display: block; color: var(--muted); }
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.matrix-table { width: 100%; min-width: 1120px; border-collapse: collapse; font-size: .78rem; }
.matrix-table.simplified-matrix { min-width: 820px; }
.matrix-table th, .matrix-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.matrix-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.matrix-table tr:last-child td { border-bottom: 0; }
.matrix-table tr.row-risk td { background: var(--danger-soft); }
.matrix-table code { font-size: .72rem; }
.matrix-table .binding-role-cell { min-width: 320px; }
.matrix-table .binding-role-detail-panel { min-width: 290px; }
.edge-status { font-weight: 800; }
.edge-status.issue { color: var(--danger); }
.edge-status.ready { color: var(--brand); }

.contract-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.contract-card { border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.contract-card summary { padding: 14px; cursor: pointer; color: var(--brand); font-weight: 800; }
.contract-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 0 14px 14px; }
.contract-fields label { font-size: .7rem; }
.ml-settings-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.ml-setting-check { display: flex; grid-template-columns: none; align-items: center; gap: 9px; color: var(--text); }
.ml-setting-check input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--brand); }
.readiness-layout { display: grid; grid-template-columns: .8fr 1.2fr; gap: 14px; margin-top: 18px; }
.strategy-card { padding: 16px; border-radius: 11px; background: var(--info-soft); border-left: 5px solid var(--brand); }
.strategy-card p:last-child { margin-bottom: 0; }
.readiness-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.readiness-item { padding: 11px; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 9px; background: var(--surface-2); }
.readiness-item.warning { border-left-color: var(--accent); background: var(--warn-soft); }
.readiness-item.blocked { border-left-color: var(--danger); background: var(--danger-soft); }
.readiness-item strong, .readiness-item small { display: block; }
.readiness-item small { margin-top: 3px; color: var(--muted); }

.governance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.governance-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.governance-card label + label { margin-top: 8px; }
.governance-card[data-status="blocked"] { border-color: var(--danger); background: var(--danger-soft); }
.governance-card[data-status="satisfied"] { border-color: var(--brand); background: var(--brand-soft); }
.matrix-filter-bar { display: grid; grid-template-columns: minmax(200px, 340px); gap: 10px; margin-bottom: 14px; }
.status-label { display: inline-flex; border-radius: 999px; padding: 3px 7px; background: var(--surface-2); border: 1px solid var(--line); font-size: .68rem; font-weight: 800; white-space: nowrap; }
.status-label.required { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.status-label.customer_one_time, .status-label.conditional, .status-label.alternative { color: var(--accent); border-color: var(--accent); background: var(--warn-soft); }
.status-label.explicitly_not_requested { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

footer { display: flex; justify-content: space-between; gap: 30px; padding: 28px 4px 46px; color: var(--muted); font-size: .82rem; }
footer p { max-width: 620px; margin-bottom: 0; }
.toast { position: fixed; z-index: 90; right: 18px; bottom: 18px; max-width: min(360px, calc(100% - 36px)); padding: 12px 16px; border-radius: 10px; background: var(--text); color: var(--surface); box-shadow: var(--shadow); opacity: 0; transform: translateY(20px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .control-grid { grid-template-columns: repeat(3, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .architecture-panel { position: static; }
  .capability-grid, .project-architecture { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .entity-columns, .readiness-layout, .quick-model-layout { grid-template-columns: 1fr; }
  .contract-grid, .governance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matrix-filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar, main, footer { width: min(100% - 20px, 1440px); }
  .topbar { flex-direction: column; padding-top: 28px; gap: 20px; }
  .top-actions { justify-content: flex-start; }
  .control-grid, .context-advice, .detail-intro, .role-grid, .permission-grid, .summary-content { grid-template-columns: 1fr; }
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { flex-direction: column; }
  .summary-block.full { grid-column: auto; }
  footer { flex-direction: column; gap: 12px; }
  .capability-grid, .project-architecture, .contract-grid, .governance-grid, .ml-settings-grid, .matrix-filter-bar { grid-template-columns: 1fr; }
  .resource-editor .entity-fields, .entity-fields, .contract-fields, .readiness-results { grid-template-columns: 1fr; }
  .quick-principal-grid { grid-template-columns: 1fr; }
  .source-route-card { grid-template-columns: 1fr; }
  .role-detail-meta { grid-template-columns: 1fr; gap: 3px; }
  .role-detail-meta dd + dt { margin-top: 7px; }
}
@media (max-width: 420px) {
  .topbar, main, footer { width: min(100% - 16px, 1440px); }
  .panel { padding: 16px; border-radius: 13px; }
  .service-grid { grid-template-columns: 1fr; }
  .service-card { min-height: 125px; }
  .action-bar .button { width: 100%; }
  .key-value { grid-template-columns: 1fr; gap: 2px; }
  .key-value dd { margin-bottom: 10px; }
  .status-pill { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
