/* ===== InBrowser Tools — shared styles =====
   Mobile-first, fast, no external fonts (good for Core Web Vitals). */
:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #36d399;
  --btn-accent: #2563eb; /* darker blue so white button text meets WCAG AA (≥4.5:1) */
  --danger: #ff5d6c;
  --radius: 12px;
  --maxw: 880px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5;
    --border: #e2e6ec; --text: #1a1d24; --muted: #5b6472;
    --accent: #2563eb;  /* darker blue: readable as link/brand text on light backgrounds */
    --accent-2: #047857; /* darker green: badge/accents meet contrast on light backgrounds */
  }
}
* { box-sizing: border-box; }
/* Ensure the [hidden] attribute always wins over display:flex/grid rules. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Themed scrollbar (WebKit/Blink) */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 999px;
  border: 3px solid var(--surface); background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: var(--surface); }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); display: flex; gap: 8px; align-items: center; }
.brand span { color: var(--accent); }
.nav { display: flex; align-items: center; }
.nav > a { color: var(--muted); margin-left: 18px; font-size: .95rem; }
.nav > a:hover { color: var(--text); text-decoration: none; }

/* Language menu */
.langmenu { position: relative; margin-left: 18px; }
.langmenu > summary {
  list-style: none; cursor: pointer; color: var(--muted); font-size: .95rem;
  display: inline-flex; align-items: center; gap: 6px; -webkit-user-select: none; user-select: none; white-space: nowrap;
}
.langmenu > summary::-webkit-details-marker { display: none; }
.langmenu > summary::after { content: "▾"; font-size: .75em; opacity: .8; }
.langmenu[open] > summary, .langmenu > summary:hover { color: var(--text); }
.langmenu-list {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.3); padding: 6px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  width: 280px; max-width: calc(100vw - 24px); max-height: 64vh; overflow: auto; z-index: 30;
}
.langmenu-list a {
  display: block; margin: 0; padding: 7px 10px; border-radius: 6px;
  font-size: .9rem; color: var(--text); white-space: nowrap;
}
.langmenu-list a:hover { background: var(--surface-2); text-decoration: none; }
.langmenu-list a.current { color: var(--accent); font-weight: 600; background: var(--surface-2); }

/* Hero / headings */
main { padding: 28px 0 60px; }
h1 { font-size: 1.9rem; line-height: 1.25; margin: 10px 0 10px; }
h2 { font-size: 1.3rem; margin: 32px 0 12px; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 24px; }
.cat-intro { color: var(--muted); font-size: .95rem; margin: 0 0 14px; max-width: 70ch; }
.badge { display: inline-block; background: var(--surface-2); color: var(--accent-2);
  border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; font-size: .8rem; margin-bottom: 14px; }

/* Cards / tool grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: .9rem; }

/* Tool UI */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 18px 0; }
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
textarea, input[type=text], input[type=number], select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 1rem; font-family: inherit;
}
textarea { min-height: 160px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--btn-accent); color: #fff; border: none; border-radius: 8px;
  padding: 12px 18px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.btn:hover { opacity: .9; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.full { width: 100%; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; flex: 1 1 100px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; color: var(--accent); }
.stat span { color: var(--muted); font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; flex: 0 0 auto; }

/* Ads */
.ad-slot { margin: 26px 0; min-height: 90px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); font-size: .8rem; }

/* SEO content block */
.article { margin-top: 36px; color: var(--text); }
.article h2 { font-size: 1.25rem; }
.article p, .article li { color: var(--text); }
.faq dt { font-weight: 600; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 26px 0; color: var(--muted); font-size: .9rem; }
.site-footer a { color: var(--muted); }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.site-footer .links a { margin-right: 0; }

.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--muted); }

/* Calculator extras */
.result {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 16px 18px; margin-top: 16px;
}
.result .big { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.result .muted { color: var(--muted); font-size: .9rem; }
.formula { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: inline-block; margin: 6px 0; }
table.data { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: .92rem; }
table.data th, table.data td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
table.data th { background: var(--surface-2); }
.swatch { display: inline-block; width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--border); vertical-align: middle; margin-right: 6px; }
.resistor-bands { display: flex; gap: 6px; align-items: center; height: 60px; background: linear-gradient(var(--surface-2), var(--surface-2)); border-radius: 8px; padding: 0 24px; margin: 12px 0; position: relative; }
.resistor-bands .body { position: absolute; left: 8px; right: 8px; top: 14px; bottom: 14px; background: #d9b382; border-radius: 6px; z-index: 0; }
.resistor-bands .band { width: 10px; height: 100%; z-index: 1; border-radius: 2px; }
.error { color: var(--danger); font-size: .9rem; margin-top: 8px; }

/* Header search */
.site-header .container { gap: 14px; }
.site-search { position: relative; flex: 1 1 220px; max-width: 420px; }
.site-search input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: .95rem;
}
.site-search input:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; display: none; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 10px 12px; color: var(--text); font-size: .92rem; border-bottom: 1px solid var(--border); }
.search-results a:last-child { border-bottom: none; }
.search-results a:hover, .search-results a.active { background: var(--surface-2); text-decoration: none; }
.brand { flex: 0 0 auto; }
.nav { flex: 0 0 auto; }
@media (max-width: 560px) {
  /* Bigger body text, smaller H1 for comfortable mobile reading. */
  body { font-size: 17px; }
  h1 { font-size: 1.5rem; }
  .article p, .article li, .faq dd, .lead { font-size: 1.05rem; }

  /* Don't stick the whole header on mobile — only the search bar stays. */
  .site-header { position: static; }
  .site-header .container { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .site-search {
    order: 3; flex-basis: 100%; max-width: none;
    position: sticky; top: 0; z-index: 20;
    background: var(--surface); padding: 8px 0;
  }
}

/* "All calculators" compact list on tool pages */
.toollist-cat { font-size: 1rem; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.toollist { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.toollist a {
  display: inline-block; padding: 6px 12px; font-size: .9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; color: var(--text);
}
.toollist a:hover { border-color: var(--accent); text-decoration: none; }
.toollist a.current { background: var(--surface-2); color: var(--muted); pointer-events: none; }

/* Result breakdown, action buttons and history */
.breakdown { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: .85rem; color: var(--muted); }
.breakdown:empty { display: none; }
.bd-k { color: var(--text); font-weight: 600; }
.result-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn.sm { padding: 7px 12px; font-size: .85rem; }
.history { margin: 22px 0; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.history-title { font-weight: 600; color: var(--text); }
.history-note { font-size: .8rem; color: var(--muted); margin: 4px 0 10px; }
.history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: .9rem; }
.history-list .h-res { font-weight: 600; color: var(--accent); }
.history-list .h-in { display: block; color: var(--muted); font-size: .82rem; margin-top: 3px; }

/* Cookie consent banner */
.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center;
  gap: 12px; justify-content: center; box-shadow: 0 -6px 20px rgba(0,0,0,.25);
}
.cookie-text { margin: 0; font-size: .85rem; color: var(--muted); flex: 1 1 320px; max-width: 760px; }
.cookie-actions { display: flex; gap: 8px; flex: 0 0 auto; }
