/* ==========================================================================
   EzieTools Network Tools — design system
   System fonts only, light/dark via prefers-color-scheme, no external assets.
   ========================================================================== */

:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #59636e;
  --accent: #0969da;
  --accent-contrast: #ffffff;
  --danger: #cf222e;
  --success: #1a7f37;
  --warn: #9a6700;
  --hover: rgba(9, 105, 218, 0.06);
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'JetBrains Mono', Consolas, 'SF Mono', Menlo, monospace;
  --radius: 10px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #4493f8;
    --accent-contrast: #0d1117;
    --danger: #f85149;
    --success: #3fb950;
    --warn: #d29922;
    --hover: rgba(68, 147, 248, 0.08);
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
  width: 100%;
}

img,
svg {
  display: inline-block;
  vertical-align: middle;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--hover);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

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

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--muted);
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 8px 14px;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

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

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  color: var(--accent);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  font-weight: 500;
  font-size: 14.5px;
  padding: 9px 12px;
  border-radius: 999px;
}

.site-nav a:hover {
  color: var(--accent);
  background: var(--hover);
  text-decoration: none;
}

.site-nav a[aria-current='page'] {
  color: var(--accent);
  background: var(--hover);
}

/* --------------------------------------------------------------------------
   Home page
   -------------------------------------------------------------------------- */

.hero {
  padding: 64px 0 20px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 12px;
}

.hero-sub {
  font-size: clamp(1.05rem, 2.5vw, 1.25rem);
  color: var(--muted);
  margin: 0 0 16px;
  max-width: 38em;
}

.hero-note {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 36px 0 8px;
}

.feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--muted);
}

.feature-icon {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.feature strong {
  display: block;
  color: var(--text);
  font-size: 14.5px;
  margin-bottom: 2px;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 44px 0 4px;
}

.section-sub {
  color: var(--muted);
  margin: 0 0 20px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin: 20px 0 56px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease;
}

.tool-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.tool-card-icon {
  color: var(--accent);
  margin-bottom: 4px;
}

.tool-card-name {
  font-weight: 650;
  font-size: 15.5px;
}

.tool-card-desc {
  color: var(--muted);
  font-size: 13.5px;
  flex-grow: 1;
}

.tool-card-path {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 22px 0 28px;
  font-size: 14px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-inner p {
  margin: 0;
}

.footer-nav {
  display: flex;
  gap: 18px;
}

.footer-note {
  margin-top: 10px;
}

.footer-note p {
  margin: 0;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Tool pages
   -------------------------------------------------------------------------- */

.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin: 26px 0 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.page-title {
  font-size: clamp(1.55rem, 3.5vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 4px 0 8px;
}

.tool-description {
  color: var(--muted);
  max-width: 68ch;
  margin: 0 0 24px;
}

.tool-body {
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 860px;
  padding-bottom: 30px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 650;
  margin: 0 0 14px;
}

.card > :last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type='text'],
input[type='number'],
input[type='search'],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

select {
  font-family: var(--font-ui);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--danger);
}

.field-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
}

.field-error {
  font-size: 13px;
  color: var(--danger);
  margin: 6px 0 0;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-contrast);
  transition: filter 0.12s ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  filter: brightness(0.95);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  filter: none;
}

.btn-sm {
  padding: 3px 10px;
  font-size: 12.5px;
  border-radius: 6px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
}

.segmented button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* --------------------------------------------------------------------------
   Results
   -------------------------------------------------------------------------- */

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.results-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.result-list {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.result-row {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child {
  border-bottom: 0;
}

.result-label {
  font-size: 13px;
  color: var(--muted);
  padding-top: 3px;
}

.result-value {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.value-text {
  font-family: var(--font-mono);
  font-size: 14.5px;
  word-break: break-all;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  border: 1px solid;
}

.badge-success {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}

.badge-info {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.badge-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

.badge-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.badge-neutral {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

tbody tr:hover {
  background: var(--hover);
}

td.mono,
.mono-cell {
  font-family: var(--font-mono);
  white-space: nowrap;
}

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

/* --------------------------------------------------------------------------
   Filters
   -------------------------------------------------------------------------- */

.filters {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.filter-field {
  flex: 1;
  min-width: 150px;
}

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.note {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.note-warn {
  border-left-color: var(--warn);
}

.cidr-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.cidr-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.cidr-list li:last-child {
  border-bottom: 0;
}

.cidr-list .cidr-range {
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-mono);
}

.gen-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.gen-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}

.gen-list li:last-child {
  border-bottom: 0;
}

.prose {
  max-width: 72ch;
  color: var(--text);
  padding-bottom: 40px;
}

.prose h2 {
  font-size: 1.15rem;
  margin: 28px 0 10px;
}

.prose p,
.prose li {
  color: var(--muted);
}

.prose ul {
  padding-left: 22px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.error-page {
  padding: 80px 0 60px;
  text-align: center;
}

.error-page h1 {
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: -0.03em;
  margin: 0 0 10px;
}

.error-page p {
  color: var(--muted);
  margin: 0 0 24px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .hero {
    padding: 40px 0 12px;
  }

  .result-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 14px;
  }

  .result-label {
    padding-top: 0;
  }

  .result-value {
    justify-content: flex-start;
  }

  .card {
    padding: 16px;
  }

  .filters {
    flex-direction: column;
  }
}
