:root {
  --bg: #f4f8ff;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0b1f4d;
  --muted: #63739a;
  --line: #dfe8f6;
  --primary: #246bfe;
  --primary-dark: #1857da;
  --shadow: 0 14px 40px rgba(21, 49, 93, .10);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
  color: var(--text);
  letter-spacing: 0;
}
body.dark {
  --bg: #0f172a;
  --surface: #111c32;
  --surface-soft: #17233c;
  --text: #eef5ff;
  --muted: #aab8d4;
  --line: #2b3a58;
  --shadow: 0 18px 50px rgba(0, 0, 0, .22);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button, input { font: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(223, 232, 246, .85);
  backdrop-filter: blur(18px);
}
body.dark .site-header { background: rgba(17, 28, 50, .88); }
.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  min-height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; color: var(--text); white-space: nowrap; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, #2f7cff, #0f5ad8);
  box-shadow: 0 10px 22px rgba(36, 107, 254, .28);
}
.brand-name { font-size: 20px; }
.brand-pro { padding: 4px 7px; border-radius: 6px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; }
.primary-nav { flex: 1; display: flex; justify-content: center; min-width: 0; }
.primary-nav .menu, .mobile-nav .menu { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.primary-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 13px;
  border-radius: 8px;
  color: #17315f;
  font-size: 14px;
  font-weight: 600;
}
body.dark .primary-nav a { color: var(--muted); }
.primary-nav a:hover, .primary-nav .current-menu-item a { background: #eaf2ff; color: var(--primary); }
body.dark .primary-nav a:hover { background: var(--surface-soft); }
.nav-ico { width: 16px; height: 16px; display: inline-grid; place-items: center; font-size: 14px; }
.nav-ico-home::before { content: "⌂"; }
.nav-ico-calculator::before { content: "▦"; }
.nav-ico-wallet::before { content: "◉"; }
.nav-ico-spark::before { content: "✧"; }
.nav-ico-heart::before { content: "♡"; }
.nav-ico-switch::before { content: "⇄"; }
.nav-ico-math::before { content: "π"; }
.nav-ico-post::before { content: "▤"; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.button, .icon-button, .mobile-menu-toggle {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
}
.button { padding: 0 18px; }
.button-primary { background: var(--primary); color: #fff; box-shadow: 0 10px 24px rgba(36, 107, 254, .25); }
.button-primary:hover { background: var(--primary-dark); }
.button-soft { width: 100%; background: var(--surface-soft); border: 1px solid var(--line); color: var(--text); }
.button-outline { border: 1px solid var(--primary); color: var(--primary); background: transparent; width: 100%; }
.icon-button, .mobile-menu-toggle { width: 40px; background: transparent; color: var(--text); }
.mobile-menu-toggle { display: none; }
.mobile-nav, .site-search { display: none; }
.mobile-nav.is-open, .site-search.is-open { display: block; }
.site-search {
  max-width: 740px;
  margin: 12px auto;
  padding: 0 20px;
  position: fixed;
  left: 0;
  right: 0;
  top: 72px;
  z-index: 60;
}
.site-search form, .search-form {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.site-search input, .search-form input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); padding: 0 10px; }

main { max-width: 1480px; margin: 0 auto; padding: 56px 32px 0; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(560px, 760px);
  gap: 40px;
  align-items: center;
  min-height: 520px;
}
.hero-copy h1 { margin: 0; font-size: 64px; line-height: 1.05; letter-spacing: 0; }
.hero-copy h1 span { display: block; color: var(--primary); }
.hero-copy p { max-width: 720px; margin: 26px 0; color: var(--muted); font-size: 18px; line-height: 1.8; }
.hero-search { position: relative; max-width: 640px; display: flex; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 28px rgba(21, 49, 93, .08); border-radius: 8px; overflow: visible; }
.hero-search input { flex: 1; min-width: 0; height: 56px; border: 0; outline: 0; padding: 0 22px; background: transparent; color: var(--text); }
.hero-search button { width: 58px; border: 0; border-radius: 0 8px 8px 0; background: var(--primary); color: #fff; cursor: pointer; font-size: 22px; }
.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 20;
}
.search-suggestions.is-open { display: block; }
.search-suggestions a { display: block; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.search-suggestions a:last-child { border-bottom: 0; }
.search-suggestions strong { display: block; font-size: 14px; }
.search-suggestions small { display: block; margin-top: 4px; color: var(--muted); }
.quick-tools { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 26px; }
.quick-tools a {
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  color: #17315f;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(36, 107, 254, .08);
}
body.dark .quick-tools a { background: var(--surface); color: var(--text); }
.hero-widgets { display: grid; grid-template-columns: minmax(320px, 1.35fr) minmax(260px, .95fr); gap: 22px; align-items: stretch; }
.calculator-card, .history-card, .panel, .content-page {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
body.dark .calculator-card, body.dark .history-card, body.dark .panel, body.dark .content-page { background: var(--surface); }
.calculator-card { padding: 20px; }
.calculator-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 24px; }
.calculator-tabs button { height: 44px; border: 0; background: transparent; color: var(--text); font-weight: 700; border-bottom: 3px solid transparent; cursor: pointer; }
.calculator-tabs .active { color: var(--primary); border-color: var(--primary); }
.calc-expression { min-height: 28px; text-align: right; color: var(--text); font-weight: 700; font-size: 18px; }
.calc-result { min-height: 58px; text-align: right; color: var(--primary); font-size: 38px; font-weight: 800; }
.calc-grid { display: grid; grid-template-columns: repeat(4, minmax(54px, 1fr)); gap: 8px; }
.calc-grid button {
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  font-weight: 800;
}
.calc-grid .equals { background: var(--primary); color: #fff; border-color: var(--primary); }
.history-card { padding: 24px; }
.card-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.card-heading h2, .section-heading h2 { margin: 0; font-size: 22px; }
.section-heading a { color: var(--primary); font-weight: 700; font-size: 14px; }
.history-card ul { list-style: none; margin: 0 0 18px; padding: 0; }
.history-card li { display: flex; justify-content: space-between; gap: 14px; padding: 17px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history-card strong { color: var(--primary); white-space: nowrap; }

.section { margin-top: 34px; }
.panel { padding: 24px; }
.tool-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 22px; }
.tool-card {
  position: relative;
  min-height: 260px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: transform .18s ease, box-shadow .18s ease;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(21, 49, 93, .12); }
.badge { position: absolute; top: 18px; right: 18px; padding: 4px 8px; border: 2px solid #ff334f; border-radius: 999px; color: #ff334f; font-weight: 800; font-size: 12px; background: var(--surface); }
.tool-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 24px;
}
.color-violet { background: linear-gradient(135deg, #9b7cff, #7156ec); }
.color-green { background: linear-gradient(135deg, #4ed17b, #20ad58); }
.color-orange { background: linear-gradient(135deg, #ff9a4a, #ff6533); }
.color-blue { background: linear-gradient(135deg, #77a9ff, #2f7cff); }
.color-pink, .color-rose { background: linear-gradient(135deg, #ff74bb, #ee43a0); }
.color-cyan { background: linear-gradient(135deg, #45cbd3, #15a9bf); }
.color-amber { background: linear-gradient(135deg, #ffc64f, #f5a400); }
.tool-card h3 { margin: 24px 0 12px; font-size: 17px; }
.tool-card p { min-height: 54px; margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.tool-card a { color: var(--primary); font-weight: 800; }
.category-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px; }
.category-card { padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.category-title { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.category-title .tool-icon { width: 40px; height: 40px; border-radius: 8px; font-size: 18px; }
.category-title h3 { margin: 0; font-size: 18px; }
.category-card ul { margin: 0 0 18px; padding: 0; list-style: none; }
.category-card li a { display: block; padding: 8px 0; color: var(--text); font-size: 14px; }
.dashboard-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 22px; margin-bottom: 56px; }
.post-list, .mini-list { display: grid; gap: 16px; }
.post-row, .mini-list a {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}
.post-row img, .post-thumb, .archive-placeholder, .generated-post-thumb {
  width: 92px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: linear-gradient(135deg, #2f7cff, #46d2c7);
}
.generated-post-thumb {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  font-weight: 900;
}
.generated-post-thumb::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-radius: 8px;
}
.generated-post-thumb::after {
  content: "%";
  position: absolute;
  right: 12px;
  bottom: 7px;
  font-size: 22px;
  opacity: .9;
}
.generated-post-thumb span {
  position: relative;
  z-index: 1;
  font-size: 28px;
}
.generated-finance { background: linear-gradient(135deg, #20ad58, #45cbd3); }
.generated-finance::after { content: "$"; }
.generated-health { background: linear-gradient(135deg, #ff6533, #ff74bb); }
.generated-health::after { content: "BMI"; font-size: 15px; bottom: 10px; }
.generated-percent { background: linear-gradient(135deg, #7156ec, #2f7cff); }
.generated-calc { background: linear-gradient(135deg, #2f7cff, #46d2c7); }
.generated-large {
  width: 100%;
  height: 190px;
  border-radius: 0;
}
.featured-image .generated-large {
  height: 320px;
  border-radius: 10px;
}
.post-row strong, .mini-list strong { display: block; font-size: 15px; margin-bottom: 6px; }
.post-row small, .mini-list small, .ranking-list small { display: block; color: var(--muted); line-height: 1.5; }
.mini-list a { grid-template-columns: 48px minmax(0, 1fr) auto; padding: 8px 0; }
.mini-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: #eaf2ff; color: var(--primary); font-weight: 800; }
.mini-list em { padding: 5px 10px; border-radius: 999px; background: #e5f8ed; color: #16a34a; font-style: normal; font-size: 12px; font-weight: 800; }
.ranking-list { margin: 0; padding: 0; list-style: none; counter-reset: none; }
.ranking-list li { display: grid; grid-template-columns: 28px 44px 1fr; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.ranking-list .tool-icon { width: 44px; height: 44px; border-radius: 10px; font-size: 18px; }
.ranking-list span { font-weight: 800; }
.ranking-list a { font-weight: 800; }

.content-wrap { max-width: 1180px; padding-top: 42px; }
.page-hero { margin-bottom: 26px; padding: 34px 0; }
.page-hero h1, .content-page h1 { margin: 0 0 14px; font-size: 48px; line-height: 1.1; }
.page-hero p { max-width: 720px; margin: 0; color: var(--muted); font-size: 18px; line-height: 1.7; }
.archive-search { margin-top: 24px; }
.archive-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.archive-card a { display: block; height: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.archive-card img, .archive-placeholder { width: 100%; height: 190px; border-radius: 0; }
.archive-body { display: block; padding: 20px; }
.archive-body strong { display: block; margin-bottom: 8px; font-size: 18px; }
.content-page { padding: 40px; margin-bottom: 42px; }
.entry-content { color: var(--text); line-height: 1.8; font-size: 17px; }
.entry-content h2, .entry-content h3 { margin-top: 34px; }
.entry-content a { color: var(--primary); font-weight: 700; }
.entry-meta { color: var(--muted); }
.featured-image { margin: 24px 0; overflow: hidden; border-radius: 10px; }
.featured-image img { width: 100%; }
.tool-detail-header {
  max-width: 840px;
  padding: 14px 0 22px;
}
.tool-detail-header h1 {
  margin: 0 0 12px;
  font-size: 48px;
  line-height: 1.1;
}
.tool-detail-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 18px;
}
.eyebrow { display: inline-flex; margin-bottom: 12px; color: var(--primary); font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: 0; }
.calc-grid.compact { grid-template-columns: repeat(3, 1fr); }
.calc-grid.compact button { height: 46px; font-size: 17px; }
.tool-widget { margin-bottom: 28px; }
.tool-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
}
.tool-form-head {
  grid-column: 1 / -1;
  max-width: 780px;
}
.tool-form-head h2 {
  margin: 0 0 8px;
  font-size: 28px;
}
.tool-form-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}
.tool-form label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
}
.tool-form input,
.tool-form select,
.tool-form textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 14px;
  outline: 0;
}
.tool-form textarea {
  min-height: 140px;
  padding-top: 14px;
  resize: vertical;
}
.tool-form input:focus,
.tool-form select:focus,
.tool-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 107, 254, .12);
}
.tool-form .full {
  grid-column: 1 / -1;
}
.contact-layout {
  margin-bottom: 42px;
}
.contact-form {
  max-width: 820px;
}
.notice-success,
.notice-error {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  font-weight: 800;
}
.notice-success {
  background: #e5f8ed;
  color: #12813c;
}
.notice-error {
  background: #ffe9ed;
  color: #c91d3b;
}
.tool-actions {
  display: flex;
  align-items: center;
  min-height: 50px;
}
.tool-result {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.result-grid div {
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.result-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.result-grid strong {
  display: block;
  color: var(--primary);
  font-size: 22px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.result-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.scientific-tool {
  grid-template-columns: 1fr;
}
.scientific-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.scientific-chips button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}
.detail-faq {
  margin-bottom: 28px;
}
.detail-faq details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px 18px;
  margin-top: 12px;
}
.detail-faq summary {
  cursor: pointer;
  font-weight: 800;
}
.detail-faq p {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0;
}
.detail-faq code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--primary);
}
.not-found { text-align: center; padding: 70px 28px; }
.not-found .search-form { max-width: 560px; margin: 22px auto; }
.pagination { grid-column: 1 / -1; display: flex; justify-content: center; gap: 8px; margin-top: 18px; }
.pagination .page-numbers { padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

.site-footer {
  position: relative;
  margin-top: 34px;
  padding: 42px 32px 28px;
  background: rgba(255, 255, 255, .66);
  border-top: 1px solid var(--line);
}
body.dark .site-footer { background: rgba(17, 28, 50, .68); }
.footer-grid {
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: 50px;
}
.footer-grid h3 { margin: 0 0 16px; font-size: 16px; }
.footer-grid p, .footer-grid a { color: var(--muted); line-height: 1.8; font-size: 14px; }
.footer-grid a { display: block; margin: 8px 0; }
.footer-brand p { max-width: 290px; }
.socials { display: flex; gap: 10px; margin-top: 18px; }
.socials a { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: #fff; margin: 0; font-weight: 800; }
.footer-bottom { max-width: 1360px; margin: 34px auto 0; display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.heart { color: #ef3355; }
.back-to-top {
  position: fixed;
  right: 26px;
  bottom: 24px;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 22px;
}

@media (max-width: 1200px) {
  .primary-nav { display: none; }
  .mobile-menu-toggle { display: inline-flex; }
  .mobile-nav { padding: 0 32px 18px; border-top: 1px solid var(--line); background: var(--surface); }
  .mobile-nav .menu { align-items: stretch; flex-direction: column; }
  .mobile-nav a { display: block; padding: 12px 0; font-weight: 700; }
  .hero { grid-template-columns: 1fr; }
  .hero-widgets { grid-template-columns: 1fr 1fr; }
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .article-panel { grid-column: 1 / -1; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .header-inner { padding: 0 18px; min-height: 64px; gap: 12px; }
  .brand-name { font-size: 16px; }
  .brand-pro, .login-button, .search-toggle { display: none; }
  main { padding: 32px 18px 0; }
  .hero-copy h1 { font-size: 38px; }
  .page-hero h1, .content-page h1 { font-size: 34px; }
  .tool-detail-header h1 { font-size: 36px; }
  .hero-copy p { font-size: 16px; }
  .hero-widgets, .dashboard-grid, .archive-grid { grid-template-columns: 1fr; }
  .history-card { order: -1; }
  .tool-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: 1fr; }
  .tool-form, .result-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .quick-tools a { width: 100%; }
  .calc-result { font-size: 30px; }
  .tool-card { min-height: auto; }
  .footer-grid { grid-template-columns: 1fr; gap: 22px; }
  .footer-bottom { flex-direction: column; gap: 12px; }
  .post-row { grid-template-columns: 74px 1fr; }
  .post-row img, .post-thumb, .post-row .generated-post-thumb { width: 74px; height: 62px; }
  .content-page { padding: 24px; }
  .back-to-top { width: 44px; height: 44px; }
}
