:root {
    color-scheme: dark;
    --dr-bg: #070a0d;
    --dr-panel: rgba(12, 19, 22, 0.92);
    --dr-border: rgba(94, 234, 212, 0.22);
    --dr-border-hot: rgba(251, 191, 36, 0.42);
    --dr-text: #d8fff8;
    --dr-muted: #7c9b99;
    --dr-green: #3dff9b;
    --dr-cyan: #36e7ff;
    --dr-amber: #ffcc57;
    --dr-red: #ff5b6e;
}

body.dockroute-shell {
    background:
        radial-gradient(circle at 15% 0%, rgba(54, 231, 255, 0.12), transparent 28rem),
        radial-gradient(circle at 88% 8%, rgba(61, 255, 155, 0.09), transparent 24rem),
        linear-gradient(180deg, #080b0e 0%, #050708 100%);
    color: var(--dr-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.crt-grid::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    background:
        linear-gradient(rgba(255, 255, 255, 0.025) 50%, rgba(0, 0, 0, 0.05) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    background-size: 100% 4px, 6px 100%;
    mix-blend-mode: screen;
}

.retro-panel {
    min-width: 0;
    background: linear-gradient(180deg, var(--dr-panel), rgba(8, 13, 16, 0.94));
    border: 1px solid var(--dr-border);
    border-radius: 8px;
    box-shadow: 0 0 0 1px rgba(61, 255, 155, 0.04), 0 18px 60px rgba(0, 0, 0, 0.28);
}

canvas {
    max-width: 100%;
}

.retro-panel-hot {
    border-color: var(--dr-border-hot);
    box-shadow: 0 0 28px rgba(255, 204, 87, 0.08);
}

.terminal-text {
    font-family: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.signal-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    display: inline-block;
    background: var(--dr-muted);
    box-shadow: 0 0 0.75rem currentColor;
}

.signal-dot.online {
    color: var(--dr-green);
    background: var(--dr-green);
    animation: pulseDot 1.6s ease-in-out infinite;
}

.signal-dot.warn {
    color: var(--dr-amber);
    background: var(--dr-amber);
}

.signal-dot.down {
    color: var(--dr-red);
    background: var(--dr-red);
}

.retro-spinner {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    border: 2px dashed var(--dr-cyan);
    border-top-color: var(--dr-amber);
    box-shadow: inset 0 0 18px rgba(54, 231, 255, 0.12), 0 0 22px rgba(54, 231, 255, 0.14);
    animation: retroSpin 2.8s linear infinite;
}

.log-stream {
    background: rgba(0, 0, 0, 0.34);
    border: 1px solid rgba(124, 155, 153, 0.18);
    border-radius: 8px;
}

.retro-table {
    width: 100%;
    border-collapse: collapse;
}

.retro-table th {
    color: var(--dr-muted);
    font-size: 0.68rem;
    letter-spacing: 0;
    text-transform: uppercase;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(124, 155, 153, 0.2);
}

.retro-table td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(124, 155, 153, 0.11);
    color: #c8f7ef;
}

.retro-action {
    border: 1px solid rgba(54, 231, 255, 0.28);
    background: rgba(54, 231, 255, 0.08);
    color: var(--dr-text);
    border-radius: 8px;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.retro-action:hover {
    transform: translateY(-1px);
    border-color: rgba(61, 255, 155, 0.56);
    background: rgba(61, 255, 155, 0.12);
}

.route-input {
    width: 100%;
    border: 1px solid rgba(54, 231, 255, 0.22);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.34);
    padding: 0.65rem 0.75rem;
    color: var(--dr-text);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.route-input:focus {
    border-color: rgba(61, 255, 155, 0.62);
    box-shadow: 0 0 0 2px rgba(61, 255, 155, 0.12);
}

.route-matrix-stage {
    position: relative;
    overflow: hidden;
    padding: 1rem;
}

.route-matrix-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.36;
    background-image: radial-gradient(circle, rgba(54, 231, 255, 0.34) 1px, transparent 1.5px);
    background-size: 18px 18px;
    mask-image: linear-gradient(180deg, black, transparent 85%);
}

.route-matrix-header,
.route-flow-legend,
.route-matrix-grid {
    position: relative;
    z-index: 1;
}

.route-matrix-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid rgba(94, 234, 212, 0.14);
    padding: 0.25rem 0.25rem 1rem;
}

.route-flow-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 0.25rem;
    color: var(--dr-muted);
    font-size: 0.72rem;
}

.route-flow-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.route-matrix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.route-empty {
    display: flex;
    min-height: 12rem;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--dr-muted);
    font-family: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.route-flow-card {
    position: relative;
    min-width: 0;
    border: 1px solid rgba(54, 231, 255, 0.2);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(10, 24, 28, 0.92), rgba(6, 11, 13, 0.96)),
        radial-gradient(circle at 20% 10%, rgba(54, 231, 255, 0.14), transparent 16rem);
    padding: 1rem;
    box-shadow: inset 0 0 0 1px rgba(61, 255, 155, 0.03), 0 12px 40px rgba(0, 0, 0, 0.22);
}

.route-flow-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    opacity: 0.22;
    background-image: radial-gradient(circle, rgba(216, 255, 248, 0.35) 1px, transparent 1.5px);
    background-size: 12px 12px;
}

.route-card-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--dr-muted);
    font-size: 0.72rem;
}

.route-source {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid rgba(54, 231, 255, 0.16);
    border-radius: 999px;
    padding: 0.22rem 0.55rem;
    color: #b8fff3;
    background: rgba(54, 231, 255, 0.07);
}

.route-flow-line {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: auto minmax(3.5rem, 1fr) auto minmax(3.5rem, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    padding: 1.2rem 0 1rem;
}

.flow-node {
    display: grid;
    width: 2.8rem;
    height: 2.8rem;
    place-items: center;
    border: 1px solid rgba(54, 231, 255, 0.32);
    border-radius: 8px;
    color: var(--dr-cyan);
    background: rgba(0, 0, 0, 0.32);
    box-shadow: 0 0 18px rgba(54, 231, 255, 0.12);
}

.flow-node.caddy {
    color: var(--dr-amber);
    border-color: rgba(255, 204, 87, 0.38);
}

.flow-node.upstream {
    color: var(--dr-green);
    border-color: rgba(61, 255, 155, 0.38);
}

.flow-track {
    position: relative;
    height: 2px;
    overflow: hidden;
    background: linear-gradient(90deg, rgba(54, 231, 255, 0.15), rgba(61, 255, 155, 0.58));
}

.flow-track::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid rgba(61, 255, 155, 0.9);
    border-top: 2px solid rgba(61, 255, 155, 0.9);
    transform: translateY(-50%) rotate(45deg);
}

.flow-pulse {
    position: absolute;
    top: -3px;
    left: -0.8rem;
    width: 0.8rem;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--dr-green);
    box-shadow: 0 0 18px rgba(61, 255, 155, 0.8);
    animation: flowPulse 1.55s linear infinite;
    animation-delay: var(--flow-delay, 0ms);
}

.route-flow-copy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.65rem;
}

.route-label {
    display: block;
    color: var(--dr-muted);
    font-family: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.64rem;
    text-transform: uppercase;
}

.route-host {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    color: #e7fffb;
    font-weight: 800;
}

.route-extra {
    margin-left: 0.4rem;
    border-radius: 999px;
    background: rgba(255, 204, 87, 0.13);
    padding: 0.1rem 0.45rem;
    color: var(--dr-amber);
    font-size: 0.72rem;
}

@keyframes flowPulse {
    to { left: calc(100% + 0.8rem); }
}

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

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 0.72; }
    50% { transform: scale(1.28); opacity: 1; }
}

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