/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #f59e0b;
  --secondary-hover: #d97706;
  --bg: #f8fafc;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --ruler-bg: #fffde7;
  --ruler-border: #1e293b;
  --mark-major: #1e293b;
  --mark-minor: #94a3b8;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 8px;
  --max-width: 900px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ===== HEADER ===== */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo a {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.logo a:hover {
  color: var(--primary);
  text-decoration: none;
}

.lang-switcher {
  display: flex;
  gap: 0.25rem;
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.2s;
  font-family: var(--font);
}

.lang-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.lang-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== MAIN CONTENT ===== */
main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

h1 {
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ===== SECTION CARDS ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

/* ===== CALIBRATION SECTION ===== */
.calibration-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calibration-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.calibration-field label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}

.calibration-field input,
.calibration-field select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

.calibration-field input:focus,
.calibration-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.btn-full {
  width: 100%;
}

.calibration-note {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.75rem;
  font-style: italic;
}

.calibration-status {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
}

.calibration-status.success {
  display: block;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.calibration-status.error {
  display: block;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ===== RULER ===== */
.ruler-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--ruler-bg);
  border: 2px solid var(--ruler-border);
  border-radius: var(--radius);
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.ruler-canvas-wrapper {
  position: relative;
  min-height: 160px;
}

#rulerCanvas {
  display: block;
  width: 100%;
  height: 140px;
  background: var(--ruler-bg);
}

.ruler-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-light);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ppi-display {
  font-weight: 600;
  color: var(--text);
}

.drag-hint {
  font-style: italic;
}

/* ===== MEASUREMENT RESULT ===== */
.measure-result {
  display: none;
  background: var(--secondary);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  margin-top: 1rem;
}

.measure-result.visible {
  display: block;
}

.measure-result span {
  display: inline-block;
  margin: 0 0.5rem;
}

/* ===== INSTRUCTIONS ===== */
.instructions-text {
  color: var(--text-light);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 2rem 1rem 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.footer-links a {
  font-size: 0.85rem;
  color: var(--text-light);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.footer-nav a {
  font-size: 0.85rem;
  color: var(--text-light);
}

.footer-legal {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.8;
}

.footer-legal .company {
  font-weight: 500;
}

/* ===== LEGAL PAGES ===== */
.legal-content {
  max-width: 720px;
  margin: 0 auto;
}

.legal-content h1 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
}

.legal-content h2 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.legal-content p,
.legal-content li {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.legal-content ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.placeholder-red {
  color: #dc2626;
  font-weight: 600;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  h1 {
    font-size: 1.35rem;
  }

  .calibration-grid {
    grid-template-columns: 1fr;
  }

  .header-inner {
    flex-direction: column;
    gap: 0.5rem;
  }

  .card {
    padding: 1rem;
  }

  .measure-result {
    font-size: 1rem;
  }

  .footer-links,
  .footer-nav {
    flex-direction: column;
    align-items: center;
  }
}

@media (min-width: 768px) {
  #rulerCanvas {
    height: 160px;
  }
}
/* ─── Footer inline layout ──────────────────────────── */
footer .cross-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.5rem;
  padding: 1rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}
footer .cross-links strong {
  color: #e2e8f0;
  font-weight: 600;
  margin-right: 0.25rem;
}
footer .cross-links a {
  color: #93c5fd;
  text-decoration: none;
  white-space: nowrap;
}
footer .cross-links a:hover {
  color: #fff;
  text-decoration: underline;
}
footer .footer-bottom {
  text-align: center;
  padding: 1rem 0 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}
footer .footer-bottom h4 {
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
footer .legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  font-size: 0.85rem;
}
footer .legal-links a {
  color: #64748b;
  text-decoration: none;
}
footer .legal-links a:hover {
  color: #fff;
  text-decoration: underline;
}
