:root {
  color-scheme: light;
  --page: #f4f5f8;
  --text: #111318;
  --muted: #646b7a;
  --panel-bg: rgb(255 255 255 / 0.72);
  --panel-solid: #ffffff;
  --panel-border: rgb(15 23 42 / 0.08);
  --panel-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.92),
    0 1px 2px rgb(15 23 42 / 0.03),
    0 24px 60px -16px rgb(15 23 42 / 0.085);
  --divider: rgb(15 23 42 / 0.06);
  --item-hover: rgb(15 23 42 / 0.036);
  --item-rec-bg: rgb(255 255 255 / 0.95);
  --item-rec-border: rgb(15 23 42 / 0.09);
  --item-rec-shadow:
    0 1px 2px rgb(15 23 42 / 0.03),
    0 6px 18px -6px rgb(15 23 42 / 0.065);
  --index-color: #8b93a4;
  --control-hover: rgb(15 23 42 / 0.055);
  --control-border: rgb(15 23 42 / 0.1);
  --action: #14161d;
  --action-hover: #282c3a;
  --action-text: #ffffff;
  --tag-bg: rgb(16 163 109 / 0.1);
  --tag-text: #0c7d53;
  --footer-bg: rgb(15 23 42 / 0.026);
  --focus-ring: #3b63d9;
  --progress-fill: #14161d;
  --dot-testing: #4b6bfb;
  --dot-ok: #10a36d;
  --dot-warn: #d48806;
  --dot-danger: #d93848;
  --bar-off: rgb(15 23 42 / 0.12);
  --sig-4: #10a36d;
  --sig-3: #d4920a;
  --sig-2: #e0631a;
  --sig-1: #d93848;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0a0b0e;
    --text: #f2f4f8;
    --muted: #8890a4;
    --panel-bg: rgb(17 19 26 / 0.72);
    --panel-solid: #13151d;
    --panel-border: rgb(255 255 255 / 0.085);
    --panel-shadow:
      inset 0 1px 0 rgb(255 255 255 / 0.08),
      0 28px 68px -16px rgb(0 0 0 / 0.68);
    --divider: rgb(255 255 255 / 0.06);
    --item-hover: rgb(255 255 255 / 0.042);
    --item-rec-bg: rgb(255 255 255 / 0.065);
    --item-rec-border: rgb(255 255 255 / 0.11);
    --item-rec-shadow:
      inset 0 1px 0 rgb(255 255 255 / 0.06),
      0 8px 22px -6px rgb(0 0 0 / 0.4);
    --index-color: #5d6578;
    --control-hover: rgb(255 255 255 / 0.075);
    --control-border: rgb(255 255 255 / 0.11);
    --action: #f2f4f8;
    --action-hover: #dfe3ec;
    --action-text: #111318;
    --tag-bg: rgb(52 211 153 / 0.14);
    --tag-text: #4ade80;
    --footer-bg: rgb(255 255 255 / 0.025);
    --focus-ring: #7c9aff;
    --progress-fill: #e2e6f0;
    --dot-testing: #7c9aff;
    --dot-ok: #34d399;
    --dot-warn: #fbbf24;
    --dot-danger: #f87171;
    --bar-off: rgb(255 255 255 / 0.13);
    --sig-4: #34d399;
    --sig-3: #facc15;
    --sig-2: #fb923c;
    --sig-1: #f87171;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--page); }

body {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: center;
  margin: 0;
  padding: clamp(2.25rem, 6vh, 4rem) clamp(1.25rem, 4vw, 2.5rem);
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
  font: 1rem / 1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.ambient-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}

body[data-canvas="fallback"]::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60rem 34rem at 28% 8%, rgb(148 163 196 / 0.18), transparent 72%),
    radial-gradient(48rem 28rem at 76% 18%, rgb(180 190 215 / 0.12), transparent 70%);
  content: "";
}

p, h1 { margin: 0; }

.shell {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  align-items: center;
  gap: clamp(2.5rem, 6vw, 5.5rem);
  width: min(100%, 63rem);
  margin-inline: auto;
  animation: stage-enter 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes stage-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Left Column */
.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.brand-group {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  margin-block-end: 1.5rem;
}

.brand-logo {
  display: block;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 0.48rem;
  object-fit: contain;
}

.brand {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.site-title-page {
  font-size: clamp(2.5rem, 4.8vw, 3.75rem);
  font-weight: 700;
  letter-spacing: -0.052em;
  line-height: 1.1;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.site-body {
  max-inline-size: 22.5rem;
  margin-block-start: 1.1rem;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.25vw, 1.03125rem);
  line-height: 1.72;
  text-wrap: pretty;
}

.site-meta {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* Right Column: Clean Sculptural Glass Monolith */
.route-area { min-width: 0; }

.route-panel {
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 1.25rem;
  background: var(--panel-solid);
  box-shadow: var(--panel-shadow);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .route-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
  }
}

/* Card Header */
.line-toolbar {
  position: relative;
  display: flex;
  min-height: 3.35rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--divider);
}

.summary-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 540;
}

.summary-status::before {
  width: 0.4rem;
  height: 0.4rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  content: "";
}

.route-panel[data-probe-state="testing"] .summary-status::before {
  background: var(--dot-testing);
  opacity: 1;
  animation: status-pulse 1.3s ease-in-out infinite;
}

.route-panel[data-probe-state="ready"] .summary-status {
  color: var(--text);
}

.route-panel[data-probe-state="ready"] .summary-status::before {
  background: var(--dot-ok);
  opacity: 1;
}

.route-panel[data-probe-state="empty"] .summary-status::before,
.route-panel[data-probe-state="unconfigured"] .summary-status::before {
  background: var(--dot-warn);
  opacity: 0.9;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: 560 0.78125rem / 1.3 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease, opacity 150ms ease;
}

.btn:focus-visible,
.line-item:focus-visible,
.line-source:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.btn-retest {
  margin-inline-end: -0.35rem;
  padding: 0.32rem 0.58rem;
  color: var(--muted);
}

.btn-retest:hover:not(:disabled) {
  background: var(--control-hover);
  color: var(--text);
}

.btn:disabled {
  cursor: default;
  opacity: 0.4;
}

.icon-refresh {
  width: 0.82rem;
  height: 0.82rem;
  flex-shrink: 0;
  transition: transform 260ms ease;
}

.btn-retest:hover:not(:disabled) .icon-refresh {
  transform: rotate(75deg);
}

.route-panel[data-probe-state="testing"] .btn-retest .icon-refresh {
  animation: spin 0.95s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.probe-progress {
  position: absolute;
  inset-inline: 0;
  inset-block-end: -1px;
  width: 100%;
  height: 1.5px;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
}

.probe-progress::-webkit-progress-bar { background: transparent; }
.probe-progress::-webkit-progress-value {
  background: var(--progress-fill);
  transition: width 200ms ease;
}
.probe-progress::-moz-progress-bar { background: var(--progress-fill); }
.probe-progress:indeterminate::-webkit-progress-value { background: transparent; }
.probe-progress:indeterminate::-moz-progress-bar { background: transparent; }

.line-toolbar:has(.probe-progress:indeterminate:not([hidden]))::after {
  position: absolute;
  inset-block-end: -1px;
  inset-inline-start: 0;
  width: 26%;
  height: 1.5px;
  background: var(--progress-fill);
  animation: probe-wait 0.95s ease-in-out infinite alternate;
  pointer-events: none;
  content: "";
}

@keyframes probe-wait {
  from { transform: translateX(0); }
  to { transform: translateX(285%); }
}

/* Calm, Borderless-at-Rest Route List */
.line-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0.5rem;
  list-style: none;
}

.line-source {
  display: block;
  padding: 0.9rem 0.95rem;
  border-radius: 0.8rem;
  color: var(--text);
  text-decoration: none;
}

.line-source[href=""] {
  color: var(--muted);
  pointer-events: none;
}

.line-item {
  display: grid;
  grid-template-columns: 1.65rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  min-height: 4.2rem;
  padding: 0.82rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 0.85rem;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 120ms ease;
}

.line-item:hover:not([aria-disabled="true"]) {
  background: var(--item-hover);
}

.line-item:active:not([aria-disabled="true"]) {
  transform: scale(0.995);
}

.line-item[aria-disabled="true"] {
  cursor: default;
}

/* Only the Recommended Route Elevates as a Highlighted Surface */
.line-entry[data-recommended="true"] .line-item {
  border-color: var(--item-rec-border);
  background: var(--item-rec-bg);
  box-shadow: var(--item-rec-shadow);
}

/* Crisp Tabular Route Index (01, 02, 03) */
.line-index {
  color: var(--index-color);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.line-entry[data-recommended="true"] .line-index {
  color: var(--text);
  font-weight: 650;
}

/* Route Title & Host */
.line-details { min-width: 0; }

.line-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 590;
  letter-spacing: -0.012em;
}

.line-entry[data-recommended="true"] .line-title {
  font-weight: 640;
}

.line-name, .line-host { overflow-wrap: anywhere; }

.line-host {
  display: block;
  margin-top: 0.12rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.78;
}

.line-host:empty { display: none; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.45rem;
  border-radius: 0.35rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  white-space: nowrap;
  font-size: 0.6875rem;
  font-weight: 620;
  line-height: 1.4;
}

/* Trailing Status & Action */
.line-trailing {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.line-result {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.line-status-text {
  color: var(--muted);
  font-size: 0.78125rem;
}

[data-state="failed"] .line-status-text {
  color: var(--dot-danger);
}

/* Hide redundant bars & chevron when unconfigured */
[data-state="unconfigured"] .signal-bars,
[data-state="unconfigured"] .line-action {
  display: none;
}

.signal-bars {
  display: block;
  flex-shrink: 0;
  overflow: visible;
}

.signal-bars .bar {
  fill: var(--bar-off);
  transition: fill 180ms ease;
}

[data-state="ready"][data-signal="4"] .signal-bars .bar {
  fill: var(--sig-4);
}

[data-state="ready"][data-signal="3"] .signal-bars .bar-1,
[data-state="ready"][data-signal="3"] .signal-bars .bar-2,
[data-state="ready"][data-signal="3"] .signal-bars .bar-3 {
  fill: var(--sig-3);
}

[data-state="ready"][data-signal="2"] .signal-bars .bar-1,
[data-state="ready"][data-signal="2"] .signal-bars .bar-2 {
  fill: var(--sig-2);
}

[data-state="ready"][data-signal="1"] .signal-bars .bar-1 {
  fill: var(--sig-1);
}

[data-state="testing"] .signal-bars .bar {
  animation: bar-scan 1.1s ease-in-out infinite;
}
[data-state="testing"] .signal-bars .bar-2 { animation-delay: 0.14s; }
[data-state="testing"] .signal-bars .bar-3 { animation-delay: 0.28s; }
[data-state="testing"] .signal-bars .bar-4 { animation-delay: 0.42s; }

@keyframes bar-scan {
  0%, 100% { fill: var(--bar-off); }
  45% { fill: var(--dot-testing); }
}

/* Clean Bare Chevron on Normal Rows, Solid Pill Only on Recommended */
.line-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: var(--muted);
  font-size: 0.78125rem;
  font-weight: 580;
  opacity: 0.55;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    opacity 150ms ease,
    transform 150ms ease;
}

.line-action-label { display: none; }

.icon-chevron {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
  transition: transform 150ms ease;
}

.line-item:hover:not([aria-disabled="true"]) .line-action {
  color: var(--text);
  opacity: 1;
}

.line-item:hover:not([aria-disabled="true"]) .icon-chevron {
  transform: translateX(2.5px);
}

.line-entry[data-recommended="true"] .line-action {
  height: 1.85rem;
  padding-inline: 0.72rem 0.48rem;
  border-radius: 999px;
  background: var(--action);
  color: var(--action-text);
  opacity: 1;
}

.line-entry[data-recommended="true"] .line-action-label {
  display: inline;
}

.line-entry[data-recommended="true"] .line-item:hover .line-action {
  background: var(--action-hover);
  color: var(--action-text);
}

/* Integrated Docked Countdown Footer Inside Card */
.line-footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.62rem 1.25rem;
  border-top: 1px solid var(--divider);
  background: var(--footer-bg);
}

.line-footer:has(#jump-notice:empty) {
  display: none;
}

.line-footer[data-counting="true"]::before {
  position: absolute;
  inset-inline: 0;
  inset-block-start: -1px;
  height: 1.5px;
  background: var(--progress-fill);
  opacity: 0.65;
  transform-origin: left center;
  animation: countdown-bar var(--countdown-ms, 2000ms) linear forwards;
  pointer-events: none;
  content: "";
}

@keyframes countdown-bar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.jump-text {
  color: var(--muted);
  font-size: 0.8125rem;
}

.btn-cancel {
  margin-inline-end: -0.35rem;
  padding: 0.25rem 0.58rem;
  color: var(--text);
}

.btn-cancel:hover {
  background: var(--control-hover);
}

@media (max-width: 52rem) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.85rem;
    width: min(100%, 32rem);
  }
  .brand-group { margin-block-end: 1.1rem; }
  .site-body { max-inline-size: 28rem; margin-block-start: 0.75rem; }
}

@media (max-width: 28rem) {
  body { padding-inline: 0.95rem; }
  .line-toolbar, .line-footer { padding-inline: 1rem; }
  .line-list { padding: 0.38rem; }
  .line-item { grid-template-columns: 1.4rem minmax(0, 1fr) auto; gap: 0.5rem; padding-inline: 0.7rem; }
}

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