:root {
  color-scheme: light;
  --brand-accent: #2563eb;
  --ink: #14243b;
  --muted: #637187;
  --soft: #8995a7;
  --paper: #f2f5f9;
  --card: #fbfdff;
  --card-strong: #ffffff;
  --line: #d6dfeb;
  --line-strong: #b7c5d8;
  --blue: #2563eb;
  --blue-dark: #174ea6;
  --blue-soft: #e8f0ff;
  --green: #16805a;
  --green-soft: #e1f3ea;
  --red: #b33d4a;
  --shadow: 0 20px 56px rgba(23, 55, 94, 0.1);
  --subnet-blue: #2563eb;
  --subnet-green: #16805a;
  --subnet-violet: #7c5ce7;
  --subnet-amber: #d97706;
  --subnet-cyan: #0787a5;
  --subnet-rose: #c94f70;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 5%, rgba(37, 99, 235, 0.13), transparent 31rem),
    radial-gradient(circle at 7% 10%, rgba(22, 128, 90, 0.09), transparent 26rem),
    linear-gradient(180deg, #f9fbfe 0, var(--paper) 54rem);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.032) 1px, transparent 1px);
  background-size: 32px 32px;
  content: "";
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 72%);
  mask-image: linear-gradient(to bottom, black, transparent 72%);
  pointer-events: none;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 10px 14px;
  color: white;
  background: var(--blue);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
.site-footer,
main {
  width: min(1480px, calc(100% - 56px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(121, 137, 128, 0.24);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  filter: drop-shadow(0 6px 10px rgba(37, 99, 235, 0.16));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-size: 15px;
  font-weight: 820;
  letter-spacing: -0.035em;
}

.brand-name strong {
  color: var(--brand-accent);
}

.brand-tagline,
.product-lockup span,
.eyebrow,
.step-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-transform: uppercase;
}

.brand-tagline {
  color: var(--muted);
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

.product-lockup {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 2px;
}

.product-lockup span {
  color: var(--blue);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.product-lockup strong {
  font-size: 11px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.7fr);
  gap: 72px;
  align-items: end;
  padding: 76px 0 62px;
}

.eyebrow,
.step-label {
  display: block;
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.eyebrow {
  margin: 0;
}

.hero h1 {
  margin: 14px 0 0;
  font-size: clamp(48px, 6.4vw, 92px);
  font-weight: 720;
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.hero h1 em {
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.hero-copy {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.68;
}

.calculator {
  display: grid;
  gap: 22px;
}

.control-panel,
.plan-panel {
  background: rgba(251, 253, 255, 0.97);
  border: 1px solid var(--line);
  border-top: 2px solid #b9ceff;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 26px 28px 28px;
}

.panel-heading,
.plan-heading,
.table-heading,
.map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

h2,
h3,
p {
  margin-top: 0;
}

.panel-heading h2,
.plan-heading h2 {
  margin: 7px 0 0;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.text-button {
  padding: 4px 0;
  color: var(--blue);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 800;
}

.text-button:hover {
  color: var(--blue-dark);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.35fr) minmax(210px, 0.8fr);
  gap: 16px;
  align-items: end;
  margin-top: 24px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.field > span:first-child {
  font-size: 12px;
  font-weight: 800;
}

.field b {
  color: var(--red);
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  background: var(--card-strong);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.field input,
.field select {
  padding: 10px 12px;
}

.field input:hover,
.field select:hover {
  border-color: #91a7c3;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
}

.field small {
  min-height: 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.field .field-feedback.is-error {
  color: var(--red);
}

.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-weight: 800;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.plan-panel {
  padding: 32px 34px 22px;
}

.plan-caption {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.plan-actions {
  display: flex;
  gap: 8px;
}

.secondary-button {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #c6d8ff;
  font-size: 12px;
}

.secondary-button:hover {
  background: #dce8ff;
  border-color: #a9c2f7;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 28px 0 34px;
  background: #f5f8fc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.summary-grid div {
  min-width: 0;
  padding: 18px 20px;
}

.summary-grid div + div {
  border-left: 1px solid var(--line);
}

.summary-grid dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-grid dd {
  margin: 0;
  overflow: hidden;
  font: 750 18px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  text-overflow: ellipsis;
}

.map-header,
.table-heading {
  align-items: end;
}

.map-header h3,
.table-heading h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.map-header p,
.table-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.map-legend {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.map-legend i {
  width: 8px;
  height: 8px;
  background: var(--blue);
  border-radius: 50%;
}

.subnet-map {
  display: flex;
  height: 132px;
  gap: 3px;
  margin: 17px 0 40px;
  padding: 4px;
  overflow: hidden;
  background: #e7edf5;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.map-segment {
  position: relative;
  min-width: 0;
  overflow: hidden;
  color: white;
  background: var(--segment-color);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  isolation: isolate;
}

.subnet-map.is-dense .map-segment {
  border-radius: 1px;
}

.map-segment::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 52%),
    linear-gradient(0deg, rgba(8, 23, 42, 0.12), transparent);
  content: "";
}

.map-segment:hover,
.map-segment:focus-visible {
  filter: brightness(1.08);
}

.map-segment span {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  overflow: hidden;
  font: 750 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-scroll {
  margin-top: 17px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th {
  padding: 12px 14px;
  color: var(--muted);
  background: #f4f7fb;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid #e5eaf1;
  font-size: 12px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  --row-color: var(--subnet-blue);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--row-color) 6%, white), transparent 180px),
    white;
}

tbody tr:hover {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--row-color) 10%, white), transparent 240px),
    #fbfdff;
}

.subnet-cell {
  white-space: nowrap;
}

.color-button {
  width: 17px;
  height: 17px;
  margin-right: 9px;
  padding: 0;
  vertical-align: middle;
  background: var(--row-color);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--row-color);
}

.cidr,
.address-range,
.host-count {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.cidr {
  font-weight: 800;
}

.address-range {
  color: #405169;
  white-space: nowrap;
}

.host-count {
  font-weight: 750;
  text-align: right;
  white-space: nowrap;
}

.note-input {
  width: 100%;
  min-width: 140px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
}

.note-input:hover,
.note-input:focus {
  background: white;
  border-color: var(--line-strong);
  outline: 0;
}

.row-actions {
  text-align: right;
  white-space: nowrap;
}

.row-actions .icon-button + .icon-button {
  margin-left: 5px;
}

.icon-button {
  min-height: 32px;
  padding: 6px 9px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  font-size: 11px;
}

.icon-button:hover {
  color: var(--blue);
  border-color: #abc3f5;
}

.icon-button:disabled,
.secondary-button:disabled {
  color: var(--soft);
  background: #f2f4f7;
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.7;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

.privacy-note span {
  color: var(--green);
  font-size: 8px;
}

.guide {
  display: grid;
  grid-template-columns: 0.55fr 1.45fr;
  gap: 70px;
  padding: 110px 0 100px;
}

.guide > div:first-child h2 {
  max-width: 330px;
  margin: 12px 0 0;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.guide article {
  padding: 24px;
  background: rgba(251, 253, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.guide article > span {
  color: var(--blue);
  font: 750 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.guide article h3 {
  margin: 42px 0 10px;
  font-size: 17px;
}

.guide article p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

code {
  padding: 2px 5px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-radius: 4px;
  font-size: 0.92em;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 38px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.site-footer a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.site-footer .author-credit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #c6d8ff;
  border-radius: 999px;
  text-decoration: none;
  transition:
    color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.author-credit span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.author-credit strong {
  font-size: 11px;
  font-weight: 850;
}

.author-credit b {
  font-size: 12px;
}

.site-footer .author-credit:hover {
  color: white;
  background: var(--blue);
  text-decoration: none;
  transform: translateY(-1px);
}

.site-footer .author-credit:hover span {
  color: rgba(255, 255, 255, 0.74);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(360px, calc(100% - 48px));
  padding: 12px 16px;
  color: white;
  background: var(--ink);
  border-radius: 9px;
  box-shadow: 0 16px 38px rgba(13, 32, 56, 0.28);
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .control-grid {
    grid-template-columns: 1.2fr 0.8fr;
  }

  .guide {
    grid-template-columns: 1fr;
    gap: 36px;
  }
}

@media (max-width: 780px) {
  .site-header,
  .site-footer,
  main {
    width: min(100% - 32px, 1480px);
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 26px;
    padding: 58px 0 42px;
  }

  .hero h1 {
    font-size: clamp(45px, 13vw, 74px);
  }

  .control-grid,
  .summary-grid,
  .guide-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-network {
    grid-column: 1 / -1;
  }

  .summary-grid div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .summary-grid div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .plan-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .plan-actions {
    align-self: flex-start;
  }
}

@media (max-width: 560px) {
  .product-lockup,
  .map-legend {
    display: none;
  }

  .control-panel,
  .plan-panel {
    padding: 22px 18px;
    border-radius: 14px;
  }

  .panel-heading,
  .table-heading,
  .map-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .control-grid,
  .guide-grid {
    grid-template-columns: 1fr;
  }

  .field-network {
    grid-column: auto;
  }

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

  .summary-grid div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .plan-actions {
    width: 100%;
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }

  .subnet-map {
    height: 104px;
  }

  .guide {
    padding: 76px 0;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-links {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
