:root {
  --ink: #18211f;
  --ink-soft: #53605c;
  --paper: #fffdf7;
  --paper-deep: #f3eee2;
  --canvas: #dcd8cd;
  --canvas-deep: #cbc6b9;
  --vermilion: #b73727;
  --vermilion-dark: #8e261b;
  --line: rgba(24, 33, 31, 0.17);
  --line-dark: rgba(24, 33, 31, 0.35);
  --success: #2e6f56;
  --warning: #a45c16;
  --shadow: 0 26px 60px rgba(41, 40, 34, 0.18), 0 4px 14px rgba(41, 40, 34, 0.1);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --sans: "Avenir Next", "Noto Sans CJK SC", "PingFang SC", sans-serif;
  --mono: "SFMono-Regular", "Menlo", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(183, 55, 39, 0.08), transparent 27rem),
    linear-gradient(135deg, #eeeadf 0%, #e5e1d7 48%, #d8d4c8 100%);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(24, 33, 31, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 33, 31, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.masthead {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(24, 33, 31, 0.14);
  background: rgba(247, 244, 235, 0.78);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--vermilion);
  border: 2px solid currentColor;
  transform: rotate(-4deg);
  position: relative;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid currentColor;
}

.brand-mark::after {
  inset: 7px;
  border-style: dotted;
}

.brand-mark span {
  font: 700 23px/1 var(--serif);
  position: relative;
  z-index: 1;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font: 700 20px/1.1 var(--serif);
  letter-spacing: 0.12em;
}

.brand small {
  margin-top: 5px;
  color: var(--ink-soft);
  font: 600 9px/1 var(--mono);
  letter-spacing: 0.24em;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.05em;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(46, 111, 86, 0.1);
  animation: breathe 2.8s ease-in-out infinite;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(580px, 1.08fr) minmax(520px, 0.92fr);
  align-items: start;
  min-height: calc(100vh - 84px);
}

.editor-panel {
  padding: clamp(34px, 5vw, 72px) clamp(24px, 5vw, 74px) 56px;
  border-right: 1px solid rgba(24, 33, 31, 0.14);
  background: rgba(248, 246, 239, 0.86);
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.6fr);
  align-items: end;
  gap: 28px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--vermilion);
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 680px;
  margin-bottom: 0;
  font: 700 clamp(30px, 3vw, 48px)/1.22 var(--serif);
  letter-spacing: -0.04em;
}

.intro {
  margin-bottom: 3px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.85;
}

.upload-rack {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.upload-card {
  min-width: 0;
  position: relative;
}

.slot-index {
  position: absolute;
  top: -10px;
  left: 18px;
  z-index: 2;
  min-width: 32px;
  height: 23px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 1px;
  font: 700 11px/1 var(--serif);
  box-shadow: 3px 3px 0 rgba(183, 55, 39, 0.2);
}

.drop-zone {
  width: 100%;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 26px 18px 22px;
  border: 1px dashed var(--line-dark);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 253, 247, 0.38)),
    repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(24, 33, 31, 0.025) 24px);
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.drop-zone:hover,
.upload-card.drag-over .drop-zone {
  border-color: var(--vermilion);
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(62, 54, 45, 0.09);
  background-color: rgba(183, 55, 39, 0.035);
}

.upload-card.has-file .drop-zone {
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 136px;
  border-style: solid;
  border-color: var(--line);
  background:
    linear-gradient(to bottom, rgba(183, 55, 39, 0.07), transparent 3px),
    var(--paper);
}

.upload-card.loading .drop-zone {
  cursor: wait;
  opacity: 0.64;
}

.upload-glyph {
  width: 43px;
  height: 43px;
  color: var(--vermilion);
}

.upload-glyph svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.has-file .upload-glyph {
  position: absolute;
  top: 23px;
  right: 20px;
  width: 34px;
  height: 34px;
  opacity: 0.42;
}

.empty-copy,
.file-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.empty-copy {
  align-items: center;
  text-align: center;
}

.file-copy {
  width: 100%;
  text-align: left;
}

.empty-copy strong,
.file-copy strong {
  font: 700 15px/1.35 var(--serif);
}

.file-copy strong {
  max-width: calc(100% - 38px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-copy small,
.file-copy small {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
}

.slot-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 9px;
  padding: 0 3px;
}

.text-button {
  border: 0;
  padding: 3px 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
}

.text-button.danger {
  margin-left: auto;
  color: var(--vermilion);
}

.slot-status {
  min-height: 18px;
  margin-top: 5px;
  color: var(--warning);
  font-size: 10px;
  line-height: 1.5;
}

.swap-button {
  min-width: 50px;
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 10px 3px;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 9px;
  cursor: pointer;
  transition: color 160ms ease, transform 160ms ease;
}

.swap-button span:first-child {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  background: rgba(255, 253, 247, 0.7);
  font-size: 19px;
}

.swap-button:hover:not(:disabled) {
  color: var(--vermilion);
  transform: translateY(-2px);
}

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

.expense-section {
  margin-top: 48px;
}

.subsection-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}

.subsection-heading h2,
.preview-toolbar h2 {
  margin: 0;
  font: 700 22px/1.25 var(--serif);
}

.field-hint {
  color: var(--ink-soft);
  font-size: 10px;
}

.expense-table-wrap {
  overflow-x: auto;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line-dark);
}

.expense-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: fixed;
}

.expense-table th,
.expense-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.expense-table th {
  height: 36px;
  color: var(--ink-soft);
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.04em;
}

.expense-table th:nth-child(1) { width: 42px; }
.expense-table th:nth-child(2) { width: 112px; }
.expense-table th:nth-child(3) { width: 152px; }
.expense-table th:nth-child(4) { width: 182px; }
.expense-table th:nth-child(6) { width: 150px; }

.expense-table td {
  padding: 9px 7px 9px 0;
  vertical-align: top;
}

.expense-table input {
  width: 100%;
  min-height: 37px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  outline: none;
  font-size: 12px;
  transition: border-color 160ms ease, background 160ms ease;
}

.expense-table input:focus {
  border-color: var(--ink);
  background: white;
}

.expense-table input.invalid {
  border-color: var(--vermilion);
  background: rgba(183, 55, 39, 0.06);
}

.readonly-field {
  min-height: 37px;
  display: flex;
  align-items: center;
  padding: 8px 9px;
  color: var(--ink-soft);
  border: 1px solid rgba(24, 33, 31, 0.08);
  border-radius: 2px;
  background:
    repeating-linear-gradient(135deg, transparent 0 5px, rgba(24, 33, 31, 0.018) 5px 6px),
    rgba(24, 33, 31, 0.035);
  font-size: 12px;
  cursor: default;
  user-select: text;
}

.readonly-field.missing {
  color: rgba(83, 96, 92, 0.62);
}

.row-number {
  display: inline-grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--ink);
  font: 700 11px/1 var(--mono);
}

.amount-editor {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) auto;
  gap: 5px;
}

.verify-button {
  min-width: 48px;
  padding: 0 7px;
  border: 1px solid var(--warning);
  border-radius: 2px;
  color: var(--warning);
  background: transparent;
  font-size: 9px;
  cursor: pointer;
}

.verify-button.confirmed {
  border-color: rgba(46, 111, 86, 0.3);
  color: var(--success);
  background: rgba(46, 111, 86, 0.07);
}

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

.empty-row td {
  height: 82px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 12px;
}

.total-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: stretch;
  margin-top: 18px;
  border: 1px solid var(--line-dark);
  background: rgba(255, 253, 247, 0.65);
}

.total-count,
.total-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.total-count {
  padding: 19px 22px;
  border-right: 1px solid var(--line);
}

.total-count span,
.total-main span {
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.total-count strong {
  margin-top: 8px;
  font: 700 20px/1 var(--serif);
}

.total-main {
  position: relative;
  min-width: 0;
  padding: 18px 22px 16px;
}

.total-main::after {
  content: "合";
  position: absolute;
  right: 17px;
  top: 13px;
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  color: rgba(183, 55, 39, 0.5);
  border: 2px solid rgba(183, 55, 39, 0.45);
  border-radius: 50%;
  font: 700 19px/1 var(--serif);
  transform: rotate(8deg);
}

.total-main > strong {
  margin-top: 3px;
  padding-right: 58px;
  color: var(--vermilion-dark);
  font: 700 clamp(28px, 4vw, 43px)/1.1 var(--serif);
  letter-spacing: -0.04em;
}

.total-main p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font: 600 12px/1.5 var(--serif);
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
}

.action-message {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
}

.action-message.error {
  color: var(--vermilion);
}

.primary-actions {
  display: flex;
  gap: 9px;
}

.button {
  min-height: 45px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  font-weight: 650;
  font-size: 12px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 9px 20px rgba(24, 33, 31, 0.15);
}

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

.button.primary {
  color: var(--paper);
  border-color: var(--vermilion-dark);
  background: var(--vermilion);
}

.button.secondary {
  background: transparent;
}

.preview-panel {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 34px clamp(24px, 3vw, 52px) 38px;
  overflow: hidden;
}

.preview-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.22), transparent 35%),
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(24, 33, 31, 0.014) 8px 9px);
}

.preview-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.preview-control-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.preview-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-dark);
  border-radius: 2px;
  background: rgba(255, 253, 247, 0.42);
}

.preview-tab {
  padding: 7px 10px;
  border: 0;
  border-radius: 1px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 10px;
  cursor: pointer;
}

.preview-tab.active {
  color: var(--paper);
  background: var(--ink);
}

.zoom-controls {
  display: inline-grid;
  grid-template-columns: 28px 52px 28px;
  height: 34px;
  border: 1px solid var(--line-dark);
  border-radius: 2px;
  background: rgba(255, 253, 247, 0.52);
}

.zoom-button,
.zoom-reset {
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
}

.zoom-button {
  font: 500 17px/1 var(--serif);
}

.zoom-reset {
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  font: 600 9px/1 var(--mono);
}

.zoom-button:hover:not(:disabled),
.zoom-reset:hover {
  color: var(--vermilion);
  background: rgba(183, 55, 39, 0.055);
}

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

.paper-viewport {
  width: 100%;
  max-height: calc(100vh - 188px);
  padding: 3px 12px 25px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(24, 33, 31, 0.26) transparent;
  scrollbar-width: thin;
}

.paper-viewport::before {
  content: "滚轮缩放";
  position: sticky;
  top: 7px;
  left: 7px;
  z-index: 3;
  display: inline-block;
  margin-bottom: -20px;
  padding: 5px 7px;
  color: rgba(24, 33, 31, 0.5);
  border: 1px solid rgba(24, 33, 31, 0.1);
  border-radius: 2px;
  background: rgba(255, 253, 247, 0.82);
  font: 600 7px/1 var(--mono);
  letter-spacing: 0.08em;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.paper-stage {
  width: min(100%, 610px);
  margin-inline: auto;
  perspective: 1800px;
  will-change: width;
}

.a4-paper {
  position: relative;
  width: 100%;
  aspect-ratio: 210 / 297;
  overflow: hidden;
  color: #171b19;
  background:
    linear-gradient(90deg, rgba(113, 89, 48, 0.018), transparent 9%, transparent 91%, rgba(113, 89, 48, 0.018)),
    #fffef9;
  box-shadow: var(--shadow);
  animation: paper-in 620ms cubic-bezier(0.2, 0.75, 0.22, 1) both;
}

.invoice-paper {
  display: grid;
  grid-template-rows: 1fr 3.02% 1fr;
  gap: 0;
  padding: 4.04%;
}

.paper-rule {
  position: absolute;
  top: 2.35%;
  left: 4.04%;
  width: 8%;
  height: 2px;
  background: var(--vermilion);
}

.invoice-preview-slot {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed rgba(24, 33, 31, 0.17);
}

.invoice-preview-slot.has-preview {
  border-color: transparent;
}

.invoice-preview-slot canvas {
  display: none;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.invoice-preview-slot.has-preview canvas {
  display: block;
}

.preview-placeholder {
  display: grid;
  justify-items: center;
  color: rgba(24, 33, 31, 0.3);
}

.has-preview .preview-placeholder {
  display: none;
}

.preview-placeholder span {
  font: 400 clamp(25px, 4vw, 46px)/1 var(--serif);
}

.preview-placeholder p {
  margin: 8px 0 0;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.paper-gap-marker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: rgba(24, 33, 31, 0.33);
  font: 500 7px/1 var(--mono);
}

.paper-gap-marker::before {
  content: "";
  flex: 1;
  border-top: 1px dotted rgba(24, 33, 31, 0.12);
}

.paper-gap-marker span {
  padding-left: 6px;
}

.paper-folio {
  position: absolute;
  right: 2.3%;
  bottom: 1.6%;
  color: rgba(24, 33, 31, 0.36);
  font: 500 7px/1 var(--mono);
}

.report-paper {
  padding: 8.2% 7.2% 6.5%;
  font-family: var(--sans);
}

.report-letterhead {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
}

.report-letterhead p {
  grid-column: 1;
  margin-bottom: 6px;
  color: var(--vermilion);
  font: 700 clamp(5px, 0.65vw, 9px)/1 var(--mono);
  letter-spacing: 0.16em;
}

.report-letterhead h3 {
  grid-column: 1;
  margin: 0;
  font: 700 clamp(23px, 3.3vw, 42px)/1.1 var(--serif);
}

.report-letterhead div {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 5px;
  font-size: clamp(6px, 0.78vw, 10px);
}

.report-letterhead div span {
  color: var(--ink-soft);
}

.report-letterhead div strong {
  font: 700 clamp(12px, 1.5vw, 18px)/1 var(--serif);
}

.report-redline {
  height: 3px;
  margin: 3.3% 0 4%;
  background: linear-gradient(90deg, var(--vermilion) 0 16%, rgba(183, 55, 39, 0.16) 16% 100%);
}

.report-preview-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: clamp(5px, 0.72vw, 9px);
}

.report-preview-table th,
.report-preview-table td {
  padding: 2.2% 1.2%;
  border-bottom: 1px solid rgba(24, 33, 31, 0.24);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.report-preview-table th {
  color: var(--ink-soft);
  border-top: 1px solid var(--ink);
  font-weight: 600;
}

.report-preview-table th:nth-child(1) { width: 7%; }
.report-preview-table th:nth-child(2) { width: 15%; }
.report-preview-table th:nth-child(3) { width: 22%; }
.report-preview-table th:nth-child(4) { width: 20%; }
.report-preview-table th:nth-child(6) { width: 15%; text-align: right; }
.report-preview-table td:last-child { text-align: right; }

.report-preview-total {
  margin-top: 7%;
  padding: 4% 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line-dark);
}

.report-preview-total > div {
  display: grid;
  grid-template-columns: 25% 1fr;
  align-items: baseline;
  gap: 12px;
}

.report-preview-total > div + div {
  margin-top: 3.3%;
}

.report-preview-total span {
  color: var(--ink-soft);
  font-size: clamp(5px, 0.72vw, 9px);
}

.report-preview-total strong {
  font: 700 clamp(11px, 1.7vw, 22px)/1.35 var(--serif);
}

.report-preview-total > div:first-child strong {
  color: var(--vermilion);
  font-size: clamp(18px, 2.6vw, 34px);
}

.report-signature {
  position: absolute;
  left: 7.2%;
  right: 7.2%;
  bottom: 12%;
  display: flex;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: clamp(5px, 0.72vw, 9px);
}

.report-footer {
  position: absolute;
  left: 7.2%;
  right: 4%;
  bottom: 3.2%;
  display: flex;
  justify-content: space-between;
  color: rgba(24, 33, 31, 0.38);
  font: 500 clamp(5px, 0.62vw, 8px)/1 var(--mono);
}

.preview-caption {
  width: min(100%, 610px);
  margin: 17px auto 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: min(460px, calc(100vw - 40px));
  padding: 12px 18px;
  color: var(--paper);
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 16px 45px rgba(24, 33, 31, 0.25);
  font-size: 12px;
  line-height: 1.5;
  transform: translateX(-50%);
  animation: toast-in 220ms ease both;
}

.toast.error {
  background: var(--vermilion-dark);
}

@keyframes paper-in {
  from { opacity: 0; transform: translateY(18px) rotateX(2deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes breathe {
  50% { box-shadow: 0 0 0 8px rgba(46, 111, 86, 0.04); }
}

@media (max-width: 1220px) {
  .app-shell {
    grid-template-columns: minmax(520px, 1fr) minmax(430px, 0.82fr);
  }

  .editor-panel {
    padding-inline: 36px;
  }

  .section-heading {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

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

  .preview-panel {
    position: relative;
    min-height: auto;
    padding-top: 38px;
  }

  .paper-viewport {
    max-height: 78vh;
  }
}

@media (max-width: 660px) {
  .masthead {
    min-height: 70px;
    padding-inline: 18px;
  }

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

  .brand strong {
    font-size: 17px;
  }

  .privacy-note span:last-child {
    display: none;
  }

  .editor-panel {
    padding: 34px 18px 40px;
  }

  h1 {
    font-size: 32px;
  }

  .upload-rack {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .swap-button {
    min-width: 0;
    grid-auto-flow: column;
    justify-content: center;
    margin: 1px 0 5px;
  }

  .swap-button span:first-child {
    width: 29px;
    height: 29px;
  }

  .expense-section {
    margin-top: 38px;
  }

  .field-hint {
    display: none;
  }

  .total-card {
    grid-template-columns: 88px 1fr;
  }

  .total-count,
  .total-main {
    padding-inline: 14px;
  }

  .total-main::after {
    display: none;
  }

  .total-main > strong {
    padding-right: 0;
    font-size: 31px;
  }

  .action-bar,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-actions,
  .primary-actions .button {
    flex: 1;
  }

  .preview-panel {
    padding: 32px 14px;
  }

  .preview-tabs {
    align-self: flex-start;
  }

  .preview-control-stack {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .paper-viewport {
    max-height: 74vh;
    padding-inline: 3px;
  }
}

@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 {
  body {
    background: white;
  }

  .masthead,
  .editor-panel,
  .preview-toolbar,
  .preview-caption,
  .ambient-grid {
    display: none !important;
  }

  .app-shell,
  .preview-panel,
  .paper-viewport,
  .paper-stage {
    display: block;
    width: auto;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: visible;
  }

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

  .a4-paper {
    width: 210mm;
    height: 297mm;
    box-shadow: none;
    page-break-after: always;
  }

  .a4-paper[hidden] {
    display: block !important;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }
}
