:root {
    --bg-a: #f2efe7;
    --bg-b: #e7f6f2;
    --panel: rgba(255, 255, 255, 0.9);
    --ink: #112a2a;
    --muted: #496060;
    --line: #c6d6d2;
    --accent: #007c7c;
    --accent-2: #eb5e28;
    --good: #1e8e3e;
    --medium: #f9ab00;
    --bad: #d93025;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    font-size: 16px;
    color: var(--ink);
    background: radial-gradient(circle at 5% 15%, #fff8ef 0%, rgba(255, 248, 239, 0) 45%),
        radial-gradient(circle at 95% 8%, #d7f8f0 0%, rgba(215, 248, 240, 0) 42%),
        linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 100%);
    min-height: 100vh;
}

.page {
    width: min(1120px, 92vw);
    margin: 0 auto;
    padding: 2.25rem 0 3rem;
}

.hero {
    margin-bottom: 1.4rem;
}

.tag {
    display: inline-block;
    margin: 0;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(0, 124, 124, 0.12);
    border: 1px solid rgba(0, 124, 124, 0.22);
}

h1 {
    margin: 0.65rem 0 0.45rem;
    font-size: clamp(1.75rem, 3vw, 2.6rem);
    line-height: 1.1;
}

.subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 64ch;
}

.panel,
.results {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    border-radius: 1rem;
    box-shadow: 0 18px 36px rgba(38, 64, 63, 0.12);
    padding: 1.2rem;
}

.results {
    margin-top: 1.2rem;
}

.audit-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.url-group {
    flex: 2;
    min-width: 280px;
}

.strategy-group {
    flex: 1;
    min-width: 180px;
}

.form-actions {
    flex: 0 0 auto;
}

label {
    font-size: 0.95rem;
    font-weight: 700;
}

input,
select,
button,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    padding: 0.76rem 0.85rem;
    background: #fff;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: 2px solid rgba(0, 124, 124, 0.28);
    outline-offset: 2px;
}

button {
    border: none;
    border-radius: 0.72rem;
    background: linear-gradient(95deg, var(--accent), #00a6a6);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    min-height: 44px;
    padding: 0.72rem 1rem;
    transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: saturate(1.08);
}

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

#auditForm button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.spinner {
    width: 0;
    height: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 999px;
    opacity: 0;
    transition: width 0.2s ease, height 0.2s ease, opacity 0.2s ease;
}

#analyzeButton.is-loading .spinner {
    width: 16px;
    height: 16px;
    opacity: 1;
    animation: spin 0.8s linear infinite;
}

.alert {
    margin-top: 0.85rem;
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    font-weight: 600;
}

.alert.error {
    color: #7d2f2f;
    border: 1px solid #f3b3b3;
    background: #fff0f0;
}

.results-header h2 {
    margin: 0;
}

.result-meta {
    margin: 0.4rem 0 0.9rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.executive-box {
    border: 1px solid #d2e1dd;
    border-radius: 0.95rem;
    background: linear-gradient(130deg, #ffffff 0%, #f6fbfa 100%);
    padding: 0.95rem;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 0.85rem;
}

.exec-column h3 {
    margin: 0;
    font-size: 1.08rem;
}

.exec-problem {
    margin: 0.5rem 0 0.75rem;
    line-height: 1.45;
    color: #2f4747;
}

.worst-scores-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.42rem;
}

.worst-scores-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.55rem;
    border: 1px solid #e1ece9;
    border-radius: 0.55rem;
}

.exec-cta {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.65rem;
    border-left: 1px solid #deebe7;
    padding-left: 0.85rem;
}

.exec-cta p {
    margin: 0;
    color: #425a5a;
    font-size: 0.94rem;
}

.cta-main {
    background: linear-gradient(95deg, #eb5e28, #ff8e3c);
    font-size: 1.03rem;
    min-height: 48px;
}

.scores-grid {
    margin-top: 0.9rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 0.72rem;
}

.score-card,
.metric-card {
    border: 1px solid #d3e1de;
    border-radius: 0.9rem;
    background: #fff;
    padding: 0.85rem;
}

.score-card h3,
.metric-card h3 {
    margin: 0;
    font-size: 1rem;
}

.score-progress {
    margin-top: 0.72rem;
    height: 11px;
    width: 100%;
    border-radius: 999px;
    background: #edf3f1;
    overflow: hidden;
}

.score-progress-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    transition: width 0.55s ease;
}

.score-value {
    margin: 0.62rem 0 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.score-good,
.score-progress-fill.score-good {
    color: var(--good);
    background: linear-gradient(90deg, #31a451, #2fbe60);
}

.score-medium,
.score-progress-fill.score-medium {
    color: #9a6b00;
    background: linear-gradient(90deg, #f7ba30, #ffd56e);
}

.score-low,
.score-progress-fill.score-low {
    color: var(--bad);
    background: linear-gradient(90deg, #e05247, #f17464);
}

.score-unknown,
.score-progress-fill.score-unknown {
    color: #5a6d6d;
    background: linear-gradient(90deg, #b9c9c4, #d7e1de);
}

.metrics-grid {
    margin-top: 0.85rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 0.7rem;
}

.metric-card {
    background: linear-gradient(180deg, #fff, #f7fbfa);
}

.metric-card p {
    margin: 0.42rem 0 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.02rem;
    font-weight: 600;
}

.audit-groups {
    margin-top: 1rem;
    display: grid;
    gap: 0.72rem;
}

.audit-category {
    border: 1px solid #d6e6e2;
    border-radius: 0.85rem;
    background: #fff;
    overflow: hidden;
}

.audit-category > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.8rem 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
}

.audit-category > summary::-webkit-details-marker {
    display: none;
}

.summary-count {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 600;
}

.audit-category-content {
    border-top: 1px solid #e7f0ed;
    padding: 0.82rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.audit-subgroup h4 {
    margin: 0 0 0.6rem;
}

.audit-item {
    border: 1px solid #dbe8e4;
    border-radius: 0.74rem;
    padding: 0.74rem;
    margin-bottom: 0.62rem;
    animation: slideIn 0.35s ease both;
}

.audit-item:last-child {
    margin-bottom: 0;
}

.audit-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.audit-description {
    margin: 0.5rem 0 0;
    color: #324949;
    line-height: 1.45;
}

.clamp-2 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.category-badge {
    display: inline-block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 999px;
    padding: 0.2rem 0.5rem;
    border: 1px solid transparent;
}

.cat-performance {
    color: #8a4600;
    background: #fff3e7;
    border-color: #ffd3ad;
}

.cat-accessibility {
    color: #105f2b;
    background: #e8f7ee;
    border-color: #bfe2cb;
}

.cat-best-practices {
    color: #125a70;
    background: #e8f4f9;
    border-color: #bddcec;
}

.cat-seo {
    color: #5c4f12;
    background: #fdf8e4;
    border-color: #f1df95;
}

.meta {
    margin-top: 0.58rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.58rem;
    font-size: 0.86rem;
    color: #3f5656;
}

.affected-list {
    margin: 0.55rem 0 0;
    padding-left: 1.1rem;
    color: #495f5f;
    font-size: 0.86rem;
}

.affected-list li {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.2rem;
}

.learn-more-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.62rem;
    color: var(--accent-2);
    font-weight: 800;
    text-decoration: none;
}

.learn-more-link:hover {
    text-decoration: underline;
}

.empty {
    margin: 0;
    border: 1px dashed #cbdad6;
    border-radius: 0.7rem;
    color: #5c6f6f;
    padding: 0.65rem;
}

.prompt-builder {
    margin-top: 1rem;
    border-top: 1px solid #d8e5e1;
    padding-top: 1rem;
}

#copyPromptBtn {
    background: linear-gradient(95deg, #eb5e28, #ff8e3c);
    margin-top: 0.55rem;
}

#promptOutput {
    min-height: 260px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.45;
}

.copy-status {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.history-panels {
    margin-top: 1rem;
    display: grid;
    gap: 0.8rem;
}

.history-panel {
    border: 1px solid #d3e1de;
    border-radius: 0.9rem;
    background: #fff;
    padding: 0.8rem;
}

.history-panel h3 {
    margin: 0 0 0.7rem;
    font-size: 1rem;
}

.panel-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.panel-header-row h3 {
    margin: 0;
}

.ghost-btn {
    background: #fff;
    color: #385252;
    border: 1px solid #cfe0dc;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #e4eeeb;
    border-radius: 0.65rem;
}

.history-table,
.ranking-table,
.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.history-table th,
.history-table td,
.ranking-table th,
.ranking-table td,
.compare-table th,
.compare-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eef4f2;
    vertical-align: top;
}

.history-table th,
.ranking-table th,
.compare-table th {
    background: #f7fbfa;
    color: #375151;
    font-weight: 700;
}

.history-table tbody tr:last-child td,
.ranking-table tbody tr:last-child td,
.compare-table tbody tr:last-child td {
    border-bottom: none;
}

.truncate-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-actions {
    margin-top: 0.65rem;
    display: flex;
    justify-content: flex-end;
}

#compareSelectedBtn {
    background: linear-gradient(95deg, #007c7c, #009f9f);
}

.comparison-output {
    margin-top: 0.8rem;
    border: 1px solid #d6e6e2;
    border-radius: 0.75rem;
    background: #f9fcfb;
    padding: 0.8rem;
}

.comparison-output h4 {
    margin: 0 0 0.45rem;
}

.comparison-output p {
    margin: 0 0 0.65rem;
    color: #3e5757;
}

.delta-good {
    color: #1e8e3e;
    font-weight: 700;
}

.delta-bad {
    color: #d93025;
    font-weight: 700;
}

.delta-neutral {
    color: #4c6363;
    font-weight: 600;
}

.results-enter {
    animation: reveal 0.45s ease both;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1024px) {
    .executive-box {
        grid-template-columns: 1fr;
    }

    .exec-cta {
        border-left: none;
        border-top: 1px solid #deebe7;
        padding-left: 0;
        padding-top: 0.72rem;
    }

    .scores-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .audit-category-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .audit-form {
        align-items: stretch;
    }

    .form-actions {
        width: 100%;
    }

    .form-actions button {
        width: 100%;
    }

    .panel-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-actions {
        justify-content: stretch;
    }

    .history-actions button,
    .panel-header-row .ghost-btn {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .page {
        width: 94vw;
        padding-top: 1.5rem;
    }

    .scores-grid,
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .truncate-cell {
        max-width: 170px;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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