:root {
  color-scheme: dark;
  --bg: #08101d;
  --surface: #0f1a2b;
  --surface-2: #15243a;
  --surface-3: #1b2c45;
  --text: #f0f5fb;
  --muted: #9eafc5;
  --line: #293b56;
  --accent: #42cab9;
  --accent-strong: #20a997;
  --accent-soft: rgba(66,202,185,.12);
  --warning: #efb957;
  --danger: #f07178;
  --ok: #62d69a;
  --shadow: 0 20px 60px rgba(0,0,0,.25);
  --radius: 18px;
  --page: 1280px;
}

body.light {
  color-scheme: light;
  --bg: #edf2f7;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --surface-3: #e9f0f6;
  --text: #142033;
  --muted: #607086;
  --line: #d7e0ea;
  --accent: #087f73;
  --accent-strong: #06685f;
  --accent-soft: rgba(8,127,115,.09);
  --warning: #986200;
  --danger: #bd343c;
  --ok: #147543;
  --shadow: 0 18px 45px rgba(24,39,58,.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  pointer-events: none;
  background: radial-gradient(circle at 75% -20%, rgba(66,202,185,.14), transparent 55%);
  z-index: -1;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(66,202,185,.35); outline-offset: 2px; }

.app-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px max(20px, calc((100vw - var(--page)) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  padding: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
}
.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.brand-copy { display: grid; line-height: 1.12; }
.brand-copy strong { font-size: 1.08rem; }
.brand-copy small { margin-top: 4px; color: var(--muted); }
.brand-copy .beta-badge { margin-top: 5px; justify-self: start; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.icon-button, .secondary-button, .back-button {
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface);
  padding: 10px 14px;
  font-weight: 700;
}
.portal-link { text-decoration: none; }
.icon-button:hover, .secondary-button:hover, .back-button:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.view { width: min(var(--page), calc(100% - 36px)); margin: 0 auto; }
.home-view { padding: 58px 0 70px; }
.hero { max-width: 860px; margin-bottom: 42px; }
.eyebrow, .category {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: .73rem;
  font-weight: 850;
  letter-spacing: .14em;
}
.hero h1 { margin-bottom: 14px; font-size: clamp(2.1rem, 5vw, 4.1rem); line-height: 1.02; letter-spacing: -.045em; }
.hero > p:not(.eyebrow) { max-width: 680px; color: var(--muted); line-height: 1.65; font-size: 1.04rem; }
.main-search {
  margin-top: 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 8px 12px 8px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.search-icon { color: var(--accent); font-size: 1.65rem; line-height: 1; transform: rotate(-20deg); }
.main-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 1rem; }
.main-search input::placeholder { color: var(--muted); }
kbd { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--muted); font: 700 .72rem ui-monospace, monospace; }

.catalog-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 32px; }
.category-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
  background: transparent;
  font-size: .86rem;
  font-weight: 750;
}
.filter-chip:hover, .filter-chip.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.result-count { color: var(--muted); font-size: .86rem; white-space: nowrap; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 20px; }
.section-heading h2 { margin-bottom: 0; font-size: clamp(1.35rem, 3vw, 1.85rem); }
.section-heading.compact { margin-bottom: 14px; }

.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tool-card {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  text-align: left;
  box-shadow: 0 8px 28px rgba(0,0,0,.10);
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.tool-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 58%, var(--line)); background: color-mix(in srgb, var(--surface) 94%, var(--accent)); }
.tool-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tool-icon, .calculator-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  font-size: 1.08rem;
  font-weight: 900;
}
.open-arrow { color: var(--muted); font-size: 1.25rem; transition: transform .16s ease; }
.tool-card:hover .open-arrow { color: var(--accent); transform: translateX(3px); }
.tool-card h3 { margin: 20px 0 8px; font-size: 1.1rem; line-height: 1.25; }
.tool-card p { margin-bottom: 18px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.tool-card .tool-category { margin-top: auto; color: var(--accent); font-size: .71rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.empty-state { padding: 55px 20px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); }
.empty-state p { margin: 7px 0 0; }
.safety-strip { display: flex; gap: 15px; align-items: flex-start; margin-top: 34px; padding: 18px 20px; border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--line)); border-radius: 15px; background: color-mix(in srgb, var(--surface) 94%, var(--warning)); }
.safety-icon { display: grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; background: var(--warning); color: #211600; font-weight: 900; }
.safety-strip strong { color: var(--warning); }
.safety-strip p { margin: 4px 0 0; color: var(--muted); line-height: 1.5; font-size: .88rem; }

.tool-view { padding: 26px 0 70px; }
.tool-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.back-button { display: inline-flex; align-items: center; gap: 8px; }
.back-button span { font-size: 1.15rem; color: var(--accent); }
.breadcrumb { color: var(--muted); font-size: .82rem; }
.calculator-page { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.calculator-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; padding: 30px 32px; border-bottom: 1px solid var(--line); }
.calculator-identity { display: flex; gap: 18px; align-items: flex-start; }
.calculator-icon { width: 60px; height: 60px; border-radius: 17px; font-size: 1.32rem; }
.calculator-header h1 { margin-bottom: 8px; font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: -.025em; }
.description { margin-bottom: 0; max-width: 760px; color: var(--muted); line-height: 1.55; }
.status-pill { flex: 0 0 auto; border: 1px solid rgba(66,202,185,.42); color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 7px 10px; font-size: .67rem; font-weight: 850; letter-spacing: .1em; }
.calculator-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.input-panel, .output-column { min-width: 0; padding: 28px 32px 32px; }
.input-panel { border-right: 1px solid var(--line); }
.output-column { background: color-mix(in srgb, var(--surface) 84%, var(--surface-2)); }
.panel-title { display: flex; gap: 11px; align-items: center; margin-bottom: 24px; }
.panel-title > span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: #061513; font-weight: 900; }
.panel-title div { display: grid; }
.panel-title strong { font-size: .95rem; }
.panel-title small { margin-top: 2px; color: var(--muted); }
.calculator-body { min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: .86rem; font-weight: 650; }
.field small { color: var(--muted); line-height: 1.42; }
input, select, textarea { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(66,202,185,.13); }
.input-group { display: grid; grid-template-columns: 1fr 84px; gap: 8px; }
.action-row { display: flex; gap: 12px; align-items: center; margin-top: 24px; flex-wrap: wrap; }
.primary-button { min-width: 150px; border: 1px solid transparent; border-radius: 11px; padding: 12px 18px; background: var(--accent); color: #061513; font-weight: 850; }
.primary-button:hover { background: var(--accent-strong); color: #fff; }
.example-button { border: 0; padding: 10px 4px; color: var(--accent); background: transparent; font-weight: 750; }
.example-button:hover { text-decoration: underline; }
.result-panel { min-height: 260px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.result-placeholder { min-height: 215px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.placeholder-symbol { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border-radius: 50%; color: var(--accent); background: var(--accent-soft); font-size: 1.45rem; font-weight: 900; }
.result-placeholder strong { color: var(--text); }
.result-placeholder p { margin: 6px 0 0; }
.result-main { margin-bottom: 15px; color: var(--accent); font-size: clamp(1.45rem, 4vw, 2.2rem); font-weight: 900; line-height: 1.15; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.metric span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .76rem; }
.metric strong { display: block; overflow-wrap: anywhere; }
.notice { margin-top: 14px; padding: 12px 13px; border-left: 4px solid var(--warning); border-radius: 8px; background: rgba(239,185,87,.08); color: var(--muted); line-height: 1.48; font-size: .86rem; }
.notice.ok { border-left-color: var(--ok); background: rgba(98,214,154,.08); }
.notice.danger { border-left-color: var(--danger); background: rgba(240,113,120,.09); }
.formula { margin-top: 13px; color: var(--muted); font: .82rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.calculator-footer { display: flex; gap: 9px; justify-content: flex-end; padding-top: 14px; flex-wrap: wrap; }
.resistor-visual { display: flex; align-items: center; justify-content: center; min-height: 100px; margin: 7px 0 18px; }
.resistor-body { position: relative; width: min(330px, 72%); height: 66px; background: #d7b27b; border-radius: 32px; box-shadow: inset 0 -9px 14px rgba(75,42,8,.18); }
.resistor-body::before, .resistor-body::after { content: ''; position: absolute; top: 30px; width: 23%; height: 6px; background: #8d99a8; }
.resistor-body::before { right: 100%; }
.resistor-body::after { left: 100%; }
.band { position: absolute; top: 5px; width: 17px; height: 56px; border-radius: 3px; border: 1px solid rgba(0,0,0,.16); }
.band:nth-child(1) { left: 19%; }.band:nth-child(2) { left: 36%; }.band:nth-child(3) { left: 53%; }.band:nth-child(4) { left: 70%; }.band:nth-child(5) { left: 83%; }
.more-tools { margin-top: 30px; }
.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.related-card { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--surface); text-align: left; }
.related-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.related-card .tool-icon { width: 40px; height: 40px; border-radius: 11px; font-size: .9rem; }
.related-card strong { display: block; font-size: .88rem; }
.related-card small { display: block; margin-top: 3px; color: var(--muted); }

@media (max-width: 1020px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calculator-layout { grid-template-columns: 1fr; }
  .input-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .output-column { background: var(--surface); }
}
@media (max-width: 720px) {
  .app-header { min-height: 68px; padding: 10px 14px; }
  .brand-copy small { display: none; }
  .icon-button { padding: 9px 11px; }
  .view { width: min(100% - 24px, var(--page)); }
  .home-view { padding-top: 35px; }
  .hero { margin-bottom: 30px; }
  .hero h1 { font-size: 2.35rem; }
  kbd { display: none; }
  .main-search { grid-template-columns: auto 1fr; min-height: 56px; }
  .catalog-toolbar { display: block; }
  .result-count { display: block; margin-top: 12px; }
  .tool-grid, .related-grid { grid-template-columns: 1fr; }
  .tool-card { min-height: 185px; }
  .tool-toolbar { align-items: flex-start; flex-direction: column; }
  .breadcrumb { display: none; }
  .calculator-header { padding: 22px 18px; }
  .calculator-identity { gap: 13px; }
  .calculator-icon { width: 48px; height: 48px; border-radius: 13px; }
  .status-pill { display: none; }
  .input-panel, .output-column { padding: 22px 18px 25px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .calculator-footer { justify-content: stretch; }
  .calculator-footer button { flex: 1; }
}
@media print {
  .app-header, .tool-toolbar, .more-tools, .calculator-footer, .action-row { display: none !important; }
  body { background: #fff; color: #000; }
  .tool-view { width: 100%; padding: 0; }
  .calculator-page { border: 0; box-shadow: none; }
  .calculator-layout { display: block; }
  .input-panel { border: 0; }
}
