@font-face {
  font-family: "Chiron Hei HK";
  src: url("fonts/ChironHeiHK-Heavy.25263221bd36.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: block;
}

:root {
  --ink: #1b1b1f;
  --paper: #f2f0eb;
  --line: #d8d4cc;
  --muted: #6f6a62;

  /* One knob for the whole operator UI. Bump this and every control, label,
   * gap and panel width grows with it; the card preview shrinks to fit. 20px
   * is roughly 1.4x the original 14px and fits a 1080p screen without scroll. */
  --ui-font: 20px;
}

* {
  box-sizing: border-box;
}

/* Author `display` rules would otherwise beat the UA's `[hidden]` rule. */
[hidden] {
  display: none !important;
}

html {
  height: 100%;
  font-size: var(--ui-font);
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  font: 1rem/1.6 -apple-system, "Segoe UI", "Microsoft JhengHei", "PingFang HK",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}

header {
  padding: 0.7rem 1.25rem;
  background: #111;
  color: #fff;
}

header h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

header .tag {
  display: inline-block;
  margin-bottom: 0.3rem;
  padding: 0.05em 0.5em;
  border-radius: 3px;
  background: #ffd34d;
  color: #111;
  font-size: 0.7rem;
  font-weight: 700;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 24rem);
  min-height: 0;
  overflow: hidden;
}

#preview {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.4rem;
  min-height: 0;
  padding: 0.75rem;
  overflow: hidden;
}

.half {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.page-frame {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.half canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 3508 / 2480;
  background: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
}

#preview.has-photo .half canvas {
  cursor: grab;
  touch-action: none;
}

#preview.dragging .half canvas {
  cursor: grabbing;
}

.half-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

#controls {
  height: 100%;
  overflow-y: auto;
  padding: 0.85rem 1.1rem 0.5rem;
  background: #fff;
  border-left: 1px solid var(--line);
}

#controls h2 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field {
  margin: 0 0 0.55rem;
}

.field label {
  display: block;
  margin-bottom: 0.18rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.field input[type="text"],
.field input[type="date"],
.field textarea {
  width: 100%;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.field textarea {
  resize: none;
  line-height: 1.4;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid #0a6cff;
  outline-offset: 1px;
}

.field input[type="file"] {
  display: none;
}

#pick-photo {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f6f3;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

#pick-photo:hover {
  background: #efeee9;
}

.photo-adjust {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem 0.6rem;
  margin-top: 0.6rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f6f3;
}

.photo-adjust .photo-adjust-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.zoom-slider {
  position: relative;
  display: flex;
  align-items: center;
  height: 1.4rem;
  cursor: pointer;
  touch-action: none;
}

.zoom-track {
  position: relative;
  width: 100%;
  height: 0.35rem;
  border-radius: 3px;
  background: var(--line);
}

.zoom-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  box-sizing: border-box;
  width: 1rem;
  height: 1rem;
  border: 2px solid #c2185b;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
}

.zoom-slider.dragging .zoom-thumb {
  background: #fbe9f1;
}

.zoom-slider:focus-visible {
  outline: 2px solid #0a6cff;
  outline-offset: 2px;
  border-radius: 4px;
}

.photo-adjust output {
  min-width: 3rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}

.photo-adjust button {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.photo-adjust button:hover {
  background: #efeee9;
}

.field-error {
  margin: 0.35rem 0 0;
  color: #b02020;
  font-size: 0.85rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.actions button {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f6f3;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

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

#export:not(:disabled) {
  border-color: #c2185b;
  background: #c2185b;
  color: #fff;
}

.summary {
  margin: 0.7rem 0 0;
  color: #b02020;
  font-size: 0.85rem;
}

.print-guidance {
  flex-basis: 100%;
  margin: 0.15rem 0 0;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f6f3;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.warning {
  margin: 0 0 0.8rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #e0b4b4;
  border-radius: 4px;
  background: #fdf1f1;
  color: #b02020;
  font-size: 0.85rem;
  font-weight: 600;
}

#status {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  color: #207a3a;
}

#status[data-kind="error"] {
  color: #b02020;
}

#site-footer {
  padding: 0.6rem 1.25rem 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
}

#site-footer p {
  margin: 0;
}

#site-footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
