:root {
  --paper: #f3efe5;
  --ink: #18201f;
  --muted: #68706d;
  --line: #d6d0c1;
  --panel: #fffaf0;
  --panel-strong: #ebe4d4;
  --copper: #b4532a;
  --teal: #0f7b7b;
  --blueprint: #12333a;
  --gold: #d49a25;
  --ok: #0d7f50;
  --danger: #b3312b;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(18, 51, 58, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(18, 51, 58, 0.055) 1px, transparent 1px),
    var(--paper);
  background-size: 26px 26px;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.home-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 44px;
}

.site-nav,
.tool-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.site-nav {
  min-height: 52px;
  border-bottom: 1px solid rgba(24, 32, 31, 0.14);
}

.site-mark,
.tool-nav a:first-child {
  color: var(--blueprint);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 800;
}

.site-nav div {
  display: flex;
  gap: 8px;
}

.site-nav div a,
.tool-nav a {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.site-nav div a:hover,
.site-nav div a[aria-current="page"],
.tool-nav a:hover {
  border-color: var(--line);
  background: rgba(255, 250, 240, 0.72);
  color: var(--ink);
}

.tool-nav {
  margin-bottom: -6px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.8fr);
  gap: 36px;
  align-items: center;
  min-height: 520px;
  padding: 44px 0 32px;
}

.hero-copy h1,
.placeholder-panel h1 {
  margin-bottom: 16px;
  font-size: clamp(3rem, 8vw, 6.4rem);
  line-height: 0.95;
}

.hero-copy p,
.placeholder-panel p,
.tool-card p {
  color: var(--muted);
  line-height: 1.75;
}

.hero-copy > p {
  max-width: 620px;
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.primary-link,
.secondary-link,
.tool-card strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--blueprint);
  border-radius: 6px;
  background: var(--blueprint);
  color: white;
  font-weight: 900;
}

.secondary-link {
  background: transparent;
  color: var(--blueprint);
}

.hero-instrument {
  display: grid;
  place-items: center;
  min-height: 430px;
  border: 1px solid rgba(24, 32, 31, 0.14);
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 18px 45px rgba(18, 51, 58, 0.12);
}

.hero-instrument svg {
  width: min(86%, 430px);
  aspect-ratio: 1;
}

.hero-instrument circle,
.hero-instrument path {
  fill: none;
  stroke: rgba(18, 51, 58, 0.3);
  stroke-width: 0.012;
}

.hero-instrument .hero-trace {
  stroke: var(--teal);
  stroke-width: 0.035;
  stroke-linecap: round;
}

.hero-instrument .hero-point {
  fill: var(--copper);
  stroke: white;
  stroke-width: 0.02;
}

.hero-instrument .hero-target {
  fill: var(--ok);
  stroke: white;
  stroke-width: 0.02;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.tool-card {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 270px;
  padding: 24px;
  border: 1px solid rgba(24, 32, 31, 0.14);
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 14px 36px rgba(18, 51, 58, 0.1);
}

.tool-card span {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 5px;
  background: rgba(15, 123, 123, 0.1);
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 900;
}

.tool-card.planned span {
  background: rgba(212, 154, 37, 0.14);
  color: #8a5c0d;
}

.tool-card h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.tool-card strong {
  justify-self: start;
  margin-top: auto;
}

.placeholder-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  gap: 30px;
  align-items: center;
  min-height: 520px;
  margin-top: 32px;
  padding: 34px;
  border: 1px solid rgba(24, 32, 31, 0.14);
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 18px 45px rgba(18, 51, 58, 0.13);
}

.microstrip-sketch {
  display: grid;
  grid-template-rows: 48px 120px 30px;
  gap: 0;
  border: 1px solid var(--line);
  background: white;
}

.microstrip-sketch span {
  display: block;
}

.microstrip-sketch .trace {
  width: 46%;
  margin: 14px auto 0;
  background: var(--copper);
}

.microstrip-sketch .dielectric {
  background:
    linear-gradient(90deg, rgba(15, 123, 123, 0.12) 1px, transparent 1px),
    #d9eee7;
  background-size: 18px 18px;
}

.microstrip-sketch .ground {
  background: var(--blueprint);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(420px, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.control-panel,
.chart-panel {
  border: 1px solid rgba(24, 32, 31, 0.14);
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 18px 45px rgba(18, 51, 58, 0.13);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  overflow: auto;
}

.chart-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 36px);
  background: #fbf7ec;
}

.brand-row,
.chart-toolbar,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--copper);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.25rem);
}

h2 {
  font-size: 1.15rem;
}

.status-pill {
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.status-pill.good {
  border-color: rgba(13, 127, 80, 0.3);
  background: rgba(13, 127, 80, 0.1);
  color: var(--ok);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.input-pair,
.load-editor {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  background: white;
}

.input-pair:focus-within,
.load-editor:focus-within {
  outline: 2px solid rgba(15, 123, 123, 0.18);
  border-color: var(--teal);
}

.input-pair input,
.input-pair select,
.load-editor input,
.load-editor select {
  min-width: 0;
  width: 100%;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: 0;
}

input {
  padding: 0 10px;
}

select {
  padding: 0 28px 0 10px;
  border-left: 1px solid var(--line) !important;
}

.single-unit strong {
  min-width: 44px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.icon-button,
.primary-button,
.quick-actions button {
  height: 40px;
  border: 1px solid rgba(24, 32, 31, 0.16);
  border-radius: 6px;
  background: var(--blueprint);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  background: transparent;
  color: var(--blueprint);
  font-size: 1.1rem;
}

.circuit-preview {
  display: flex;
  align-items: stretch;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--line);
  background: white;
  overflow-x: auto;
}

.circuit-node,
.circuit-step {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  min-width: 92px;
  padding: 6px 8px;
}

.circuit-node::before,
.circuit-step::before {
  position: absolute;
  top: 32px;
  right: 0;
  left: 0;
  height: 4px;
  background: var(--ink);
  content: "";
}

.circuit-node:last-child::before {
  left: 0;
  right: 50%;
}

.circuit-box,
.circuit-symbol {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 54px;
  min-height: 38px;
  padding: 5px 8px;
  border: 3px solid var(--ink);
  background: white;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.circuit-symbol {
  border: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  line-height: 1;
}

.circuit-step.shunt .circuit-symbol::after {
  position: absolute;
  top: 31px;
  left: 50%;
  width: 4px;
  height: 24px;
  background: var(--ink);
  content: "";
  transform: translateX(-50%);
}

.circuit-label {
  position: relative;
  z-index: 1;
  max-width: 82px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
  white-space: normal;
}

.load-editor {
  grid-template-columns: 0.9fr 0.95fr 0.9fr 0.78fr auto;
}

.primary-button {
  min-width: 64px;
  border-radius: 0;
  background: var(--copper);
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 0.52fr;
  gap: 10px;
}

.quick-actions button {
  background: transparent;
  color: var(--blueprint);
}

.quick-actions button:first-child {
  background: var(--teal);
  color: white;
}

.step-list {
  display: grid;
  gap: 8px;
  min-height: 86px;
  max-height: 220px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}

.step-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 10px 10px 12px;
  border-left: 4px solid var(--gold);
  background: rgba(235, 228, 212, 0.62);
}

.step-list strong {
  display: block;
  margin-bottom: 2px;
}

.step-list span {
  color: var(--muted);
  font-size: 0.82rem;
}

.step-list button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 5px;
  background: rgba(179, 49, 43, 0.1);
  color: var(--danger);
  cursor: pointer;
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: auto;
  border: 1px solid var(--line);
  background: var(--line);
}

.readout div {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: white;
}

.readout span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.readout strong {
  font-size: 1rem;
}

.chart-toolbar {
  padding: 22px 24px 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.start {
  background: var(--copper);
}

.dot.path {
  background: var(--teal);
}

.dot.target {
  background: var(--ok);
}

.chart-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 6px 24px 24px;
}

#smithChart {
  width: min(100%, calc(100vh - 120px));
  max-width: 920px;
  aspect-ratio: 1;
  overflow: visible;
}

.grid-line {
  fill: none;
  stroke: rgba(18, 51, 58, 0.19);
  stroke-width: 0.006;
}

.grid-line.major {
  stroke: rgba(18, 51, 58, 0.35);
  stroke-width: 0.008;
}

.axis-line {
  stroke: rgba(24, 32, 31, 0.45);
  stroke-width: 0.007;
}

.chart-label {
  fill: rgba(24, 32, 31, 0.62);
  font-size: 0.04px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  text-anchor: middle;
}

.path-line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 0.018;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.step-path {
  fill: none;
  stroke: rgba(180, 83, 42, 0.38);
  stroke-width: 0.01;
  stroke-linecap: round;
}

.point {
  stroke: white;
  stroke-width: 0.018;
}

@media (max-width: 920px) {
  .home-hero,
  .placeholder-panel {
    grid-template-columns: 1fr;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

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

  .chart-panel {
    min-height: 62vh;
  }

  .control-panel {
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .home-shell {
    width: min(100% - 20px, 1180px);
  }

  .site-nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0;
  }

  .home-hero {
    min-height: auto;
    padding-top: 30px;
  }

  .hero-instrument,
  .placeholder-panel {
    min-height: 320px;
  }

  .placeholder-panel,
  .tool-card {
    padding: 18px;
  }

  .app-shell {
    padding: 10px;
  }

  .field-grid,
  .quick-actions,
  .readout {
    grid-template-columns: 1fr;
  }

  .load-editor {
    grid-template-columns: 1fr 1fr;
  }

  .primary-button {
    grid-column: 1 / -1;
    border-radius: 0;
  }

  .brand-row,
  .chart-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
