:root {
  --ink: #17212b;
  --navy: #17324d;
  --navy-strong: #10283e;
  --muted: #687582;
  --soft: #f3f5f7;
  --panel: #ffffff;
  --line: #d8dee5;
  --line-strong: #b9c3cd;
  --red: #d9213a;
  --red-dark: #ba1730;
  --red-soft: #fff0f2;
  --success: #187450;
  --success-soft: #eaf7f1;
  --warning: #8a5a00;
  --warning-soft: #fff7e5;
  --danger: #b42333;
  --focus: #2b6fa8;
  --shadow: 0 10px 28px rgba(20, 42, 61, 0.08);
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--soft);
  color: var(--ink);
}

body {
  min-width: 0;
  margin: 0;
  background: var(--soft);
  font-size: 14px;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.drop-zone:focus-within {
  outline: 3px solid rgba(43, 111, 168, 0.2);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 9px 12px;
  transform: translateY(-150%);
  background: var(--navy);
  color: #fff;
  text-decoration: none;
}

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

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

.svg-symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px clamp(18px, 3vw, 44px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  color: var(--navy);
}

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

.brand-eyebrow,
.section-kicker {
  margin: 0;
  color: var(--red);
  font-family: "Segoe UI", sans-serif;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.15em;
}

.brand h1 {
  margin: 1px 0 0;
  color: var(--navy-strong);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.2;
  letter-spacing: 0.03em;
}

.profile-trigger {
  min-width: 190px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.profile-trigger:hover:not(:disabled) {
  border-color: var(--navy);
  background: #f8fafb;
}

.profile-trigger-copy {
  min-width: 0;
  display: grid;
  line-height: 1.25;
}

.profile-trigger-copy small {
  color: var(--muted);
  font-size: 9px;
}

.profile-trigger-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-trigger-action {
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.profile-trigger:disabled {
  cursor: wait;
  opacity: 0.62;
}

main {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 2.7vw, 42px) 44px;
}

.briefing {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 32px;
  align-items: end;
  margin-bottom: 18px;
}

.briefing h2 {
  margin: 5px 0 4px;
  color: var(--navy-strong);
  font-size: clamp(22px, 2.3vw, 34px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.briefing p:not(.section-kicker) {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.rule-area {
  min-width: 0;
}

.rule-strip {
  display: grid;
  grid-template-columns: repeat(4, auto);
  margin: 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.rule-strip > div {
  min-width: 108px;
  padding: 9px 12px;
  border-left: 1px solid var(--line);
}

.rule-strip > div:first-child {
  border-left: 0;
}

.rule-strip dt {
  color: var(--muted);
  font-size: 10px;
}

.rule-strip dd {
  margin: 1px 0 0;
  color: var(--navy);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(390px, 1.18fr) minmax(360px, 1fr);
  gap: 14px;
  align-items: start;
}

.work-panel {
  min-width: 0;
  min-height: 650px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(20, 42, 61, 0.045);
}

.panel-heading {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.step-number {
  flex: 0 0 auto;
  color: var(--red);
  font-family: "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.panel-heading > div {
  min-width: 0;
}

.panel-heading h2 {
  margin: 0;
  color: var(--navy-strong);
  font-size: 16px;
  line-height: 1.3;
}

.panel-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.panel-body {
  min-height: 0;
  flex: 1;
  padding: 16px;
}

.source-body {
  display: flex;
  flex-direction: column;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
}

#sourceText {
  width: 100%;
  min-height: 286px;
  flex: 1 1 286px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  line-height: 1.75;
}

#sourceText::placeholder {
  color: #6f7c88;
  opacity: 1;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button.primary {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: var(--navy-strong);
}

.button.secondary {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--navy);
}

.button.secondary:hover:not(:disabled) {
  border-color: var(--navy);
  background: #f6f9fb;
}

.button.text-button {
  padding-inline: 8px;
  background: transparent;
  color: var(--muted);
}

.button.compact {
  min-height: 34px;
  font-size: 12px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: #687582;
  font-size: 10px;
}

.divider::before,
.divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.drop-zone {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 14px;
  border: 1px dashed #aeb9c3;
  border-radius: 6px;
  background: #f8fafb;
  color: var(--navy);
  cursor: pointer;
  text-align: center;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--red);
  background: var(--red-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  font-weight: 750;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.drop-help {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.inline-status {
  min-height: 36px;
  margin-top: 12px;
  padding: 8px 10px;
  border-left: 3px solid var(--line-strong);
  background: #f7f8f9;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.inline-status[data-state="success"] {
  border-left-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.inline-status[data-state="warning"] {
  border-left-color: var(--warning);
  background: var(--warning-soft);
  color: var(--warning);
}

.inline-status[data-state="error"] {
  border-left-color: var(--danger);
  background: var(--red-soft);
  color: var(--danger);
}

.count-badge {
  min-width: 46px;
  margin-left: auto;
  padding: 4px 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.role-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  color: var(--muted);
  font-size: 10px;
}

.role-guide span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.role-line {
  width: 12px;
  height: 2px;
  background: var(--line-strong);
}

.title-line { background: var(--red); }
.h1-line { background: var(--navy); }
.h2-line { background: #50708c; }
.h3-line { background: #8b98a4; }

.blocks-list {
  min-height: 0;
  max-height: 531px;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-content: center;
  padding: 40px;
  text-align: center;
}

.empty-index {
  color: var(--red);
  font-family: "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.empty-state h3 {
  margin: 10px 0 6px;
  color: var(--navy);
  font-size: 16px;
}

.empty-state p {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.block-row {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 11px 14px;
  border-bottom: 1px solid #e8ecf0;
  background: #fff;
}

.block-row::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--line-strong);
  content: "";
}

.block-row[data-type="title"]::before { background: var(--red); }
.block-row[data-type="heading1"]::before { background: var(--navy); }
.block-row[data-type="heading2"]::before { background: #50708c; }
.block-row[data-type="heading3"]::before { background: #8b98a4; }

.block-row:last-child {
  border-bottom: 0;
}

.block-row:focus-within {
  background: #fbfcfd;
}

.block-meta {
  display: grid;
  gap: 4px;
}

.block-index {
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.block-type {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
}

.block-text-label {
  min-width: 0;
}

.block-text {
  width: 100%;
  min-height: 48px;
  resize: none;
  overflow: hidden;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  line-height: 1.6;
}

.block-text:hover {
  border-color: var(--line);
}

.block-text:focus {
  border-color: var(--focus);
  background: #fff;
}

.block-actions {
  display: grid;
  gap: 3px;
}

.block-actions button {
  min-width: 44px;
  min-height: 27px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}

.block-actions button:hover:not(:disabled) {
  background: #eef2f5;
  color: var(--navy);
}

.block-actions button[data-action="delete"]:hover {
  background: var(--red-soft);
  color: var(--danger);
}

.block-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.structure-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.preview-panel {
  position: sticky;
  top: 90px;
}

.preview-layout {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.preview-stage {
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #e7ebef;
}

.paper {
  position: relative;
  container-type: inline-size;
  width: min(100%, 420px);
  aspect-ratio: var(--profile-page-ratio, 210 / 297);
  overflow: hidden;
  background: #fff;
  color: #090909;
  box-shadow: var(--shadow);
}

.paper-content {
  position: absolute;
  top: var(--profile-margin-top, 12.46%);
  right: var(--profile-margin-right, 13.33%);
  bottom: var(--profile-margin-bottom, 11.78%);
  left: var(--profile-margin-left, 13.33%);
  overflow: hidden;
  font-size: 2.67cqw;
}

.paper-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: #71808d;
  text-align: center;
}

.paper-empty span {
  font-family: "Times New Roman", serif;
  font-size: clamp(28px, 7cqw, 42px);
  line-height: 1;
}

.paper-empty p {
  margin: 10px 0 0;
  font-size: 11px;
}

.preview-block {
  margin: 0;
  color: #090909;
  overflow-wrap: anywhere;
}

.preview-block[data-type="title"] {
  margin-bottom: var(--profile-title-after, 2.7cqw);
  font-family: var(--profile-title-font, "方正小标宋_GBK", "STZhongsong", "SimSun", serif);
  font-size: var(--profile-title-size, 3.68cqw);
  font-weight: var(--profile-title-weight, 400);
  line-height: var(--profile-title-line, 5.38cqw);
  text-align: center;
}

.preview-block:not([data-type="title"]) {
  font-family: var(--profile-body-font, "方正仿宋_GBK", "FangSong", serif);
  font-size: var(--profile-body-size, 2.67cqw);
  font-weight: var(--profile-body-weight, 400);
  line-height: var(--profile-body-line, 4.7cqw);
  text-align: justify;
  text-indent: var(--profile-body-indent, 2em);
}

.preview-block[data-type="heading1"] {
  font-family: var(--profile-heading1-font, "方正黑体_GBK", "SimHei", sans-serif);
  font-size: var(--profile-heading1-size, 2.67cqw);
  font-weight: var(--profile-heading1-weight, 400);
  line-height: var(--profile-heading1-line, 4.7cqw);
}

.preview-block[data-type="heading2"] {
  font-family: var(--profile-heading2-font, "方正楷体_GBK", "KaiTi", serif);
  font-size: var(--profile-heading2-size, 2.67cqw);
  font-weight: var(--profile-heading2-weight, 400);
  line-height: var(--profile-heading2-line, 4.7cqw);
}

.preview-block[data-type="heading3"] {
  font-family: var(--profile-heading3-font, "方正仿宋_GBK", "FangSong", serif);
  font-size: var(--profile-heading3-size, 2.67cqw);
  font-weight: var(--profile-heading3-weight, 700);
  line-height: var(--profile-heading3-line, 4.7cqw);
}

.page-number {
  position: absolute;
  right: 0;
  bottom: 2.35%;
  left: 0;
  font-family: var(--profile-page-number-font, "Times New Roman", serif);
  font-size: var(--profile-page-number-size, 2.34cqw);
  line-height: 1.2;
  text-align: center;
}

.page-overflow-note {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  padding: 5px 7px;
  border: 1px solid #e0a400;
  background: rgba(255, 248, 225, 0.96);
  color: #765000;
  font-size: 9px;
  text-align: center;
}

.export-panel {
  padding: 14px 16px 16px;
}

.template-summary {
  margin-bottom: 13px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.summary-label {
  margin: 0;
  color: var(--red);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.template-summary h3 {
  margin: 2px 0 8px;
  color: var(--navy);
  font-size: 15px;
}

.template-summary ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.template-summary li {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.template-summary li span {
  color: var(--muted);
  font-size: 9px;
}

.template-summary li b {
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-status {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.font-status[data-state="success"] { color: var(--success); }
.font-status[data-state="warning"] { color: var(--warning); }

.filename-field {
  height: 40px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.filename-field:focus-within {
  border-color: var(--focus);
  outline: 3px solid rgba(43, 111, 168, 0.14);
}

.filename-field input {
  min-width: 0;
  height: 100%;
  flex: 1;
  border: 0;
  padding: 0 10px;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.filename-field span {
  padding-right: 10px;
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
  font-size: 12px;
}

.export-button {
  width: 100%;
  min-height: 46px;
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  font-size: 14px;
}

.export-button:hover:not(:disabled) {
  background: var(--red-dark);
}

.export-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.export-panel .inline-status {
  margin-top: 9px;
}

.app-footer {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 0 clamp(14px, 2.7vw, 42px) 28px;
}

.app-footer-inner {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
}

.app-footer p {
  margin: 0;
}

.app-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.app-identity span::before {
  margin-right: 7px;
  color: var(--line-strong);
  content: "/";
}

.app-identity strong {
  color: var(--navy);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.app-principle {
  text-align: right;
}

.app-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
}

.app-footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.app-footer-links a:hover,
.app-footer-links a:focus-visible {
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.app-footer-links a:focus-visible,
.static-brand:focus-visible,
.static-back:focus-visible,
.static-card a:focus-visible {
  outline: 3px solid rgba(43, 111, 168, 0.22);
  outline-offset: 3px;
}

.about-button {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  font-size: 11px;
}

.app-dialog {
  width: min(1040px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100vh - 28px);
  border: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  color: var(--ink);
}

.app-dialog::backdrop {
  background: rgba(10, 29, 45, 0.54);
  backdrop-filter: blur(2px);
}

.dialog-shell {
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 36, 53, 0.24);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px 17px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 4px 0 2px;
  color: var(--navy-strong);
  font-size: 22px;
}

.dialog-header p:not(.section-kicker) {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.dialog-close {
  min-width: 48px;
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.dialog-close:hover {
  border-color: var(--navy);
  color: var(--navy);
}

.profile-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.profile-select-field {
  min-width: min(360px, 100%);
  display: grid;
  gap: 4px;
}

.profile-select-field span,
.profile-field-grid label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.profile-select-field select,
.profile-field-grid input,
.profile-field-grid select,
.style-editor-row input[type="text"],
.style-editor-row input[type="number"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
}

.profile-toolbar-actions {
  display: flex;
  gap: 7px;
}

.profile-editor {
  min-height: 0;
  overflow-y: auto;
}

.profile-section {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.profile-section > header {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.profile-section > header > span {
  color: var(--red);
  font-family: "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 800;
}

.profile-section h3 {
  margin: 0;
  color: var(--navy);
  font-size: 14px;
}

.profile-section header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.profile-field-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.profile-field-grid label {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.profile-field-grid .wide-field {
  grid-column: span 2;
}

.style-editor {
  min-width: 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.style-editor-head,
.style-editor-row {
  display: grid;
  grid-template-columns: 86px minmax(150px, 1fr) 84px 84px 64px;
  gap: 8px;
  align-items: center;
}

.style-editor-head {
  min-height: 30px;
  padding: 0 8px;
  background: #f4f6f8;
  color: var(--muted);
  font-size: 9px;
}

.style-editor-row {
  min-height: 48px;
  padding: 6px 8px;
  border-top: 1px solid #e9edf1;
}

.style-editor-row strong {
  color: var(--navy);
  font-size: 11px;
}

.check-field {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.check-field input {
  width: 16px;
  height: 16px;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 22px;
  background: #f8fafb;
}

.dialog-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.dialog-footer p[data-state="error"] {
  color: var(--danger);
}

.dialog-footer p[data-state="success"] {
  color: var(--success);
}

.dialog-footer > div {
  display: flex;
  gap: 8px;
}

.about-dialog {
  width: min(430px, calc(100% - 28px));
}

.about-shell {
  align-items: flex-start;
  padding: 28px;
}

.about-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  color: var(--red);
}

.about-shell h2 {
  margin: 4px 0 7px;
  color: var(--navy-strong);
  font-size: 21px;
}

.about-shell > p:not(.section-kicker) {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.about-shell dl {
  width: 100%;
  margin: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.about-shell dl div {
  display: grid;
  grid-template-columns: 64px 1fr;
  padding: 9px 0;
  border-top: 1px solid #edf0f3;
}

.about-shell dl div:first-child {
  border-top: 0;
}

.about-shell dt {
  color: var(--muted);
  font-size: 11px;
}

.about-shell dd {
  margin: 0;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
}

.about-shell .button {
  align-self: stretch;
}

button[aria-busy="true"] {
  cursor: progress;
}

.drop-zone[aria-busy="true"] {
  cursor: progress;
  opacity: 0.7;
}

/* Static product pages share the same restrained palette as the workbench. */
.static-page {
  min-height: 100vh;
  background: var(--soft);
}

.static-topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(18px, 3vw, 44px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.static-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--navy-strong);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.static-brand img {
  width: 38px;
  height: 38px;
}

.static-topbar .static-back {
  color: var(--muted);
  font-size: 12px;
}

.static-back:hover,
.static-back:focus-visible {
  color: var(--navy);
}

.static-main {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 44px clamp(16px, 4vw, 54px) 70px;
}

.static-card {
  padding: clamp(24px, 5vw, 52px);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.static-card .section-kicker {
  margin-bottom: 8px;
}

.static-card h1 {
  margin: 0;
  color: var(--navy-strong);
  font-size: clamp(25px, 4vw, 36px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.static-lead {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.static-card section {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.static-card h2 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 18px;
}

.static-card h3 {
  margin: 20px 0 7px;
  color: var(--navy);
  font-size: 14px;
}

.static-card p,
.static-card li {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.85;
}

.static-card p {
  margin: 0 0 10px;
}

.static-card ul,
.static-card ol {
  margin: 8px 0 0;
  padding-left: 1.35em;
}

.static-card a {
  color: var(--navy);
  text-underline-offset: 3px;
}

.static-card code {
  padding: 1px 4px;
  background: #f0f3f5;
  color: var(--navy);
  font-family: "Consolas", monospace;
  font-size: 0.92em;
}

.static-note {
  margin-top: 24px !important;
  padding: 11px 13px;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: var(--navy) !important;
}

.static-footer {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 54px) 28px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1260px) {
  .briefing {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .rule-area {
    width: fit-content;
  }

  .workspace {
    grid-template-columns: minmax(280px, 0.9fr) minmax(390px, 1.1fr);
  }

  .preview-panel {
    position: static;
    grid-column: 1 / -1;
    min-height: auto;
  }

  .preview-layout {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(300px, 0.72fr);
  }

  .preview-stage {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }
}

@media (max-width: 900px) {
  .topbar {
    position: static;
  }

  main {
    padding-top: 18px;
  }

  .rule-area,
  .rule-strip {
    width: 100%;
  }

  .profile-section {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 16px;
  }

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

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

  .work-panel,
  .preview-panel {
    min-height: auto;
    grid-column: auto;
  }

  .blocks-list {
    max-height: none;
    overflow: visible;
  }

  .preview-layout {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .paper {
    width: min(100%, 480px);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    padding: 12px 14px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .profile-trigger {
    min-width: 0;
    max-width: 132px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 7px;
    padding: 5px 7px;
  }

  .profile-trigger-action {
    display: inline;
    font-size: 9px;
  }

  .profile-trigger-copy strong {
    font-size: 11px;
  }

  main {
    padding-inline: 10px;
  }

  .briefing h2 {
    font-size: 23px;
  }

  .briefing p:not(.section-kicker) {
    font-size: 12px;
  }

  .rule-strip {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-strip > div {
    min-width: 0;
    border-bottom: 1px solid var(--line);
  }

  .rule-strip > div:nth-child(odd) {
    border-left: 0;
  }

  .rule-strip > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .panel-body,
  .export-panel {
    padding: 13px;
  }

  #sourceText {
    min-height: 250px;
  }

  .source-actions .button.primary {
    width: 100%;
  }

  .block-row {
    grid-template-columns: 98px minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .block-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #edf0f3;
    padding-top: 4px;
  }

  .block-actions button {
    min-width: 54px;
    min-height: 34px;
  }

  .structure-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-stage {
    padding: 12px;
  }

  .template-summary ul {
    grid-template-columns: 1fr;
  }

  .app-footer-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .app-principle {
    text-align: left;
  }

  .app-footer-links {
    justify-content: flex-start;
  }

  .app-dialog,
  .about-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
  }

  .dialog-shell {
    max-height: calc(100vh - 16px);
  }

  .dialog-header {
    gap: 12px;
    padding: 16px;
  }

  .dialog-header h2 {
    font-size: 19px;
  }

  .profile-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 16px;
  }

  .profile-select-field {
    min-width: 0;
  }

  .profile-toolbar-actions .button {
    flex: 1;
  }

  .profile-section {
    grid-template-columns: 1fr;
    gap: 11px;
    padding: 15px 16px;
  }

  .profile-section > header {
    align-items: center;
  }

  .style-editor-head {
    display: none;
  }

  .style-editor-row {
    grid-template-columns: 76px minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: 50px 50px;
    gap: 6px;
    padding: 8px;
  }

  .style-editor-row > label:not(.check-field) {
    display: grid;
    align-self: stretch;
    gap: 3px;
  }

  .style-editor-row .sr-only {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
  }

  .style-editor-row > strong {
    grid-column: 1;
    grid-row: 1;
  }

  .style-editor-row > label:nth-of-type(1) {
    grid-column: 2 / 4;
    grid-row: 1;
  }

  .style-editor-row > label:nth-of-type(2) {
    grid-column: 2;
    grid-row: 2;
  }

  .style-editor-row > label:nth-of-type(3) {
    grid-column: 3;
    grid-row: 2;
  }

  .style-editor-row > .check-field {
    grid-column: 1;
    grid-row: 2;
  }

  .dialog-footer {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 16px;
  }

  .dialog-footer > div .button {
    flex: 1;
  }

  .about-shell {
    padding: 22px;
  }
}

@media (max-height: 820px) and (min-width: 641px) {
  .dialog-header {
    padding: 13px 18px 11px;
  }

  .dialog-header h2 {
    font-size: 20px;
  }

  .profile-toolbar {
    padding: 9px 18px;
  }

  .profile-section {
    padding: 11px 18px;
  }

  .style-editor-row {
    min-height: 40px;
    padding-block: 2px;
  }

  .profile-select-field select,
  .profile-field-grid input,
  .profile-field-grid select,
  .style-editor-row input[type="text"],
  .style-editor-row input[type="number"] {
    height: 32px;
  }

  .dialog-footer {
    padding: 9px 18px;
  }
}

@media (max-width: 440px) {
  .brand h1 {
    font-size: 18px;
  }

  .static-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .static-main {
    padding-top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
