/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:          #f5f4f1;
  --surface:     #ffffff;
  --border:      #e4e2dd;
  --text:        #1a1a18;
  --text-muted:  #6b6b67;
  --accent:      #1d4ed8;
  --accent-dark: #1e3a8a;
  --accent-bg:   #eff6ff;
  --red:         #dc2626;
  --radius:      10px;
  --shadow:      0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --font-sans:   'Inter', system-ui, sans-serif;
  --font-serif:  'Lora', Georgia, serif;
}

/* ── Reset / Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Container ─────────────────────────────────────────── */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.step-label {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.card-desc {
  font-size: .875rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ── Text Input ────────────────────────────────────────── */
.text-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.text-input::placeholder { color: var(--text-muted); }

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}

/* ── Letter Preview ────────────────────────────────────── */
.letter-preview {
  padding: 0;
  overflow: hidden;
}

.letter-preview-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.letter-body {
  font-family: var(--font-serif);
  font-size: .9rem;
  line-height: 1.75;
  color: var(--text);
  padding: 28px 36px 36px;
}

.letter-body p {
  margin-bottom: 1.1em;
}

.letter-date {
  margin-bottom: 1.5em;
  font-style: italic;
  color: var(--text-muted);
}

.name-slot {
  font-weight: 600;
  color: var(--accent);
  font-style: normal;
}

.name-slot:empty::before {
  content: '(Your Name / Organization)';
  color: #d97706;
  font-weight: 400;
  font-style: italic;
}

/* Signature block in letter */
.sig-block {
  margin-top: 2em;
}

.sig-closing {
  margin-bottom: 1em;
}

.sig-row {
  display: flex;
  align-items: flex-end;
  gap: 20px;
}

.sig-image-area {
  width: 220px;
  height: 80px;
  border-bottom: 1.5px solid var(--text);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.sig-image-area img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.sig-empty-hint {
  font-family: var(--font-sans);
  font-size: .7rem;
  color: #d97706;
  font-style: italic;
  padding-bottom: 6px;
}

.sig-text-meta {
  padding-bottom: 4px;
  font-family: var(--font-sans);
}

.sig-name-line {
  font-size: .875rem;
  font-weight: 600;
  min-height: 1.4em;
}

.sig-date-line {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Tabs ──────────────────────────────────────────────── */
.tab-row {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
  margin-bottom: 20px;
  width: fit-content;
}

.tab {
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 7px 18px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* ── Tab Panels ────────────────────────────────────────── */
.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* ── Canvas ────────────────────────────────────────────── */
.canvas-wrap {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fafafa;
  margin-bottom: 12px;
  touch-action: none;
}

#sig-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}

/* ── Upload Area ───────────────────────────────────────── */
.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  padding: 36px 24px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
  background: #fafafa;
}

.upload-label:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.upload-icon {
  color: var(--text-muted);
  margin-bottom: 4px;
}

.upload-text {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
}

.upload-sub {
  font-size: .78rem;
  color: var(--text-muted);
}

.upload-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.upload-preview.hidden { display: none; }

.upload-preview img {
  max-height: 120px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

/* ── Ghost Button ──────────────────────────────────────── */
.ghost-btn {
  font-family: var(--font-sans);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.ghost-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ── Action Area ───────────────────────────────────────── */
.action-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  text-align: center;
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(29,78,216,.25);
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(29,78,216,.35);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

.action-notice {
  font-size: .875rem;
  font-weight: 500;
  color: #15803d;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 10px 18px;
}

.action-notice.hidden { display: none; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  .card { padding: 22px 18px; }
  .letter-body { padding: 20px 20px 28px; font-size: .85rem; }
  .sig-row { flex-direction: column; align-items: flex-start; }
  .sig-image-area { width: 100%; }
  .submit-btn { width: 100%; justify-content: center; }
}
