
:root{
  --bg:#f6f7fb;
  --text:#1f2933;
  --muted:#667085;
  --primary:#1d4ed8;
  --primary-dark:#1e40af;
  --border:#e4e7ec;
  --card:#fff;
  --shadow:0 12px 24px rgba(16,24,40,.08);
  --radius:12px;
  --radius-sm:8px;
}
body.theme-dark{
  --bg:#0f172a;
  --text:#e2e8f0;
  --muted:#94a3b8;
  --primary:#7aa2ff;
  --primary-dark:#5f89f0;
  --border:#1f2a44;
  --card:#111827;
  --shadow:0 10px 24px rgba(0,0,0,.35);
}
*{box-sizing:border-box}
body{
  font-family:"Segoe UI",Tahoma,Arial,sans-serif;
  margin:0;
  background:var(--bg);
  color:var(--text);
  line-height:1.6;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  font-size:16px;
}
a{color:var(--primary);text-decoration:none}
a:hover{color:var(--primary-dark)}
header{background:#ffffff;color:var(--text);border-bottom:1px solid var(--border)}
footer{background:#111827;color:#fff}
.container{max-width:1100px;margin:0 auto;padding:20px;width:100%}
.site-header{position:sticky;top:0;z-index:10;box-shadow:0 8px 20px rgba(16,24,40,.08)}
.header-inner{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}
.brand{color:#111827;font-weight:700;font-size:1.1rem;letter-spacing:.2px}
.site-nav{display:flex;gap:12px;flex-wrap:wrap}
.site-nav a{color:#475467;font-weight:600;padding:6px 10px;border-radius:999px}
.site-nav a:hover{background:#eef2ff;color:#1d4ed8}
.theme-toggle{
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  padding:6px 10px;
  border-radius:999px;
  font-weight:600;
  cursor:pointer;
  margin-left:auto;
}
.theme-toggle:hover{background:#f1f5f9}
body.theme-dark header{background:#0b1220}
body.theme-dark .brand{color:#e2e8f0}
body.theme-dark .site-nav a{color:#cbd5f5}
body.theme-dark .site-nav a:hover{background:#1f2a44;color:#e2e8f0}
body.theme-dark .calc-card,
body.theme-dark .calculator-box,
body.theme-dark .related,
body.theme-dark .content-card,
body.theme-dark .calc-steps,
body.theme-dark .calc-faq{
  background:var(--card);
  border-color:var(--border);
}
body.theme-dark .result{
  background:#0b1220;
  border-color:#1f2a44;
  color:#e2e8f0;
}
body.theme-dark input,
body.theme-dark textarea,
body.theme-dark .unit-select{
  background:#0b1220;
  border-color:#1f2a44;
  color:#e2e8f0;
}
.site-footer{margin-top:40px;padding:28px 0;background:#0b1220;color:#e5e7eb}
.footer-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:20px;
}
.footer-title{color:#fff;font-weight:700;margin:0 0 8px}
.footer-meta{color:#94a3b8;font-size:.9rem}
.site-footer a{color:#c7d2fe}
.site-footer a:hover{color:#fff}
.footer-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 14px;
  border-radius:999px;
  background:#4f46e5;
  color:#fff !important;
  font-weight:600;
  text-decoration:none;
  box-shadow:0 8px 16px rgba(79,70,229,.2);
}
.footer-button:hover{background:#4338ca}
.footer-bottom{
  border-top:1px solid rgba(148,163,184,.3);
  margin-top:18px;
  padding-top:14px;
  color:#94a3b8;
  font-size:.9rem;
}
main{padding:10px 0 30px;flex:1}
.calculator-layout{display:block}
.main-content{min-width:0}
.ad-sidebar .ad{margin-top:0}
h1,h2{color:#111827;line-height:1.2;margin-top:0}
p,li,label,input,textarea,button{font-size:1rem}
p{margin:0 0 12px}
main.container h1{margin-bottom:6px}
main.container h1 + p{color:var(--muted);margin-bottom:18px}
.formula-card{
  background:#f8fafc;
  border:1px solid var(--border);
  border-left:4px solid var(--primary);
  border-radius:var(--radius);
  padding:12px 14px;
  margin:0 0 16px;
  font-weight:600;
  color:#1f2937;
}
.calc-explain{color:#475467;margin:0 0 18px}
.calc-steps,
.calc-faq{
  background:#fff;
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  box-shadow:0 8px 18px rgba(16,24,40,.06);
  margin:0 0 16px;
}
.calc-example{
  background:#f8fafc;
  border:1px dashed var(--border);
  border-radius:var(--radius);
  padding:14px 16px;
  margin:0 0 16px;
}
.calc-example p{margin:0 0 6px}
.calc-example pre{
  margin:0;
  white-space:pre-wrap;
  font-family:Consolas,"Courier New",monospace;
  color:#475467;
}
.calc-dynamic{
  background:#f1f5f9;
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px 14px;
  margin:10px 0 0;
  width:100%;
}
.calc-dynamic p{margin:0 0 6px}
.calc-dynamic pre{
  margin:0;
  white-space:pre-wrap;
  font-family:Consolas,"Courier New",monospace;
  color:#475467;
}
.calc-steps h3,
.calc-faq h3{margin:0 0 10px}
.calc-steps ol{margin:0;padding-left:20px}
.calc-steps li{margin:6px 0;color:#475467}
.calc-faq dl{margin:0}
.calc-faq dt{font-weight:700;margin-top:8px}
.calc-faq dd{margin:4px 0 8px;color:#475467}
.hero{
  background:linear-gradient(135deg,#e0e7ff 0%,#f8fafc 50%,#ecfeff 100%);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:24px;
  box-shadow:var(--shadow);
}
.theme-dark .hero{
  background:linear-gradient(135deg,#0b1220 0%,#0f172a 55%,#0b1220 100%);
}
.hero p{color:var(--muted)}
.breadcrumb{
  display:flex;
  gap:8px;
  align-items:center;
  font-size:.95rem;
  color:var(--muted);
  margin:10px 0 18px;
}
.breadcrumb a{color:var(--muted)}
.breadcrumb a:hover{color:var(--primary)}
.breadcrumb span{color:var(--text);font-weight:600}
.breadcrumb .sep{color:#98a2b3;font-weight:500}
.page-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:6px 0 14px;
  flex-wrap:wrap;
}
.back-link{
  color:#475467;
  font-weight:600;
}
.back-link:hover{color:var(--primary)}
.category-chip{
  background:#eef2ff;
  color:#1d4ed8;
  border:1px solid #c7d2fe;
  padding:4px 10px;
  border-radius:999px;
  font-size:.85rem;
  font-weight:600;
}
.search-bar{
  margin-top:16px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  width:100%;
}
.search-bar input{
  flex:1 1 240px;
  min-width:180px;
}
.search-bar button{
  flex:0 0 auto;
}
.calc-grid{list-style:none;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px;padding:0;margin:20px 0 0}
.calc-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  padding:0;
  box-shadow:0 8px 18px rgba(16,24,40,.06);
}
.calc-card a{display:block;height:100%;font-weight:600;color:var(--text);padding:14px;border-radius:var(--radius-sm)}
.calc-card a:hover{background:#f8fafc}
.calc-icon{
  display:inline-flex;
  width:1.2em;
  justify-content:center;
  margin-right:8px;
}
.filter-bar{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:18px 0 8px;
}
.filter-chip{
  border:1px solid var(--border);
  background:#fff;
  color:#475467;
  padding:6px 12px;
  border-radius:999px;
  font-weight:600;
  cursor:pointer;
}
.filter-chip:hover{background:#f8fafc;color:#1d4ed8}
.filter-chip.is-active{background:#eef2ff;color:#1d4ed8;border-color:#c7d2fe}
.category-section{margin-top:22px}
.category-section h2{margin-top:0}
.calc-card a:hover{color:var(--primary)}
.calculator-box{
  background:var(--card);
  padding:22px;
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  border:1px solid var(--border);
  display:grid;
  gap:12px;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
}
label{display:block;margin-bottom:14px;font-weight:600;color:#111827}
label span{display:block;font-weight:600;margin-bottom:6px}
.unit-hint{font-weight:500;color:var(--muted);font-size:.9rem;margin-left:6px}
.input-row{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.input-row input{flex:1 1 160px}
.unit-select{
  border:1px solid var(--border);
  background:#f9fafb;
  border-radius:var(--radius-sm);
  padding:10px 10px;
  font-size:.95rem;
  color:#111827;
  min-width:90px;
}
input{
  width:100%;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  background:#f9fafb;
  font-size:1rem;
}
input:focus{
  outline:2px solid rgba(29,78,216,.2);
  border-color:var(--primary);
  background:#fff;
}
.input-error{
  border-color:#fca5a5 !important;
  background:#fff1f2 !important;
}
.input-error:focus{
  outline:2px solid rgba(248,113,113,.2);
}
button{
  padding:11px 18px;
  background:var(--primary);
  color:#fff;
  border:none;
  border-radius:999px;
  cursor:pointer;
  font-weight:600;
  box-shadow:0 10px 16px rgba(29,78,216,.2);
}
button:hover{background:var(--primary-dark)}
.calculator-box button,
.calculator-box .result{
  grid-column:1/-1;
}
.calculator-box .calc-dynamic{
  grid-column:1/-1;
}
.result{
  margin-top:15px;
  font-weight:700;
  color:#0f172a;
  background:#eff6ff;
  padding:10px 12px;
  border-radius:var(--radius-sm);
  border:1px solid #dbeafe;
}
.result.is-error{
  background:#fff1f2;
  border-color:#fecdd3;
  color:#be123c;
}
.ad{
  min-height:60px;
  margin:18px 0;
  background:#f8fafc;
  text-align:center;
  border-radius:var(--radius-sm);
  border:1px dashed #e2e8f0;
  color:#94a3b8;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:.85rem;
}
.related{
  background:#fff;
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:18px;
  box-shadow:0 8px 18px rgba(16,24,40,.06);
}
.related ul{padding-left:18px;margin:0}
.related li{margin:6px 0}
.content-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:20px;
  box-shadow:var(--shadow);
}
.contact-list{list-style:none;padding:0;margin:0}
.contact-list li{margin:8px 0}
.contact-form{display:grid;gap:12px;margin-top:12px}
textarea{
  width:100%;
  min-height:120px;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  background:#f9fafb;
  font-family:inherit;
}
@media (max-width:900px){
  .container{padding:18px}
  .hero{padding:20px}
  .calc-grid{grid-template-columns:repeat(auto-fit,minmax(200px,1fr))}
  .calculator-box{grid-template-columns:repeat(auto-fit,minmax(200px,1fr))}
}
@media (min-width:900px){
  .calculator-layout{
    display:grid;
    grid-template-columns:7fr 3fr;
    gap:24px;
    align-items:start;
  }
}
@media (max-width:700px){
  .header-inner{flex-direction:column;align-items:flex-start}
  .footer-inner{flex-direction:column;align-items:flex-start}
  .site-nav{
    width:100%;
    gap:8px;
    flex-direction:column;
    align-items:flex-start;
  }
  .site-nav a{
    display:block;
    width:100%;
    background:#f8fafc;
  }
  .menu-toggle{display:inline-flex}
  .breadcrumb{flex-wrap:wrap}
  .search-bar{flex-direction:column;align-items:stretch}
  .search-bar input,
  .search-bar button{width:100%}
  .search-bar input{padding:9px 10px}
  .search-bar button{padding:9px 12px}
  .calculator-box,.content-card,.related{padding:16px}
  button{width:100%}
}
@media (max-width:480px){
  .container{padding:14px}
  h1{font-size:1.45rem}
  h2{font-size:1.15rem}
  .calc-grid{grid-template-columns:1fr}
  .calculator-box{grid-template-columns:1fr}
  .ad{min-height:70px}
}
