:root {
  color-scheme: light dark;
  --bg: #0f1419;
  --surface: #1a222c;
  --border: #2d3a47;
  --text: #e7ecf1;
  --muted: #9aa7b2;
  --accent: #3d8bfd;
  --danger: #f87171;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f8;
    --surface: #fff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #57606a;
    --accent: #0969da;
    --danger: #cf222e;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.note {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: var(--radius);
  color: var(--text);
}

.panel {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.row input[type="text"] {
  flex: 1 1 12rem;
  min-width: 0;
}

input,
select,
button {
  font: inherit;
  border-radius: 8px;
}

input,
select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 85%, var(--bg));
  color: var(--text);
}

button {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

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

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.hint.small {
  margin-top: 0.35rem;
}

.hint code {
  font-size: 0.78em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
}

.error {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 520px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.field select,
.field input[type="number"] {
  width: 100%;
}

.preview-wrap {
  margin-top: 1rem;
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 40%, var(--surface));
  border-radius: 8px;
  border: 1px dashed var(--border);
}

#printCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.meta {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status {
  margin: 0.65rem 0 0;
  font-size: 0.9rem;
}

.log {
  margin: 0.75rem 0 0;
  max-height: 10rem;
  overflow: auto;
  padding: 0.5rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.4;
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

.site-footer {
  margin-top: 2rem;
  padding-top: 0.5rem;
  text-align: center;
}

.site-footer a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

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