:root {
    --bg: #0b1220;
    --panel: #121a2c;
    --text: #e6ecff;
    --muted: #8a9bbf;
    --brand: #65d9a0;
    --accent: #ffb63c;
    --error: #ff5e5e;
    --warn: #ffb63c;
    --info: #66a8ff;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(circle at top, #162440 0%, var(--bg) 60%);
    color: var(--text);
    line-height: 1.5;
    overflow-wrap: break-word;
    word-wrap: break-word;
    -webkit-hyphens: auto;
    hyphens: auto;
}

img { max-width: 100%; height: auto; }
code, pre { word-break: break-word; overflow-wrap: anywhere; }

a { color: var(--brand); word-break: break-word; }

/* --- topbar -------------------------------------------------------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
    gap: 16px;
    flex-wrap: wrap;
}
.brand { font-size: 22px; font-weight: 800; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand span { color: var(--brand); }
nav { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; }
nav a { text-decoration: none; color: var(--muted); white-space: nowrap; }
nav a.cta { color: var(--accent); font-weight: 600; }

/* --- language switcher --------------------------------------------- */
.lang-switcher { margin: 0; }
.lang-switcher select {
    background: rgba(255,255,255,0.08);
    color: var(--muted);
    border: 1px solid #2a3759;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 13px;
    cursor: pointer;
}

/* --- RTL support for Arabic ---------------------------------------- */
html[dir="rtl"] .topbar { flex-direction: row-reverse; }
html[dir="rtl"] nav { flex-direction: row-reverse; }
html[dir="rtl"] .audit-form { flex-direction: row-reverse; }
html[dir="rtl"] .finding { border-left: none; border-right: 4px solid var(--info); }
html[dir="rtl"] .finding--error { border-right-color: var(--error); }
html[dir="rtl"] .finding--warn { border-right-color: var(--warn); }
html[dir="rtl"] .htree__item { border-left: none; border-right: 2px solid #1b2540; padding-left: 0; padding-right: 8px; }
html[dir="rtl"] .htree__item--h1 { border-right-color: var(--brand); }
html[dir="rtl"] .htree__item--h2 { border-right-color: #4db88c; }
html[dir="rtl"] .htree__item--h3 { border-right-color: #3a8a6a; }
html[dir="rtl"] .check { flex-direction: row-reverse; text-align: right; }
html[dir="rtl"] .report__error { border-left: none; border-right: 4px solid var(--error); }

/* --- layout -------------------------------------------------------- */
main { max-width: 960px; margin: 0 auto; padding: 32px 20px; }

.hero h1 { font-size: clamp(28px, 5vw, 42px); margin: 0 0 12px; line-height: 1.15; }
.lede { color: var(--muted); max-width: 680px; font-size: clamp(15px, 2vw, 17px); }

.audit-form {
    display: flex; gap: 12px; margin: 28px 0 16px;
    flex-wrap: wrap;
}
.audit-form input {
    flex: 1 1 260px; min-width: 0;
    padding: 14px 16px; font-size: 16px; border-radius: 10px;
    border: 1px solid #2a3759; background: var(--panel); color: var(--text);
}
.audit-form button {
    flex: 0 0 auto;
    padding: 14px 22px; font-size: 16px; border: 0; border-radius: 10px;
    background: var(--brand); color: #0b1220; font-weight: 700; cursor: pointer;
    min-height: 48px;
}
.audit-form button:hover { filter: brightness(1.08); }

.quota-line { color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }

.flashes { list-style: none; padding: 0; margin: 0 auto; max-width: 960px; }
.flash { padding: 12px 18px; border-radius: 8px; margin: 8px 20px; background: var(--panel); }
.flash--error { border-left: 4px solid var(--error); }
.flash--success { border-left: 4px solid var(--brand); }

.recent { margin-top: 32px; }
.recent ul { list-style: none; padding: 0; }
.recent li { padding: 10px 0; border-bottom: 1px solid #1c2744; }

.pitch { margin-top: 32px; }
.pitch ul { padding-left: 18px; color: var(--muted); }

/* --- report -------------------------------------------------------- */
.report__head h1 { font-size: clamp(24px, 4vw, 32px); margin: 0 0 8px; }
.report__url code {
    display: inline-block;
    max-width: 100%;
    color: var(--accent);
    font-size: 0.9em;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.report__meta { color: var(--muted); font-size: 14px; line-height: 1.8; }

.state {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.state--pending { background: #2a3759; color: var(--muted); }
.state--running { background: #2a3759; color: var(--info); }
.state--done    { background: rgba(101, 217, 160, 0.15); color: var(--brand); }
.state--failed  { background: rgba(255, 94, 94, 0.15); color: var(--error); }

.score--good { color: var(--brand); }
.score--mid  { color: var(--warn); }
.score--bad  { color: var(--error); }

.waiting {
    background: var(--panel);
    padding: 24px;
    border-radius: 12px;
    margin: 24px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    border-left: 4px solid var(--info);
}
.waiting p { margin: 0; }
.waiting__elapsed { display: block; margin-top: 6px; font-size: 13px; }

.spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(102, 168, 255, 0.25);
    border-top-color: var(--info);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.report__error {
    background: var(--panel);
    padding: 24px;
    border-radius: 12px;
    margin: 24px 0;
    border-left: 4px solid var(--error);
}
.report__error h2 { margin-top: 0; }
.error-detail {
    background: #0b1220;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--error);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
}
.retry-form {
    display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap;
}
.retry-form input {
    flex: 1 1 220px; min-width: 0;
    padding: 10px 12px; font-size: 15px; border-radius: 8px;
    border: 1px solid #2a3759; background: #0b1220; color: var(--text);
}
.retry-form button {
    padding: 10px 18px; font-size: 15px; border: 0; border-radius: 8px;
    background: var(--accent); color: #1b1300; font-weight: 700; cursor: pointer;
}

.summary { margin: 24px 0; }
.summary dl {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr;
    gap: 8px 16px;
    margin: 0;
}
.summary dt { color: var(--muted); }
.summary dd { margin: 0; word-break: break-word; }

.findings__list { list-style: none; padding: 0; margin: 0; }
.finding {
    background: var(--panel);
    padding: 16px 18px;
    margin: 12px 0;
    border-radius: 12px;
    border-left: 4px solid var(--info);
}
.finding--error { border-left-color: var(--error); }
.finding--warn  { border-left-color: var(--warn); }
.finding__head  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.finding__head h3 { margin: 0; font-size: 17px; flex: 1 1 auto; min-width: 0; }
.tag {
    background: #1b2540;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    white-space: nowrap;
}
.tag--muted   { opacity: 0.7; }
.tag--error   { background: rgba(255, 94, 94, 0.15);  color: var(--error); }
.tag--warn    { background: rgba(255, 182, 60, 0.15); color: var(--warn); }
.tag--info    { background: rgba(102, 168, 255, 0.15); color: var(--info); }
.evidence {
    background: #0b1220; padding: 10px; border-radius: 6px;
    overflow-x: auto;
    color: var(--muted); font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
}
.fix { margin-top: 6px; color: var(--text); }

.report__back { margin-top: 32px; }

/* --- pricing ------------------------------------------------------- */
.pricing__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 24px;
}
.plan { background: var(--panel); padding: 22px; border-radius: 14px; }
.plan__price { font-size: 36px; font-weight: 800; margin: 4px 0; color: var(--brand); }
.plan button {
    width: 100%; padding: 12px; border: 0; border-radius: 8px;
    background: var(--accent); color: #1b1300; font-weight: 700; cursor: pointer;
    min-height: 48px;
}
.pricing__rex { margin-top: 36px; padding: 24px; background: var(--panel); border-radius: 14px; }
.cta { color: var(--accent); font-weight: 700; }

/* --- rexlama banner ------------------------------------------------ */
.rexlama-banner {
    max-width: 960px;
    margin: 24px auto;
    padding: 16px 20px;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, #1b2540, #2a1c40);
    border-radius: 14px;
    border: 1px solid #3b2e60;
    flex-wrap: wrap;
}
.rexlama-banner__text { flex: 1 1 260px; min-width: 0; }
.rexlama-banner__text strong { display: block; font-size: 16px; }
.rexlama-banner__text span { color: var(--muted); }
.rexlama-banner__cta {
    background: var(--accent);
    color: #1b1300;
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    flex: 0 0 auto;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* --- footer -------------------------------------------------------- */
footer {
    max-width: 960px;
    margin: 40px auto 60px;
    padding: 0 20px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

/* --- score hero ------------------------------------------------ */
.score-hero {
    display: flex;
    gap: 32px;
    align-items: center;
    margin: 32px 0;
    flex-wrap: wrap;
}
.score-gauge {
    position: relative;
    width: 150px; height: 150px;
    flex: 0 0 auto;
}
.score-gauge__ring {
    width: 100%; height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        var(--brand) 0% calc(var(--pct) * 1%),
        #1b2540 calc(var(--pct) * 1%) 100%
    );
    mask: radial-gradient(closest-side, transparent 72%, #000 73%);
    -webkit-mask: radial-gradient(closest-side, transparent 72%, #000 73%);
}
.score-gauge__center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.score-gauge__number { font-size: 42px; font-weight: 800; line-height: 1; }
.score-gauge__label { font-size: 14px; color: var(--muted); }
.score-hero__text { flex: 1 1 200px; }
.grade {
    display: inline-block;
    font-size: 28px; font-weight: 900;
    padding: 4px 16px;
    border-radius: 8px;
    background: rgba(101, 217, 160, 0.15);
    margin-bottom: 8px;
}
.grade--A { color: var(--brand); background: rgba(101, 217, 160, 0.15); }
.grade--B { color: #8ee0ba; background: rgba(142, 224, 186, 0.12); }
.grade--C { color: var(--warn); background: rgba(255, 182, 60, 0.12); }
.grade--D { color: #ff8b3c; background: rgba(255, 139, 60, 0.12); }
.grade--F { color: var(--error); background: rgba(255, 94, 94, 0.12); }

/* --- quick stats ------------------------------------------------ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin: 24px 0;
}
.stat {
    background: var(--panel);
    padding: 16px 14px;
    border-radius: 12px;
    text-align: center;
}
.stat__num { display: block; font-size: 26px; font-weight: 800; color: var(--text); }
.stat__num small { font-size: 14px; font-weight: 400; color: var(--muted); }
.stat__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* --- SERP preview ---------------------------------------------- */
.serp-preview { margin: 28px 0; }
.serp-card {
    background: #fff;
    color: #222;
    border-radius: 10px;
    padding: 18px 20px;
    max-width: 600px;
    font-family: Arial, sans-serif;
}
.serp-card__url { display: block; font-size: 13px; color: #202124; margin-bottom: 2px; word-break: break-all; font-style: normal; }
.serp-card__title { font-size: 20px; color: #1a0dab; margin: 0; font-weight: 400; line-height: 1.3; word-break: break-word; }
.serp-card__desc { font-size: 14px; color: #4d5156; margin: 4px 0 0; line-height: 1.5; word-break: break-word; }

/* --- checklist ------------------------------------------------- */
.checklist-section { margin: 32px 0; }
.checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}
.checklist__group { background: var(--panel); border-radius: 12px; padding: 18px 16px; }
.checklist__group h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 14px;
}
.check:last-child { border-bottom: none; }
.check__icon {
    flex: 0 0 24px;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
}
.check--pass .check__icon { background: rgba(101, 217, 160, 0.2); color: var(--brand); }
.check--fail .check__icon { background: rgba(255, 94, 94, 0.2); color: var(--error); }
.check--pass .check__label { color: var(--text); }
.check--fail .check__label { color: var(--error); }

/* --- tech details grid ----------------------------------------- */
.tech-details { margin: 28px 0; }
.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px 24px;
}
.tech-item { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.tech-item dt { color: var(--muted); min-width: 120px; flex: 0 0 auto; font-size: 14px; }
.tech-item dd { margin: 0; font-size: 14px; }
.dd-wrap { word-break: break-word; }

/* --- heading tree ---------------------------------------------- */
.heading-tree { margin: 28px 0; }
.htree { list-style: none; padding: 0; margin: 0; }
.htree__item {
    display: flex; align-items: flex-start; gap: 8px; padding: 4px 0;
    border-left: 2px solid #1b2540;
    margin-left: 0;
}
.htree__item--h1 { margin-left: 0;   border-left-color: var(--brand); padding-left: 8px; }
.htree__item--h2 { margin-left: 18px; border-left-color: #4db88c; padding-left: 8px; }
.htree__item--h3 { margin-left: 36px; border-left-color: #3a8a6a; padding-left: 8px; }
.htree__item--h4 { margin-left: 54px; border-left-color: #2d6b52; padding-left: 8px; }
.htree__item--h5 { margin-left: 72px; border-left-color: #224e3d; padding-left: 8px; }
.htree__item--h6 { margin-left: 90px; border-left-color: #193627; padding-left: 8px; }
.htree__tag {
    flex: 0 0 auto;
    background: #1b2540; padding: 1px 7px; border-radius: 4px;
    font-size: 11px; font-weight: 700; color: var(--brand);
}
.htree__text { font-size: 14px; color: var(--text); word-break: break-word; }

/* --- findings section ------------------------------------------ */
.findings-section { margin: 32px 0; }
.findings-cat { margin: 20px 0; }
.findings-cat__name { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 10px; }
.finding__head h4 { margin: 0; font-size: 17px; flex: 1 1 auto; min-width: 0; }
.finding__msg { margin: 6px 0; font-size: 14px; color: var(--text); }
.finding__details { margin: 8px 0; }
.finding__details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* --- all pass --- */
.all-pass {
    background: rgba(101, 217, 160, 0.08);
    border: 1px solid rgba(101, 217, 160, 0.2);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}
.all-pass p:first-child { font-size: 18px; font-weight: 700; color: var(--brand); }

/* --- report CTA ------------------------------------------------ */
/* --- recheck buttons ------------------------------------------- */
.finding__actions {
    display: flex; gap: 12px; align-items: center; margin-top: 10px; flex-wrap: wrap;
}
.recheck-btn {
    padding: 7px 16px; font-size: 13px; font-weight: 700;
    border: 1px solid #2a3759; border-radius: 8px;
    background: transparent; color: var(--info); cursor: pointer;
    min-height: 36px; transition: background 0.15s, color 0.15s;
}
.recheck-btn:hover:not(:disabled) { background: rgba(102, 168, 255, 0.1); }
.recheck-btn:disabled { opacity: 0.6; cursor: default; }
.recheck-btn--fixed { color: var(--brand); border-color: rgba(101, 217, 160, 0.3); }
.recheck-btn--still { color: var(--warn); border-color: rgba(255, 182, 60, 0.3); }
.recheck-btn--exhausted { color: var(--error); border-color: rgba(255, 94, 94, 0.3); font-size: 12px; }
.recheck-time { font-size: 12px; }
.finding--fixed { border-left-color: var(--brand) !important; opacity: 0.75; }
.finding--fixed .finding__msg { color: var(--brand); }
.tag--fixed { background: rgba(101, 217, 160, 0.2); color: var(--brand); }
.tag--still { background: rgba(255, 182, 60, 0.15); color: var(--warn); }

/* --- report CTA ------------------------------------------------ */
.report-cta {
    background: linear-gradient(135deg, #1b2540, #2a1c40);
    border-radius: 14px;
    padding: 28px 24px;
    margin: 32px 0;
    border: 1px solid #3b2e60;
    text-align: center;
}
.report-cta h2 { margin-top: 0; }
.report-cta .rexlama-banner__cta { margin-top: 12px; }

/* ----------------------------------------------------------- */
/* Mobile + narrow viewports                                   */
/* ----------------------------------------------------------- */
@media (max-width: 720px) {
    .topbar {
        padding: 14px 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    nav { width: 100%; justify-content: flex-start; gap: 10px 14px; }
    nav a { font-size: 14px; }

    main { padding: 24px 16px; }

    .hero h1 { font-size: 28px; }
    .audit-form { flex-direction: column; align-items: stretch; }
    .audit-form button { width: 100%; }

    .summary dl {
        grid-template-columns: 1fr;
        gap: 2px 0;
    }
    .summary dt {
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-top: 10px;
    }
    .summary dd { margin-bottom: 6px; }

    .finding { padding: 14px; }
    .finding__head h3 { font-size: 16px; }

    .rexlama-banner {
        margin: 20px 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    .rexlama-banner__cta { width: 100%; justify-content: center; }

    .flash { margin: 8px 16px; }

    .pricing__grid { grid-template-columns: 1fr; }
    .plan__price { font-size: 32px; }

    .retry-form { flex-direction: column; }
    .retry-form button { width: 100%; }

    footer { margin: 32px auto 48px; padding: 0 16px; }
    .report__meta { line-height: 1.6; }

    .score-hero { flex-direction: column; gap: 20px; align-items: center; text-align: center; }
    .score-gauge { width: 120px; height: 120px; }
    .score-gauge__number { font-size: 34px; }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
    .stat__num { font-size: 22px; }
    .checklist { grid-template-columns: 1fr; }
    .tech-grid { grid-template-columns: 1fr; }
    .tech-item { flex-direction: column; gap: 2px; }
    .tech-item dt { min-width: unset; }
    .htree__item--h2 { margin-left: 12px; }
    .htree__item--h3 { margin-left: 24px; }
    .htree__item--h4 { margin-left: 36px; }
    .htree__item--h5 { margin-left: 48px; }
    .htree__item--h6 { margin-left: 60px; }
    .serp-card { padding: 14px; }
    .serp-card__title { font-size: 17px; }
}

@media (max-width: 420px) {
    .hero h1 { font-size: 26px; }
    .lede { font-size: 15px; }
    nav { gap: 8px 12px; }
    nav a { font-size: 13px; }
}
