/* ═══════════════════════════════════════════════════════════════════════════
   WESA-IT IP Tool — Material You inspired dark theme
   Fonts: DM Sans (UI) + JetBrains Mono (code/IP)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    /* Surface */
    --bg:          #1e1e2e;
    --surface:     #252537;
    --surface-2:   #2e2e45;
    --surface-3:   #363655;

    /* Text */
    --text:        #cdd6f4;
    --text-sub:    #a6adc8;
    --text-muted:  #6c7086;

    /* Accent – VSCode-ish blue-purple */
    --accent:      #89b4fa;
    --accent-dim:  rgba(137, 180, 250, 0.12);
    --accent-glow: rgba(137, 180, 250, 0.25);

    /* Borders */
    --border:      rgba(255,255,255,0.07);
    --border-strong: rgba(255,255,255,0.14);

    /* Radius */
    --r-sm:  8px;
    --r-md:  14px;
    --r-lg:  20px;
    --r-xl:  28px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,.45);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.55);
}

[data-theme="light"] {
    --bg:          #f0f0f8;
    --surface:     #ffffff;
    --surface-2:   #f5f5fc;
    --surface-3:   #eaeaf8;

    --text:        #1e1e2e;
    --text-sub:    #444466;
    --text-muted:  #7777aa;

    --accent:      #4361c2;
    --accent-dim:  rgba(67, 97, 194, 0.1);
    --accent-glow: rgba(67, 97, 194, 0.2);

    --border:      rgba(0,0,0,0.07);
    --border-strong: rgba(0,0,0,0.14);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    /* subtle noise texture */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container  { width: 92%; max-width: 1060px; margin: 0 auto; }
.text-center { text-align: center; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
    background: rgba(30, 30, 46, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: .85rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

[data-theme="light"] .navbar {
    background: rgba(240,240,248,0.85);
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    background: var(--accent-dim);
    border-radius: var(--r-sm);
    font-size: .85rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.nav-link {
    color: var(--text-sub);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    padding: .35rem .75rem;
    border-radius: var(--r-sm);
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.nav-link:hover {
    background: var(--accent-dim);
    color: var(--accent);
}

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-sub);
    text-decoration: none;
    padding: .35rem .75rem;
    border-radius: var(--r-sm);
    transition: all .2s;
}

.lang-switch:hover {
    background: var(--accent-dim);
    color: var(--accent);
}

.lang-switch .fi { border-radius: 2px; }

.icon-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-sub);
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    transition: all .2s;
}

.icon-btn:hover {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

/* ── Main ────────────────────────────────────────────────────────────────── */
main.container { padding-top: 2.5rem; padding-bottom: 4rem; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2.5rem 1rem 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 50% at 50% 0%, var(--accent-glow), transparent 70%);
    pointer-events: none;
}

.hero-label {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .75rem;
}

.hero-ip-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    flex-wrap: nowrap;
    margin-bottom: 1rem;
}

.hero-ver {
    color: var(--accent);
    font-weight: 800;
}

.hero-ip {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(1.3rem, 4vw, 3rem);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
    word-break: break-all;
    overflow-wrap: anywhere;
    max-width: min(80vw, 700px);
    line-height: 1.2;
}

.flag-hero {
    font-size: 2rem;
    flex-shrink: 0;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.hero-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    flex-wrap: wrap;
}

/* ── Chips ───────────────────────────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .75rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.4;
    transition: all .2s;
    cursor: default;
    border: 1px solid transparent;
}

.chip-primary {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(137,180,250,.25);
}

.chip-ghost {
    background: transparent;
    color: var(--text-sub);
    border-color: var(--border-strong);
    cursor: pointer;
}

.chip-ghost:hover {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

.chip-sm { font-size: .72rem; padding: .15rem .55rem; }

/* ── Detail grid ─────────────────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .25s, border-color .25s;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.card-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.1rem;
    padding-bottom: .8rem;
    border-bottom: 1px solid var(--border);
}

.card-head h3 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}

.card-icon {
    color: var(--accent);
    font-size: .95rem;
    opacity: .85;
}

/* ── Data list ───────────────────────────────────────────────────────────── */
.data-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.data-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

/* Per-row copy button — always visible */
.row-copy-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: .2rem .3rem;
    border-radius: var(--r-sm);
    font-size: .75rem;
    line-height: 1;
    transition: color .15s, background .15s;
}

.row-copy-btn:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

/* Hero IP — klickbar zum Kopieren */
.hero-ip {
    cursor: copy;
    border-radius: var(--r-sm);
    transition: opacity .15s;
}

.hero-ip:hover {
    opacity: .75;
}

.data-list li:last-child { border-bottom: none; }

.dl-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
    flex-shrink: 0;
}

.dl-value {
    font-size: .875rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .4rem;
    text-align: right;
    justify-content: flex-end;
    min-width: 0;
    flex: 1;
}

/* Flaggen in dl-value rechtsbündig — flag-span kommt vor dem Text im innerHTML */
.dl-value .fi {
    order: 1;
    flex-shrink: 0;
}

.dl-value > span:not(.fi),
.dl-value > .skeleton {
    order: 0;
}

.dl-value .fa-brands,
.dl-value .fab,
.dl-value .fas {
    font-size: 1rem;
    flex-shrink: 0;
}

.dl-ua {
    flex-direction: column;
    align-items: flex-start !important;
}

.dl-ua .dl-value {
    text-align: left;
    margin-top: .25rem;
}

.mono { font-family: 'JetBrains Mono', monospace; font-size: .8rem !important; }
.small { font-size: .75rem !important; }
.break-all { word-break: break-all; }

/* ── Skeleton loader ─────────────────────────────────────────────────────── */
.skeleton {
    display: inline-block;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 4px;
    color: transparent;
    user-select: none;
    min-width: 80px;
    height: .85em;
    vertical-align: middle;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Map ─────────────────────────────────────────────────────────────────── */
.map-card { margin-bottom: 1.25rem; }

#map {
    height: 320px;
    border-radius: var(--r-md);
    overflow: hidden;
    margin-top: .25rem;
    border: 1px solid var(--border);
}

/* ── Leaflet overrides ───────────────────────────────────────────────────── */
/* fix z-index in stacking context */
.leaflet-pane { z-index: 1 !important; }
.leaflet-top, .leaflet-bottom { z-index: 2 !important; }

/* Map background matches dark surface while tiles load — no white flash */
.leaflet-container {
    background: var(--surface-2) !important;
}

/* Popup — dark themed */
.leaflet-popup-content-wrapper {
    background: var(--surface-3) !important;
    color: var(--text) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--r-md) !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-popup-tip {
    background: var(--surface-3) !important;
}

.leaflet-popup-content {
    font-family: 'DM Sans', sans-serif !important;
    font-size: .85rem !important;
    line-height: 1.5 !important;
    color: var(--text) !important;
}

.leaflet-popup-content b {
    font-family: 'JetBrains Mono', monospace !important;
    font-size: .78rem !important;
    color: var(--accent) !important;
}

.leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

.leaflet-popup-close-button:hover {
    color: var(--text) !important;
}

/* Attribution */
.leaflet-control-attribution {
    background: rgba(30,30,46,0.75) !important;
    color: var(--text-muted) !important;
    font-size: .7rem !important;
}

[data-theme="light"] .leaflet-control-attribution {
    background: rgba(240,240,248,0.85) !important;
}

.leaflet-control-attribution a {
    color: var(--accent) !important;
}

/* Zoom buttons */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    background: var(--surface-3) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    background: var(--surface-2) !important;
    color: var(--accent) !important;
}

/* ── API page ────────────────────────────────────────────────────────────── */
.api-grid { margin-bottom: 1.25rem; }
.api-desc { font-size: .875rem; color: var(--text-sub); margin-bottom: .75rem; line-height: 1.5; }

.code-block {
    display: block;
    background: var(--surface-2);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: .7rem 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
}

/* ── Error page ──────────────────────────────────────────────────────────── */
.error-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
}

.error-card {
    text-align: center;
    max-width: 480px;
    width: 100%;
}

.error-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 6rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: .5rem;
}

.error-title { font-size: 1.4rem; margin-bottom: 1rem; }

.error-msg { color: var(--text-sub); margin-bottom: 2rem; }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--accent);
    color: #1e1e2e;
    text-decoration: none;
    font-weight: 700;
    padding: .6rem 1.5rem;
    border-radius: 999px;
    transition: opacity .2s;
}

.btn-back:hover { opacity: .85; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-top: 1rem;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: .5rem;
}

.footer-links { display: flex; gap: 1rem; }

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color .2s;
}

.footer-link:hover { color: var(--accent); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: .5rem 1.2rem;
    font-size: .85rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 999;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Hero IP tooltip ─────────────────────────────────────────────────────── */
.hero-ip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* invisible bridge so moving mouse from IP to tooltip doesn't close it */
.hero-ip-wrap::after {
    content: '';
    position: absolute;
    bottom: -0.6rem;
    left: 0; right: 0;
    height: .6rem;
}

.hero-copy-tooltip {
    position: absolute;
    bottom: calc(100% + .5rem);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: .3rem .8rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-sub);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s, transform .15s;
    z-index: 10;
}

.hero-ip-wrap:hover .hero-copy-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Card format popover ─────────────────────────────────────────────────── */
.card-fmt-wrap {
    position: relative;
    display: inline-flex;
}

.card-fmt-menu {
    position: absolute;
    top: calc(100% + .4rem);
    right: 0;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: .4rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    z-index: 50;
    /* JS-controlled via .open class */
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity .15s, transform .15s;
}

.card-fmt-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.copy-fmt-btn {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: .8rem;
    font-weight: 600;
    padding: .35rem .75rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    text-align: left;
    display: flex;
    align-items: center;
    gap: .5rem;
    transition: background .15s, color .15s;
}

.copy-fmt-btn:hover {
    background: var(--accent-dim);
    color: var(--accent);
}

/* ── Language dropdown ───────────────────────────────────────────────────── */
.lang-wrap {
    position: relative;
}

/* invisible bridge */
.lang-wrap::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    height: .4rem;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + .4rem);
    right: 0;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: .4rem;
    min-width: 170px;
    max-height: 320px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s, transform .15s;
    transform: translateY(4px);
    box-shadow: var(--shadow-md);
    z-index: 200;
    scrollbar-width: thin;
}

.lang-wrap:hover .lang-dropdown,
.lang-dropdown:hover {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .6rem;
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--text-sub);
    font-size: .85rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.lang-option:hover { background: var(--accent-dim); color: var(--accent); }
.lang-option.active { color: var(--accent); background: var(--accent-dim); }
.lang-option .fi { border-radius: 2px; flex-shrink: 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
    .hero-ip { font-size: clamp(1.2rem, 8vw, 1.8rem); }
    .detail-grid { grid-template-columns: 1fr; }
    .footer-inner { flex-direction: column; text-align: center; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Download Calculator
   ═══════════════════════════════════════════════════════════════════════════ */

/* Speed inputs row */
.speed-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-top: .25rem;
}

@media (max-width: 640px) {
    .speed-inputs { grid-template-columns: 1fr; }
}

.speed-group { display: flex; flex-direction: column; gap: .4rem; }

.speed-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
}

.speed-select,
.speed-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: .9rem;
    padding: .5rem .75rem;
    width: 100%;
    transition: border-color .2s;
    outline: none;
}

.speed-select:focus,
.speed-input:focus {
    border-color: var(--accent);
}

.speed-input-wrap {
    display: flex;
    gap: .4rem;
}

.speed-input-wrap .speed-input { flex: 1; }

.speed-unit {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-sub);
    font-size: .8rem;
    padding: .5rem .4rem;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
}

/* Table header inside card-head */
.card-head.dl-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding-bottom: .8rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.card-head .dl-col-head {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    text-align: right;
    flex-shrink: 0;
    width: 80px;
}

.card-head .dl-col-head:last-child {
    width: 90px;
}

.card-head .dl-col-head:first-of-type {
    width: 80px;
}

.card-head h3 {
    flex: 1;
}

@media (max-width: 640px) {
    .card-head.dl-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding-bottom: .8rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}
    .dl-row { grid-template-columns: 1fr 80px 80px; }
    .custom-size-input { max-width: 80px; }
    .card-head .dl-col-head:first-of-type { display: none; }
}

/* Table rows */
.dl-table {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dl-row {
    display: grid;
    grid-template-columns: 1fr 80px 90px 90px;
    align-items: center;
    gap: .5rem;
    padding: .6rem .25rem;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.dl-row:last-child { border-bottom: none; }

.dl-row:hover { background: var(--surface-2); border-radius: var(--r-sm); }

.dl-name {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    color: var(--text);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dl-head-label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
}

.dl-row-icon {
    color: var(--accent);
    opacity: .7;
    font-size: .85rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.dl-size {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
    color: var(--text-sub);
    text-align: right;
    justify-self: end;
}

.dl-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: .85rem;
    font-weight: 700;
    color: var(--accent);
    text-align: right;
    justify-self: end;
    transition: color .2s;
}



.custom-size-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: .78rem;
    padding: .3rem .5rem;
    width: 100%;
    max-width: 80px;
    min-width: 0;
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s;
}
.custom-size-input:focus { border-color: var(--accent); }



.custom-size-input:focus { border-color: var(--accent); }

/* Speedbar */
.speedbar-wrap {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    margin-top: .25rem;
}

.speedbar-row {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.speedbar-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    width: 70px;
    flex-shrink: 0;
}

.speedbar-track {
    flex: 1;
    height: 8px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.speedbar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    width: 0%;
    transition: width .4s cubic-bezier(.4,0,.2,1);
}

.speedbar-fill-ul {
    background: linear-gradient(90deg, var(--accent), #a78bfa);
}

.speedbar-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
    color: var(--text-sub);
    width: 130px;
    text-align: right;
    flex-shrink: 0;
}

@media (max-width: 640px) {

    .dl-row .dl-size { display: none; }
    .card-head .dl-col-head:first-of-type { display: none; }
    .speedbar-val { width: 90px; font-size: .72rem; }
}

/* ── Map lazy load ───────────────────────────────────────────────────────── */
#map-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
}

.map-load-btn {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: 'DM Sans', sans-serif;
    font-size: .9rem;
    font-weight: 600;
    padding: .65rem 1.4rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background .2s, box-shadow .2s, transform .15s;
}

.map-load-btn:hover {
    background: var(--accent);
    color: #1e1e2e;
    box-shadow: 0 0 16px var(--accent-glow);
    transform: translateY(-1px);
}

.map-load-btn i {
    font-size: 1rem;
}

/* ── Speed inputs — nicer unit selects ──────────────────────────────────── */
.speed-unit {
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: .78rem;
    font-weight: 700;
    padding: .5rem .5rem;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color .2s, background .2s;
    /* keep native dropdown but style the select itself */
    min-width: 64px;
    color-scheme: dark;
}

.speed-unit:focus,
.speed-unit:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.speed-select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: .875rem;
    padding: .55rem .75rem;
    width: 100%;
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c7086' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
}

.speed-select:focus { border-color: var(--accent); }

.speed-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: .95rem;
    font-weight: 700;
    padding: .55rem .75rem;
    width: 100%;
    outline: none;
    transition: border-color .2s;
    -moz-appearance: textfield;
}

.speed-input:focus { border-color: var(--accent); }
.speed-input::-webkit-outer-spin-button,
.speed-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   Speedtest
   ═══════════════════════════════════════════════════════════════════════════ */

.st-card {
    padding: 2rem;
    text-align: center;
}

.st-status {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    min-height: 1.2em;
    transition: color .3s;
}

/* Gauges */
.st-gauges {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.st-gauge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}

.st-gauge-label {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.st-gauge {
    position: relative;
    width: 160px;
}

.st-arc-svg {
    width: 100%;
    display: block;
    overflow: visible;
}

.st-arc-bg {
    fill: none;
    stroke: var(--surface-2);
    stroke-width: 10;
    stroke-linecap: round;
}

.st-arc-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 0 173;
    transition: stroke-dasharray .3s ease-out;
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.st-arc-ul {
    stroke: #a78bfa;
    filter: drop-shadow(0 0 6px rgba(167,139,250,.4));
}

.st-arc-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    fill: var(--accent);
    text-anchor: middle;
    dominant-baseline: auto;
}

.st-arc-text-ul {
    fill: #a78bfa;
}

.st-arc-unit {
    font-family: 'DM Sans', sans-serif;
    font-size: 9px;
    font-weight: 600;
    fill: var(--text-muted);
    text-anchor: middle;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.st-unit {
    font-size: .65rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    margin-left: .2rem;
}

/* Center ping/jitter */
.st-center-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
    align-self: center;
}

.st-small-stat {
    text-align: center;
}

.st-small-label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .15rem;
}

.st-small-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

/* Progress bar */
.st-progress-wrap {
    height: 4px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin: 0 auto;
    max-width: 400px;
}

.st-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    border-radius: 999px;
    transition: width .3s ease-out;
}

/* Start/Stop button */
.st-btn {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: .75rem 2.5rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background .2s, box-shadow .2s, transform .15s, color .2s;
    letter-spacing: .02em;
}

.st-btn:hover {
    background: var(--accent);
    color: #1e1e2e;
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

.st-btn.st-btn-running {
    background: rgba(239,68,68,.1);
    border-color: #ef4444;
    color: #ef4444;
}

.st-btn.st-btn-running:hover {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 0 20px rgba(239,68,68,.3);
}

/* Share */
.st-share {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1.25rem;
    justify-content: center;
    flex-wrap: wrap;
}

.st-share-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-sub);
    font-family: 'JetBrains Mono', monospace;
    font-size: .75rem;
    padding: .4rem .75rem;
    width: 260px;
    outline: none;
}