:root {
    color-scheme: light;
    --ink: #192123;
    --muted: #58666a;
    --line: #d8e0df;
    --paper: #fbfbf7;
    --surface: #ffffff;
    --surface-strong: #eef6f1;
    --green: #1f6b4f;
    --green-dark: #174d3a;
    --blue: #265f8f;
    --amber: #a65f00;
    --red: #9f2e2e;
    --shadow: 0 14px 40px rgba(25, 33, 35, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--paper);
    color: var(--ink);
}

body {
    margin: 0;
    min-height: 100vh;
}

a {
    color: inherit;
}

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

button,
.button {
    border: 0;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.7rem 1rem;
    text-decoration: none;
    font-weight: 700;
}

button:hover,
.button:hover,
button:focus-visible,
.button:focus-visible {
    background: var(--green-dark);
    outline: 3px solid rgba(31, 107, 79, 0.25);
    outline-offset: 2px;
}

.button.secondary,
button.secondary {
    background: #e6eeeb;
    color: var(--green-dark);
}

.button.secondary:hover,
button.secondary:hover,
.button.secondary:focus-visible,
button.secondary:focus-visible {
    background: #d6e6df;
}

.button.warning,
button.warning {
    background: var(--amber);
}

.site-header {
    align-items: center;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
    padding: 1rem clamp(1rem, 4vw, 3rem);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    align-items: center;
    display: inline-flex;
    font-weight: 800;
    gap: 0.6rem;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: var(--ink);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
    justify-content: flex-end;
}

.nav-links a {
    border-radius: 8px;
    color: var(--muted);
    padding: 0.45rem 0.6rem;
    text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
    background: var(--surface-strong);
    color: var(--ink);
    outline: none;
}

main {
    padding: clamp(1rem, 4vw, 3rem);
}

.site-footer {
    align-items: center;
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    padding: 1.4rem clamp(1rem, 4vw, 3rem);
}

.messages {
    display: grid;
    gap: 0.5rem;
    padding: 1rem clamp(1rem, 4vw, 3rem) 0;
}

.message {
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.message-success {
    background: #e4f5ec;
    color: #14533b;
}

.message-error {
    background: #fde8e8;
    color: var(--red);
}

.message-info {
    background: #e7f0f8;
    color: #164b73;
}

.message-warning {
    background: #fff2d7;
    color: #6b3e00;
}

.hero {
    align-items: stretch;
    display: grid;
    gap: clamp(1rem, 3vw, 2rem);
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    margin: 0 auto 2rem;
    max-width: 1200px;
}

.hero-panel {
    background: linear-gradient(135deg, #ffffff 0%, #eef6f1 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: clamp(1.5rem, 4vw, 3rem);
}

.eyebrow {
    color: var(--green);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 0.7rem;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    letter-spacing: 0;
    line-height: 1.08;
    margin: 0;
}

h1 {
    font-size: clamp(2.2rem, 6vw, 5rem);
    max-width: 10ch;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
}

h3 {
    font-size: 1.1rem;
}

p {
    color: var(--muted);
    line-height: 1.65;
}

.lead {
    color: #334144;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    max-width: 66ch;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.2rem;
}

.metric-grid,
.stage-grid,
.subject-grid,
.concept-grid,
.summary-grid {
    display: grid;
    gap: 1rem;
}

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

.stage-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.subject-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.concept-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.section {
    margin: 0 auto 2rem;
    max-width: 1200px;
}

.section-header {
    align-items: end;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card,
.metric,
.form-panel,
.lesson-panel,
.table-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.table-panel {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.card.compact {
    box-shadow: none;
}

.json-panel {
    color: #253336;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    max-height: 70vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.mini-panel {
    background: #f6f8f7;
    border-left: 4px solid var(--green);
    border-radius: 8px;
    padding: 0.8rem 1rem;
}

.two-column {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1rem;
}

.response-mode-panel {
    border-left-color: var(--blue);
}

.recovery-panel {
    border-left: 4px solid var(--red);
}

.consent-panel,
.risk-banner {
    background: #fff9ec;
    border: 1px solid #efd6a6;
    border-radius: 8px;
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
}

.risk-banner {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
}

.checkbox-row {
    align-items: start;
    color: #314143;
    display: grid;
    gap: 0.65rem;
    grid-template-columns: auto minmax(0, 1fr);
    line-height: 1.5;
}

.checkbox-row input[type="checkbox"] {
    margin-top: 0.25rem;
    min-height: auto;
    width: auto;
}

.inline-form {
    display: grid;
    gap: 0.6rem;
    margin-top: 1rem;
}

.metric strong {
    color: var(--ink);
    display: block;
    font-size: 2rem;
}

.metric span {
    color: var(--muted);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.8rem;
}

.tag {
    background: #eef2f1;
    border: 1px solid #d9e2e0;
    border-radius: 999px;
    color: #3f5053;
    display: inline-flex;
    font-size: 0.85rem;
    padding: 0.25rem 0.6rem;
}

.tag.secure {
    background: #e3f5eb;
    color: #14533b;
}

.tag.warning {
    background: #fff2d7;
    color: #6b3e00;
}

.tag.danger {
    background: #fde8e8;
    color: var(--red);
}

.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
    display: grid;
    gap: 0.35rem;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    color: #314143;
    font-weight: 700;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid #cbd8d6;
    border-radius: 8px;
    color: var(--ink);
    min-height: 44px;
    padding: 0.7rem 0.8rem;
    width: 100%;
}

textarea {
    min-height: 120px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    outline: 3px solid rgba(31, 107, 79, 0.2);
}

.progress-bar {
    background: #e7eeec;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.progress-bar span {
    background: var(--green);
    display: block;
    height: 100%;
}

.evidence-list {
    display: grid;
    gap: 0.75rem;
}

.evidence-item {
    border-left: 4px solid var(--blue);
    padding-left: 0.8rem;
}

.evidence-item.misconception {
    border-color: var(--red);
}

.evidence-item.partial,
.evidence-item.unsupported {
    border-color: var(--amber);
}

.learning-table {
    border-collapse: collapse;
    min-width: 680px;
    width: 100%;
}

.learning-table th,
.learning-table td {
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
    padding: 0.7rem;
    text-align: left;
    vertical-align: top;
}

.learning-table th {
    color: #314143;
    font-size: 0.9rem;
}

.empty-state {
    background: #f4f7f5;
    border: 1px dashed #bdcbc7;
    border-radius: 8px;
    padding: 1rem;
}

.compact-list {
    color: var(--muted);
    line-height: 1.55;
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
}

@media (max-width: 820px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-links {
        justify-content: flex-start;
    }

    .hero,
    .two-column,
    .form-grid,
    .risk-banner {
        grid-template-columns: 1fr;
    }

    h1 {
        max-width: 12ch;
    }
}
