:root {
  --navy-950: #071426;
  --navy-900: #0b1f3a;
  --navy-800: #12365f;
  --navy-700: #175184;
  --blue-500: #2f80ed;
  --cyan-500: #1cb5c9;
  --gold-500: #f0b429;
  --green-500: #2aa876;
  --violet-500: #7967e8;
  --red-500: #d95763;
  --ink: #14213d;
  --muted: #5d6b82;
  --line: #d8e0eb;
  --surface: #ffffff;
  --surface-soft: #f4f7fb;
  --surface-blue: #eaf3ff;
  --shadow: 0 12px 30px rgba(10, 35, 66, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(47, 128, 237, 0.12), transparent 340px),
    linear-gradient(180deg, #eef4fb 0, #f7f9fc 340px, #f7f9fc 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

a {
  color: var(--navy-700);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--gold-500);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 18px 0 34px;
  padding: 14px 20px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  color: white;
  background: rgba(7, 20, 38, 0.96);
  box-shadow: 0 12px 30px rgba(7, 20, 38, 0.22);
  backdrop-filter: blur(12px);
}

.site-name {
  flex: 0 0 auto;
  color: white;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  overflow-x: auto;
}

.site-nav a {
  padding: 8px 11px;
  border-radius: 8px;
  color: #dce9f8;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: white;
  background: rgba(255,255,255,0.12);
}

.page-header {
  margin: 0 0 28px;
  padding: 8px 4px 10px;
}

.page-header h1 {
  max-width: 850px;
  margin: 0 0 10px;
  color: var(--navy-950);
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.page-header p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.page-header .article-meta {
  margin-top: 10px;
  font-size: 14px;
}

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 28px;
  padding: clamp(30px, 6vw, 64px);
  border-radius: 24px;
  color: white;
  background: linear-gradient(130deg, var(--navy-950), var(--navy-800) 65%, #176b93);
  box-shadow: 0 24px 50px rgba(7, 31, 58, 0.22);
}

.hero::after {
  position: absolute;
  right: -60px;
  bottom: -100px;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 50%;
  box-shadow: 0 0 0 45px rgba(255,255,255,0.03), 0 0 0 90px rgba(255,255,255,0.025);
  content: "";
}

.hero h1 {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 0 14px;
  font-size: clamp(38px, 7vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.hero p {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0;
  color: #dbe9f8;
  font-size: 19px;
}

.hero-kicker,
.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: #8fd8ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.breadcrumbs {
  margin: -14px 4px 22px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs a {
  color: var(--navy-700);
}

.card {
  margin-bottom: 24px;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid rgba(20, 58, 95, 0.1);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card > h2:first-child {
  margin-top: 0;
  color: var(--navy-900);
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: -0.025em;
}

.tool-finder {
  margin-top: -42px;
  padding: 22px;
}

.search-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.search-shell input {
  margin: 0;
  padding: 15px 17px;
  border: 2px solid #cbd8e8;
  border-radius: 12px;
  font-size: 17px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 4px;
}

.filter-chip {
  margin: 0;
  padding: 8px 13px;
  border: 1px solid #cbd8e8;
  border-radius: 999px;
  color: var(--navy-800);
  background: white;
  font-size: 14px;
}

.filter-chip:hover,
.filter-chip.active {
  border-color: var(--navy-700);
  color: white;
  background: var(--navy-700);
}

.discipline-grid,
.calculator-list,
.content-grid,
.related-links,
.trust-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
}

.discipline-card {
  position: relative;
  overflow: hidden;
  min-height: 175px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: white;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.discipline-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--discipline-color, var(--blue-500));
  content: "";
}

.discipline-card:hover {
  transform: translateY(-3px);
  border-color: var(--discipline-color, var(--blue-500));
  box-shadow: var(--shadow);
}

.discipline-card h3 {
  margin: 0 0 7px;
  color: var(--navy-900);
  font-size: 20px;
}

.discipline-card p {
  margin: 0;
  color: var(--muted);
}

.discipline-card .tool-count {
  display: block;
  margin-top: 16px;
  color: var(--discipline-color, var(--blue-500));
  font-size: 13px;
  font-weight: 800;
}

.calculator-link,
.related-link,
.info-box {
  position: relative;
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.calculator-link {
  border-top: 4px solid var(--accent, var(--blue-500));
}

.calculator-link:hover,
.related-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent, var(--blue-500));
  box-shadow: 0 12px 24px rgba(10, 45, 82, 0.1);
}

.calculator-link h3,
.related-link h3,
.info-box h3 {
  margin: 0 0 6px;
  color: var(--navy-900);
}

.calculator-link p,
.related-link p,
.info-box p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.tool-type {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent, var(--blue-500));
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

[data-discipline="power"] { --accent: #2f80ed; --discipline-color: #2f80ed; }
[data-discipline="circuits"] { --accent: #2aa876; --discipline-color: #2aa876; }
[data-discipline="signals"] { --accent: #7967e8; --discipline-color: #7967e8; }
[data-discipline="energy"] { --accent: #e09a22; --discipline-color: #e09a22; }
[data-discipline="students"] { --accent: #d95763; --discipline-color: #d95763; }
[data-discipline="controls"] { --accent: #1cb5c9; --discipline-color: #1cb5c9; }
[data-discipline="em"] { --accent: #8c6c3f; --discipline-color: #8c6c3f; }
[data-discipline="dsp"] { --accent: #9b51e0; --discipline-color: #9b51e0; }

.category-section {
  scroll-margin-top: 100px;
}

.category-section + .category-section {
  margin-top: 34px;
}

.category-section > h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--navy-900);
  font-size: 23px;
}

.category-section > h3::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

label {
  display: block;
  margin-top: 15px;
  color: var(--navy-900);
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  border: 1px solid #b9c8da;
  border-radius: 9px;
  color: var(--ink);
  background: white;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-500);
}

button {
  margin-top: 20px;
  padding: 11px 18px;
  border: 0;
  border-radius: 9px;
  color: white;
  background: var(--navy-800);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--navy-700);
}

.button-row,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.button-row button,
.row-actions button {
  margin-top: 0;
}

.secondary-button {
  border: 1px solid #9eb1c8;
  color: var(--navy-800);
  background: white;
}

.secondary-button:hover {
  background: var(--surface-blue);
}

.danger-button {
  color: #9e2531;
  background: #fff0f1;
}

.result {
  margin-top: 20px;
  padding: 17px;
  border: 1px solid #bcd5f1;
  border-left: 5px solid var(--blue-500);
  border-radius: 10px;
  color: var(--navy-950);
  background: var(--surface-blue);
  font-size: 19px;
  font-weight: 800;
}

.result:empty {
  display: none;
}

.result.error {
  border-color: #efc3c8;
  border-left-color: var(--red-500);
  color: #8b1e2a;
  background: #fff1f2;
}

.copy-status {
  min-height: 24px;
  margin: 8px 0 0;
  color: #18734f;
  font-size: 14px;
}

.small,
.article-meta {
  color: var(--muted);
  font-size: 14px;
}

.formula-line,
.equation {
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.equation {
  padding: 14px 16px;
  border: 1px solid #cfe0f3;
  border-radius: 10px;
  color: var(--navy-900);
  background: #edf5ff;
  font-weight: 750;
}

.notice {
  padding: 15px 17px;
  border: 1px solid #eed9a5;
  border-left: 5px solid var(--gold-500);
  border-radius: 8px;
  background: #fff9e9;
}

.companion-guide {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0 0 24px;
  padding: 17px 19px;
  border: 1px solid #bcd5f1;
  border-radius: 14px;
  background: linear-gradient(135deg, #edf6ff, #f8fbff);
}

.companion-guide strong {
  color: var(--navy-900);
}

.compact-list {
  padding-left: 21px;
}

.compact-list li + li {
  margin-top: 8px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--navy-900);
  background: #eef4fb;
}

.article-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.article-nav a {
  padding: 8px 12px;
  border: 1px solid #cbd8e8;
  border-radius: 999px;
  color: var(--navy-800);
  background: white;
  text-decoration: none;
}

.article-nav a:hover {
  color: white;
  background: var(--navy-700);
}

.dynamic-table {
  width: 100%;
}

.dynamic-table input,
.dynamic-table select {
  min-width: 90px;
  margin: 0;
}

.dynamic-table .name-input {
  min-width: 180px;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-top: 18px;
}

.summary-stat {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.summary-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-stat strong {
  display: block;
  margin-top: 4px;
  color: var(--navy-900);
  font-size: 24px;
}

.recent-list {
  display: grid;
  gap: 12px;
}

.recent-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fd);
}

.recent-item-title {
  display: inline-block;
  margin-bottom: 4px;
  font-weight: 800;
  text-decoration: none;
}

.recent-item-result,
.recent-calculation-formula {
  margin: 0;
  color: var(--muted);
}

.recent-item time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.workbench-layout {
  display: grid;
  gap: 20px;
}

.workbench-search {
  display: grid;
  gap: 14px;
}

.query-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.query-pill {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #cbd8e8;
  border-radius: 999px;
  color: var(--navy-800);
  background: #fff;
  font-size: 14px;
}

.formula-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.math-workspace-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.math-workspace-header h2,
.math-mode-card h3 {
  margin-top: 0;
}

.math-workspace-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
  min-width: min(360px, 100%);
}

.math-display-panel {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(20, 58, 95, 0.12);
  background: linear-gradient(180deg, #f8fbff 0, #edf4fc 100%);
}

.math-launchpad {
  margin-bottom: 22px;
}

.math-launch-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.math-launch-card {
  display: block;
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0, #f5f9fd 100%);
  text-decoration: none;
}

.math-launch-card h3 {
  margin: 0 0 6px;
  color: var(--navy-900);
}

.math-launch-card p {
  margin: 0;
  color: var(--muted);
}

.math-display {
  min-height: 72px;
  padding: 16px 18px;
  border: 1px solid #9eb7d4;
  border-radius: 16px;
  color: #08162a;
  background: linear-gradient(180deg, #fefefe 0, #eef4fb 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: right;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.math-display::placeholder {
  color: #95a8bf;
}

.math-memory-bar,
.math-control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.math-control-row {
  margin-bottom: 12px;
}

.math-mini-button {
  margin-top: 0;
  padding: 9px 13px;
  font-size: 13px;
}

.math-keypad {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.math-keypad button {
  margin-top: 0;
  padding: 13px 10px;
  border: 1px solid #b9c8da;
  border-radius: 12px;
  color: #103055;
  background: linear-gradient(180deg, #ffffff 0, #eaf1f8 100%);
  box-shadow: 0 2px 0 rgba(7, 20, 38, 0.06);
  font-size: 16px;
  font-weight: 800;
}

.math-keypad button:hover,
.math-keypad button:focus-visible {
  border-color: var(--navy-700);
  color: white;
  background: linear-gradient(180deg, var(--navy-700) 0, var(--navy-800) 100%);
}

.math-key-wide {
  grid-column: span 2;
}

.math-advanced-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.math-mode-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.math-mode-card p:last-child {
  margin-bottom: 0;
}

.math-graph {
  width: 100%;
  height: auto;
  margin-top: 16px;
  border: 1px solid #c7d7e8;
  border-radius: 14px;
  background: white;
}

.math-table {
  overflow-x: auto;
  margin-top: 16px;
}

.math-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 360px;
}

.math-table th,
.math-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

.math-table th {
  color: var(--navy-900);
  background: #eef4fb;
}

.math-table tr:nth-child(even) td {
  background: #fafcff;
}

.formula-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f5f9fd);
}

.formula-card h3 {
  margin-top: 0;
}

.color-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 90px;
  margin-top: 18px;
  padding: 16px 28px;
  border-radius: 999px;
  background: #d9bf8b;
  box-shadow: inset 0 0 20px rgba(64, 44, 17, 0.15);
}

.color-band {
  width: 24px;
  height: 58px;
  border: 1px solid rgba(0,0,0,0.25);
}

.color-band.tolerance-band {
  margin-left: 24px;
}

.site-footer {
  margin: 34px 0 22px;
  padding: 26px;
  border-radius: 16px;
  color: #b8c8dc;
  background: var(--navy-950);
  font-size: 14px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 13px;
}

.footer-links a {
  color: #e2edf9;
}

.site-footer p {
  margin: 0;
}

.footer-disclaimer {
  max-width: 900px;
}

.ad-space {
  min-height: 90px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border: 1px dashed #9eb1c8;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.55);
  font-size: 13px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 780px) {
  body {
    padding: 0 14px;
  }

  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .site-nav {
    width: 100%;
  }

  .hero {
    padding: 34px 24px;
  }

  .tool-finder {
    margin-top: -18px;
  }

  .search-shell {
    grid-template-columns: 1fr;
  }

  .dynamic-table {
    min-width: 720px;
  }
}

@media print {
  body {
    max-width: none;
    color: black;
    background: white;
  }

  .site-header,
  .site-footer,
  .button-row,
  .filter-chips,
  .ad-space {
    display: none;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
  }
}
