@import url('https://cdn-uicons.flaticon.com/2.1.0/uicons-solid-rounded/css/uicons-solid-rounded.css');

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --ink: #1c2733;
  --muted: #5c6b7a;
  --line: #e3e8ef;
  --brand: #1f6feb;
  --brand-dark: #1857c0;
  --accent: #0f9d58;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
}

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

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 48px; }
.muted { color: var(--muted); }
.emoji { font-size: 1.1em; vertical-align: middle; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { margin-right: 4px; }

.search { display: flex; flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px 0 0 8px; font-size: .95rem; background: #fff;
}
.search button {
  padding: 9px 16px; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  border-radius: 0 8px 8px 0; cursor: pointer; font-weight: 600;
}
.search button:hover { background: var(--brand-dark); }

.catnav { background: var(--surface); border-bottom: 1px solid var(--line); }
.catnav-inner { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 16px; }
.catnav-link {
  color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .9rem; font-weight: 500;
}
.catnav-link:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.catnav-link.is-active { background: #e8f0fe; color: var(--brand); }
.catnav-link .emoji { margin-right: 5px; }

/* Hero */
.hero { padding: 32px 0 12px; }
.hero h1 { font-size: 2rem; margin: 0 0 8px; }
.lede { font-size: 1.08rem; color: var(--muted); margin: 0 0 16px; }
.search-big { max-width: 640px; margin: 16px 0 8px; }
.search-big input { padding: 13px 14px; font-size: 1rem; }
.search-big button { padding: 13px 22px; }

.section-title { font-size: 1.25rem; margin: 28px 0 14px; }
.section-title .emoji { margin-right: 6px; }

/* Cards / grids */
.grid { display: grid; gap: 14px; }
.cat-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.calc-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  transition: border-color .12s ease, transform .12s ease;
}
.card:hover { border-color: #c7d2e0; text-decoration: none; transform: translateY(-1px); }

.cat-card { display: flex; gap: 14px; align-items: flex-start; }
.cat-emoji { font-size: 1.6rem; color: var(--brand); line-height: 1; margin-top: 4px; }
.cat-name { font-weight: 700; color: var(--ink); }
.cat-count { color: var(--brand); font-size: .85rem; font-weight: 600; margin: 2px 0 6px; }
.cat-tag { color: var(--muted); font-size: .88rem; margin: 0; }

.calc-card { display: flex; flex-direction: column; }
.calc-emoji { font-size: 1.3rem; color: var(--brand); margin-bottom: 4px; }
.calc-name { font-weight: 700; color: var(--ink); margin: 6px 0 4px; }
.calc-short { color: var(--muted); font-size: .88rem; }

/* Breadcrumbs */
.crumbs { font-size: .85rem; color: var(--muted); margin: 4px 0 14px; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 6px; }

.cat-head h1 { font-size: 1.7rem; margin: 0 0 6px; }
.subgroup { margin-top: 8px; }

/* Calculator page */
.calc-page { max-width: 820px; }
.calc-header h1 { font-size: 1.7rem; margin: 0 0 6px; }

.calc-widget { 
  padding: 24px 30px; margin: 12px 0 32px; 
  background: #ffffff; border-radius: 16px; 
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06); 
  border: 1px solid var(--line); 
}
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; }
.field label { font-size: .88rem; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field .unit { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.field input, .field select:not(.inline-unit), .field textarea {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 1rem;
  background: #f8fafc; width: 100%; font-family: inherit; transition: all 0.2s ease;
  color: var(--ink);
}
.field input:focus, .field select:not(.inline-unit):focus, .field textarea:focus { 
  outline: none; border-color: var(--brand); 
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15); 
  background: #ffffff; 
}

.results { margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 20px; display: grid; gap: 10px; }
.result { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; background: #f8fafc; }
.res-label { color: var(--muted); font-size: .95rem; font-weight: 500; }
.res-value { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.res-unit { color: var(--muted); font-weight: 500; font-size: .85em; }
.result.is-primary {
  background: #eef6ee; border: 1px solid #cfe8d4; padding: 16px 20px;
}
.result.is-primary .res-value { color: var(--accent); font-size: 1.6rem; }
.result.is-primary .res-label { color: #2d663b; font-weight: 600; }

.formula {
  margin: 20px 0 0; background: #f3f6fb; border: 1px solid #dce4f0; border-radius: 10px;
  padding: 12px 16px; font-size: .95rem; color: var(--ink); font-family: monospace;
}

.helpful { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 24px; font-size: .92rem; }
.helpful button {
  border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px;
  cursor: pointer; font-size: .9rem;
}
.helpful button:hover { border-color: var(--brand); }
.helpful-thanks { color: var(--accent); font-weight: 600; }

/* Content */
.content h2 { font-size: 1.25rem; margin: 26px 0 8px; }
.content p { margin: 0 0 12px; }
.content .intro { font-size: 1.05rem; }
.example {
  background: #1f2630; color: #e7eef7; padding: 14px 16px; border-radius: 10px;
  overflow-x: auto; font-size: .9rem; white-space: pre-wrap; line-height: 1.6;
}
.faqs { display: grid; gap: 8px; }
.faq { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; color: var(--muted); }

.related { margin-top: 30px; }

.btn { display: inline-block; background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 600; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }

/* Unit selector inside labels */
.inline-unit {
  margin-left: 6px; padding: 2px 22px 2px 8px; font-size: 0.82rem;
  background: var(--surface) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%235c6b7a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>') no-repeat right 6px center;
  border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); font-weight: 600; cursor: pointer;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  transition: all 0.15s ease;
}
.inline-unit:hover { border-color: #cbd5e1; background-color: #f1f5f9; }
.inline-unit:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.15); }

/* Chart container */
.chart-container { padding: 8px; background: var(--bg); border-radius: var(--radius); }

/* Steps (step-by-step work) */
.steps { margin-top: 16px; padding: 14px; background: #f0f4ff; border-radius: 10px; font-size: .93rem; line-height: 1.6; }
.step { padding: 2px 0; }
.step-num { font-weight: 700; color: var(--brand); margin-right: 6px; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 0; }
.site-footer p { margin: 0 0 6px; font-size: .9rem; }
.footer-links { margin-top: 12px; display: flex; gap: 16px; }
.footer-links a { font-size: .85rem; color: var(--muted); }
.footer-links a:hover { color: var(--brand); }

/* Legal page */
.page { max-width: 720px; margin: 20px auto; }
.page h2 { font-size: 1.15rem; margin-top: 24px; }

/* Ad Banner */
.ad-banner-container {
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
  text-align: center;
  min-height: 260px; /* Force minimum height for banners */
  min-width: 300px;
  background: transparent;
  display: block;
}

/* Search Suggestions */
.search { position: relative; }
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}
.search-suggestions.is-active { display: block; }
.search-suggestion-item {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.search-suggestion-item:last-child { border-bottom: none; }
.search-suggestion-item:hover { background: #f8fafc; text-decoration: none; }
.search-suggestion-title { font-weight: 600; font-size: 0.95rem; }
.search-suggestion-cat { font-size: 0.8rem; color: var(--muted); margin-top: 2px; text-transform: capitalize; }

.desktop-only { display: block; }
.mobile-only { display: none; }

.calc-layout-with-ad {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.calc-sidebar-ad { display: none; }

@media (min-width: 900px) {
  .calc-layout-with-ad {
    flex-direction: row;
    align-items: flex-start;
  }
  .calc-sidebar-ad {
    display: block;
    width: 300px;
    flex-shrink: 0;
    min-height: 600px;
  }
}

@media (max-width: 768px) {
  .mobile-only { display: block; }
  .desktop-only { display: none; }
}

@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 10px; }
  .search { max-width: none; width: 100%; }
  .hero h1 { font-size: 1.6rem; }
  
  .catnav-inner {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    scrollbar-width: none; /* Firefox */
  }
  .catnav-inner::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Edge */
  }
  .catnav-link {
    white-space: nowrap;
  }
}
