:root {
  color-scheme: light;
  --canvas: #f3eee4;
  --canvas-deep: #e8dfd0;
  --paper: #fffdf8;
  --paper-soft: #faf6ee;
  --paper-muted: #f2ebdf;
  --ink: #193246;
  --ink-strong: #102535;
  --ink-muted: #66737b;
  --ink-faint: #8c979d;
  --line: rgba(53, 69, 75, 0.15);
  --line-strong: rgba(53, 69, 75, 0.26);
  --accent: #24617a;
  --accent-dark: #17485f;
  --accent-soft: #e4eff1;
  --warm: #b66a48;
  --warm-soft: #f7e9df;
  --success: #47735f;
  --success-soft: #e8f1eb;
  --danger: #a9463f;
  --danger-soft: #f8e9e6;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 9px;
  --shadow-card: 0 24px 60px rgba(73, 60, 42, 0.1), 0 2px 8px rgba(73, 60, 42, 0.05);
  --shadow-raised: 0 16px 36px rgba(37, 59, 70, 0.15);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

::selection {
  color: var(--ink-strong);
  background: rgba(182, 106, 72, 0.2);
}

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

button,
a,
summary,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(36, 97, 122, 0.24);
  outline-offset: 2px;
}

.page-texture {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 5% 8%, rgba(181, 107, 72, 0.12), transparent 31%),
    radial-gradient(circle at 92% 14%, rgba(36, 97, 122, 0.12), transparent 33%),
    linear-gradient(rgba(91, 75, 54, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 75, 54, 0.018) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
}

.page-texture::before,
.page-texture::after {
  content: "";
  position: absolute;
  width: 390px;
  height: 390px;
  border: 1px solid rgba(77, 91, 90, 0.07);
  border-radius: 50%;
}

.page-texture::before {
  top: -245px;
  right: 8%;
}

.page-texture::after {
  bottom: -280px;
  left: 4%;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1420px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 28px 0 38px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  align-items: end;
  gap: 32px;
  padding: 0 6px 24px;
}

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

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  place-items: center;
  color: #fffaf1;
  border-radius: 17px 8px 17px 8px;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 10px 24px rgba(23, 72, 95, 0.24);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 27px;
  transform: rotate(-2deg);
}

.brand-kicker,
.eyebrow {
  margin: 0;
  color: var(--warm);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.15em;
  line-height: 1.4;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

h1 {
  margin: 3px 0 0;
  color: var(--ink-strong);
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  font-size: clamp(29px, 3vw, 42px);
  font-weight: 650;
  letter-spacing: 0.015em;
  line-height: 1.18;
}

.header-copy {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.header-copy > p {
  max-width: 440px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(470px, 0.96fr) minmax(480px, 1.04fr);
  align-items: start;
  gap: 20px;
}

.composer,
.viewer {
  border: 1px solid rgba(84, 76, 61, 0.13);
  border-radius: var(--radius-xl);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow-card);
}

.composer {
  padding: 25px 27px 23px;
}

.viewer {
  position: sticky;
  top: 18px;
  min-height: 680px;
  max-height: calc(100vh - 36px);
  padding: 23px;
  overflow: auto;
  scrollbar-color: rgba(36, 97, 122, 0.25) transparent;
}

.card-heading,
.viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.card-heading {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.card-heading h2,
.viewer-head h2 {
  margin: 3px 0 0;
  color: var(--ink-strong);
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.required-note {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 11px;
}

.required-note i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warm);
}

.form-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 13px;
  color: var(--danger);
  border: 1px solid rgba(169, 70, 63, 0.25);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  font-size: 13px;
}

.form-status.is-success {
  color: var(--success);
  border-color: rgba(71, 115, 95, 0.25);
  background: var(--success-soft);
}

.status-icon {
  display: grid;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: currentColor;
  font-size: 0;
}

.status-icon::after {
  content: "!";
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.form-status.is-success .status-icon::after {
  content: "✓";
}

.form-status p {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 0;
}

.form-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 13px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 1px;
}

.block-title {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.block-title h3,
.panel-headline h3,
.success-banner h3 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 720;
  letter-spacing: 0.01em;
}

.block-title p,
.panel-headline p,
.success-banner p {
  margin: 3px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.5;
}

.block-title h3 small {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 550;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-option {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.template-option:hover {
  border-color: rgba(36, 97, 122, 0.34);
  background: #fffdf9;
  transform: translateY(-1px);
}

.template-option.is-selected,
.template-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(36, 97, 122, 0.09);
}

.template-option:has(input:focus-visible) {
  outline: 3px solid rgba(36, 97, 122, 0.24);
  outline-offset: 2px;
}

.template-option > input {
  position: absolute;
  width: 1px;
  min-height: 0;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

.template-preview {
  display: grid;
  width: 58px;
  height: 76px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(61, 68, 66, 0.13);
  border-radius: 7px;
  background: #ece8df;
}

.template-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.template-preview i {
  color: var(--ink-faint);
  font-size: 9px;
  font-style: normal;
  text-align: center;
}

.template-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.template-copy strong,
.template-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-copy strong {
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 720;
}

.template-copy small {
  color: var(--ink-muted);
  font-size: 10px;
}

.template-check {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.template-option.is-selected .template-check,
.template-option input:checked ~ .template-check {
  opacity: 1;
  transform: scale(1);
}

.dual-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

[data-template-fields] {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field > span {
  color: #53636b;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.field > span small {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  color: var(--ink-strong);
  border: 1px solid rgba(62, 79, 84, 0.2);
  border-radius: var(--radius-sm);
  outline: none;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input,
select {
  min-height: 43px;
  padding: 9px 11px;
}

select {
  cursor: pointer;
}

input[type="date"] {
  display: block;
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  -webkit-min-logical-width: 0;
}

input[type="date"]::-webkit-date-and-time-value {
  min-width: 0;
  height: 1.5em;
  margin: 0;
  text-align: left;
}

textarea {
  min-height: clamp(250px, 33vh, 390px);
  padding: 14px;
  resize: vertical;
  line-height: 1.75;
}

input::placeholder,
textarea::placeholder {
  color: #9aa2a4;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(36, 97, 122, 0.36);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(36, 97, 122, 0.11);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffaf9;
}

.field-help,
.field-error {
  color: var(--ink-muted);
  font-size: 11px;
  line-height: 1.5;
}

.field-error {
  color: var(--danger);
  font-weight: 600;
}

.content-block {
  padding-bottom: 20px;
}

.content-head {
  align-items: center;
}

.content-tools {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  color: var(--accent-dark);
  border: 1px solid rgba(36, 97, 122, 0.2);
  border-radius: 999px;
  background: rgba(228, 239, 241, 0.7);
  font-size: 11px;
  font-weight: 680;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.mini-btn:hover {
  color: var(--accent-dark);
  border-color: rgba(36, 97, 122, 0.4);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

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

.textarea-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.content-count {
  flex: 0 0 auto;
  color: var(--ink-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.content-count.is-near-limit {
  color: var(--warm);
  font-weight: 700;
}

.content-count.is-at-limit {
  color: var(--danger);
  font-weight: 750;
}

.form-actions {
  display: grid;
  gap: 8px;
  padding-top: 20px;
}

.primary-btn {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 18px;
  color: #fffdf8;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(125deg, var(--accent-dark), var(--accent));
  box-shadow: 0 10px 22px rgba(23, 72, 95, 0.2);
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.primary-btn:hover {
  box-shadow: 0 14px 28px rgba(23, 72, 95, 0.26);
  filter: saturate(1.08);
  transform: translateY(-1px);
}

.primary-btn:active {
  box-shadow: 0 7px 16px rgba(23, 72, 95, 0.2);
  transform: translateY(0);
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.74;
  box-shadow: none;
  transform: none;
}

.primary-btn.is-loading .button-symbol {
  animation: buttonSpin 1.2s linear infinite;
}

.button-symbol {
  display: inline-block;
  font-size: 16px;
}

.form-actions > p {
  margin: 0;
  color: var(--ink-faint);
  font-size: 10px;
  text-align: center;
}

.viewer-head {
  align-items: center;
  padding: 1px 1px 16px;
  border-bottom: 1px solid var(--line);
}

.result-count {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 5px 9px;
  color: var(--accent-dark);
  border: 1px solid rgba(36, 97, 122, 0.17);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-body {
  display: grid;
  gap: 15px;
  padding-top: 17px;
}

.panel-headline {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.panel-headline > span {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.image-item {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding: 9px;
  overflow: hidden;
  border: 1px solid rgba(59, 76, 81, 0.14);
  border-radius: var(--radius-md);
  background: var(--paper-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.image-item:hover {
  border-color: rgba(36, 97, 122, 0.3);
  box-shadow: 0 12px 26px rgba(49, 66, 70, 0.1);
  transform: translateY(-2px);
}

.thumb-btn {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 9px;
  background: #e9e5dc;
  cursor: zoom-in;
}

.thumb-img {
  display: block;
  width: 100%;
  aspect-ratio: 1170 / 1655;
  object-fit: contain;
  border: 1px solid rgba(72, 75, 69, 0.11);
  border-radius: 9px;
  background: #ece8df;
}

.zoom-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 8px;
  color: #fff;
  border-radius: 999px;
  background: rgba(16, 37, 53, 0.74);
  font-size: 10px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.thumb-btn:hover .zoom-hint,
.thumb-btn:focus-visible .zoom-hint {
  opacity: 1;
  transform: translateY(0);
}

.thumb-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.thumb-meta p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-grid .thumb-meta {
  justify-content: flex-start;
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 50px 20px;
  color: var(--ink-muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--paper-soft);
  text-align: center;
}

.empty-state > span {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 11px;
  place-items: center;
  color: var(--ink-faint);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 20px;
}

.empty-state h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.empty-state p {
  max-width: 300px;
  margin: 5px 0 0;
  font-size: 12px;
}

.loading-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  min-height: 100%;
  place-items: center;
  padding: 28px;
  border-radius: inherit;
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(5px);
}

.loading-panel.show {
  display: grid;
}

.loading-content {
  width: min(420px, 100%);
  text-align: center;
}

.writing-indicator {
  position: relative;
  width: 82px;
  height: 74px;
  margin: 0 auto 18px;
}

.paper-sheet {
  position: absolute;
  inset: 0 9px 0 0;
  border: 1px solid rgba(74, 72, 64, 0.2);
  border-radius: 7px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 12px, rgba(36, 97, 122, 0.11) 12px 13px),
    #fff;
  box-shadow: 0 9px 20px rgba(55, 55, 48, 0.1);
  transform: rotate(-2deg);
}

.writing-pen {
  position: absolute;
  right: 0;
  bottom: 5px;
  color: var(--accent-dark);
  font-family: serif;
  font-size: 34px;
  transform: rotate(-12deg);
  animation: writingPen 1.4s ease-in-out infinite;
}

.loading-kicker {
  margin: 0 0 4px;
  color: var(--warm);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.loading-title {
  margin: 0;
  color: var(--ink-strong);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 20px;
  font-weight: 650;
}

.loading-subtitle {
  min-height: 42px;
  margin: 7px 0 16px;
  color: var(--ink-muted);
  font-size: 12px;
}

.loading-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-muted);
}

.loading-track span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #5e8b8d);
  animation: loadingTravel 1.5s ease-in-out infinite;
}

.loading-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--ink-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.result-panel {
  gap: 17px;
}

.success-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  color: var(--success);
  border: 1px solid rgba(71, 115, 95, 0.2);
  border-radius: var(--radius-md);
  background: var(--success-soft);
}

.success-icon {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: var(--success);
  font-size: 16px;
  font-weight: 800;
}

.success-banner h3 {
  color: #345b49;
}

.success-banner p {
  color: #5e7569;
}

.result-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-btn,
.lightbox-download,
.tool-btn,
.icon-btn {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  font-size: 11px;
  font-weight: 720;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.action-btn:hover,
.lightbox-download:hover,
.tool-btn:hover,
.icon-btn:hover {
  border-color: rgba(36, 97, 122, 0.38);
  box-shadow: 0 7px 16px rgba(37, 58, 64, 0.08);
  transform: translateY(-1px);
}

.action-primary {
  color: #fff;
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.action-primary:hover {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.action-secondary {
  color: var(--accent-dark);
  border-color: rgba(36, 97, 122, 0.24);
  background: var(--accent-soft);
}

.action-quiet {
  color: var(--ink-muted);
}

.danger-link {
  color: var(--danger);
  border-color: rgba(169, 70, 63, 0.17);
}

.result-headline {
  padding-top: 2px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(12, 26, 34, 0.82);
  backdrop-filter: blur(5px);
}

.lightbox.show {
  display: flex;
}

.lightbox-inner {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(1220px, 96vw);
  height: min(920px, 94vh);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.38);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.lightbox-header h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 14px;
}

.lightbox-header p {
  margin: 1px 0 0;
  color: var(--ink-muted);
  font-size: 10px;
}

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

.lightbox-download {
  min-height: 32px;
  padding: 5px 10px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.icon-btn {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 19px;
  line-height: 1;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 45px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
}

.tool-btn {
  min-width: 32px;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 15px;
}

.tool-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

.reset-tool {
  padding-inline: 10px;
  font-size: 10px;
}

.lightbox-zoom-level {
  min-width: 50px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 780;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.toolbar-tip {
  margin-left: 6px;
  color: var(--ink-faint);
  font-size: 10px;
}

.lightbox-stage {
  position: relative;
  min-height: 0;
  padding: 18px 56px;
  overflow: auto;
  background:
    linear-gradient(45deg, rgba(80, 84, 80, 0.035) 25%, transparent 25%, transparent 75%, rgba(80, 84, 80, 0.035) 75%),
    linear-gradient(45deg, rgba(80, 84, 80, 0.035) 25%, transparent 25%, transparent 75%, rgba(80, 84, 80, 0.035) 75%),
    #e8e5de;
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
  scrollbar-color: rgba(25, 50, 70, 0.35) transparent;
  cursor: grab;
  overscroll-behavior: contain;
}

.lightbox-stage.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.lightbox-img {
  display: block;
  max-width: none;
  height: auto;
  margin: 0 auto;
  border: 1px solid rgba(55, 57, 53, 0.14);
  background: #fff;
  box-shadow: 0 12px 30px rgba(33, 38, 38, 0.16);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-nav {
  position: absolute;
  z-index: 2;
  top: 55%;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  color: var(--ink-strong);
  border: 1px solid rgba(32, 51, 59, 0.2);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 8px 20px rgba(23, 35, 40, 0.16);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.lightbox-nav:hover {
  background: #fff;
  box-shadow: 0 10px 24px rgba(23, 35, 40, 0.22);
  transform: translateY(-50%) scale(1.04);
}

.lightbox-nav.prev {
  left: 12px;
}

.lightbox-nav.next {
  right: 12px;
}

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

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: revealUp 0.48s cubic-bezier(0.22, 0.9, 0.26, 1) forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes writingPen {
  0%,
  100% {
    transform: translate(-3px, 0) rotate(-12deg);
  }
  50% {
    transform: translate(5px, -2px) rotate(-8deg);
  }
}

@keyframes loadingTravel {
  0% {
    left: -45%;
  }
  55% {
    left: 48%;
  }
  100% {
    left: 102%;
  }
}

@keyframes buttonSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1120px) {
  .app-shell {
    width: min(920px, calc(100vw - 28px));
    padding-top: 20px;
  }

  .app-header {
    grid-template-columns: 1fr;
    gap: 13px;
    padding-bottom: 19px;
  }

  .header-copy {
    justify-items: start;
  }

  .header-copy > p {
    max-width: none;
    text-align: left;
  }

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

  .viewer {
    position: relative;
    top: auto;
    min-height: 560px;
    max-height: none;
    overflow: hidden;
  }

  .preview-grid,
  .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: calc(100vw - 16px);
    padding: 10px 0 18px;
  }

  .app-header {
    padding: 2px 4px 14px;
  }

  .brand-lockup {
    align-items: flex-start;
    gap: 11px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 13px 6px 13px 6px;
    font-size: 22px;
  }

  h1 {
    font-size: clamp(23px, 7.7vw, 30px);
  }

  .header-copy > p {
    font-size: 12px;
  }

  .composer,
  .viewer {
    border-radius: 17px;
  }

  .composer {
    padding: 18px 15px 17px;
  }

  .viewer {
    min-height: 480px;
    padding: 17px 14px;
  }

  .card-heading h2,
  .viewer-head h2 {
    font-size: 19px;
  }

  .required-note {
    display: none;
  }

  .form-block {
    padding: 19px 0;
  }

  .meeting-block,
  .meeting-block .field {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .meeting-block input[type="date"] {
    width: 100%;
    width: -webkit-fill-available;
    min-width: 0;
    max-width: 100%;
    -webkit-min-logical-width: 0;
    -webkit-appearance: none;
    appearance: none;
  }

  .template-grid,
  .dual-row {
    grid-template-columns: 1fr;
  }

  .content-head {
    align-items: flex-start;
  }

  .content-head.block-head {
    display: grid;
  }

  .content-tools {
    padding-left: 0;
  }

  textarea {
    min-height: 280px;
  }

  .textarea-meta {
    align-items: flex-start;
  }

  .textarea-meta .field-help {
    max-width: 68%;
  }

  .viewer-head {
    align-items: flex-start;
  }

  .images-grid,
  .preview-grid,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .image-item {
    padding: 6px;
  }

  .result-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-btn {
    width: 100%;
    min-height: 40px;
    padding-inline: 8px;
    text-align: center;
  }

  .lightbox {
    padding: 7px;
  }

  .lightbox-inner {
    width: 100%;
    height: 96vh;
    border-radius: 13px;
  }

  .lightbox-header {
    padding: 9px 10px;
  }

  .lightbox-download {
    padding-inline: 8px;
  }

  .lightbox-toolbar {
    justify-content: flex-start;
    min-height: 43px;
    padding-inline: 10px;
    overflow-x: auto;
  }

  .toolbar-tip {
    display: none;
  }

  .lightbox-stage {
    padding: 12px 40px;
  }

  .lightbox-nav {
    width: 34px;
    height: 34px;
    font-size: 21px;
  }

  .lightbox-nav.prev {
    left: 5px;
  }

  .lightbox-nav.next {
    right: 5px;
  }
}

@media (max-width: 410px) {
  .block-title p {
    font-size: 11px;
  }

  .content-tools {
    padding-left: 0;
  }

  .images-grid,
  .preview-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-toolbar {
    grid-template-columns: 1fr;
  }

  .thumb-img {
    max-height: 70vh;
  }
}

.site-footer {
  margin-top: 30px;
  padding: 22px 8px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  text-align: center;
  font-size: 12px;
}

.site-footer nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.site-footer a,
.info-card a,
.info-header a,
.header-copy > a,
.usage-notice a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.header-copy > a { font-size: 13px; }
.form-actions .usage-notice { line-height: 1.8; }
.info-shell { max-width: 900px; }
.info-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0 0 22px;
}
.info-card {
  padding: clamp(20px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow-card);
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.info-card h1 { margin: 8px 0 24px; }
.info-card h2 { margin: 30px 0 12px; font-size: 20px; line-height: 1.5; }
.info-card li { margin: 10px 0; }
.info-card ul,
.info-card ol { padding-left: 1.5em; }
.info-lead { font-size: 17px; }
.info-date { color: var(--ink-muted); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
