/* ==========================================================================
   Internet Hız Testi – Premium UI Redesign
   Responsive PC & Mobile · Info Modals · Live Test Log
   ========================================================================== */

@font-face {
    font-family: 'Coolvetica';
    src: url('Coolvetica-Rg.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --font: 'Coolvetica', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Segoe UI Mono', Menlo, Consolas, monospace;
    --red: #dc2626;
    --red-dim: rgba(220, 38, 38, 0.12);
    --red-glow: rgba(220, 38, 38, 0.35);
    --green: #22c55e;
    --blue: #3b82f6;
    --amber: #f59e0b;
    --purple: #8b5cf6;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Dark ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg: #09090b;
    --surface: #111114;
    --card: #16161a;
    --border: rgba(255, 255, 255, 0.08);
    --t1: #fafafa;
    --t2: #d4d4d8;
    --t3: #a1a1aa;
    --t4: #3f3f46;
    --canvas-bg: #16161a;
    --glow-opacity: 0.45;
    --modal-bg: rgba(0, 0, 0, 0.7);
    --log-bg: #111114;
    --log-entry-bg: rgba(255, 255, 255, 0.03);
    --server-accent: rgba(220, 38, 38, 0.08);
}

/* ── Light ────────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg: #f8f8fa;
    --surface: #ffffff;
    --card: #ffffff;
    --border: rgba(0, 0, 0, 0.1);
    --t1: #09090b;
    --t2: #27272a;
    --t3: #3f3f46;
    --t4: #d4d4d8;
    --canvas-bg: #f0f0f3;
    --glow-opacity: 0.25;
    --modal-bg: rgba(0, 0, 0, 0.45);
    --log-bg: #f0f0f3;
    --log-entry-bg: rgba(0, 0, 0, 0.04);
    --server-accent: rgba(220, 38, 38, 0.06);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--t1);
    min-height: 100dvh;
    transition: background 300ms var(--ease), color 300ms var(--ease);
}

.mono {
    font-family: var(--mono);
}

/* ── App Container ────────────────────────────────────────────────── */
.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 32px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100dvh;
}

/* ── Nav ──────────────────────────────────────────────────────────── */
.nav {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0 20px;
}

.nav-brand {
    display: flex;
    align-items: center;
    height: 120px;
}

.logo-white,
.logo-dark {
    height: 100%;
    width: auto;
}

[data-theme="dark"] .logo-white {
    display: block;
}

[data-theme="dark"] .logo-dark {
    display: none;
}

[data-theme="light"] .logo-white {
    display: none;
}

[data-theme="light"] .logo-dark {
    display: block;
}

.nav-theme,
.nav-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--t2);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 200ms var(--ease);
}

.nav-theme:hover,
.nav-btn:hover {
    color: var(--t2);
    border-color: var(--t3);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Settings Dropdown ──────────────────────────────────────────── */
.settings-wrap {
    position: relative;
}

.settings-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 0;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: all 200ms var(--ease);
    z-index: 100;
}

.settings-dropdown.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.settings-label {
    padding: 8px 16px 6px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--t3);
}

.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--t2);
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms var(--ease);
    text-align: left;
}

.settings-option span {
    font-family: var(--font);
    font-size: 0.58rem;
    font-weight: 400;
    color: var(--t3);
}

.settings-option:hover {
    background: var(--red-dim);
    color: var(--t1);
}

.settings-option.active {
    color: var(--red);
}

[data-theme="dark"] .ico-sun {
    display: block;
}

[data-theme="dark"] .ico-moon {
    display: none;
}

[data-theme="light"] .ico-sun {
    display: none;
}

[data-theme="light"] .ico-moon {
    display: block;
}

/* ── Connection Strip ─────────────────────────────────────────────── */
.conn-strip {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 0 16px;
    flex-wrap: wrap;
}

.conn-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--t2);
}

.conn-chip svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.conn-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--t2);
}

.conn-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--t1);
}

.conn-sep {
    color: var(--t4);
    font-size: 0.9rem;
    user-select: none;
}

/* ── Server Info ──────────────────────────────────────────────────── */
.server-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0;
    border: none;
    background: transparent;
    margin-bottom: 8px;
}

.server-info-icon {
    display: none;
}

.server-info-text {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.server-info-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--t2);
}

.server-info-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--t1);
    text-decoration: none;
    transition: opacity 200ms var(--ease);
}

.server-info-name:hover {
    opacity: 0.8;
}

.server-info-loc {
    font-size: 0.72rem;
    color: var(--t2);
    font-weight: 500;
}

.server-info-sep {
    color: var(--t3);
    font-size: 0.6rem;
    user-select: none;
}

/* ── Hero / Gauge ─────────────────────────────────────────────────── */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-bottom: 24px;
}

.gauge-ring {
    position: relative;
    width: 320px;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--red-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 600ms var(--ease);
    pointer-events: none;
}

.gauge-glow.on {
    opacity: var(--glow-opacity);
}

#gaugeCanvas {
    width: 320px;
    height: 320px;
    position: absolute;
}

.gauge-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.gauge-reading {
    display: none;
    align-items: baseline;
    gap: 5px;
}

.gauge-reading.active {
    display: flex;
    animation: fadeScaleIn 400ms var(--ease) both;
}

@keyframes fadeScaleIn {
    from {
        opacity: 0;
        transform: scale(0.7);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gauge-number {
    font-family: 'Coolvetica', var(--font);
    font-size: 4.2rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--t1);
}

.gauge-suffix {
    font-size: 1rem;
    font-weight: 500;
    color: var(--t2);
}

.gauge-phase {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--t2);
    margin-top: 4px;
    display: none;
}

.gauge-phase.active {
    display: block;
    animation: fadeIn 300ms var(--ease) both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── GO Button (inside gauge circle) ──────────────────────────────── */
.go {
    width: 160px;
    height: 160px;
    border: none;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-family: 'Coolvetica', var(--font);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    cursor: pointer;
    transition: transform 400ms var(--ease), opacity 400ms var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 10;
    position: relative;
}

.go::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    transform: scale(0);
    transition: transform 300ms var(--ease);
    z-index: 0;
}

.go:hover::before {
    transform: scale(1);
}

.go:hover {
    transform: scale(1.03);
}

.go span {
    position: relative;
    z-index: 1;
}

.go:active {
    transform: scale(0.97);
}

.go:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.go:disabled::before {
    transform: scale(0);
}

.go.hiding {
    opacity: 0;
    transform: scale(0.3);
    pointer-events: none;
}

.go.hidden-btn {
    display: none;
}

/* ── Results Card ─────────────────────────────────────────────────── */
.results-card {
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card);
    overflow: hidden;
    margin-bottom: 20px;
    animation: cardSlideIn 500ms var(--ease) both;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.results-card.show {
    display: flex;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.results-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--green);
}

.results-title svg {
    color: var(--green);
}

.results-retry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--t2);
    font-family: var(--font);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 200ms var(--ease);
}

.results-retry:hover {
    border-color: var(--red);
    color: var(--red);
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-share {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--t2);
    font-family: var(--font);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 200ms var(--ease);
}

.results-share:hover {
    border-color: var(--green);
    color: var(--green);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--border);
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 20px;
    animation: resultFadeUp 400ms var(--ease) both;
}

.result-item:first-child {
    border-right: 1px solid var(--border);
}

.result-item:nth-child(1) {
    animation-delay: 100ms;
}

.result-item:nth-child(2) {
    animation-delay: 200ms;
}

@keyframes resultFadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    margin-bottom: 12px;
}

.result-download .result-icon {
    background: var(--red-dim);
    color: var(--red);
}

.result-upload .result-icon {
    background: rgba(139, 92, 246, 0.12);
    color: var(--purple);
}

.result-value {
    font-family: 'Coolvetica', var(--font);
    font-size: 2.6rem;
    font-weight: 400;
    color: var(--t1);
    line-height: 1;
    letter-spacing: -0.02em;
}

.result-unit {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--t3);
    margin-top: 2px;
}

.result-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--t3);
    margin-top: 6px;
}

/* Results sub-metrics */
.results-metrics {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    animation: resultFadeUp 400ms var(--ease) 300ms both;
}

.results-metric {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
}

.results-metric-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.results-metric-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.results-metric-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--t1);
}

.results-metric-unit {
    font-size: 0.6rem;
    color: var(--t3);
    font-weight: 500;
}

.results-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
}

/* Results scenarios */
.results-scenarios {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.results-scenario {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    animation: resultFadeUp 400ms var(--ease) both;
}

.results-scenario:nth-child(1) {
    animation-delay: 400ms;
}

.results-scenario:nth-child(2) {
    animation-delay: 500ms;
}

.results-scenario:nth-child(3) {
    animation-delay: 600ms;
    border-bottom: none;
}

.results-sc-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--red-dim);
    color: var(--red);
    flex-shrink: 0;
}

.results-sc-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.results-sc-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--t1);
}

.results-sc-detail {
    font-size: 0.62rem;
    color: var(--t3);
}

/* Hero hide/show */
.hero.hidden {
    display: none;
}

/* ── Metrics ──────────────────────────────────────────────────────── */
.metrics {
    width: 100%;
    display: none;
    grid-template-columns: repeat(5, 1fr);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
}

.metrics.show {
    display: grid;
}

/* ── Test Layout (desktop two-column) ─────────────────────────────── */
.test-layout {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.test-layout-left {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.test-layout-right {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Right Intro Panel ───────────────────────────────────────────── */
.right-intro {
    padding: 28px 24px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    transition: opacity 400ms var(--ease), transform 400ms var(--ease);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.right-intro.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    position: absolute;
    visibility: hidden;
}

.right-intro-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--t1);
    margin: 0 0 12px;
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.right-intro-subtitle {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--t1);
    margin: 4px 0 8px;
    letter-spacing: -0.01em;
}

.right-intro-text {
    font-size: 0.7rem;
    color: var(--t3);
    line-height: 1.7;
    margin: 0 0 12px;
}

.right-intro-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.right-intro-feat {
    font-size: 0.68rem;
    color: var(--t2);
    line-height: 1.65;
}

.right-intro-feat strong {
    color: var(--t1);
    font-weight: 600;
}

.right-intro-list {
    font-size: 0.68rem;
    color: var(--t2);
    line-height: 1.65;
    margin: 0;
    padding-left: 18px;
}

.right-intro-list li {
    margin-bottom: 4px;
}

.right-intro-list li:last-child {
    margin-bottom: 0;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 8px;
    transition: background 200ms var(--ease);
    position: relative;
}

.metric+.metric::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: var(--border);
}

.metric.active {
    background: var(--red-dim);
}

.metric-head {
    display: flex;
    align-items: center;
    gap: 5px;
}

.metric-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

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

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

.dot-loss {
    background: #ef4444;
}

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

.dot-up {
    background: var(--purple);
}

.metric-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--t2);
}

.metric-body {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.metric-val {
    font-family: 'Coolvetica', var(--font);
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--t1);
    line-height: 1;
    letter-spacing: -0.01em;
}

.metric-val.pulse {
    color: var(--red);
    animation: pulse 1s ease-in-out infinite;
}

.metric-unit {
    font-size: 0.68rem;
    color: var(--t2);
    font-weight: 500;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.35;
    }
}

/* ── Info Button (?) ──────────────────────────────────────────────── */
.info-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--t3);
    background: transparent;
    color: var(--t3);
    font-size: 0.55rem;
    font-weight: 700;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 200ms var(--ease);
    font-family: var(--font);
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.info-btn:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-dim);
}

/* ── Progress ─────────────────────────────────────────────────────── */
.pbar {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 200ms var(--ease);
}

.pbar.on {
    opacity: 1;
}

.pbar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--red), #ef4444, var(--purple));
    transition: width 400ms ease-out;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.3);
}

/* ── Live Test Log ────────────────────────────────────────────────── */
.test-log {
    width: 100%;
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--log-bg);
    overflow: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 400ms var(--ease), transform 400ms var(--ease);
    pointer-events: none;
}

.test-log.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.test-log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--t2);
    cursor: pointer;
    transition: all 200ms var(--ease);
    font-family: var(--font);
}

.test-log-header:hover {
    background: var(--log-entry-bg);
}

.test-log-header svg:first-child {
    color: var(--red);
}

.test-log-chevron {
    margin-left: auto;
    transition: transform 300ms var(--ease);
    color: var(--t3);
}

.test-log.collapsed .test-log-chevron {
    transform: rotate(-180deg);
}

.test-log-body {
    max-height: 240px;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--t4) transparent;
    transition: max-height 300ms var(--ease), padding 300ms var(--ease), opacity 200ms var(--ease);
}

.test-log.collapsed .test-log-body {
    max-height: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
}

.log-entry {
    padding: 5px 16px;
    font-size: 0.68rem;
    font-family: var(--mono);
    color: var(--t2);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: logFadeIn 200ms var(--ease);
}

@keyframes logFadeIn {
    from {
        opacity: 0;
        transform: translateX(-4px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-entry::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    flex-shrink: 0;
}

.log-entry.log-info::before {
    background: var(--blue);
}

.log-entry.log-ping::before {
    background: var(--amber);
}

.log-entry.log-download::before {
    background: var(--red);
}

.log-entry.log-upload::before {
    background: var(--purple);
}

.log-entry.log-success::before {
    background: var(--green);
}

.log-entry.log-error::before {
    background: #ef4444;
}

.log-entry .log-time {
    color: var(--t3);
    font-size: 0.6rem;
    flex-shrink: 0;
    min-width: 48px;
}

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms var(--ease);
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 420px;
    width: 100%;
    transform: scale(0.92) translateY(8px);
    transition: transform 250ms var(--ease);
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--t1);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--log-entry-bg);
    border-radius: 8px;
    color: var(--t2);
    font-size: 1.2rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 150ms var(--ease);
}

.modal-close:hover {
    background: var(--red-dim);
    color: var(--red);
}

.modal-body {
    padding: 20px 24px 24px;
}

.modal-body p {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--t2);
    margin-bottom: 16px;
}

.modal-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.modal-info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    gap: 4px;
}

.modal-info-val {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 700;
}

.modal-info-item.good {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green);
}

.modal-info-item.ok {
    background: rgba(59, 130, 246, 0.1);
    color: var(--blue);
}

.modal-info-item.warn {
    background: rgba(245, 158, 11, 0.1);
    color: var(--amber);
}

.modal-info-item.bad {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.modal-note {
    font-size: 0.75rem !important;
    color: var(--t3) !important;
    font-style: italic;
    margin-bottom: 0 !important;
}

/* Scenario badges (used in results card) */
.scenario-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex-shrink: 0;
    background: var(--t4);
    color: var(--t3);
}

.scenario-badge.excellent {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.scenario-badge.good {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

.scenario-badge.fair {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.scenario-badge.poor {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

/* ── Powered By Footer ──────────────────────────────────────────── */
.powered-by {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 36px 0 16px;
    margin-top: 32px;
    border-top: 1px solid var(--border);
}

.powered-by span {
    font-size: 0.82rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--t2);
}

.powered-logo {
    height: 36px;
    width: auto;
    opacity: 0.8;
    transition: opacity 200ms var(--ease);
}

.powered-logo:hover {
    opacity: 1;
}

[data-theme="dark"] .powered-logo {
    filter: brightness(0) invert(1);
}

/* ── PC Layout ───────────────────────────────────────────────────── */
@media (min-width: 768px) {
    .app {
        max-width: 1400px;
        padding: 0 64px 60px;
    }

    .nav {
        padding: 32px 0 28px;
    }

    .nav-brand {
        height: 160px;
    }

    .conn-strip {
        gap: 24px;
        padding: 0 0 24px;
    }

    .conn-text {
        font-size: 0.85rem;
    }

    .conn-label {
        font-size: 0.72rem;
    }

    .server-info {
        padding: 16px 24px;
        gap: 16px;
    }

    .gauge-ring {
        width: 420px;
        height: 420px;
    }

    #gaugeCanvas {
        width: 420px;
        height: 420px;
    }

    .gauge-number {
        font-size: 5.5rem;
    }

    .go {
        width: 200px;
        height: 200px;
        font-size: 1.5rem;
    }

    /* Desktop: side-by-side layout */
    .test-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 32px;
    }

    .test-layout-left {
        flex: 0 0 auto;
        width: auto;
    }

    .test-layout-right {
        flex: 1;
        min-width: 0;
    }

    .right-intro {
        min-height: 420px;
    }

    .metrics {
        grid-template-columns: repeat(5, 1fr);
    }

    .scenario-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }

    .scenario {
        flex-direction: column;
        text-align: center;
        padding: 24px 18px;
    }

    .scenario-info {
        text-align: center;
    }

    .result-value {
        font-size: 3rem;
    }

    .modal {
        max-width: 480px;
    }
}

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .app {
        padding: 0 16px 32px;
    }

    .nav-brand {
        height: 100px;
    }

    .nav-theme,
    .nav-btn {
        width: 36px;
        height: 36px;
    }

    .conn-strip {
        gap: 8px;
        padding: 0 0 12px;
    }

    .conn-text {
        font-size: 0.7rem;
    }

    .conn-label {
        font-size: 0.6rem;
    }

    .server-info {
        padding: 10px 14px;
        gap: 10px;
    }

    .server-info-text {
        gap: 6px;
    }

    .gauge-ring {
        width: 260px;
        height: 260px;
    }

    #gaugeCanvas {
        width: 260px;
        height: 260px;
    }

    .gauge-number {
        font-size: 3.4rem;
    }

    .go {
        font-size: 1rem;
    }

    .metrics {
        grid-template-columns: repeat(3, 1fr);
    }

    .metric {
        padding: 16px 6px;
        gap: 8px;
    }

    .metric-val {
        font-size: 1.2rem;
    }

    .metric-title {
        font-size: 0.55rem;
    }

    .info-btn {
        width: 15px;
        height: 15px;
        font-size: 0.5rem;
    }

    .test-log-body {
        max-height: 180px;
    }

    .log-entry {
        font-size: 0.62rem;
        padding: 5px 12px;
        gap: 6px;
    }

    .scenario {
        padding: 12px;
        gap: 10px;
    }

    .results-metrics {
        flex-wrap: wrap;
        gap: 8px;
    }

    .result-value {
        font-size: 2rem;
    }
}

/* ── Consent Banner ──────────────────────────────────────────────── */
.consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    animation: consentSlideUp 500ms var(--ease) both;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.consent-banner.hidden {
    animation: consentSlideDown 400ms var(--ease) both;
    pointer-events: none;
}

@keyframes consentSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes consentSlideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.consent-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.consent-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--red-dim);
    color: var(--red);
    display: grid;
    place-items: center;
    margin-top: 2px;
}

.consent-content {
    flex: 1;
    min-width: 0;
}

.consent-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--t1);
    margin-bottom: 4px;
}

.consent-summary {
    font-size: 0.75rem;
    color: var(--t2);
    line-height: 1.5;
}

.consent-details {
    display: none;
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--t4) transparent;
}

.consent-details.show {
    display: block;
}

.consent-section {
    margin-bottom: 12px;
}

.consent-section:last-child {
    margin-bottom: 0;
}

.consent-section strong {
    display: block;
    font-size: 0.72rem;
    color: var(--t1);
    margin-bottom: 6px;
}

.consent-section ul {
    list-style: none;
    padding: 0;
}

.consent-section li {
    font-size: 0.68rem;
    color: var(--t2);
    line-height: 1.6;
    padding-left: 14px;
    position: relative;
    margin-bottom: 2px;
}

.consent-section li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--red);
}

.consent-section p {
    font-size: 0.68rem;
    color: var(--t2);
    line-height: 1.6;
}

.consent-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 0;
    border: none;
    background: none;
    color: var(--red);
    font-size: 0.68rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: opacity 200ms var(--ease);
}

.consent-toggle:hover {
    opacity: 0.7;
}

.consent-toggle svg {
    transition: transform 200ms var(--ease);
}

.consent-toggle.expanded svg {
    transform: rotate(180deg);
}

.consent-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    margin-top: 4px;
}

.consent-accept {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    background: var(--red);
    color: #fff;
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 200ms var(--ease);
    white-space: nowrap;
}

.consent-accept:hover {
    background: #b91c1c;
    transform: scale(1.02);
}

.consent-reject {
    padding: 8px 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--t3);
    font-family: var(--font);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 200ms var(--ease);
    white-space: nowrap;
}

.consent-reject:hover {
    border-color: var(--t3);
    color: var(--t2);
}

/* Mobile consent */
@media (max-width: 600px) {
    .consent-inner {
        flex-direction: column;
        padding: 16px;
        gap: 12px;
    }

    .consent-icon {
        display: none;
    }

    .consent-actions {
        flex-direction: row;
        width: 100%;
    }

    .consent-accept {
        flex: 1;
    }

    .consent-reject {
        flex: 0;
    }

    .consent-details {
        max-height: 200px;
    }
}