/* ---------- Layout: preview on the right on wide screens, on top on narrow ones ---------- */
.tcg { --tcg-blue: #356df1; --tcg-ink: #111827; --tcg-muted: #64748b; --tcg-line: #d1d5db; --tcg-soft: #f3f4f6;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); grid-template-areas: "side form";
  gap: 24px; align-items: start; max-width: 1200px; margin: 0 auto; color: var(--tcg-ink); }
.tcg *, .tcg *::before, .tcg *::after { box-sizing: border-box; }
.tcg [hidden] { display: none !important; }
.tcg-side { grid-area: side; position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tcg-form { grid-area: form; min-width: 0; }
@media (max-width: 900px) {
  .tcg { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "form"; }
  .tcg-side { position: static; }
}

/* ---------- Preview ---------- */
.tcg-preview { border-radius: 8px; overflow: hidden; box-shadow: 0 6px 24px rgba(15, 23, 42, .14); background: #fff; line-height: 0; }
.tcg-preview svg { display: block; width: 100%; height: auto; }
.tcg-nav { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 14px; }
.tcg .tcg-nav .tcg-btn { padding: 4px 14px; font-size: 18px; }

/* ---------- Form ---------- */
.tcg .tcg-card { border: 1px solid var(--tcg-line); border-radius: 10px; padding: 16px; margin: 0 0 16px; min-width: 0; }
.tcg .tcg-card legend { font-weight: 700; padding: 0 6px; font-size: 16px; }
.tcg legend span, .tcg label span, .tcg .tcg-label span { font-weight: 400; color: var(--tcg-muted); font-size: 12px; }
.tcg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tcg-wide { grid-column: 1 / -1; }
.tcg label, .tcg .tcg-label { display: block; font-size: 13px; font-weight: 600; margin: 0; }
.tcg input[type="text"], .tcg input[type="number"], .tcg input[type="date"], .tcg input[type="url"], .tcg select, .tcg textarea {
  display: block; width: 100%; padding: 8px 10px; border: 1px solid var(--tcg-line); border-radius: 6px; font: inherit;
  font-size: 14px; font-weight: 400; background: #fff; color: var(--tcg-ink); margin: 4px 0 0; }
.tcg textarea { resize: vertical; }
.tcg input:focus, .tcg select:focus, .tcg textarea:focus { outline: 2px solid var(--tcg-blue); outline-offset: 0; border-color: var(--tcg-blue); }
.tcg input[type="color"] { display: block; margin-top: 4px; width: 100%; height: 38px; padding: 2px; border: 1px solid var(--tcg-line); border-radius: 6px; background: #fff; }
.tcg .tcg-check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 12px 0 0; }
.tcg .tcg-check input { width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
.tcg .tcg-remember { margin: 0 0 16px; }
.tcg-gap { margin-top: 12px !important; }
.tcg-hint { font-size: 13px; color: var(--tcg-muted); margin: 8px 0 0; }
.tcg-hint code, .tcg code { font-size: 12px; background: var(--tcg-soft); padding: 1px 4px; border-radius: 4px; }
.tcg-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.tcg-thumb { max-height: 40px; max-width: 120px; object-fit: contain; border: 1px solid var(--tcg-line); border-radius: 4px; padding: 2px; background: #fff; }
.tcg-signer + .tcg-check { margin-top: 14px; }
.tcg-signer[data-signer="2"] { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--tcg-line); }

/* ---------- Buttons ---------- */
.tcg .tcg-btn { display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border-radius: 6px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--tcg-blue); line-height: 1.2;
  transition: background .15s, color .15s, box-shadow .15s; margin: 0; }
.tcg .tcg-btn-primary { background: var(--tcg-blue); color: #fff; box-shadow: 0 2px 6px rgba(53, 109, 241, .35); }
.tcg .tcg-btn-primary:hover:not(:disabled) { background: #2453c9; }
.tcg .tcg-btn-ghost { background: #fff; color: var(--tcg-blue); }
.tcg .tcg-btn-ghost:hover:not(:disabled) { background: var(--tcg-blue); color: #fff; }
.tcg .tcg-btn-link { background: none; border-color: transparent; color: var(--tcg-muted); text-decoration: underline; padding: 9px 6px; }
.tcg .tcg-btn:disabled { opacity: .6; cursor: progress; }
.tcg-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tcg-status { min-height: 1.2em; margin: 0; font-size: 14px; font-weight: 600; }
.tcg-status.tcg-error { color: #c62828; }

/* ---------- Signature pad ---------- */
.tcg-pad { border: 0; border-radius: 12px; padding: 20px; width: min(94vw, 640px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.tcg-pad::backdrop { background: rgba(15, 23, 42, .5); }
.tcg-pad-title { margin: 0 0 10px; font-weight: 700; }
.tcg-pad canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; border: 1px dashed var(--tcg-line, #d1d5db);
  border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; }
