:root {
    --ink: #172033;
    --muted: #657083;
    --line: #dfe6ef;
    --panel: #ffffff;
    --soft: #f6f8fb;
    --brand: #2c6bed;
    --brand-dark: #174bb3;
    --accent: #12b886;
    --warn: #f59f00;
    --danger: #e03131;
    --shadow: 0 22px 60px rgba(23, 32, 51, 0.12);
    --radius: 24px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(44, 107, 237, 0.12), transparent 34rem),
        linear-gradient(180deg, #fbfcff 0%, #eef3f8 100%);
    line-height: 1.6;
}

.speed-page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0;
}

.hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: stretch;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 16px;
    font-size: clamp(2.35rem, 6vw, 4.65rem);
    line-height: 0.96;
    letter-spacing: -0.055em;
}

h2 {
    margin-bottom: 8px;
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    letter-spacing: -0.035em;
}

h3 {
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.hero__content,
.tool-card,
.result-section,
.results-cta {
    border: 1px solid rgba(223, 230, 239, 0.95);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.hero__content { padding: clamp(28px, 5vw, 54px); }

.hero__subtitle {
    max-width: 740px;
    margin-bottom: 14px;
    color: #334158;
    font-size: clamp(1.08rem, 2vw, 1.35rem);
}

.hero__helper { max-width: 640px; margin-bottom: 0; color: var(--muted); }

.tool-card { padding: clamp(22px, 4vw, 34px); margin-bottom: 32px; }
.tool-card__header p, .section-heading p { color: var(--muted); margin-bottom: 0; }

.speed-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 18px;
    align-items: end;
    margin-top: 24px;
}

.field-group label,
.strategy-group legend {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
}

.field-group input {
    width: 100%;
    min-height: 56px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field-group input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(44, 107, 237, 0.14);
}

.field-help { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; }

.strategy-group {
    display: flex;
    gap: 10px;
    min-width: 310px;
    padding: 0;
    border: 0;
}

.strategy-group legend { width: 100%; }

.strategy-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    cursor: pointer;
}

.strategy-option:has(input:checked) {
    border-color: var(--brand);
    box-shadow: inset 0 0 0 1px var(--brand);
}

.strategy-option small { display: block; color: var(--muted); font-size: 0.78rem; }

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.primary-button {
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    box-shadow: 0 14px 30px rgba(44, 107, 237, 0.28);
}

.primary-button:hover,
.secondary-button:hover { transform: translateY(-1px); }

.primary-button:disabled { opacity: 0.65; cursor: wait; transform: none; }

.secondary-button {
    margin-top: 16px;
    color: var(--brand-dark);
    background: #eaf0ff;
}

.status-message,
.error-message {
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: 16px;
    font-weight: 700;
}

.status-message { color: #155d48; background: #e6fcf5; }
.error-message { color: #8f1b1b; background: #fff0f0; }

.results { display: grid; gap: 24px; }

.results__header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    padding: 28px;
    border-radius: var(--radius);
    color: #fff;
    background: linear-gradient(135deg, #16233f, #243b6b);
    box-shadow: var(--shadow);
}

.results__summary { margin-bottom: 0; color: rgba(255,255,255,0.82); }
.results__header .eyebrow { color: #91b4ff; }

.cached-badge {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 999px;
    color: #dff7ec;
    background: rgba(18, 184, 134, 0.16);
    font-size: 0.84rem;
    font-weight: 900;
}

.result-section { padding: clamp(20px, 4vw, 30px); }

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 18px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.score-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--soft);
}

.score-ring {
    --score-color: var(--accent);
    display: grid;
    place-items: center;
    width: 108px;
    height: 108px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: conic-gradient(var(--score-color) calc(var(--score) * 1%), #e5eaf2 0);
}

.score-ring span {
    display: grid;
    place-items: center;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: #fff;
    font-size: 1.8rem;
    font-weight: 950;
    letter-spacing: -0.06em;
}

.score-card h4 { margin: 0 0 4px; font-size: 1rem; }
.score-card p { margin: 0; color: var(--muted); font-weight: 700; }

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

.metric-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}

.metric-card strong { display: block; margin-bottom: 5px; }
.metric-value { font-size: 1.45rem; font-weight: 950; letter-spacing: -0.045em; }
.metric-card p { margin: 8px 0 0; color: var(--muted); font-size: 0.92rem; }

.field-data {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    color: #345;
    background: #f4f7fb;
}

.audit-list { display: grid; gap: 12px; }

.audit-item {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}

.audit-item__top {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.audit-item h4 { margin: 0; }
.audit-item p { margin: 0; color: var(--muted); }
.audit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.pill {
    padding: 5px 9px;
    border-radius: 999px;
    background: #edf2f7;
    color: #3c4858;
    font-size: 0.8rem;
    font-weight: 800;
}

.pill--savings { color: #7a4c00; background: #fff4d6; }
.pill--passed { color: #087f5b; background: #dff7ec; }

.prompt-section {
    background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(245,248,255,0.92));
}

.prompt-tabs {
    display: inline-flex;
    gap: 6px;
    padding: 6px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f2f6fb;
}

.prompt-tab {
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.prompt-tab.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    box-shadow: 0 10px 24px rgba(44, 107, 237, 0.22);
}

.prompt-panel {
    display: grid;
    gap: 14px;
}

.prompt-instructions {
    padding: 18px;
    border: 1px solid #dbe7ff;
    border-radius: 18px;
    background: #f7faff;
}

.prompt-instructions h4 {
    margin: 0 0 8px;
}

.prompt-instructions ol {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--muted);
}

.prompt-panel label {
    font-weight: 900;
}

.prompt-output {
    width: 100%;
    min-height: 320px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #101828;
    color: #f8fbff;
    font: 0.92rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    resize: vertical;
}

.prompt-output:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(44, 107, 237, 0.14);
}

.copy-prompt-button {
    justify-self: start;
    margin-top: 0;
}

.copy-status {
    margin: 12px 0 0;
    color: #155d48;
    font-weight: 800;
}

.technical-details {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 12px 18px;
    margin: 0;
}

.technical-details dt { color: var(--muted); font-weight: 900; }
.technical-details dd { margin: 0; word-break: break-word; }

.results-cta {
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, #ffffff, #eef5ff);
}

.results-cta p { color: var(--muted); }

.provider-credit {
    max-width: 760px;
    margin: 26px auto 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.provider-credit a {
    color: var(--brand-dark);
    font-weight: 800;
    text-decoration: none;
}

.provider-credit a:hover { text-decoration: underline; }

@media (max-width: 920px) {
    .speed-form { grid-template-columns: 1fr; }
    .strategy-group { min-width: 0; }
    .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .speed-page { width: min(100% - 20px, 1120px); padding: 20px 0; }
    .strategy-group,
    .results__header,
    .section-heading,
    .audit-item__top { display: block; }
    .strategy-option + .strategy-option { margin-top: 10px; }
    .score-grid,
    .metrics-grid { grid-template-columns: 1fr; }
    .technical-details { grid-template-columns: 1fr; }
    .prompt-tabs { display: flex; width: 100%; }
    .prompt-tab { flex: 1; }
}