:root {
  color-scheme: light;
  font-family: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --page: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --ink: #14201c;
  --ink-soft: #34453f;
  --muted: #66766f;
  --subtle: #87958f;
  --line: #dce6e2;
  --line-strong: #c6d5cf;
  --green: #0d806a;
  --green-strong: #086752;
  --green-soft: #e8f6f2;
  --coral: #c95638;
  --coral-soft: #fff0eb;
  --blue: #356da8;
  --blue-soft: #edf4fb;
  --amber: #94691c;
  --amber-soft: #fff6df;
  --pink: #aa3b70;
  --pink-soft: #fcecf4;
  --danger: #b93d4c;
  --danger-soft: #fdecef;
  --focus: 0 0 0 3px rgba(13, 128, 106, .22);
  --shadow: 0 12px 32px rgba(26, 54, 44, .08);
  --topbar-height: 68px;
}

* { box-sizing: border-box; letter-spacing: 0; }
html { min-width: 320px; background: var(--page); }
body { min-height: 100dvh; margin: 0; overflow-x: hidden; color: var(--ink); background: var(--page); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a, label:has(input[type="radio"]), label:has(input[type="checkbox"]) { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, a { cursor: pointer; }
button { border: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, dl, dt, dd, fieldset, legend { margin: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link { position: fixed; top: -56px; left: 16px; z-index: 100; padding: 10px 14px; border-radius: 6px; color: #fff; background: var(--ink); transition: top .18s ease; }
.skip-link:focus { top: 12px; }

.topbar { position: sticky; top: 0; z-index: 40; display: grid; grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr); align-items: center; min-height: var(--topbar-height); padding: 0 clamp(18px, 3vw, 44px); border-bottom: 1px solid rgba(220, 230, 226, .95); background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); }
.brand { display: inline-flex; align-items: center; justify-self: start; gap: 14px; min-height: 44px; font-size: 14px; font-weight: 750; }
.brand img { display: block; width: 92px; height: 30px; object-fit: contain; filter: brightness(.32); }
.brand span { padding-left: 14px; border-left: 1px solid var(--line-strong); white-space: nowrap; }
.topnav { display: flex; align-items: center; justify-content: center; gap: 4px; }
.topnav a { display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 0 12px; border-radius: 7px; color: var(--muted); font-size: 12px; font-weight: 650; transition: color .18s ease, background .18s ease; }
.topnav a:hover { color: var(--ink); background: var(--surface-soft); }
.topnav a.is-active { color: var(--green-strong); background: var(--green-soft); }
.topnav svg { width: 17px; height: 17px; stroke-width: 1.8; }
.save-state { display: inline-flex; align-items: center; justify-self: end; gap: 7px; min-height: 38px; padding: 0 10px; color: var(--muted); font-size: 11px; }
.save-state svg { width: 16px; height: 16px; color: var(--green); stroke-width: 1.9; }
.save-state.is-saving svg { animation: pulse .7s ease infinite alternate; }

.page-shell { width: min(calc(100% - clamp(32px, 5vw, 72px)), 1540px); margin: 0 auto; padding: 30px 0 64px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 36px; padding-bottom: 24px; }
.eyebrow, .section-index { color: var(--green); font-size: 9px; font-weight: 850; line-height: 1.4; }
.page-heading h1 { margin-top: 7px; font-size: 30px; line-height: 1.15; }
.page-heading > div > p:last-child { margin-top: 8px; color: var(--muted); font-size: 13px; }
.workflow-steps { display: grid; grid-template-columns: repeat(3, minmax(108px, 1fr)); width: min(430px, 100%); padding: 0; list-style: none; }
.workflow-steps li { position: relative; display: grid; gap: 2px; min-width: 0; padding: 0 14px 6px; color: var(--subtle); border-bottom: 2px solid var(--line); }
.workflow-steps li + li::before { position: absolute; bottom: -2px; left: 0; width: 8px; border-bottom: 2px solid var(--line); content: ""; }
.workflow-steps span { font-size: 9px; font-weight: 800; }
.workflow-steps strong { overflow: hidden; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.workflow-steps li.is-current { color: var(--green-strong); border-color: var(--green); }
.workflow-steps li.is-complete { color: var(--ink-soft); border-color: #8abbb0; }

.builder-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; align-items: start; gap: 18px; }
.materials-panel { min-width: 0; }
.panel-heading, .output-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.panel-heading h2, .output-heading h2 { margin-top: 4px; font-size: 20px; line-height: 1.25; }
.panel-actions, .output-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.count-badge { display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--surface); transition: color .18s ease, border-color .18s ease, background .18s ease, opacity .18s ease; }
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-soft); }
.icon-button:disabled { cursor: not-allowed; opacity: .4; }
.icon-button:active, .secondary-button:active, .primary-button:active { opacity: .72; }
.icon-button svg { width: 18px; height: 18px; stroke-width: 1.9; }
.danger-button:hover { color: var(--danger); border-color: #e8c3c8; background: var(--danger-soft); }
.secondary-button, .primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; font-weight: 750; transition: color .18s ease, border-color .18s ease, background .18s ease, opacity .18s ease; }
.secondary-button { color: var(--ink-soft); background: var(--surface); }
.secondary-button:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-soft); }
.primary-button { color: #fff; border-color: var(--green); background: var(--green); }
.primary-button:hover { border-color: var(--green-strong); background: var(--green-strong); }
.primary-button:disabled, .secondary-button:disabled { opacity: .46; }
.secondary-button svg, .primary-button svg { width: 17px; height: 17px; stroke-width: 2; }

.framework-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.framework-card { --accent: var(--green); --accent-soft: var(--green-soft); min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 2px 8px rgba(26, 54, 44, .025); transition: border-color .18s ease, box-shadow .18s ease; }
.framework-card:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 7px 20px rgba(26, 54, 44, .06); }
.framework-card[data-key="trust"] { --accent: var(--blue); --accent-soft: var(--blue-soft); }
.framework-card[data-key="product"] { --accent: var(--coral); --accent-soft: var(--coral-soft); }
.framework-card[data-key="mechanism"] { --accent: var(--pink); --accent-soft: var(--pink-soft); }
.framework-card[data-key="conversion"] { --accent: var(--amber); --accent-soft: var(--amber-soft); }
.framework-card[data-key="urgency"] { --accent: #9d414b; --accent-soft: #fcedef; }
.framework-heading { display: flex; align-items: center; gap: 10px; }
.framework-number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; color: var(--accent); background: var(--accent-soft); font-size: 10px; font-weight: 850; }
.framework-heading > div { display: grid; flex: 1; min-width: 0; }
.framework-heading label { color: var(--ink); font-size: 13px; font-weight: 780; }
.framework-heading small { margin-top: 1px; color: var(--muted); font-size: 9px; }
.framework-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; }
.framework-heading output { flex: 0 0 auto; color: var(--accent); font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
.framework-manage { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 62px; min-height: 36px; padding: 0 8px; border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 750; transition: color .18s ease, background .18s ease; }
.framework-manage:hover { color: var(--accent); background: var(--accent-soft); }
.framework-manage svg { width: 14px; height: 14px; stroke-width: 1.9; }
.framework-card textarea { display: block; width: 100%; min-height: 126px; margin-top: 12px; padding: 11px 12px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; outline: 0; color: var(--ink); background: var(--surface-soft); font-size: 13px; line-height: 1.65; transition: border-color .18s ease, background .18s ease; }
.framework-card textarea:hover { border-color: var(--line-strong); }
.framework-card textarea:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.framework-card textarea::placeholder { color: #9aa7a1; }

.rules-panel { position: sticky; top: calc(var(--topbar-height) + 18px); padding: 19px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 5px 18px rgba(26, 54, 44, .05); }
.compact-heading { margin-bottom: 17px; }
.mode-fieldset, .export-mode-fieldset { padding: 0; border: 0; }
.mode-fieldset legend, .export-mode-fieldset legend { margin-bottom: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 750; }
.mode-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.mode-switch label, .export-mode-fieldset label { position: relative; cursor: pointer; }
.mode-switch input, .export-mode-fieldset input { position: absolute; opacity: 0; pointer-events: none; }
.mode-switch label > span, .export-mode-fieldset label > span { display: grid; min-height: 68px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); transition: border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.mode-switch label > span strong, .export-mode-fieldset label > span strong { font-size: 12px; }
.mode-switch label > span small, .export-mode-fieldset label > span small { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.mode-switch input:checked + span, .export-mode-fieldset input:checked + span { border-color: #7eb8aa; color: var(--green-strong); background: var(--green-soft); box-shadow: inset 0 0 0 1px rgba(13, 128, 106, .1); }
.mode-switch input:focus-visible + span, .export-mode-fieldset input:focus-visible + span { box-shadow: var(--focus); }
.anchor-options { display: grid; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-field { display: grid; gap: 7px; min-width: 0; }
.form-field > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 750; }
.form-field > span b { color: var(--subtle); font-size: 9px; font-weight: 650; }
.form-field select, .form-field input { width: 100%; min-height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; outline: 0; color: var(--ink); background: #fff; font-size: 12px; }
.form-field select:focus, .form-field input:focus { border-color: var(--green); }
.rules-panel > .form-field { margin-top: 14px; }
.number-stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; }
.number-stepper button { display: grid; place-items: center; min-height: 44px; color: var(--muted); background: var(--surface-soft); }
.number-stepper button:hover { color: var(--ink); background: #edf2ef; }
.number-stepper button:first-child { border-right: 1px solid var(--line); }
.number-stepper button:last-child { border-left: 1px solid var(--line); }
.number-stepper button svg { width: 16px; height: 16px; }
.number-stepper input { min-height: 44px; padding: 0; border: 0; border-radius: 0; text-align: center; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.number-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.mix-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 17px; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mix-summary > div { min-width: 0; padding: 0 8px; }
.mix-summary > div + div { border-left: 1px solid var(--line); }
.mix-summary dt { color: var(--muted); font-size: 9px; white-space: nowrap; }
.mix-summary dd { margin-top: 4px; overflow: hidden; font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-control { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 42px; color: var(--muted); font-size: 9px; }
.history-control > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-control button { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; min-height: 36px; padding: 0 8px; border-radius: 6px; color: var(--muted); background: transparent; font-size: 9px; font-weight: 750; }
.history-control button:hover:not(:disabled) { color: var(--green-strong); background: var(--green-soft); }
.history-control button:disabled { opacity: .42; }
.history-control svg { width: 14px; height: 14px; }
.rule-note { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 9px; margin-top: 16px; padding: 11px; border-radius: 7px; color: #74541b; background: var(--amber-soft); }
.rule-note > svg { width: 17px; height: 17px; margin: 3px auto 0; stroke-width: 1.9; }
.rule-note p { display: grid; }
.rule-note strong { font-size: 10px; }
.rule-note span { margin-top: 2px; color: #806b43; font-size: 9px; line-height: 1.5; }
.generate-button { width: 100%; margin-top: 16px; }

.output-section { padding-top: 38px; }
.output-heading { align-items: center; }
.output-heading > div > p:last-child { margin-top: 5px; color: var(--muted); font-size: 11px; }
.check-control { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 8px; color: var(--muted); cursor: pointer; font-size: 11px; }
.check-control input { width: 16px; height: 16px; accent-color: var(--green); }
.empty-output { display: flex; align-items: center; justify-content: center; gap: 15px; min-height: 230px; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); background: rgba(255, 255, 255, .45); }
.empty-output > span { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 7px; color: var(--green); background: var(--green-soft); }
.empty-output svg { width: 23px; height: 23px; stroke-width: 1.7; }
.empty-output strong { color: var(--ink-soft); font-size: 13px; }
.empty-output p { margin-top: 3px; font-size: 11px; }
.result-workbench { display: grid; grid-template-columns: 292px minmax(0, 1fr); min-height: 660px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 6px 20px rgba(26, 54, 44, .05); }
.result-index { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; border-right: 1px solid var(--line); background: var(--surface-soft); }
.result-index-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 58px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.result-index-heading strong { font-size: 12px; }
.result-index-heading span { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }
.result-list { max-height: 702px; overflow-y: auto; overscroll-behavior: contain; }
.result-row { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) 18px; align-items: center; gap: 8px; width: 100%; min-height: 74px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink-soft); background: transparent; text-align: left; content-visibility: auto; contain-intrinsic-size: 74px; transition: color .18s ease, background .18s ease; }
.result-row:hover { color: var(--ink); background: #fff; }
.result-row.is-active { color: var(--green-strong); background: var(--green-soft); }
.result-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.result-row-copy { display: grid; min-width: 0; }
.result-row-copy strong { font-size: 11px; }
.result-row-copy span { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.result-row-open { display: grid; grid-template-columns: minmax(0, 1fr) 18px; align-items: center; gap: 8px; min-width: 0; min-height: 48px; padding: 0; color: inherit; background: transparent; text-align: left; }
.result-row-open > svg { width: 15px; height: 15px; stroke-width: 2; }
.document-preview { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; background: #eef2f0; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 70px; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94); }
.preview-toolbar > div:first-child { display: grid; }
.preview-toolbar span { color: var(--muted); font-size: 9px; }
.preview-toolbar h3 { margin-top: 2px; font-size: 14px; }
.preview-toolbar > div:last-child { display: flex; gap: 8px; }
.paper { width: min(calc(100% - 64px), 760px); min-height: 540px; margin: 28px auto; padding: 46px 54px 56px; border: 1px solid #dfe5e2; background: #fff; box-shadow: 0 12px 30px rgba(30, 47, 41, .1); }
.paper-heading { padding-bottom: 19px; border-bottom: 2px solid var(--ink); }
.paper-heading span { color: var(--green); font-size: 9px; font-weight: 850; }
.paper-heading h4 { margin: 5px 0 0; font-size: 23px; line-height: 1.25; }
.preview-part { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-bottom: 1px solid #e6ebe8; }
.preview-part label { padding-top: 8px; color: var(--muted); font-size: 10px; font-weight: 750; }
.preview-part textarea { width: 100%; min-height: 62px; padding: 7px 8px; resize: vertical; border: 1px solid transparent; border-radius: 5px; outline: 0; color: #1e2925; background: transparent; font-family: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.85; transition: border-color .18s ease, background .18s ease; }
.preview-part textarea:hover { border-color: var(--line); background: var(--surface-soft); }
.preview-part textarea:focus { border-color: #82b9ac; background: #fff; box-shadow: 0 0 0 3px rgba(13, 128, 106, .12); }
.preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 44px; padding: 0 18px; border-top: 1px solid var(--line); color: var(--muted); background: rgba(255, 255, 255, .94); font-size: 9px; font-variant-numeric: tabular-nums; }

.export-dialog { width: min(calc(100% - 32px), 510px); padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 70px rgba(20, 32, 28, .22); }
.export-dialog::backdrop, .library-dialog::backdrop { background: rgba(20, 32, 28, .46); backdrop-filter: blur(2px); }
.export-dialog form { padding: 20px; }
.export-dialog header { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 12px; margin-bottom: 20px; }
.dialog-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 7px; color: var(--green); background: var(--green-soft); }
.dialog-icon svg { width: 20px; height: 20px; }
.export-dialog header h2 { font-size: 18px; }
.export-dialog header p { margin-top: 2px; color: var(--muted); font-size: 10px; }
.export-dialog > form > .form-field { margin-bottom: 17px; }
.export-mode-fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.export-mode-fieldset legend { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.library-dialog { width: min(calc(100% - 32px), 860px); max-height: min(88dvh, 820px); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 70px rgba(20, 32, 28, .22); }
.library-dialog-shell { display: grid; grid-template-rows: auto auto auto minmax(180px, 1fr) auto; max-height: min(88dvh, 820px); padding: 20px; }
.library-dialog header { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 12px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.library-dialog header h2 { font-size: 18px; }
.library-dialog header p { margin-top: 2px; color: var(--muted); font-size: 10px; }
.library-add { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 16px 0; }
.library-add > div { display: grid; }
.library-add h3 { font-size: 12px; }
.library-add > div span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.library-add textarea { min-height: 76px; padding: 9px 10px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; outline: 0; color: var(--ink); background: var(--surface-soft); font-size: 12px; line-height: 1.55; }
.library-add textarea:focus { border-color: var(--green); background: #fff; box-shadow: var(--focus); }
.library-toolbar { display: flex; align-items: center; gap: 8px; padding: 11px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.library-search { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; flex: 1; min-width: 160px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.library-search svg { width: 15px; height: 15px; color: var(--subtle); }
.library-search input { min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.danger-text { color: var(--danger); }
.danger-text:hover { color: #912c38; border-color: #e5bcc2; background: var(--danger-soft); }
.library-list { min-height: 180px; overflow-y: auto; overscroll-behavior: contain; }
.library-item { display: grid; grid-template-columns: 22px 42px minmax(0, 1fr); align-items: start; gap: 8px; min-height: 48px; padding: 10px 8px; border-bottom: 1px solid var(--line); cursor: pointer; content-visibility: auto; contain-intrinsic-size: 48px; transition: background .18s ease; }
.library-item:hover { background: var(--surface-soft); }
.library-item input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--green); }
.library-item > span { padding-top: 2px; color: var(--subtle); font-size: 9px; font-variant-numeric: tabular-nums; }
.library-item p { min-width: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.library-empty { display: grid; place-items: center; align-content: center; min-height: 180px; color: var(--muted); text-align: center; }
.library-empty svg { width: 25px; height: 25px; color: var(--subtle); }
.library-empty strong { margin-top: 9px; color: var(--ink-soft); font-size: 12px; }
.library-empty span { margin-top: 3px; font-size: 10px; }
.library-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 58px; padding-top: 12px; border-top: 1px solid var(--line); }
.library-pagination span { min-width: 132px; color: var(--muted); font-size: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(380px, calc(100% - 32px)); padding: 11px 14px; border: 1px solid #b8d9d0; border-radius: 7px; color: #075a49; background: #effaf7; box-shadow: var(--shadow); font-size: 12px; }
.toast.is-error { color: #8e2c39; border-color: #e2b6bc; background: #fff2f3; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: minmax(190px, 1fr) auto auto; }
  .save-state span { display: none; }
  .builder-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .framework-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --topbar-height: 62px; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 16px; }
  .brand img { width: 82px; }
  .brand span { display: none; }
  .topnav { justify-content: flex-end; }
  .topnav a { width: 44px; padding: 0; justify-content: center; }
  .topnav a span { display: none; }
  .save-state { padding: 0 0 0 10px; }
  .page-shell { width: min(calc(100% - 32px), 760px); padding-top: 22px; }
  .page-heading { display: grid; align-items: start; }
  .workflow-steps { width: 100%; }
  .builder-layout { grid-template-columns: 1fr; }
  .rules-panel { position: static; }
  .framework-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-workbench { grid-template-columns: 238px minmax(0, 1fr); }
  .paper { width: min(calc(100% - 32px), 660px); padding: 38px 34px 48px; }
  .preview-part { grid-template-columns: 1fr; gap: 4px; }
  .preview-part label { padding-top: 0; }
}

@media (max-width: 680px) {
  .topbar { grid-template-columns: auto 1fr; }
  .save-state { display: none; }
  .page-shell { width: min(calc(100% - 24px), 560px); padding-bottom: 40px; }
  .page-heading { gap: 22px; }
  .page-heading h1 { font-size: 26px; }
  .workflow-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workflow-steps li { padding-inline: 8px; }
  .panel-heading, .output-heading { display: grid; align-items: start; }
  .panel-actions, .output-actions { justify-content: flex-start; }
  .count-badge { padding-left: 0; }
  .framework-grid { grid-template-columns: 1fr; }
  .framework-card textarea { min-height: 112px; }
  .output-actions { display: grid; grid-template-columns: auto 1fr; width: 100%; }
  .output-actions .primary-button { grid-column: 1 / -1; }
  .empty-output { min-height: 190px; padding: 24px; }
  .result-workbench { display: block; min-height: 0; overflow: visible; }
  .result-index { border-right: 0; border-bottom: 1px solid var(--line); }
  .result-list { display: flex; max-height: none; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; }
  .result-row { flex: 0 0 210px; min-height: 70px; border-right: 1px solid var(--line); border-bottom: 0; scroll-snap-align: start; }
  .paper { width: calc(100% - 24px); min-height: 0; margin: 12px; padding: 30px 20px 36px; }
  .preview-toolbar { padding-inline: 12px; }
  .preview-part textarea { font-size: 16px; }
  .export-mode-fieldset { grid-template-columns: 1fr; }
  .library-dialog-shell { padding: 14px; }
  .library-add { grid-template-columns: 1fr; }
  .library-add .primary-button { width: 100%; }
  .library-toolbar { align-items: stretch; flex-wrap: wrap; }
  .library-search { flex-basis: 100%; }
  .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .dialog-actions button { width: 100%; }
}

@media (max-width: 390px) {
  .topbar { padding-inline: 10px; }
  .brand img { width: 76px; }
  .topnav { gap: 0; }
  .topnav a { width: 42px; }
  .page-shell { width: calc(100% - 20px); }
  .panel-actions .secondary-button { flex: 1 1 120px; }
  .mode-switch { grid-template-columns: 1fr; }
  .mix-summary { grid-template-columns: 1fr; gap: 10px; }
  .mix-summary > div { padding: 0; }
  .mix-summary > div + div { padding-top: 10px; border-top: 1px solid var(--line); border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@keyframes pulse { from { opacity: .45; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.is-loading svg { animation: spin .8s linear infinite; }
