:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172126;
  --muted: #64727a;
  --line: #d9e1e4;
  --accent: #0e8f83;
  --accent-strong: #08766d;
  --accent-soft: #d9f3ee;
  --danger: #be4b49;
  --warn: #9f681e;
  --warn-bg: #fff6e3;
  --shadow: 0 18px 45px rgba(28, 39, 45, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  overflow-anchor: none;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--bg) 44%, #edf2f3 100%);
  color: var(--ink);
}

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

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  padding: 18px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
}

.status {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.button,
.wide-button,
.small-button,
.segment,
.count-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.button,
.wide-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
  text-decoration: none;
}

.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  color: #2f3d43;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.button svg,
.wide-button svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button:hover:not(:disabled):not(.disabled),
.wide-button:hover:not(:disabled),
.small-button:hover:not(:disabled),
.segment:hover,
.count-button:hover {
  border-color: #b9c7cb;
  box-shadow: 0 10px 24px rgba(28, 39, 45, 0.1);
}

.button:active:not(:disabled):not(.disabled),
.wide-button:active:not(:disabled),
.small-button:active:not(:disabled),
.segment:active,
.count-button:active {
  transform: translateY(1px);
}

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

.button.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

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

.button.disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
  pointer-events: none;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(238px, 300px) 1fr;
  gap: clamp(14px, 2vw, 24px);
  padding: clamp(14px, 2.6vw, 30px);
  min-height: 0;
}

.controls {
  align-self: stretch;
  align-content: start;
  display: grid;
  gap: 14px;
}

.control-group {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(28, 39, 45, 0.06);
}

.item-editor {
  order: -1;
}

.control-heading {
  color: #2f3d43;
  font-size: 13px;
  font-weight: 800;
}

.background-details {
  display: block;
}

.background-details > summary {
  cursor: pointer;
}

.background-details > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.background-details-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

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

.count-button {
  min-width: 0;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.count-button.active,
.segment.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.stamp-layout-grid {
  display: grid;
  gap: 10px;
}

.layout-option {
  display: grid;
  gap: 7px;
  min-height: 0;
  padding: 12px;
  text-align: left;
}

.layout-option-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.layout-option-heading strong {
  font-size: 20px;
}

.recommended-badge,
.sheet-count-badge {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 850;
  padding: 4px 7px;
}

.layout-option-sheets,
.layout-option-grid,
.layout-option-size {
  display: block;
}

.layout-option-sheets {
  color: #2f3d43;
  font-size: 13px;
  font-weight: 800;
}

.layout-option-grid {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 850;
}

.layout-option-size {
  color: #66747a;
  font-size: 11px;
  font-weight: 700;
}

.layout-diagram-row {
  display: flex;
  width: 100%;
}

.mini-sheet {
  --cols: 6;
  --rows: 4;
  display: block;
  width: 100%;
  aspect-ratio: var(--cols) / var(--rows);
  border: 2px solid var(--accent);
  border-radius: 5px;
  background-color: #f8fbfb;
  background-image:
    linear-gradient(to right, transparent calc(100% - 1px), #bcd9d4 calc(100% - 1px)),
    linear-gradient(to bottom, transparent calc(100% - 1px), #bcd9d4 calc(100% - 1px));
  background-size:
    calc(100% / var(--cols)) 100%,
    100% calc(100% / var(--rows));
}

.grid-4x4 {
  --cols: 4;
  --rows: 4;
}

.grid-6x4 {
  --cols: 6;
  --rows: 4;
}

.layout-rule {
  margin: 0;
  color: #59666c;
  font-size: 11px;
  line-height: 1.65;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented.input-mode {
  grid-template-columns: repeat(2, 1fr);
}

.segment {
  min-width: 0;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font-weight: 750;
}

.segment + .segment {
  border-left: 1px solid var(--line);
}

.wide-button {
  width: 100%;
}

.wide-button.danger,
.small-button.danger {
  color: var(--danger);
}

.small-button.accent {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.split-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.split-controls .wide-button {
  grid-column: 1 / -1;
}

.input-row,
.check-row,
.slider-row {
  display: grid;
  align-items: center;
  gap: 10px;
  color: #2f3d43;
  font-size: 13px;
  font-weight: 750;
}

.input-row,
.slider-row {
  grid-template-columns: 1fr auto;
}

.check-row {
  grid-template-columns: auto 1fr;
}

.input-row input[type="number"] {
  width: 74px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 750;
}

.mini-heading {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.selected-stamp {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  color: var(--ink);
  line-height: 1.35;
}

.selected-stamp strong,
.selected-stamp span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.selected-stamp strong {
  font-size: 12px;
  font-weight: 850;
}

.selected-stamp span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.selection-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.selection-actions .confirm {
  grid-column: 1 / -1;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.selection-actions .confirm:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.editor-preview {
  min-width: 0;
}

.editor-preview-strip {
  display: flex;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: thin;
}

.editor-preview-strip.single {
  display: grid;
}

.editor-preview-card {
  min-width: 112px;
  display: grid;
  gap: 6px;
}

.editor-preview-strip.single .editor-preview-card {
  min-width: 0;
}

.editor-preview-frame {
  aspect-ratio: 370 / 320;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(-45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dce4e7 75%),
    linear-gradient(-45deg, transparent 75%, #dce4e7 75%);
  background-color: #f9fbfb;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.editor-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eraser-frame {
  display: block;
  overflow: auto;
}

.eraser-canvas-wrap {
  position: relative;
  width: 100%;
}

.eraser-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}

.eraser-canvas.pan-mode {
  cursor: grab;
}

.eraser-canvas.pan-mode:active {
  cursor: grabbing;
}

.eraser-cursor {
  position: absolute;
  z-index: 1;
  transform: translate(-50%, -50%);
  border: 1px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #26343a;
  pointer-events: none;
}

.eraser-panel {
  display: grid;
  gap: 7px;
}

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

.eraser-actions .small-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.editor-preview-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

output {
  min-width: 3ch;
  color: var(--accent-strong);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.workspace {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 14px;
}

.prompt-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid #b9ddd7;
  border-radius: 10px;
  background: #f3fbf9;
  box-shadow: 0 10px 26px rgba(28, 102, 93, 0.08);
}

.prompt-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.prompt-panel-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.prompt-panel-heading strong {
  color: #173b37;
  font-size: 16px;
}

#promptModeLabel {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 850;
  padding: 4px 8px;
  white-space: nowrap;
}

.prompt-help {
  margin: 0;
  color: #4f6965;
  font-size: 12px;
  line-height: 1.65;
}

.prompt-variable-editor {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid #f0b7b7;
  border-radius: 8px;
  background: #fff8f8;
}

.prompt-variable-editor > span {
  color: #c32626;
  font-size: 12px;
  font-weight: 850;
}

.prompt-variable-editor input,
.prompt-variable-editor textarea {
  width: 100%;
  border: 1px solid #dc7b7b;
  border-radius: 7px;
  background: #fff;
  color: #d32626;
  font-size: 14px;
  font-weight: 800;
}

.prompt-variable-editor input {
  min-height: 40px;
  padding: 0 10px;
}

.prompt-variable-editor textarea {
  height: 132px;
  min-height: 96px;
  max-height: 280px;
  padding: 10px;
  resize: vertical;
  font: 750 13px/1.65 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.prompt-variable-editor input:focus,
.prompt-variable-editor textarea:focus {
  border-color: #c32626;
  box-shadow: 0 0 0 3px rgba(195, 38, 38, 0.11);
  outline: none;
}

.prompt-variable-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.prompt-variable-title strong {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e6f5ef;
  color: #187353;
  font-size: 11px;
  padding: 4px 8px;
}

.prompt-variable-title strong.invalid {
  background: #ffe6e6;
  color: #b91c1c;
}

.prompt-variable-editor small {
  color: #7d6767;
  font-size: 10px;
  line-height: 1.5;
}

.prompt-text {
  width: 100%;
  height: 96px;
  overflow: auto;
  border: 1px solid #b9d8d3;
  border-radius: 8px;
  background: #fff;
  color: #111;
  font: 500 13px/1.75 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 12px 14px;
  white-space: pre-wrap;
}

.prompt-variable {
  color: #d32626;
  font-weight: 850;
}

.prompt-text:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 143, 131, 0.12);
  outline: none;
}

.prompt-copy-button {
  justify-self: start;
  width: auto;
  min-width: 230px;
}

.input-note {
  color: #59666c;
  font-size: 12px;
  line-height: 1.65;
  margin: 0;
}

.drop-zone {
  min-height: 112px;
  display: grid;
  place-items: center;
  padding: 20px;
  border: 1px dashed #a7b7bc;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(-45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dce4e7 75%),
    linear-gradient(-45deg, transparent 75%, #dce4e7 75%);
  background-color: #fbfdfd;
  background-position:
    0 0,
    0 13px,
    13px -13px,
    -13px 0;
  background-size: 26px 26px;
  box-shadow: var(--shadow);
}

.drop-zone.dragging {
  border-color: var(--accent);
  box-shadow:
    0 0 0 4px rgba(14, 143, 131, 0.16),
    var(--shadow);
}

.drop-copy {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--muted);
  text-align: center;
}

.drop-copy strong {
  color: var(--ink);
  font-size: 18px;
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.notice {
  padding: 12px 14px;
  border: 1px solid #f1d198;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.single-sheet-notice,
.preview-appearance {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.single-sheet-notice .button {
  margin-left: auto;
}

.preview-appearance {
  padding: 4px 0;
}

.preview-appearance .segmented {
  width: 140px;
}

.preview-color-presets,
.preview-color-custom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.background-swatch {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #9daeb5;
  border-radius: 50%;
  background: var(--swatch-color);
  cursor: pointer;
}

.background-swatch[aria-pressed="true"] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.background-swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preview-appearance input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.preview-appearance input[type="text"] {
  width: 96px;
  height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: monospace;
}

.preview-export-note {
  color: var(--muted);
  font-size: 12px;
}

body[data-preview-background="color"] .stamp-preview,
body[data-preview-background="color"] .editor-preview-frame {
  background-image: none;
  background-color: var(--preview-background-color, #fff);
}

.download-panel {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.download-panel .button {
  flex: 1 1 180px;
}

.cover-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  flex: 0 1 260px;
  padding: 5px 6px 5px 12px;
  border: 1px solid #d7aa2f;
  border-radius: 8px;
  background: #fff9e6;
  color: #6f5000;
  font-size: 13px;
  font-weight: 850;
}

.cover-picker span {
  flex: 0 0 auto;
}

.cover-picker select {
  min-width: 0;
  min-height: 32px;
  flex: 1 1 auto;
  padding: 0 30px 0 9px;
  border: 1px solid rgba(122, 87, 0, 0.28);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.cover-picker select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.history-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(28, 39, 45, 0.06);
}

.history-page-panel {
  padding: clamp(16px, 2vw, 22px);
}

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

.history-head h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.history-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.history-thumb {
  aspect-ratio: 92 / 80;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(-45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dce4e7 75%),
    linear-gradient(-45deg, transparent 75%, #dce4e7 75%);
  background-color: #f9fbfb;
  background-position:
    0 0,
    0 6px,
    6px -6px,
    -6px 0;
  background-size: 12px 12px;
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.history-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.history-meta strong,
.history-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta strong {
  font-size: 13px;
}

.history-meta span {
  color: var(--muted);
  font-size: 12px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-empty {
  padding: 12px;
  border: 1px dashed #b8c7cb;
  border-radius: 8px;
  background: #f8fbfb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: 12px;
}

.stamp-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(28, 39, 45, 0.06);
}

.stamp-card.selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(14, 143, 131, 0.16),
    0 10px 26px rgba(28, 39, 45, 0.06);
}

.stamp-card.cover:not(.selected) {
  border-color: #d7aa2f;
  box-shadow:
    0 0 0 3px rgba(215, 170, 47, 0.16),
    0 10px 26px rgba(28, 39, 45, 0.06);
}

.cover-badge {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 9px;
  padding: 4px 7px;
  border: 1px solid rgba(122, 87, 0, 0.22);
  border-radius: 6px;
  background: #fff3c2;
  color: #6f5000;
  box-shadow: 0 2px 8px rgba(28, 39, 45, 0.14);
  font-size: 11px;
  font-weight: 850;
}

.stamp-card.adjusted::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(28, 39, 45, 0.2);
}

.stamp-preview {
  aspect-ratio: 370 / 320;
  display: grid;
  place-items: center;
  padding: 8px;
  background:
    linear-gradient(45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(-45deg, #dce4e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dce4e7 75%),
    linear-gradient(-45deg, transparent 75%, #dce4e7 75%);
  background-color: #f9fbfb;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.stamp-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.stamp-meta {
  display: grid;
  gap: 3px;
  padding: 10px;
}

.stamp-meta strong,
.stamp-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stamp-meta strong {
  font-size: 13px;
}

.stamp-meta span {
  color: var(--muted);
  font-size: 12px;
}

.stamp-edit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 20px);
  min-height: 34px;
  margin: 0 10px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  color: #2f3d43;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.stamp-edit-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.stamp-edit-button svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.stamp-card.extra {
  opacity: 0.52;
}

.stamp-card.problem {
  border-color: #e5b2b1;
}

.manual-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 34px);
  display: grid;
  gap: 16px;
}

.manual-intro,
.manual-section {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(28, 39, 45, 0.06);
}

.manual-intro h2,
.manual-section h2,
.manual-section h3 {
  margin: 0;
  letter-spacing: 0;
}

.manual-intro h2,
.manual-section h2 {
  font-size: 20px;
}

.manual-section h3 {
  font-size: 15px;
}

.manual-intro p,
.manual-intro li,
.manual-section p,
.manual-section li,
.setting-list dd {
  color: #39474d;
  font-size: 14px;
  line-height: 1.75;
}

.manual-intro ol,
.manual-section ul {
  margin: 0;
  padding-left: 1.35em;
}

.setting-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.setting-list > div {
  display: grid;
  grid-template-columns: minmax(112px, 180px) 1fr;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.setting-list > div:first-child {
  border-top: 0;
  padding-top: 0;
}

.setting-list > div:last-child {
  padding-bottom: 0;
}

.setting-list dt {
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.55;
}

.setting-list dd {
  margin: 0;
}

.manual-note {
  margin: 0;
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  background: #f0faf7;
  color: #2f3d43;
  font-weight: 750;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.manual-grid article {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.manual-grid p {
  margin: 0;
}

code {
  padding: 0.08em 0.32em;
  border-radius: 5px;
  background: #eef4f5;
  color: #26343a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

@media (min-width: 861px) {
  .item-editor {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow: auto;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions .button,
  .top-actions label.button {
    flex: 1 1 150px;
  }

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

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

  .item-editor {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .controls,
  .summary-bar {
    grid-template-columns: 1fr;
  }

  .download-panel .button,
  .cover-picker {
    flex-basis: 100%;
  }

  .history-head {
    align-items: stretch;
    flex-direction: column;
  }

  .history-item {
    grid-template-columns: 64px 1fr;
  }

  .history-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .history-actions .small-button {
    flex: 1 1 110px;
  }

  .count-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .prompt-panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-copy-button {
    width: 100%;
  }

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

  .setting-list > div {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
