@font-face {
  font-family: "LicensePlate";
  src: url("assets/fonts/license-plate-usa.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --ink: #1d1f22;
  --muted: #74787e;
  --line: #e6e6e3;
  --accent: #1d1f22;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 20px;
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 0;
  height: calc(100% - 65px);
}

/* ---------- picker ---------- */
.picker {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 22px 18px;
  overflow-y: auto;
}
.picker-title,
.control-title {
  margin: 0 0 16px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}
.plate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.plate-thumb {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fbfbfa;
  padding: 8px 6px 6px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  text-align: center;
}
.plate-thumb:hover {
  border-color: #c9c9c4;
  transform: translateY(-1px);
}
.plate-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.plate-thumb img {
  width: 100%;
  height: 92px;
  object-fit: contain;
  display: block;
}
.plate-thumb span {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

/* ---------- stage / cover ---------- */
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}
.stage-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover {
  position: relative;
  height: 100%;
  max-height: 760px;
  /* artwork aspect ratio 540 x 1134 */
  aspect-ratio: 540 / 1134;
}
.cover-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

/* The personalized name is rendered onto this canvas (same routine as the PNG
   export, so preview and export are pixel-identical). */
.name-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cover { cursor: text; }

/* ---------- controls ---------- */
.controls {
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 22px 20px;
  overflow-y: auto;
}
.control-card { max-width: 320px; }
.control-title {
  color: var(--ink);
  font-size: 22px;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 2px;
  font-weight: 700;
}
.control-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}
.field-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.name-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: #fbfbfa;
  outline: none;
  transition: border-color 0.15s;
}
.name-input:focus { border-color: var(--accent); }
.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.4;
}
.hint.locked { margin-top: 4px; }

.swatch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.swatch-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-right: auto;
}
input.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
input.swatch::-webkit-color-swatch-wrapper { padding: 0; }
input.swatch::-webkit-color-swatch { border: none; border-radius: 50%; }
input.swatch::-moz-color-swatch { border: none; border-radius: 50%; }
.swatch-hex {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.reset-color {
  margin-top: 12px;
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.reset-color:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.export-btn {
  display: block;
  width: 100%;
  margin-top: 28px;
  padding: 14px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: opacity 0.15s;
}
.export-btn:hover { opacity: 0.85; }
.export-btn:active { opacity: 0.7; }
.export-btn:disabled { opacity: 0.5; cursor: default; }
.export-btn.secondary {
  margin-top: 10px;
  background: #fff;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .picker { order: 2; border-right: none; border-top: 1px solid var(--line); }
  .stage { order: 1; height: 60vh; }
  .controls { order: 3; border-left: none; border-top: 1px solid var(--line); }
  .plate-grid { grid-template-columns: repeat(3, 1fr); }
}
