:root {
  --bg: #f2ede2;
  --bg-deep: #e9e1d3;
  --surface: #fbf7ee;
  --surface-strong: #fffdf8;
  --ink: #1d2b24;
  --ink-soft: #526059;
  --muted: #7e837a;
  --line: #dcd3c2;
  --line-strong: #c8bdab;
  --green: #244b3b;
  --green-deep: #1b352b;
  --green-soft: #e5ede7;
  --vermillion: #c75138;
  --vermillion-soft: #f4ddd6;
  --gold: #ad8a50;
  --paper: #fffdf7;
  --paper-line: #d9d1c1;
  --paper-ink: #26322a;
  --shadow-sm: 0 2px 8px rgba(48, 41, 30, 0.06);
  --shadow-md: 0 16px 40px rgba(48, 41, 30, 0.1);
  --shadow-lg: 0 26px 80px rgba(44, 37, 25, 0.16);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --font-ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --cell-size: 27px;
  --columns: 25;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% -10%, rgba(255, 253, 247, 0.9), transparent 38%),
    radial-gradient(circle at 95% 10%, rgba(205, 190, 162, 0.28), transparent 30%),
    var(--bg);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--vermillion);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: none;
}

.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;
}

.page-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    repeating-linear-gradient(0deg, rgba(77, 62, 39, 0.035) 0, rgba(77, 62, 39, 0.035) 1px, transparent 1px, transparent 4px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0, rgba(255, 255, 255, 0.25) 1px, transparent 1px, transparent 5px);
}

.site-header {
  width: min(1440px, 100%);
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 34px 16px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.brand-mark {
  display: block;
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 4px 10px rgba(27, 53, 43, 0.18));
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  color: var(--ink-soft);
  background: rgba(255, 253, 248, 0.55);
  border: 1px solid rgba(200, 189, 171, 0.55);
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.privacy-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #58866b;
  box-shadow: 0 0 0 4px rgba(88, 134, 107, 0.12);
}

.text-button {
  padding: 0;
  color: var(--green);
  background: none;
  border: 0;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(36, 75, 59, 0.28);
  text-underline-offset: 4px;
  cursor: pointer;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.text-button:hover {
  color: var(--vermillion);
  text-decoration-color: currentColor;
}

.text-button--muted {
  color: var(--muted);
  font-weight: 500;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(380px, 438px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(26px, 4vw, 56px);
  width: min(1440px, 100%);
  padding: 18px 34px 52px;
  margin: 0 auto;
}

.editor-pane {
  min-width: 0;
  animation: rise 560ms cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.intro {
  padding: 12px 2px 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(38px, 3.6vw, 54px);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.035em;
}

.intro h1 em {
  color: var(--vermillion);
  font-style: normal;
  position: relative;
  white-space: nowrap;
}

.intro h1 em::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: 1px;
  left: -2px;
  height: 7px;
  background: var(--vermillion-soft);
  z-index: -1;
  transform: rotate(-1deg);
}

.intro-copy {
  max-width: 405px;
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.9;
}

.editor-card {
  margin-top: 26px;
  overflow: hidden;
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid rgba(200, 189, 171, 0.72);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
  backdrop-filter: blur(10px);
}

.editor-card:focus-within {
  background: var(--surface-strong);
  border-color: rgba(36, 75, 59, 0.55);
  box-shadow: 0 15px 36px rgba(48, 41, 30, 0.09);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid rgba(220, 211, 194, 0.72);
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.status-light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--vermillion);
  box-shadow: 0 0 0 4px var(--vermillion-soft);
}

.editor-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mini-button {
  padding: 5px 8px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.mini-button:hover {
  color: var(--green);
  background: var(--green-soft);
}

.mini-button--quiet {
  color: #9a8d7e;
}

#answerInput {
  display: block;
  width: 100%;
  min-height: 252px;
  max-height: 440px;
  padding: 20px 19px 17px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  resize: vertical;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.95;
  letter-spacing: 0.015em;
}

#answerInput::placeholder {
  color: #a69b8b;
  line-height: 1.9;
}

.editor-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 12px;
  color: #9b9287;
  border-top: 1px solid rgba(220, 211, 194, 0.48);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.count-panel {
  position: relative;
  margin-top: 20px;
  padding: 20px 21px 17px;
  overflow: hidden;
  color: #f6efdf;
  background:
    radial-gradient(circle at 100% 0, rgba(202, 178, 132, 0.16), transparent 42%),
    linear-gradient(135deg, var(--green-deep), #284d3e);
  border: 1px solid rgba(23, 48, 37, 0.7);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 32px rgba(27, 53, 43, 0.17);
}

.count-panel::after {
  content: "字";
  position: absolute;
  top: -37px;
  right: 5px;
  color: rgba(245, 236, 215, 0.045);
  font-family: var(--font-serif);
  font-size: 160px;
  line-height: 1;
  pointer-events: none;
}

.count-hero {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 15px;
}

.stat-label {
  margin: 0;
  color: rgba(246, 239, 223, 0.62);
  font-size: 10.5px;
  letter-spacing: 0.17em;
}

.stat-number {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 2px 0 0;
}

.stat-number strong {
  font-family: var(--font-serif);
  font-size: 52px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.stat-number span {
  color: rgba(246, 239, 223, 0.62);
  font-size: 12px;
}

.count-note {
  padding-bottom: 4px;
  color: rgba(246, 239, 223, 0.45);
  font-size: 9px;
  line-height: 1.7;
  text-align: right;
  letter-spacing: 0.08em;
}

.count-breakdown {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-top: 13px;
  border-top: 1px solid rgba(246, 239, 223, 0.14);
}

.breakdown-item {
  padding-left: 12px;
  border-left: 1px solid rgba(246, 239, 223, 0.12);
}

.breakdown-item:first-child {
  padding-left: 0;
  border-left: 0;
}

.breakdown-item span {
  display: block;
  margin-bottom: 3px;
  color: rgba(246, 239, 223, 0.48);
  font-size: 9.5px;
  white-space: nowrap;
}

.breakdown-item strong {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.breakdown-item--accent strong {
  color: #e6a58f;
}

.editor-footnote {
  padding: 15px 3px 0;
}

.footnote-rule {
  display: block;
  width: 24px;
  height: 1px;
  margin-bottom: 12px;
  background: var(--vermillion);
}

.editor-footnote p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.025em;
}

.editor-footnote p strong {
  color: var(--ink);
  font-weight: 600;
}

.editor-footnote .footnote-muted {
  margin-top: 5px;
  color: #948a7d;
  font-size: 10px;
}

.preview-pane {
  min-width: 0;
  animation: rise 640ms 80ms cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.preview-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  padding: 12px 2px 0;
}

.preview-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(26px, 2.5vw, 36px);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.preview-actions {
  display: flex;
  align-items: center;
  flex: none;
  gap: 7px;
}

.primary-button,
.outline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.primary-button svg,
.outline-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button {
  color: #fff8e9;
  background: var(--green);
  border: 1px solid var(--green);
  box-shadow: 0 8px 18px rgba(36, 75, 59, 0.17);
}

.primary-button:hover {
  background: #163b2d;
  border-color: #163b2d;
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(36, 75, 59, 0.22);
}

.outline-button {
  color: var(--green);
  background: rgba(255, 253, 248, 0.58);
  border: 1px solid rgba(200, 189, 171, 0.8);
}

.outline-button:hover {
  background: var(--surface-strong);
  border-color: var(--green);
  transform: translateY(-1px);
}

.outline-button--icon {
  width: 38px;
  padding: 0;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 12px;
  padding: 7px 9px 7px 12px;
  background: rgba(255, 253, 248, 0.48);
  border: 1px solid rgba(200, 189, 171, 0.6);
  border-radius: 12px;
}

.preview-facts {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 10.5px;
  white-space: nowrap;
}

.page-chip {
  padding: 5px 9px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 7px;
  font-weight: 600;
}

.fact-divider {
  width: 1px;
  height: 12px;
  background: var(--line);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--ink-soft);
  font-size: 10px;
  white-space: nowrap;
}

.zoom-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.zoom-controls button:hover {
  color: var(--green);
  background: var(--green-soft);
}

.zoom-controls #zoomLabel {
  min-width: 38px;
  text-align: center;
  color: var(--muted);
}

.paper-stage {
  position: relative;
  min-height: 590px;
  padding: clamp(20px, 3.1vw, 38px);
  overflow: auto;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.45), transparent 34%),
    linear-gradient(145deg, #ded5c4, #d4c9b6);
  border: 1px solid rgba(170, 155, 128, 0.45);
  border-radius: var(--radius-xl);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.55), inset 0 -20px 40px rgba(102, 86, 59, 0.06);
}

.paper-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    radial-gradient(rgba(94, 75, 45, 0.12) 0.65px, transparent 0.65px),
    radial-gradient(rgba(255, 255, 255, 0.7) 0.65px, transparent 0.65px);
  background-position: 0 0, 3px 3px;
  background-size: 6px 6px;
}

.paper-list {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.paper {
  flex: none;
  width: fit-content;
  max-width: none;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(190, 172, 137, 0.035) 1px, transparent 1px) 0 0 / 5px 5px,
    var(--paper);
  border: 1px solid #dbd1bf;
  border-radius: 3px;
  box-shadow: 0 18px 38px rgba(70, 58, 40, 0.16), 0 2px 4px rgba(70, 58, 40, 0.08);
}

.paper-head,
.paper-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #9c917f;
  font-size: 9px;
  letter-spacing: 0.1em;
}

.paper-head {
  padding: 10px 13px 8px;
}

.paper-brand {
  color: #7e8c78;
  font-family: var(--font-serif);
  font-size: 9.5px;
  letter-spacing: 0.14em;
}

.paper-title {
  color: #777467;
  font-weight: 600;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  width: fit-content;
  margin: 0 auto;
  border-top: 1px solid var(--paper-line);
  border-left: 1px solid var(--paper-line);
  background: rgba(255, 254, 249, 0.3);
}

.paper-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--cell-size);
  height: var(--cell-size);
  overflow: hidden;
  color: var(--paper-ink);
  border-right: 1px solid var(--paper-line);
  border-bottom: 1px solid var(--paper-line);
  font-family: var(--font-serif);
  font-size: calc(var(--cell-size) * 0.61);
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: pre;
  user-select: text;
}

.paper-cell[data-space="true"] {
  color: transparent;
}

.paper-foot {
  padding: 8px 13px 10px;
}

.paper-foot .page-number {
  color: #736b5c;
  font-variant-numeric: tabular-nums;
}

.paper-foot .paper-hint {
  color: #a69a87;
  letter-spacing: 0.04em;
}

.preview-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  max-width: 720px;
  margin: 12px 4px 0;
  color: #8e8476;
  font-size: 10px;
  line-height: 1.7;
}

.note-mark {
  color: var(--vermillion);
  font-size: 11px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1440px, 100%);
  padding: 22px 34px 30px;
  margin: 0 auto;
  color: #978c7d;
  border-top: 1px solid rgba(200, 189, 171, 0.52);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.site-footer p {
  margin: 0;
}

.site-footer strong {
  margin-right: 9px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.site-footer span {
  color: #a29789;
}

.sheet-dialog {
  width: 100%;
  max-width: none;
  max-height: none;
  padding: 24px;
  margin: 0;
  background: transparent;
  border: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.sheet-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-dialog::backdrop {
  background: rgba(25, 32, 27, 0.48);
  backdrop-filter: blur(5px);
}

.dialog-card {
  width: min(586px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface-strong);
  border: 1px solid rgba(201, 190, 172, 0.68);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 220ms cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding: 25px 28px 10px;
}

.dialog-header .eyebrow {
  margin-bottom: 7px;
}

.dialog-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dialog-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(200, 189, 171, 0.6);
  border-radius: 50%;
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  color: var(--ink);
  background: var(--bg);
}

.dialog-body {
  padding: 8px 28px 4px;
}

.setting-block {
  padding: 17px 0 20px;
  border-bottom: 1px solid rgba(220, 211, 194, 0.7);
}

.setting-copy h3,
.setting-line h3,
.help-steps h3,
.help-callout h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.setting-copy p,
.setting-line p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.65;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 13px;
  padding: 4px;
  background: var(--bg);
  border-radius: 11px;
}

.segmented button {
  min-height: 33px;
  padding: 0 5px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.segmented button:hover {
  color: var(--green);
  background: rgba(255, 253, 248, 0.7);
}

.segmented button.is-active {
  color: var(--green);
  background: var(--surface-strong);
  box-shadow: 0 2px 7px rgba(48, 41, 30, 0.1);
  font-weight: 600;
}

.setting-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid rgba(220, 211, 194, 0.7);
}

.setting-line--sub {
  padding-top: 2px;
  opacity: 1;
  transition: opacity 160ms ease;
}

.setting-line.is-disabled {
  opacity: 0.38;
  pointer-events: none;
}

.stepper {
  display: flex;
  align-items: center;
  flex: none;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(200, 189, 171, 0.8);
  border-radius: 9px;
}

.stepper button {
  width: 34px;
  height: 100%;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  font-size: 16px;
  cursor: pointer;
}

.stepper button:hover {
  background: var(--green-soft);
  color: var(--green);
}

.stepper output {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 100%;
  color: var(--ink);
  border-right: 1px solid rgba(200, 189, 171, 0.8);
  border-left: 1px solid rgba(200, 189, 171, 0.8);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: block;
  width: 42px;
  height: 24px;
  background: #d5cbbb;
  border-radius: 999px;
  transition: background 180ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fffdf8;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(40, 32, 21, 0.2);
  transition: transform 180ms ease;
}

.switch input:checked + .switch-track {
  background: var(--green);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--vermillion);
  outline-offset: 3px;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 26px;
}

.dialog-footer--single {
  justify-content: flex-end;
}

.dialog-footer .primary-button {
  min-width: 108px;
  min-height: 40px;
}

.help-body {
  padding-top: 4px;
}

.help-steps {
  display: grid;
  gap: 18px;
  padding: 0;
  margin: 8px 0 22px;
  list-style: none;
}

.help-steps li {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.step-number {
  flex: none;
  padding-top: 2px;
  color: var(--vermillion);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
}

.help-steps p,
.help-callout p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.75;
}

.help-callout {
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--green-soft);
  border-radius: 13px;
}

.help-callout h3 {
  color: var(--green);
}

.help-callout--soft {
  background: #f5ede1;
}

.help-callout--soft h3 {
  color: #8b6b3b;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 17px;
  color: #f9f2e4;
  background: rgba(27, 53, 43, 0.94);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(20, 30, 24, 0.24);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1120px) {
  .site-header {
    padding-right: 24px;
    padding-left: 24px;
  }

  .app-shell {
    grid-template-columns: minmax(350px, 400px) minmax(0, 1fr);
    gap: 26px;
    padding-right: 24px;
    padding-left: 24px;
  }

  .preview-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .preview-header {
    align-items: flex-start;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 42px;
    max-width: 760px;
    padding-top: 8px;
  }

  .intro h1 {
    font-size: 46px;
  }

  .intro-copy {
    max-width: 550px;
  }

  .editor-pane {
    width: 100%;
  }

  .preview-pane {
    width: 100%;
  }

  .site-footer {
    max-width: 760px;
  }

  .paper-stage {
    min-height: 500px;
  }
}

@media (max-width: 640px) {
  .site-header {
    min-height: 76px;
    padding: 14px 16px 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-copy strong {
    font-size: 18px;
  }

  .brand-copy small {
    font-size: 8.5px;
    letter-spacing: 0.14em;
  }

  .privacy-pill {
    display: none;
  }

  .header-actions {
    gap: 12px;
  }

  .app-shell {
    gap: 34px;
    padding: 8px 14px 38px;
  }

  .intro {
    padding-top: 4px;
  }

  .intro h1 {
    font-size: 38px;
    line-height: 1.18;
  }

  .intro-copy {
    margin-top: 14px;
    font-size: 12.5px;
  }

  .editor-card {
    margin-top: 20px;
  }

  .editor-toolbar {
    padding-left: 14px;
  }

  .editor-tools {
    gap: 0;
  }

  .mini-button {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 10.5px;
  }

  #answerInput {
    min-height: 220px;
    padding: 17px 15px 14px;
    font-size: 14px;
  }

  .count-panel {
    padding: 18px 18px 15px;
  }

  .stat-number strong {
    font-size: 46px;
  }

  .breakdown-item {
    padding-left: 8px;
  }

  .breakdown-item span {
    font-size: 8.5px;
  }

  .breakdown-item strong {
    font-size: 18px;
  }

  .preview-header {
    display: block;
    padding-top: 4px;
  }

  .preview-header h2 {
    font-size: 28px;
  }

  .preview-actions {
    justify-content: flex-start;
    margin-top: 16px;
  }

  .primary-button,
  .outline-button {
    min-height: 36px;
    padding-right: 12px;
    padding-left: 12px;
    font-size: 11px;
  }

  .outline-button--icon {
    width: 36px;
    padding: 0;
  }

  .preview-toolbar {
    margin-top: 15px;
  }

  .preview-facts {
    gap: 8px;
    font-size: 9.5px;
  }

  .preview-facts #layoutMode,
  .preview-facts .fact-divider {
    display: none;
  }

  .zoom-controls #zoomLabel {
    display: none;
  }

  .paper-stage {
    min-height: 430px;
    padding: 18px 12px;
    border-radius: 20px;
  }

  .paper-list {
    gap: 20px;
  }

  .paper-head,
  .paper-foot {
    font-size: 8px;
  }

  .site-footer {
    display: block;
    padding: 18px 18px 24px;
    line-height: 1.8;
  }

  .site-footer p + p {
    margin-top: 4px;
  }

  .sheet-dialog {
    padding: 12px;
  }

  .sheet-dialog[open] {
    align-items: flex-end;
  }

  .dialog-card {
    max-height: calc(100vh - 24px);
    border-radius: 22px;
  }

  .dialog-header {
    padding: 21px 20px 7px;
  }

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

  .dialog-body {
    padding-right: 20px;
    padding-left: 20px;
  }

  .dialog-footer {
    padding: 18px 20px 22px;
  }

  .setting-line {
    gap: 16px;
  }

  .segmented {
    gap: 2px;
  }

  .segmented button {
    font-size: 10px;
  }
}

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

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  :root {
    --cell-size: 6mm !important;
    --paper-line: #8a8a8a;
  }

  body {
    min-width: 0;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .page-grain,
  .site-header,
  .editor-pane,
  .preview-header,
  .preview-toolbar,
  .preview-note,
  .site-footer,
  .toast,
  .sheet-dialog {
    display: none !important;
  }

  .app-shell {
    display: block;
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .preview-pane {
    display: block;
    width: 100%;
  }

  .paper-stage {
    min-height: 0;
    padding: 0;
    overflow: visible;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .paper-stage::before {
    display: none;
  }

  .paper-list {
    display: block;
    gap: 0;
  }

  .paper {
    width: fit-content;
    margin: 0 auto;
    overflow: visible;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .paper:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .paper-head,
  .paper-foot {
    display: none;
  }

  .paper-grid {
    border-color: #777;
    background: #fff;
  }

  .paper-cell {
    color: #111;
    border-color: #999;
    font-size: calc(var(--cell-size) * 0.58);
  }
}
