:root {
    --bg: #0b1020;
    --bg-soft: #121a30;
    --card: #161f38;
    --card-2: #1b2746;
    --border: #243156;
    --text: #e8edf7;
    --muted: #93a0bd;
    --accent: #c8ff3d;
    --accent-soft: rgba(200, 255, 61, 0.14);
    --glow: 0 0 24px rgba(200, 255, 61, 0.35);

    --grade-A: #34d399;
    --grade-B: #a3e635;
    --grade-C: #fbbf24;
    --grade-D: #fb923c;
    --grade-F: #f87171;

    --radius: 14px;
    --maxw: 880px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 50% -10%, #16213f 0%, var(--bg) 55%) no-repeat;
    color: var(--text);
    font-family: var(--font);
    line-height: 1.55;
    min-height: 100vh;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 22px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--text); text-decoration: none;
    font-weight: 700; letter-spacing: -0.01em;
}
.brand-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent); box-shadow: var(--glow);
}
.brand-tool { color: var(--accent); font-weight: 600; }

.lang-switch { display: flex; gap: 4px; }
.lang-switch a {
    color: var(--muted); text-decoration: none;
    font-size: 13px; font-weight: 600;
    padding: 6px 9px; border-radius: 8px;
    transition: background .15s, color .15s;
}
.lang-switch a:hover { color: var(--text); background: var(--bg-soft); }
.lang-switch a.active { color: var(--bg); background: var(--accent); }

/* Hero */
.hero { text-align: center; padding: 40px 0 28px; }
.hero h1 {
    font-size: clamp(34px, 7vw, 52px);
    margin: 0 0 12px;
    letter-spacing: -0.03em;
    background: linear-gradient(180deg, #fff, #b9c6e6);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { color: var(--muted); max-width: 560px; margin: 0 auto 28px; font-size: 17px; }

/* Form */
.tester { max-width: 620px; margin: 0 auto; }
.input-row {
    display: flex; gap: 10px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.input-row input {
    flex: 1; min-width: 0;
    background: transparent; border: 0; outline: none;
    color: var(--text); font-size: 16px; padding: 12px 14px;
    font-family: var(--mono);
}
.input-row input::placeholder { color: #5d6b8c; }
.input-row button {
    background: var(--accent); color: #0c1326;
    border: 0; border-radius: 10px;
    font-weight: 700; font-size: 15px;
    padding: 0 22px; cursor: pointer; white-space: nowrap;
    transition: transform .1s, box-shadow .15s, opacity .15s;
}
.input-row button:hover { box-shadow: var(--glow); }
.input-row button:active { transform: scale(.98); }
.input-row button[disabled] { opacity: .55; cursor: progress; box-shadow: none; }

.error {
    color: var(--grade-F); font-size: 14px; margin: 12px 2px 0;
    text-align: left;
}

/* Result card */
.result-card {
    text-align: left;
    margin: 26px auto 0; max-width: 620px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
    animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.result-head { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.result-grade {
    width: 58px; height: 58px; border-radius: 12px;
    display: grid; place-items: center;
    font-size: 28px; font-weight: 800; color: #0c1326; flex: none;
}
.result-title { flex: 1; min-width: 0; }
.result-title .host { font-family: var(--mono); font-size: 16px; word-break: break-all; }
.result-title .sub { color: var(--muted); font-size: 13px; }
.result-ttfb { text-align: right; flex: none; }
.result-ttfb .v { font-size: 30px; font-weight: 800; font-family: var(--mono); }
.result-ttfb .u { color: var(--muted); font-size: 13px; }

.waterfall { margin-top: 18px; display: grid; gap: 9px; }
.wf-row { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 10px; }
.wf-label { color: var(--muted); font-size: 13px; }
.wf-bar { background: var(--bg-soft); border-radius: 6px; height: 10px; overflow: hidden; }
.wf-fill { height: 100%; border-radius: 6px; transition: width .5s ease; }
.wf-fill.dns { background: #818cf8; }
.wf-fill.connect { background: #38bdf8; }
.wf-fill.tls { background: #2dd4bf; }
.wf-fill.wait { background: var(--accent); }
.wf-val { text-align: right; font-family: var(--mono); font-size: 13px; }

.result-meta {
    margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
    display: flex; flex-wrap: wrap; gap: 6px 18px;
    color: var(--muted); font-size: 13px;
}
.result-meta b { color: var(--text); font-weight: 600; }

/* Grade colors */
[data-grade="A"], .g-A { background: var(--grade-A); }
[data-grade="B"], .g-B { background: var(--grade-B); }
[data-grade="C"], .g-C { background: var(--grade-C); }
[data-grade="D"], .g-D { background: var(--grade-D); }
[data-grade="F"], .g-F { background: var(--grade-F); }

/* Recent */
.recent { margin: 54px 0 10px; }
.recent h2, .content h2 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 16px; }
.empty { color: var(--muted); }

.recent-table {
    width: 100%; border-collapse: collapse;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.recent-table th, .recent-table td {
    padding: 13px 16px; text-align: left; font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.recent-table thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--bg-soft); }
.recent-table tbody tr:last-child td { border-bottom: 0; }
.recent-table tbody tr { transition: background .15s; }
.recent-table tbody tr:hover { background: var(--card-2); }
.recent-table .host { font-family: var(--mono); word-break: break-all; }
.recent-table .num { font-family: var(--mono); }
.recent-table .center { text-align: center; }
.recent-table .right { text-align: right; }
.recent-table .when { color: var(--muted); white-space: nowrap; }
.recent-table tr.new td { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

.grade {
    display: inline-grid; place-items: center;
    width: 26px; height: 26px; border-radius: 7px;
    font-weight: 800; font-size: 13px; color: #0c1326;
}

/* Content / FAQ */
.content { margin: 48px 0; color: var(--muted); }
.content p { max-width: 70ch; }
.faq { display: grid; gap: 10px; max-width: 70ch; }
.faq details {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 10px; padding: 4px 16px;
}
.faq summary {
    cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--text);
    list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--accent); font-weight: 700; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 14px; }

/* Footer */
.site-footer {
    max-width: var(--maxw); margin: 40px auto 0; padding: 24px 20px 48px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    color: var(--muted); font-size: 14px;
}
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 560px) {
    .wf-row { grid-template-columns: 96px 1fr 56px; }
    .result-head { flex-wrap: wrap; }
    .recent-table th:nth-child(2), .recent-table td:nth-child(2) { display: none; }
}
