/* ─── Custom Properties ─────────────────────────────── */
:root {
  --bg: #f8f9fa;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);

  /* BMI status colors */
  --underweight: #60a5fa;
  --normal: #22c55e;
  --overweight: #f59e0b;
  --obese: #ef4444;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ────────────────────────────────────────── */
header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.logo:hover {
  color: var(--primary-hover);
}

/* ─── Language Switcher ─────────────────────────────── */
.lang-switcher {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lang-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.lang-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

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

/* ─── Main ──────────────────────────────────────────── */
main {
  flex: 1;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 520px;
}

/* ─── Home: Tool Grid ───────────────────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 520px;
  margin: 0 auto;
}

.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  min-height: 140px;
  padding: 1.5rem 1rem;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.tool-card .icon {
  font-size: 2.5rem;
  line-height: 1;
}

.tool-card .label {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ─── Calculator Card ───────────────────────────────── */
.calc-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2rem 1.5rem;
}

/* ─── Input Groups ──────────────────────────────────── */
.input-group {
  margin-bottom: 1.25rem;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unit-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 1.75rem;
  text-align: center;
}

.field-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.125rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s;
  background: var(--bg);
  min-width: 0;
}

.field-input:focus {
  border-color: var(--primary);
  outline: none;
}

.field-input[type="date"] {
  font-size: 1rem;
}

.unit-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* ─── Toggle Pills ──────────────────────────────────── */
.toggle-group {
  display: flex;
  gap: 4px;
  margin-bottom: 0.625rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 3px;
  width: fit-content;
}

.toggle-btn {
  background: transparent;
  border: none;
  border-radius: 9999px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 4px 14px;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ─── Result Display ─────────────────────────────────── */
.result-section {
  margin-top: 1.75rem;
  text-align: center;
}

.result-number {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  letter-spacing: -2px;
}

.result-unit {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Age result: three columns */
.result-triple {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.result-triple .result-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.result-triple .result-number {
  font-size: 3rem;
}

.result-triple .result-unit {
  font-size: 1rem;
  margin-left: 0;
}

/* Days secondary */
.result-secondary {
  margin-top: 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ─── BMI Scale Bar ──────────────────────────────────── */
.bmi-scale {
  margin-top: 1.5rem;
  position: relative;
}

.bmi-bar {
  display: flex;
  border-radius: 9999px;
  overflow: hidden;
  height: 12px;
}

.bmi-bar-seg {
  flex: 1;
}

.bmi-bar-seg.underweight { background: var(--underweight); }
.bmi-bar-seg.normal      { background: var(--normal);      flex: 1.3; }
.bmi-bar-seg.overweight  { background: var(--overweight);  }
.bmi-bar-seg.obese       { background: var(--obese);       flex: 2; }

.bmi-pointer-track {
  position: relative;
  height: 20px;
  margin-top: 4px;
}

.bmi-pointer {
  position: absolute;
  top: 0;
  width: 14px;
  height: 14px;
  background: var(--text);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transform: translateX(-50%);
  transition: left 0.25s ease;
}

.bmi-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.bmi-status {
  margin-top: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.bmi-status.underweight { color: var(--underweight); }
.bmi-status.normal      { color: var(--normal); }
.bmi-status.overweight  { color: var(--overweight); }
.bmi-status.obese       { color: var(--obese); }

/* ─── Divider ────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ─── Footer / Ad slot ───────────────────────────────── */
footer {
  padding: 1rem;
  display: flex;
  justify-content: center;
}

.ad-slot {
  max-width: 728px;
  width: 100%;
  min-height: 90px;
  background: transparent;
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 400px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .result-number {
    font-size: 2.75rem;
  }

  .result-triple .result-number {
    font-size: 2.25rem;
  }

  .calc-card {
    padding: 1.25rem 1rem;
  }

  header {
    height: auto;
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.375rem;
  }
}

@media (min-width: 640px) {
  main {
    padding: 2.5rem 1.5rem;
  }

  .calc-card {
    padding: 2.5rem 2rem;
  }
}
