@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── CSS Variables ─────────────────────────────── */
:root {
  --ink: #0F1729;
  --ink-soft: #1C2638;
  --paper: #FAF8F3;
  --paper-dim: #F1EDE3;
  --amber: #E8A33D;
  --amber-dark: #C8842A;
  --slate: #5C6B7A;
  --slate-light: #8B97A3;
  --green: #3D8B5F;
  --red: #C75450;
  --border: #E2DDD2;
  --shadow-sm: 0 1px 3px rgba(15,23,41,0.06);
  --shadow-md: 0 4px 16px rgba(15,23,41,0.10);
  --shadow-lg: 0 8px 32px rgba(15,23,41,0.13);
  --radius: 10px;
  --radius-sm: 6px;
  --max-w: 1120px;
  --transition: 180ms ease;
}

/* ─── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ─── Typography ─────────────────────────────────── */
.font-display { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.02em; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.02em; line-height: 1.2; }

/* ─── Layout ─────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Header ─────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
}
.header-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.03em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.header-logo-dot {
  width: 8px;
  height: 8px;
  background: var(--amber);
  border-radius: 50%;
  display: inline-block;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
.header-nav a {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--slate);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.header-nav a:hover { color: var(--ink); background: var(--paper-dim); }
.header-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--slate-light);
  background: var(--paper-dim);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Breadcrumb ─────────────────────────────────── */
.breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--slate-light);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--slate); }
.breadcrumb a:hover { color: var(--amber-dark); }
.breadcrumb-sep { color: var(--border); }

/* ─── Tool Page Layout ───────────────────────────── */
.tool-page { flex: 1; padding: 40px 0 64px; }
.tool-header { margin-bottom: 32px; }
.tool-icon-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}
.tool-icon-tile {
  width: 48px;
  height: 48px;
  background: var(--paper-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tool-icon-tile svg { width: 24px; height: 24px; stroke: var(--ink); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tool-page-title { font-size: clamp(22px, 4vw, 30px); font-weight: 600; }
.tool-page-desc { color: var(--slate); margin-top: 4px; }

/* ─── Panel ──────────────────────────────────────── */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 16px;
}
.result-area {
  background: var(--paper-dim);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  color: var(--ink);
  min-height: 60px;
}
.result-area.is-error { border-color: var(--red); color: var(--red); }
.result-area.is-success { border-color: var(--green); }
.result-empty { color: var(--slate-light); font-style: italic; }

/* ─── Stats Grid ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.stat-card {
  background: var(--paper-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11.5px;
  color: var(--slate-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ─── Form Elements ──────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: 6px;
}
input[type="text"], input[type="number"], input[type="date"], input[type="url"],
textarea, select {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--slate-light); }
input:focus, textarea:focus, select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232,163,61,0.15);
}
textarea { resize: vertical; min-height: 140px; line-height: 1.6; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%235C6B7A' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-row { margin-bottom: 16px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  transition: background var(--transition), color var(--transition), transform 80ms, box-shadow var(--transition);
  border: 1.5px solid transparent;
  line-height: 1;
}
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-soft); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--slate-light); background: var(--paper-dim); }
.btn-amber { background: var(--amber); color: var(--ink); border-color: var(--amber); }
.btn-amber:hover { background: var(--amber-dark); border-color: var(--amber-dark); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ─── Tabs ───────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--paper-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
  margin-bottom: 20px;
}
.tab-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
  padding: 7px 16px;
  border-radius: 5px;
  transition: all var(--transition);
  border: none;
  background: none;
}
.tab-btn.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Checkbox / Range ───────────────────────────── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
}
.checkbox-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--amber-dark);
  cursor: pointer;
  flex-shrink: 0;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--amber-dark);
  height: 4px;
  cursor: pointer;
  padding: 0;
  border: none;
  box-shadow: none;
}
input[type="range"]:focus { box-shadow: none; }
input[type="range"]:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }

/* ─── Pill / Badge ───────────────────────────────── */
.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  letter-spacing: 0.04em;
}
.pill-green { background: #d4eddf; color: var(--green); }
.pill-amber { background: #fcefd6; color: var(--amber-dark); }
.pill-red { background: #f5dada; color: var(--red); }
.pill-slate { background: var(--paper-dim); color: var(--slate); }

/* ─── Error / Success inline ─────────────────────── */
.field-error { font-size: 12.5px; color: var(--red); margin-top: 5px; display: block; }
.field-success { font-size: 12.5px; color: var(--green); margin-top: 5px; display: block; }

/* ─── Section label ──────────────────────────────── */
.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--slate-light);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

/* ─── Related Tools ──────────────────────────────── */
.related-tools { margin-top: 48px; }
.related-tools-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--slate-light);
  margin-bottom: 14px;
}
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.related-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.related-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.related-card-icon { width: 34px; height: 34px; background: var(--paper-dim); border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.related-card-icon svg { width: 18px; height: 18px; stroke: var(--ink); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.related-card-name { font-family: 'Space Grotesk', sans-serif; font-size: 14px; font-weight: 600; }
.related-card-arrow { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--slate-light); margin-left: auto; transition: color var(--transition); }
.related-card:hover .related-card-arrow { color: var(--amber-dark); }

/* ─── Toast ──────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--paper);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 100px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 999;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Footer ─────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: auto;
}
.site-footer .container { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-left { font-size: 13px; color: var(--slate-light); }
.footer-left strong { color: var(--slate); font-weight: 500; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { font-size: 13px; color: var(--slate-light); transition: color var(--transition); }
.footer-links a:hover { color: var(--amber-dark); }

/* ─── Homepage Hero ──────────────────────────────── */
.hero { padding: 64px 0 48px; }
.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--slate);
  margin-bottom: 20px;
}
.hero-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; animation: pulse-dot 2.4s ease infinite; }
@keyframes pulse-dot { 0%,100%{box-shadow:0 0 0 0 rgba(61,139,95,0.4)} 50%{box-shadow:0 0 0 5px rgba(61,139,95,0)} }
.hero-headline { font-size: clamp(32px, 6vw, 52px); font-weight: 700; max-width: 640px; margin-bottom: 12px; }
.hero-headline span { color: var(--amber-dark); }
.hero-sub { font-size: 16px; color: var(--slate); max-width: 520px; margin-bottom: 32px; }
.hero-search {
  position: relative;
  max-width: 440px;
}
.hero-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-light);
  pointer-events: none;
}
.hero-search input {
  padding-left: 42px;
  font-size: 14.5px;
  background: #fff;
  border-color: var(--border);
  border-radius: var(--radius);
  height: 46px;
}

/* ─── Tool Grid ──────────────────────────────────── */
.tools-section { padding-bottom: 48px; }
.tools-group { margin-bottom: 48px; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 20px; }
.tool-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
}
.tool-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tool-card-icon {
  width: 38px;
  height: 38px;
  background: var(--paper-dim);
  border: 1px solid var(--border);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tool-card-icon svg { width: 20px; height: 20px; stroke: var(--ink); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tool-card-name { font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-weight: 600; }
.tool-card-desc { font-size: 13px; color: var(--slate); line-height: 1.5; flex: 1; }
.tool-card-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--slate-light);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
  margin-top: 4px;
}
.tool-card:hover .tool-card-link { color: var(--amber-dark); }

/* ─── Color Swatch ───────────────────────────────── */
.color-swatch {
  width: 100%;
  height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background 200ms ease;
}

/* ─── BMI Scale Bar ──────────────────────────────── */
.scale-bar-wrap { margin-top: 16px; }
.scale-bar-track { height: 10px; border-radius: 100px; background: linear-gradient(to right, #6baed6 0%, #74c476 18.5%, #74c476 50%, #fd8d3c 62.5%, #e6550d 100%); position: relative; margin-bottom: 6px; }
.scale-bar-marker { position: absolute; top: -4px; width: 18px; height: 18px; background: var(--ink); border: 3px solid #fff; border-radius: 50%; transform: translateX(-50%); box-shadow: var(--shadow-sm); transition: left 400ms ease; }
.scale-bar-labels { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--slate-light); }

/* ─── Strength Meter ─────────────────────────────── */
.strength-bar-wrap { margin-top: 12px; }
.strength-bar-track { height: 6px; background: var(--border); border-radius: 100px; overflow: hidden; }
.strength-bar-fill { height: 100%; border-radius: 100px; transition: width 300ms ease, background 300ms ease; width: 0; }
.strength-label { font-size: 12px; color: var(--slate-light); margin-top: 5px; font-family: 'JetBrains Mono', monospace; }

/* ─── Amortization Bar ───────────────────────────── */
.amort-bar { height: 22px; border-radius: var(--radius-sm); overflow: hidden; display: flex; margin-top: 12px; }
.amort-principal { background: var(--ink); }
.amort-interest { background: var(--amber); }
.amort-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--slate); }
.amort-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ─── QR Canvas ──────────────────────────────────── */
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 20px; }
#qr-canvas { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; display: none; }
.qr-placeholder { width: 200px; height: 200px; border: 1.5px dashed var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--slate-light); font-size: 13px; font-family: 'JetBrains Mono', monospace; }

/* ─── Image compressor ───────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--slate);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--amber); background: #fdf6e8; }
.drop-zone input[type="file"] { display: none; }
.drop-zone-icon { margin: 0 auto 12px; }
.image-preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.image-preview-box { text-align: center; }
.image-preview-box img { max-width: 100%; max-height: 200px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 8px; }
.image-preview-label { font-size: 12px; color: var(--slate-light); font-family: 'JetBrains Mono', monospace; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 640px) {
  .header-nav { display: none; }
  .hero { padding: 40px 0 32px; }
  .panel { padding: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .image-preview-grid { grid-template-columns: 1fr; }
  .site-footer .container { flex-direction: column; }
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .related-grid { grid-template-columns: 1fr; }
  .tab-bar { width: 100%; }
  .tab-btn { flex: 1; text-align: center; }
}

/* ─── Reduced Motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .hero-dot { animation: none; }
}

/* ─── Focus Styles ───────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 3px;
}
