:root {
  --bg: #ffffff;
  --text: #3c4043;
  --ink: #1a1a1a;
  --muted: #5f6368;
  --muted-2: #80868b;
  --faint: #9aa0a6;
  --pill: #f1f3f4;
  --pill-hover: #e6e8ea;
  --line: #c2c6cc;
  --line-soft: #dadce0;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 20px calc(64px + env(safe-area-inset-bottom));
  text-align: center;
}

.card {
  width: 100%;
  max-width: 440px;
}

h1 {
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.2px;
}
.subtitle {
  font-size: 16px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 10px;
}

/* Preview — bordo sempre visibile */
.preview {
  margin: 28px auto 0;
  width: 220px;
  height: 220px;
  border: 1.5px solid var(--line-soft);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color .2s ease;
}
.preview.has-qr { border-color: var(--ink); }
.preview canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.preview canvas.hidden { display: none; }
.empty-icon { color: var(--line); }
.empty-icon svg { width: 64px; height: 64px; }

.note {
  font-size: 13px;
  min-height: 18px;
  color: var(--muted-2);
  margin-top: 10px;
}
.note.error { color: #c5221f; }

/* Bottoni */
.actions {
  display: flex;
  gap: 9px;
  margin-top: 16px;
  width: 220px;
  margin-left: auto;
  margin-right: auto;
}
.btn {
  flex: 1;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.btn-secondary { background: var(--pill); color: var(--ink); }
.btn-secondary:hover { background: var(--pill-hover); }
.btn:disabled { opacity: .35; cursor: default; }

/* Textarea */
/* Suggerimento rilevamento tipo */
.hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--faint);
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.hint-btn {
  appearance: none;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.2;
}
.hint-btn:hover { color: var(--ink); border-color: var(--ink); }

.input-wrap { margin-top: 24px; }
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 13px 14px;
  resize: none;
  height: 78px;
  line-height: 1.5;
  transition: border-color .15s ease;
}
textarea:focus { outline: none; border-color: var(--ink); }
textarea::placeholder { color: var(--faint); }

/* Footer fisso */
.site-footer {
  position: fixed;
  left: 0; right: 0;
  bottom: 16px;
  text-align: center;
  font-size: 12px;
  color: #6b7075;
  letter-spacing: .2px;
}
.site-footer a { color: #6b7075; text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.site-footer a:hover { color: var(--ink); }

.hidden { display: none !important; }

@media (max-width: 460px) {
  h1 { font-size: 22px; }
  .subtitle { font-size: 15px; }
  .preview { width: 200px; height: 200px; }
}
