:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --ink: #1e2320;
  --muted: #68716b;
  --faint: #8b938d;
  --line: #ddd6c8;
  --line-soft: #e7e1d5;
  --panel: #fffdf9;
  --panel-2: #efeadd;
  --green: #23725c;
  --amber: #a4690f;
  --blue: #2f6787;
  --red: #a2452f;
  --black: #141815;
  --shadow: 0 14px 40px rgba(30, 40, 34, 0.10);
  --shadow-sm: 0 2px 8px rgba(30, 40, 34, 0.06);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(30, 37, 34, 0.028) 1px, transparent 1px),
    linear-gradient(rgba(30, 37, 34, 0.028) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Noto Sans SC",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 20;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--black);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

/* Top bar ---------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 241, 233, 0.88);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex: 0 0 auto;
}

.brand-mark {
  align-self: center;
  color: var(--green);
  font-size: 18px;
  line-height: 1;
}

.brand-name {
  font-family: "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-tag {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--faint);
  font-size: 18px;
  pointer-events: none;
}

input[type="search"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 74px 0 40px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

input[type="search"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 114, 92, 0.15);
}

.search-clear {
  position: absolute;
  right: 42px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-clear:hover {
  background: var(--line);
  color: var(--ink);
}

.search-clear:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(35, 114, 92, 0.18);
}

.search-hint {
  position: absolute;
  right: 12px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--faint);
  font-family: monospace;
  font-size: 12px;
}

.count {
  flex: 0 0 auto;
  margin: 0;
  color: var(--muted);
  font-family: "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.count #match-count {
  color: var(--ink);
  font-weight: 700;
}

.count-sep {
  margin: 0 2px;
  color: var(--faint);
}

/* Shell + filters -------------------------------------------------------- */
.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease,
    background 0.15s ease, box-shadow 0.15s ease;
}

.chip:hover {
  border-color: var(--faint);
  color: var(--ink);
}

.chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(35, 114, 92, 0.18);
}

.chip.is-active {
  border-color: var(--black);
  background: var(--black);
  color: #fff;
}

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

.dot.online {
  background: var(--green);
}

.dot.protected {
  background: var(--amber);
}

.dot.asset {
  background: var(--blue);
}

.dot.route {
  background: var(--red);
}

.chip.is-active .dot {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

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

.domain-card {
  position: relative;
  display: flex;
  min-height: 210px;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.15s ease;
}

.domain-card:hover {
  border-color: var(--faint);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.domain-card.current {
  border-color: var(--black);
  background:
    linear-gradient(180deg, rgba(20, 24, 21, 0.03), transparent 60%),
    var(--panel);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.status .dot {
  background: rgba(255, 255, 255, 0.85);
}

.status.online {
  background: var(--green);
}

.status.protected {
  background: var(--amber);
}

.status.asset {
  background: var(--blue);
}

.status.route {
  background: var(--red);
}

.status.current {
  background: var(--black);
}

.here {
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.domain-name {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.purpose {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.tag {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 3px 8px;
  background: var(--panel-2);
  color: #55605a;
  font-family: "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.tag::before {
  content: "#";
  color: var(--faint);
}

.tag:hover {
  border-color: var(--green);
  background: var(--panel);
  color: var(--green);
}

.tag:focus-visible {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 114, 92, 0.18);
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--black);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--black);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.open-link .arrow {
  transition: transform 0.15s ease;
}

.open-link:hover,
.open-link:focus-visible {
  background: transparent;
  color: var(--black);
  outline: none;
}

.open-link:hover .arrow,
.open-link:focus-visible .arrow {
  transform: translateX(3px);
}

.domain-card.current .open-link {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  cursor: default;
}

.empty {
  margin: 28px 0 0;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

/* Footer ----------------------------------------------------------------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 13px;
}

.foot p {
  margin: 0;
}

.foot kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  font-family: monospace;
  font-size: 12px;
  text-align: center;
}

/* Responsive ------------------------------------------------------------- */
@media (max-width: 900px) {
  .domain-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
  }

  .brand {
    flex: 1 1 auto;
  }

  .count {
    order: 2;
  }

  .search {
    order: 3;
    flex-basis: 100%;
  }

  .search-hint {
    display: none;
  }

  .search-clear {
    right: 12px;
  }

  input[type="search"] {
    padding-right: 44px;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
