:root {
  --primary: #1B3A4B;
  --primary-light: #24506A;
  --accent: #C49A2C;
  --accent-hover: #A8832A;
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-alt: #ECEEF1;
  --text: #1E2328;
  --text-secondary: #4F5B66;
  --text-muted: #8A9199;
  --border: #DBD8D1;
  --success: #2B7A4B;
  --success-bg: #EBF5EF;
  --error: #C44133;
  --error-bg: #FDF0EE;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(27,58,75,0.06), 0 1px 2px rgba(27,58,75,0.03);
  --shadow-md: 0 2px 8px rgba(27,58,75,0.08), 0 1px 3px rgba(27,58,75,0.04);
  --font-display: 'Young Serif', serif;
  --font-body: 'Figtree', sans-serif;
}

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

.hidden { display: none !important; }

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── ANIMATIONS ─── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Page load stagger */
header { animation: fadeUp 0.5s ease-out both; }
main > *:nth-child(1) { animation: fadeUp 0.45s ease-out 0.05s both; }
main > *:nth-child(2) { animation: fadeUp 0.45s ease-out 0.1s both; }
main > *:nth-child(3) { animation: fadeUp 0.45s ease-out 0.2s both; }
main > *:nth-child(4) { animation: fadeUp 0.45s ease-out 0.3s both; }
footer { animation: fadeUp 0.45s ease-out 0.35s both; }

/* ─── HEADER ─── */

header {
  background: linear-gradient(135deg, #B8510D 0%, #1B3A4B 45%, #1A5C3A 100%);
  color: #fff;
  border-bottom: 3px solid var(--accent);
}

.header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-logo {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-text h1 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 400;
  letter-spacing: 0;
}

.header-text p {
  color: rgba(255,255,255,0.6);
  font-size: 1.05rem;
  margin-top: 0.25rem;
}


/* ─── MAIN ─── */

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ─── INTRO ─── */

.intro {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.intro-main {
  flex: 1;
  min-width: 0;
}

.intro-main h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.85rem;
}

.intro-sidebar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 250px;
}

.sidebar-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.sidebar-item svg {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 2px;
}

.sidebar-item strong {
  display: block;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-item span {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ─── BACKSTORY ─── */

.backstory {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.backstory summary {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.3rem 0;
  list-style: none;
}

.backstory summary::-webkit-details-marker { display: none; }

.backstory summary::before {
  content: "\25B6\FE0E";
  display: inline-block;
  font-size: 0.6rem;
  margin-right: 0.5rem;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.backstory[open] summary::before {
  transform: rotate(90deg);
}

.backstory p {
  margin-top: 0.5rem;
  padding-left: 1.15rem;
}

.how-steps {
  list-style: none;
  counter-reset: step;
}

.how-steps li {
  counter-increment: step;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 0.45rem 0 0.45rem 2.5rem;
  position: relative;
}

.how-steps li strong {
  color: var(--text);
}

.how-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.4rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── PANEL ─── */

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border-left: 3px solid var(--accent);
  padding: 2rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(27,58,75,0.1), 0 2px 6px rgba(27,58,75,0.05);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.step-num {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1rem;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
}

.panel-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ─── DROP ZONE ─── */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.15s;
  position: relative;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: rgba(196, 154, 44, 0.04);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(196, 154, 44, 0.07);
  transform: scale(1.005);
}

.drop-zone.processing {
  pointer-events: none;
}

.drop-zone.processing::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  border-radius: inherit;
  z-index: 1;
}

.drop-zone.processing::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.75rem;
  height: 1.75rem;
  margin: -0.875rem 0 0 -0.875rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  z-index: 2;
}

.drop-icon {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  transition: transform 0.2s, color 0.2s;
}

.drop-zone:hover .drop-icon {
  transform: scale(1.1);
  color: var(--accent);
}

.drop-text {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.drop-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.drop-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

input[type="file"] { display: none; }

/* ─── SIGNATURE MODE TABS ─── */

.sig-mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.sig-mode-tab {
  flex: 1;
  padding: 0.55rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.sig-mode-tab + .sig-mode-tab {
  border-left: 1px solid var(--border);
}

.sig-mode-tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.sig-mode-tab:not(.active):hover {
  background: var(--surface-alt);
}

/* ─── SIGNATURE PAD ─── */

.sig-pad-container {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  aspect-ratio: 3 / 1;
}

.sig-pad-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.sig-pad-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.sig-pad-clear,
.sig-pad-done {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.sig-pad-clear {
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.sig-pad-clear:hover {
  background: var(--border);
}

.sig-pad-done {
  background: var(--primary);
  color: #fff;
  border: none;
}

.sig-pad-done:hover {
  background: var(--primary-light);
}

.sig-pad-clear:active,
.sig-pad-done:active {
  transform: scale(0.97);
}

/* ─── TOGGLE ─── */

.option-row {
  margin-top: 1rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.toggle input { display: none; }

.toggle-track {
  width: 2.25rem;
  height: 1.25rem;
  background: var(--border);
  border-radius: 1rem;
  position: relative;
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(1rem);
}

.toggle-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* ─── STATUS ─── */

.status {
  min-height: 1.5rem;
  margin: 0.85rem 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.status.error { color: var(--error); }
.status.success { color: var(--success); font-weight: 600; }

/* ─── PREVIEWS ─── */

.previews {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 1.25rem;
}


.preview-col {
  flex: 1;
  min-width: 0;
}


.preview-tag {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.preview-frame {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.preview-frame img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 6px;
  display: block;
}

.preview-frame.wide {
  min-height: 80px;
}

.preview-frame.wide img {
  max-height: 140px;
}

.preview-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  padding-top: 4.5rem;
}

/* ─── CHECKS ─── */

.checks {
  margin: 1rem 0 0;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  animation: slideIn 0.3s ease-out both;
}

.check-item:nth-child(1) { animation-delay: 0s; }
.check-item:nth-child(2) { animation-delay: 0.06s; }
.check-item:nth-child(3) { animation-delay: 0.12s; }
.check-item:nth-child(4) { animation-delay: 0.18s; }
.check-item:nth-child(5) { animation-delay: 0.24s; }

.check-item.pass { background: var(--success-bg); }
.check-item.fail { background: var(--error-bg); }

.check-icon {
  font-weight: 700;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

.check-item.pass .check-icon { color: var(--success); }
.check-item.fail .check-icon { color: var(--error); }

.check-label {
  font-weight: 600;
  min-width: 5.5rem;
  color: var(--text);
}

.check-detail {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ─── DOWNLOAD ─── */

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 1.25rem;
}

.download-btn:hover {
  background: var(--primary-light);
}

.download-btn:active {
  transform: scale(0.97);
}


/* ─── FOOTER ─── */

footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Specs */

.footer-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.75rem;
}

.spec-group h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.spec-group span {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* Disclaimer */

.footer-disclaimer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.25rem 1rem;
  line-height: 1.55;
}

/* Bottom line */

.footer-bottom {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.footer-bottom .heart {
  color: var(--accent);
}

.footer-sep {
  color: var(--border);
}

.footer-bottom a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
}

.footer-bottom a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── RESPONSIVE ─── */

@media (max-width: 600px) {
  body { font-size: 1rem; }

  .header-inner { padding: 1.5rem 1rem 1.25rem; gap: 1rem; }
  .header-text h1 { font-size: 1.35rem; }
  .header-text p { font-size: 0.88rem; }
  .header-logo { width: 2.25rem; height: 2.25rem; }
  .header-logo svg { width: 34px; height: 34px; }

  main { padding: 1.25rem 1rem; gap: 1.25rem; }

  .intro { flex-direction: column; gap: 1rem; }
  .intro-sidebar { width: 100%; flex-direction: row; gap: 0.5rem; }
  .sidebar-item { flex: 1; }

  .panel { padding: 1.25rem; }
  .panel-header { gap: 0.75rem; }
  .panel-header h2 { font-size: 1.25rem; }

  .drop-zone { padding: 2rem 1rem; }
  .drop-text { font-size: 0.95rem; }

  .download-btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
  }

  .previews { flex-direction: column; align-items: stretch; }
  .preview-arrow {
    padding-top: 0;
    text-align: center;
    transform: rotate(90deg);
    align-self: center;
  }
  .preview-frame { min-height: 100px; }
  .preview-frame img { max-height: 180px; }

  .footer-specs { grid-template-columns: 1fr; }
  .footer-bottom { flex-wrap: wrap; }

  /* Disable hover lift on touch devices */
  .panel:hover {
    transform: none;
    box-shadow: var(--shadow-md);
  }
}

/* ─── DARK MODE ─── */

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #4B9AC5;
    --primary-light: #5EADD6;
    --accent: #D4AA3C;
    --accent-hover: #C49A2C;
    --bg: #141618;
    --surface: #1E2124;
    --surface-alt: #282C30;
    --text: #E2E4E7;
    --text-secondary: #A0A6AD;
    --text-muted: #6B7280;
    --border: #363A3F;
    --success: #4ADE80;
    --success-bg: rgba(74,222,128,0.1);
    --error: #F87171;
    --error-bg: rgba(248,113,113,0.1);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.25);
  }

  header {
    background: linear-gradient(135deg, #7A360A 0%, #122630 45%, #123A26 100%);
  }

  .panel:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.3);
  }

  .drop-zone.processing::before {
    background: rgba(30, 33, 36, 0.88);
  }

  .toggle-thumb {
    background: var(--surface-alt);
  }

  .header-logo svg path {
    stroke: rgba(255,255,255,0.25);
  }

  .sig-pad-container {
    border-color: var(--border);
  }
}
