:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #22c55e;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius: 16px;
  --shadow: 0 10px 25px -5px rgba(0,0,0,0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
header {
  background: linear-gradient(135deg, #1e3a8a, #1e40af);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
  position: relative;
}
header h1 { font-size: 2.25rem; font-weight: 700; }
header p { color: #bfdbfe; margin-top: 0.5rem; }
.theme-toggle {
  position: absolute; top: 1.2rem; right: 1.5rem;
  background: rgba(255,255,255,0.15); border: none; color: white;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  font-size: 1.2rem; transition: var(--transition);
}
.theme-toggle:hover { background: rgba(255,255,255,0.25); }
nav {
  background: var(--bg-card);
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  padding: 1rem 1.5rem; justify-content: center;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
nav button {
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); padding: 0.6rem 1.2rem;
  border-radius: 999px; cursor: pointer; font-weight: 500;
  transition: var(--transition);
}
nav button:hover, nav button.active {
  background: var(--primary); color: white; border-color: var(--primary);
}
main { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem 4rem; }
.section { display: none; animation: fadeIn 0.4s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.calc-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 2rem; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.calc-card h2 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.calc-card .desc { color: var(--text-muted); margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1.2rem; }
label { display: block; margin-bottom: 0.4rem; font-weight: 500; color: #cbd5e1; }
input, select {
  width: 100%; padding: 0.85rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: #0f172a; color: var(--text);
  font-size: 1rem; transition: var(--transition);
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.btn {
  background: var(--primary); color: white; border: none;
  padding: 0.9rem 1.8rem; border-radius: 10px; font-weight: 600;
  cursor: pointer; width: 100%; margin-top: 0.5rem;
  transition: var(--transition); font-size: 1rem;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.result {
  margin-top: 1.5rem; padding: 1.25rem; background: #064e3b;
  border-radius: 12px; border-left: 4px solid var(--accent);
  display: none; animation: fadeIn 0.3s;
}
.result.show { display: block; }
.copy-btn {
  margin-top: 0.8rem; background: var(--accent); color: white; border: none;
  padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; font-size: 0.9rem;
}
.copy-btn:hover { opacity: 0.9; }
.explanation {
  margin-top: 1.5rem; padding: 1rem; background: rgba(59,130,246,0.1);
  border-radius: 10px; font-size: 0.95rem; color: var(--text-muted);
}
.explanation h3 { color: var(--primary); margin-bottom: 0.5rem; font-size: 1.1rem; }
.ad-space {
  margin-top: 1.5rem; padding: 2rem; text-align: center; border: 2px dashed var(--border);
  border-radius: 12px; color: var(--text-muted); background: rgba(255,255,255,0.03);
}
.search-box { margin-bottom: 1.5rem; }
.search-box input { max-width: 500px; margin: 0 auto; display: block; }
.history-item {
  background: var(--bg-hover); padding: 0.9rem 1rem; border-radius: 10px;
  margin-bottom: 0.6rem; border-left: 3px solid var(--primary);
  font-size: 0.95rem;
}
.history-item small { color: var(--text-muted); display: block; margin-top: 0.3rem; }
body { transition: background-color 0.3s ease, color 0.3s ease; }
.calc-card, .tool-card, nav, header { transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; }
.tool-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 1.5rem;
  border: 1px solid var(--border); cursor: pointer; transition: var(--transition);
}
.tool-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--shadow); }
.tool-card h3 { color: var(--primary); margin-bottom: 0.4rem; }
footer {
  text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem;
  border-top: 1px solid var(--border);
}
/* Light mode */
body.light {
  --bg: #f8fafc; --bg-card: #ffffff; --bg-hover: #f1f5f9;
  --text: #0f172a; --text-muted: #475569; --border: #e2e8f0;
  --shadow: 0 10px 25px -5px rgba(0,0,0,0.08);
}
body.light header { background: linear-gradient(135deg, #2563eb, #3b82f6); }
body.light input, body.light select { background: #fff; }
body.light .result { background: #ecfdf5; color: #065f46; }
@media (max-width: 600px) {
  header h1 { font-size: 1.75rem; }
  .theme-toggle { position: static; margin: 1rem auto 0; display: block; }
}
.no-results { display: none; text-align: center; color: var(--text-muted); margin-top: 2rem; }
.btn-danger { background: #ef4444 !important; margin-top: 1rem; }
.btn-danger:hover { background: #dc2626 !important; }
textarea {
  width: 100%; padding: 0.85rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 1rem; resize: vertical; font-family: inherit;
}
.footer-link { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; }
.footer-link:hover { text-decoration: underline; }
.commitment-list { margin-left: 1.2rem; margin-top: 0.5rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }