/* ===== GLOBAL STYLES ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3354;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --text: #e8eaf6;
  --muted: #8892b0;
  --danger: #ff4f6a;
  --warn: #ffb347;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(108,99,255,0.15);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== NAV ===== */
nav {
  background: rgba(15,17,23,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 2rem;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}
.nav-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  list-style: none;
}
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--surface2);
}
.nav-links a.active { color: var(--accent); }

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, #0f1117 0%, #1a1d27 50%, #131729 100%);
  padding: 4rem 2rem 3rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -60px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 300px;
  background: radial-gradient(ellipse, rgba(108,99,255,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #fff 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
}
.layout-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 768px) {
  .layout-2col { grid-template-columns: 1fr; }
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title .icon { font-size: 1.3rem; }

/* ===== CALCULATOR DISPLAY ===== */
.calc-display {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  text-align: right;
}
.calc-display .expr {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2rem;
  margin-bottom: 0.25rem;
  word-break: break-all;
}
.calc-display .result {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

/* ===== BUTTONS GRID ===== */
.btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.btn-grid button {
  padding: 0.9rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface2);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
}
.btn-grid button:hover { background: var(--border); transform: translateY(-1px); }
.btn-grid button:active { transform: translateY(0); }
.btn-grid .btn-op { background: rgba(108,99,255,0.15); color: var(--accent); border-color: rgba(108,99,255,0.3); }
.btn-grid .btn-op:hover { background: rgba(108,99,255,0.25); }
.btn-grid .btn-eq { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-grid .btn-eq:hover { background: #7c74ff; }
.btn-grid .btn-clear { background: rgba(255,79,106,0.15); color: var(--danger); border-color: rgba(255,79,106,0.3); }
.btn-grid .btn-clear:hover { background: rgba(255,79,106,0.25); }
.btn-grid .btn-wide { grid-column: span 2; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input, .form-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: 'Inter', sans-serif;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-group select option { background: var(--surface); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Space Grotesk', sans-serif;
  margin-top: 0.5rem;
}
.btn-primary:hover { background: #7c74ff; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(108,99,255,0.4); }

/* ===== RESULT BOX ===== */
.result-box {
  background: rgba(0,212,170,0.08);
  border: 1px solid rgba(0,212,170,0.25);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
}
.result-box .result-label {
  font-size: 0.78rem;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.3rem;
  font-weight: 500;
}
.result-box .result-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent2);
}
.result-box .result-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.5rem;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.result-row:last-child { border-bottom: none; }
.result-row span:first-child { color: var(--muted); }
.result-row span:last-child { font-weight: 600; color: var(--text); }

/* ===== SEO DESCRIPTION ===== */
.seo-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4rem 2rem;
}
.seo-section .seo-inner {
  max-width: 900px;
  margin: 0 auto;
}
.seo-section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}
.seo-section h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.75rem 0 0.6rem;
  color: var(--accent);
}
.seo-section p {
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 0.75rem;
  font-size: 0.97rem;
}
.seo-section ul {
  padding-left: 1.5rem;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 2;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.faq-q {
  padding: 1rem 1.25rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
  color: var(--text);
}
.faq-q:hover { background: var(--surface2); }
.faq-a {
  padding: 0 1.25rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.75;
}
.faq-item.open .faq-a { max-height: 300px; padding: 0.75rem 1.25rem 1.25rem; }
.faq-item.open .faq-arrow { transform: rotate(180deg); }
.faq-arrow { transition: transform 0.3s; font-size: 0.75rem; color: var(--muted); }

/* ===== FOOTER ===== */
footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
footer a { color: var(--accent); text-decoration: none; }

/* ===== CHIPS ===== */
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover, .chip.active { background: rgba(108,99,255,0.2); border-color: var(--accent); color: var(--accent); }

/* ===== UNIT CONVERTER ===== */
.convert-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}
.swap-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-bottom: 0.05rem;
}
.swap-btn:hover { background: rgba(108,99,255,0.2); transform: rotate(180deg); }

/* ===== PERCENTAGE VISUAL ===== */
.pct-bar-wrap { background: var(--bg); border-radius: 8px; height: 12px; margin: 0.75rem 0; overflow: hidden; }
.pct-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 8px; transition: width 0.5s ease; width: 0%; }

/* ===== BMI METER ===== */
.bmi-meter {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, #00d4aa 0%, #6c63ff 40%, #ffb347 70%, #ff4f6a 100%);
  position: relative;
  margin: 1rem 0 0.4rem;
}
.bmi-needle {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 24px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.6s ease;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}
.bmi-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.bmi-cat {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

/* ===== HISTORY LOG ===== */
.history-log {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.history-log::-webkit-scrollbar { width: 4px; }
.history-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.history-entry {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(46,51,84,0.5);
  color: var(--muted);
}
.history-entry span:last-child { color: var(--text); font-weight: 500; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1.5rem; background: var(--bg); border-radius: 10px; padding: 4px; }
.tab-btn {
  flex: 1;
  padding: 0.55rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.tab-btn.active { background: var(--surface2); color: var(--text); }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .hero { padding: 2.5rem 1rem 2rem; }
  .container { padding: 2rem 1rem; }
  .btn-grid button { padding: 0.75rem 0.3rem; font-size: 0.92rem; }
  .calc-display .result { font-size: 1.8rem; }
  .convert-row { grid-template-columns: 1fr auto 1fr; gap: 0.5rem; }
}