:root {
    --bg: #060913;
    --panel: rgba(12, 18, 36, 0.86);
    --panel-strong: rgba(16, 25, 50, 0.96);
    --border: rgba(132, 220, 255, 0.18);
    --text: #eef7ff;
    --muted: #8fa4b8;
    --soft: #c8d8e8;
    --cyan: #11d8ff;
    --green: #28f7a5;
    --pink: #ff4dd8;
    --amber: #ffc64d;
    --red: #ff5b6b;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

[hidden] { display: none !important; }

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 10%, rgba(17, 216, 255, 0.24), transparent 28%),
        radial-gradient(circle at 90% 15%, rgba(255, 77, 216, 0.16), transparent 32%),
        linear-gradient(135deg, #050812 0%, #09101f 48%, #03050b 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent 70%);
}

.page-shell {
    position: relative;
    width: min(1420px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.hero-panel,
.metric-card,
.chart-card,
.info-card,
.explain-card {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(17, 27, 54, 0.88), rgba(8, 13, 28, 0.88));
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 28px;
    align-items: end;
    padding: 34px;
    border-radius: 30px;
    overflow: hidden;
}

.hero-panel::after {
    content: "";
    position: absolute;
    width: 320px;
    height: 320px;
    top: -160px;
    right: 120px;
    background: radial-gradient(circle, rgba(17, 216, 255, 0.2), transparent 65%);
    pointer-events: none;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--cyan);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    max-width: 840px;
    margin-bottom: 14px;
    font-size: clamp(38px, 5vw, 74px);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.lead {
    max-width: 820px;
    margin-bottom: 0;
    color: var(--soft);
    font-size: clamp(17px, 2vw, 21px);
    line-height: 1.5;
}

.hero-actions {
    min-width: 260px;
    display: grid;
    gap: 12px;
}

button {
    border: 0;
    border-radius: 16px;
    padding: 15px 20px;
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

button:not(:disabled):hover {
    transform: translateY(-1px);
}

.primary-btn {
    background: linear-gradient(135deg, var(--cyan), var(--green));
    color: #001018;
    box-shadow: 0 0 28px rgba(17, 216, 255, 0.26);
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.status-text {
    min-height: 22px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-top: 18px;
}

body:not(.test-complete) .score-grid { display: none; }

.summary-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    overflow: hidden;
    margin-top: 18px;
    border: 1px solid rgba(17, 216, 255, 0.26);
    border-radius: 24px;
    background: rgba(17, 216, 255, 0.12);
}

.summary-panel article,
.summary-panel p {
    margin: 0;
    padding: 18px 22px;
    background: rgba(7, 13, 29, 0.92);
}

.summary-panel span,
.summary-panel small,
.summary-panel p {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.summary-panel strong {
    display: inline-block;
    margin: 8px 7px 0 0;
    font-size: clamp(30px, 4vw, 52px);
    letter-spacing: -.06em;
}

.summary-panel p {
    grid-column: 1 / -1;
    text-align: center;
}

.details-panel { margin-top: 18px; }

.details-panel > summary {
    cursor: pointer;
    color: var(--ink);
    font-weight: 800;
    list-style: none;
    padding: 16px 20px;
    border: 1px solid rgba(143, 164, 184, 0.25);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
}

.details-panel > summary::before { content: '+'; margin-right: 10px; color: var(--cyan); }
.details-panel[open] > summary::before { content: '−'; }

.details-panel > summary.receive-flash {
    border-color: rgba(40, 247, 165, 0.7);
    box-shadow: 0 0 30px rgba(40, 247, 165, 0.18);
    animation: receiveFlash 850ms cubic-bezier(.2,.8,.2,1) both;
}

.share-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: 30px 0 12px;
    color: var(--muted);
}

.share-bar > span {
    margin-right: 3px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.share-button {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(143, 164, 184, 0.25);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    font: 800 15px/1 system-ui, sans-serif;
    text-decoration: none;
    transition: transform .18s ease, color .18s ease, border-color .18s ease, background .18s ease;
}

.share-button:hover {
    transform: translateY(-2px);
    border-color: rgba(17, 216, 255, 0.7);
    background: rgba(17, 216, 255, 0.12);
    color: var(--ink);
}

.share-button svg { width: 17px; height: 17px; fill: currentColor; }

.secondary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 18px;
}

.metric-card {
    min-height: 150px;
    padding: 20px;
    border-radius: 24px;
}

.main-metric {
    grid-column: span 2;
}

.metric-label,
.metric-unit {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    margin: 12px 0 8px;
    font-size: clamp(34px, 4.2vw, 62px);
    line-height: 1;
    letter-spacing: -0.06em;
    text-shadow: 0 0 22px rgba(17, 216, 255, 0.28);
}

.grade-card strong {
    color: var(--green);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-top: 18px;
}

.chart-card {
    padding: 22px;
    border-radius: 28px;
}

.history-tabs {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-tab {
    border: 1px solid rgba(143, 164, 184, 0.28);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 12px;
}

.history-tab:hover, .history-tab.is-selected {
    color: var(--ink);
    border-color: rgba(17, 216, 255, 0.75);
    background: rgba(17, 216, 255, 0.12);
}

.metric-card.has-history { cursor: pointer; }

.metric-explainer {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.metric-explainer summary {
    cursor: pointer;
    font-weight: 800;
    list-style: none;
}

.metric-explainer summary::-webkit-details-marker { display: none; }
.metric-explainer summary::before { content: '?'; margin-right: 6px; color: var(--cyan); }
.metric-explainer p { margin: 7px 0 0; }

.card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
}

.card-head h2,
.info-card h2,
.explain-card h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.02em;
}

.card-head span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chart-wrap {
    height: 330px;
}

.diagnostics-grid {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    gap: 18px;
    margin-top: 18px;
}

.info-card,
.explain-card {
    padding: 24px;
    border-radius: 28px;
}

.suitability-list {
    display: grid;
    gap: 14px;
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
}

.suitability-list li {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 4px 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
}

.suitability-list small {
    grid-column: 2;
    color: var(--muted);
    font-size: 14px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    box-shadow: 0 0 12px currentColor;
}

.dot.good { color: var(--green); background: var(--green); }
.dot.warn { color: var(--amber); background: var(--amber); }
.dot.bad { color: var(--red); background: var(--red); }
.dot.neutral { color: var(--muted); background: var(--muted); }

.tech-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin: 22px 0 0;
}

.tech-list div {
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 0;
}

.tech-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tech-list dd {
    margin: 6px 0 0;
    color: var(--soft);
    overflow-wrap: anywhere;
}

.explain-card {
    margin-top: 18px;
}

.explain-card p {
    color: var(--soft);
    line-height: 1.6;
}

.explain-card p:last-child {
    margin-bottom: 0;
}

@media (max-width: 1100px) {
    .hero-panel,
    .diagnostics-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }

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

    .detail-grid,
    .secondary-grid { grid-template-columns: repeat(2, 1fr); }

    .main-metric {
        grid-column: span 3;
    }
}

@media (max-width: 680px) {
    .page-shell {
        width: min(100% - 20px, 1420px);
        padding-top: 14px;
    }

    .hero-panel,
    .metric-card,
    .chart-card,
    .info-card,
    .explain-card {
        border-radius: 20px;
    }

    .hero-panel {
        padding: 22px;
    }

    .score-grid,
    .summary-panel,
    .secondary-grid,
    .detail-grid,
    .tech-list {
        grid-template-columns: 1fr;
    }

    .main-metric {
        grid-column: span 1;
    }

    .chart-wrap {
        height: 260px;
    }
}

/* Compact, translation-friendly interface */
.hero-panel { padding: 34px; }
.hero-copy { max-width: 540px; }
.hero-copy h1 { font-size: clamp(34px, 5vw, 62px); }
.lead { margin: 8px 0 0; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.score-grid .metric-card { min-height: 132px; }
.metric-label { letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
.suitability-list small { font-weight: 800; }

/* Live-lava ja tulemuste lendamise animatsioonid */
.test-stage {
    position: relative;
    align-items: stretch;
    transition: transform 420ms ease, filter 420ms ease;
}

.stage-ribbon {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border: 1px solid rgba(17, 216, 255, 0.18);
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(17, 216, 255, 0.12), rgba(255, 77, 216, 0.08));
    color: var(--muted);
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.22);
}

.stage-ribbon span {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.stage-ribbon strong {
    color: var(--text);
    font-size: 15px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.test-stage .chart-card {
    min-height: 430px;
    transition: transform 420ms cubic-bezier(.2,.8,.2,1), border-color 420ms ease, box-shadow 420ms ease, opacity 420ms ease;
}

.test-stage:not(.is-active) .chart-card {
    opacity: 0.78;
}

.test-stage:not(.is-active):not(.has-results) {
    display: block;
    min-height: 0;
    padding: 0;
}

.test-stage:not(.is-active):not(.has-results) .chart-card,
.test-stage:not(.is-active):not(.has-results) .history-tabs {
    display: none;
}

.test-stage.is-active {
    animation: liveStageIn 620ms cubic-bezier(.2,.8,.2,1) both;
}

.test-stage.is-active .chart-card {
    min-height: 500px;
    border-color: rgba(17, 216, 255, 0.34);
    box-shadow: 0 34px 95px rgba(0, 0, 0, 0.55), 0 0 54px rgba(17, 216, 255, 0.12);
}

.chart-card.stage-focus {
    transform: translateY(-6px) scale(1.012);
    border-color: rgba(40, 247, 165, 0.52);
    box-shadow: 0 38px 105px rgba(0, 0, 0, 0.58), 0 0 62px rgba(40, 247, 165, 0.16);
}

.mini-copy {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.live-value {
    flex: 0 0 auto;
    padding: 10px 13px;
    border: 1px solid rgba(17, 216, 255, 0.28);
    border-radius: 999px;
    background: rgba(17, 216, 255, 0.08);
    color: var(--green);
    font-size: clamp(18px, 2.3vw, 30px);
    letter-spacing: -0.04em;
    text-shadow: 0 0 18px rgba(40, 247, 165, 0.35);
    white-space: nowrap;
}

.pulse-soft {
    animation: pulseSoft 360ms ease both;
}

.metric-card {
    position: relative;
    overflow: hidden;
    transition: transform 260ms ease, border-color 260ms ease, box-shadow 260ms ease;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle, rgba(17,216,255,0.20), transparent 54%);
    opacity: 0;
    transform: scale(0.7);
    pointer-events: none;
    transition: opacity 260ms ease, transform 260ms ease;
}

.metric-card.is-active {
    transform: translateY(-4px);
    border-color: rgba(255, 198, 77, 0.48);
    box-shadow: 0 26px 78px rgba(0,0,0,0.52), 0 0 40px rgba(255,198,77,0.12);
}

.metric-card.is-active::after {
    opacity: 1;
    transform: scale(1);
    animation: metricScan 1.2s ease-in-out infinite;
}

.metric-card.is-complete,
.metric-card.receive-flash {
    border-color: rgba(40, 247, 165, 0.56);
    box-shadow: 0 28px 82px rgba(0,0,0,0.54), 0 0 42px rgba(40,247,165,0.17);
}

.metric-card.receive-flash {
    animation: receiveFlash 850ms cubic-bezier(.2,.8,.2,1) both;
}

.result-flyer {
    position: fixed;
    z-index: 9999;
    min-width: 178px;
    padding: 13px 16px;
    border: 1px solid rgba(40, 247, 165, 0.55);
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(8, 13, 28, 0.96), rgba(17, 40, 64, 0.96));
    color: var(--text);
    box-shadow: 0 28px 88px rgba(0,0,0,0.62), 0 0 44px rgba(40,247,165,0.20);
    pointer-events: none;
    transform: translate(-50%, -50%);
    backdrop-filter: blur(18px);
}

.result-flyer span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.result-flyer strong {
    display: block;
    margin-top: 4px;
    color: var(--green);
    font-size: 26px;
    line-height: 1;
    letter-spacing: -0.05em;
}

body.test-running .hero-panel {
    transform: scale(0.985);
    opacity: 0.88;
}

@keyframes liveStageIn {
    0% { transform: translateY(24px) scale(0.97); opacity: 0.42; filter: blur(8px); }
    100% { transform: translateY(0) scale(1); opacity: 1; filter: blur(0); }
}

@keyframes pulseSoft {
    0% { transform: scale(0.96); }
    45% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes metricScan {
    0%, 100% { opacity: 0.28; transform: translateX(-20%) scale(0.85); }
    50% { opacity: 0.58; transform: translateX(20%) scale(1.02); }
}

@keyframes receiveFlash {
    0% { transform: scale(1); }
    42% { transform: scale(1.045); }
    100% { transform: scale(1); }
}

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

@media (max-width: 1100px) {
    .stage-ribbon {
        grid-column: auto;
    }

    .test-stage .chart-card,
    .test-stage.is-active .chart-card {
        min-height: 390px;
    }
}

@media (max-width: 680px) {
    .stage-ribbon {
        align-items: flex-start;
        flex-direction: column;
    }

    .card-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .live-value {
        width: 100%;
        text-align: center;
    }

    .test-stage .chart-card,
    .test-stage.is-active .chart-card {
        min-height: 340px;
    }

    .result-flyer {
        min-width: 142px;
    }

    .result-flyer strong {
        font-size: 21px;
    }
}
