:root {
  --bg: #f1f1f1;
  --card: #fff;
  --ink: #303030;
  --muted: #616161;
  --line: #e3e3e3;
  --line-strong: #8a8a8a;
  --primary: #303030;
  --primary-ink: #fff;
  --accent: #1f3a2e;
  --critical: #8e1f0b;
  --critical-bg: #fee9e8;
  --success-bg: #cdfee1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgb(26 26 26 / 0.07), inset 0 -1px 0 rgb(0 0 0 / 0.08), 0 0 0 1px rgb(0 0 0 / 0.04);
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
.app { max-width: 1100px; margin: 0 auto; padding: 16px 16px 64px; display: grid; gap: 16px; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 14px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #e3e3e3; border-radius: 10px; width: fit-content; }
.tab { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-weight: 550; color: var(--ink); cursor: pointer; min-height: 32px; }
.tab[aria-selected="true"] { background: #fff; box-shadow: var(--shadow); }
.tab:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid #005bd3; outline-offset: 1px; }

/* Layout */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.head-left { display: flex; align-items: center; gap: 8px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }

/* Form controls */
label.field { display: grid; gap: 4px; }
label.field > span { font-weight: 550; }
.hint { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="number"], select {
  height: 34px; line-height: 20px;
}
input[type="text"], input[type="number"], select, textarea {
  width: 100%; padding: 6px 10px; font: inherit; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fdfdfd;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #005bd3; outline-offset: -1px; border-color: transparent; }
.check { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.colour-row { display: flex; gap: 8px; align-items: center; }
.colour-row input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 6px 12px;
  border-radius: var(--radius-sm); border: 0; font: inherit; font-weight: 600; cursor: pointer;
  background: #fff; color: var(--ink); box-shadow: var(--shadow);
}
.btn:hover { background: #f7f7f7; }
.btn.primary { background: var(--primary); color: var(--primary-ink); box-shadow: inset 0 -1px 0 #000, 0 1px 0 rgb(0 0 0 / 0.2); }
.btn.primary:hover { background: #1a1a1a; }
.btn.critical { color: var(--critical); }
.btn.critical.armed { background: var(--critical); color: #fff; }
.btn.plain { background: transparent; box-shadow: none; padding-inline: 6px; color: #005bd3; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.icon-btn { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; color: var(--muted); font-size: 14px; }
.icon-btn:hover { background: #f1f1f1; color: var(--ink); }
.icon-btn[disabled] { opacity: 0.3; cursor: default; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 8px; background: #e3e3e3; font-size: 12px; font-weight: 550; white-space: nowrap; }
.badge.foil { background: #fff1cc; }
.badge.laser { background: #f6e8dc; }
.badge.emboss { background: #e7e1f5; }
.badge.ok { background: var(--success-bg); }

/* Type list */
.type-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.type-card { text-align: left; cursor: pointer; border: 0; font: inherit; color: inherit; }
.type-card:hover { box-shadow: var(--shadow), 0 0 0 2px #c9c9c9; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 12px; }

/* Ordered pickers */
.picker { display: grid; gap: 6px; }
.picker-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.picker-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid var(--line); min-height: 40px; }
.picker-list li:first-child { border-top: 0; }
.picker-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-empty { padding: 10px; color: var(--muted); }
.picker-add { display: flex; gap: 8px; }
.sample { font-size: 18px; line-height: 1.2; }
.swatch { width: 24px; height: 24px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2); background-size: cover; background-position: center; }
.thumb { width: 32px; height: 32px; flex: none; object-fit: contain; border-radius: 6px; background: #f6f6f6; }

/* Tables */
.rows { display: grid; }
.row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-edit { padding: 12px; margin: 4px 0 8px; border-radius: var(--radius-sm); background: #f7f7f7; display: grid; gap: 12px; }
.font-sample { font-size: 24px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Preview */
#preview { display: grid; gap: 10px; }
.plate {
  display: grid; place-items: center; min-height: 150px; padding: 24px 16px; border-radius: 12px;
  outline: 1px dashed rgb(0 0 0 / 0.18); outline-offset: -8px; text-align: center; overflow: hidden;
}
.plate-text { font-size: 40px; line-height: 1.3; padding-inline: 0.2em; overflow-wrap: anywhere; }
.plate-line2 { font-size: 16px; letter-spacing: 0.06em; margin-top: 4px; font-family: "Cormorant Garamond", serif; }
.plate-icon { height: 36px; aspect-ratio: 1; margin-top: 6px; -webkit-mask: var(--art) center / contain no-repeat; mask: var(--art) center / contain no-repeat; }
.preview-fonts { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 4px 10px; cursor: pointer; font: inherit; }
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }

.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: #eaf4ff; }
.notice.error { background: var(--critical-bg); color: var(--critical); }
.drop { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drop input[type="file"] { font: inherit; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
