:root {
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --bg: #ffffff;
  --card: #ffffff;
}

/* Base */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
.container {
  max-width: 1080px;
  margin: 40px auto;
  padding: 0 16px;
}
.header h1 { margin: 0 0 6px; }
.muted { color: var(--muted); margin: 0; }

/* Card + layout */
.card {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--card);
}
.grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-top: 10px;
}
@media (max-width: 740px) {
  .grid { grid-template-columns: 1fr; }
}

/* Form controls */
label {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
}
textarea {
  width: 100%;
  min-height: 110px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 6px;
  font-size: 14px;
  resize: vertical;
}
select,
input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 6px;
}

/* UPDATED: color inputs can fill the column for better alignment */
input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 6px;
  background: none;
}

/* Hint/status text */
.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  font-weight: 400;
}
.status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* Rows + alignment helpers */
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  align-items: center;
}
.space-between { justify-content: space-between; }

/* Buttons */
button,
.btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f9fafb;
  cursor: pointer;
  display: inline-block;
  font-size: 14px;
  line-height: 1;
}
button:hover,
.btn:hover { background: #f3f4f6; }

/* Options grid */
.options {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 740px) {
  .options { grid-template-columns: 1fr; }
}

/* UPDATED: checkbox row spans both columns so it doesn't push Background down */
.options .check{
  grid-column: 1 / -1;
  margin-top: 0;
}

.option-wide { grid-column: 1 / -1; }

/* Preset fields */
.preset-fields {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfbfb;
}
.preset-fields:empty { display: none; }

/* Preview panel */
.preview { margin-top: 0; }
.preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 320px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  margin-top: 10px;
  background: #fafafa;
}
.preview-box img {
  max-width: 320px;
  max-height: 320px;
  display: none; /* shown by JS */
}

/* UPDATED: download buttons fill the preview width equally */
.preview .row {
  width: 100%;
}
.preview .row button {
  flex: 1;
  min-width: 0;
}

/* Footer */
.footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.footer a { color: inherit; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.dot { opacity: 0.7; }

/* Small badge */
.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

/* Code */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

/* ---- Custom file picker (logo) ---- */
.file-input {
  position: absolute;
  left: -9999px;
}
.file-btn {
  margin-top: 6px;
}
.file-name {
  margin-left: 10px;
  color: var(--muted);
  font-size: 13px;
}

/* Checkbox row style */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.check label { margin: 0; font-weight: 500; }

/* QR type tiles */
.type-grid{
  display:grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
@media (max-width: 740px){
  .type-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.section-title { margin-top: 16px; margin-bottom: 6px; }

.type-tile{
  border:1px solid var(--border);
  background:#fff;
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
  text-align:left;
  font-size:14px;
}
.type-tile:hover{ background:#f9fafb; }
.type-tile.active{
  border-color:#10b981;
  background:#ecfdf5;
}

.hint.error { color: #b91c1c; }   /* red-ish */

/* --- Validation / status styling --- */
.hint {
  opacity: 0.85;
}

/* Character counter states */
#char_hint {
  margin-top: 6px;
  font-size: 0.95rem;
  line-height: 1.2;
}

#char_hint.ok {
  color: #1f7a1f; /* green */
}

#char_hint.warn {
  color: #a36a00; /* amber */
}

#char_hint.bad {
  color: #b42318; /* red */
  font-weight: 600;
}

/* Status message (errors + info) */
.status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.25;
  display: none; /* hidden by default; shown when text exists */
}

.status.info {
  display: block;
  background: #eef4ff;
  border: 1px solid #b6ccff;
  color: #1d3b8b;
}

.status.error {
  display: block;
  background: #fff1f1;
  border: 1px solid #ffd0d0;
  color: #b42318;
  font-weight: 600;
}

/* Optional: disabled buttons look clearer */
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal-backdrop[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}

.modal {
  width: min(900px, 96vw);
  max-height: 85vh;
  background: white;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.modal-close {
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  margin: 0;
  padding: 14px;
  overflow: auto;          /* <-- scrollable */
  white-space: pre-wrap;   /* wrap long lines */
  word-break: break-word;
  font-size: 13px;
  line-height: 1.45;
}

