/* =========================================================
   Speedtest – gleiche Farben und Schrift wie das Portfolio
   ========================================================= */

@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url('fonts/manrope-latin-wght-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD;
}

:root {
    --bg: #FAF8F5;
    --surface: #FFFFFF;
    --ink: #1C1B1A;
    --ink-soft: #6B665F;
    --line: #E9E4DC;
    --accent: #3A3DF0;
    --accent-ink: #FFFFFF;
    --danger: #C23B40;
    --shadow: 0 1px 2px rgba(28, 27, 26, 0.04), 0 8px 24px rgba(28, 27, 26, 0.06);
    --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

:root.dark-mode {
    --bg: #161513;
    --surface: #211F1D;
    --ink: #F4F1EC;
    --ink-soft: #A8A29A;
    --line: #35322E;
    --accent: #9AA0FF;
    --accent-ink: #161513;
    --danger: #FF8A8E;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
}

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

html { font-size: clamp(16px, 0.55vw + 9.5px, 24px); }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* ---------- Obere Leiste ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 60rem;
    margin: 0 auto;
    padding: 1rem 1.25rem;
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.18s ease;
}

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

.icon-btn {
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: color 0.18s ease, background 0.3s ease, border-color 0.3s ease;
}

.icon-btn:hover { color: var(--accent); }
.icon-sun { display: none; }
:root.dark-mode .icon-sun { display: block; }
:root.dark-mode .icon-moon { display: none; }

/* ---------- Seite ---------- */

main {
    max-width: 38rem;
    margin: 0 auto;
    padding: 0.5rem 1.25rem 4rem;
    text-align: center;
}

h1 {
    margin: 0.5rem 0 0.2rem;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.lead {
    margin: 0 0 1.5rem;
    color: var(--ink-soft);
}

/* ---------- Reiter ---------- */

.tabs {
    display: inline-flex;
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.tab {
    padding: 0.5rem 1.3rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.tab:hover { color: var(--ink); }

.tab[aria-selected="true"] {
    background: var(--ink);
    color: var(--bg);
}

.panel[hidden] { display: none; }

/* ---------- Karte ---------- */

.card {
    padding: 1.75rem 1.25rem 0.5rem;
    border-radius: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.note {
    max-width: 30rem;
    margin: 1rem auto 0;
    color: var(--ink-soft);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* ---------- Tacho ---------- */

.gauge {
    position: relative;
    width: min(100%, 22rem);
    margin: 0 auto;
}

.gauge-svg {
    display: block;
    width: 100%;
    height: auto;
}

.gauge-track { stroke: var(--line); }

.gauge-fill {
    stroke: var(--accent);
    opacity: 0;
}

.tick {
    font: 600 9px var(--font);
    fill: var(--ink-soft);
}

.gauge-readout {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 3%;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.gauge-zahl {
    font-size: clamp(2.4rem, 9vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.gauge-einheit {
    color: var(--ink-soft);
    font-size: 0.85rem;
    font-weight: 600;
}

.phase {
    min-height: 1.6rem;
    margin: 0.75rem 0 1rem;
    color: var(--ink-soft);
    font-size: 0.95rem;
    font-weight: 600;
}

/* ---------- Start-Knopf ---------- */

.start {
    min-width: 12rem;
    padding: 0.85rem 2.2rem;
    border: 2px solid var(--accent);
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.start:hover { transform: translateY(-2px); }
.start:active { transform: scale(0.97); }

.start.laeuft {
    background: transparent;
    color: var(--accent);
}

.fehler {
    max-width: 28rem;
    margin: 1rem auto 0;
    color: var(--danger);
    font-size: 0.85rem;
    line-height: 1.5;
}

.fehler[hidden] { display: none; }

/* ---------- Messwerte ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 1.75rem -1.25rem 0;
    padding: 0;
    border-top: 1px solid var(--line);
}

.stat {
    padding: 1rem 0.25rem 1.1rem;
    border-left: 1px solid var(--line);
}

.stat:first-child { border-left: 0; }

.stat dt {
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-weight: 600;
}

.stat dd {
    margin: 0.1rem 0 0;
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.stat small {
    display: block;
    color: var(--ink-soft);
    font-size: 0.7rem;
    font-weight: 600;
}

/* ---------- Meine IP ---------- */

.ip-label {
    margin: 0.25rem 0 0.4rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 600;
}

.ip-adresse {
    margin: 0 0 1rem;
    font-size: clamp(1.5rem, 6vw, 2.3rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.kopieren {
    padding: 0.55rem 1.4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.kopieren:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.kopieren:disabled {
    opacity: 0.5;
    cursor: default;
}

.details {
    margin: 1.75rem -1.25rem 0;
    padding: 0;
    text-align: left;
}

.details > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1.25rem;
    border-top: 1px solid var(--line);
    font-size: 0.9rem;
}

.details dt {
    flex: none;
    color: var(--ink-soft);
    font-weight: 600;
}

.details dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
    overflow-wrap: anywhere;
}

/* ---------- Kleine Bildschirme ---------- */

@media (max-width: 520px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stat:nth-child(3) { border-left: 0; }
    .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

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