body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    background: #f3f6fb;
    color: #1e293b;
}

a {
    color: #1d4ed8;
}

code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.site-header {
    background: #0f172a;
    color: #ffffff;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-top: 18px;
    padding-bottom: 18px;
}

.brand a,
.nav-links a,
.nav-link-button {
    color: #ffffff;
    text-decoration: none;
}

.brand a {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.nav-links,
.button-row,
.lookup-row,
.test-actions,
.page-header,
.progress-meta,
.result-meta,
.facet-head,
.actions-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-form,
.inline-form {
    margin: 0;
}

.nav-link-button {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.nav-link-button:hover {
    text-decoration: underline;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.9rem;
}

.status-pill {
    background: #dbeafe;
    color: #1d4ed8;
}

.pill-self {
    background: #dcfce7;
    color: #166534;
}

.pill-peer {
    background: #dbeafe;
    color: #1e40af;
}

.content {
    padding: 30px 0 60px;
}

.card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    padding: 36px;
    margin-bottom: 20px;
}

.evaluation-card {
    padding: 40px;
}

.nested-card {
    margin-top: 18px;
    margin-bottom: 0;
    background: #f8fafc;
    box-shadow: none;
}

.auth-card {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.hero {
    display: grid;
    grid-template-columns: 1.7fr 1fr;
    gap: 24px;
}

.hero-copy h1 {
    margin-top: 10px;
    font-size: 2.4rem;
    line-height: 1.15;
}

.lead {
    font-size: 1.05rem;
    color: #475569;
    line-height: 1.7;
}

.hero-meta,
.stats-grid,
.dimension-grid,
.info-grid,
.admin-grid,
.admin-meta-grid {
    display: grid;
    gap: 16px;
}

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

.info-grid,
.admin-grid {
    grid-template-columns: repeat(2, 1fr);
}

.hero-meta {
    grid-template-columns: repeat(2, 1fr);
}

.admin-meta-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.meta-card,
.stat-card {
    background: #eff6ff;
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-card strong,
.stat-value {
    font-size: 1.8rem;
    color: #0f172a;
}

.stat-label,
.meta-card span,
.muted {
    color: #64748b;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: #2563eb;
    color: #ffffff;
    padding: 12px 18px;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.button:hover {
    background: #1d4ed8;
}

.button-secondary {
    background: #334155;
}

.button-secondary:hover {
    background: #1e293b;
}

.button-small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.button[disabled],
button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.alert {
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-info {
    background: #dbeafe;
    color: #1d4ed8;
}

.is-hidden {
    display: none;
}

.page-header {
    justify-content: space-between;
    margin-bottom: 18px;
}

.language-form,
.lookup-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 400;
}

.checkbox-label input {
    margin: 0;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font: inherit;
    background: #ffffff;
}

.lookup-row input {
    flex: 1 1 320px;
}

.test-meta {
    margin-bottom: 18px;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-row .progress-track {
    flex: 1;
}

.timer-inline {
    font-size: 0.85rem;
    color: #475569;
    white-space: nowrap;
    min-width: 48px;
    text-align: right;
}

.progress-track {
    height: 12px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    position: relative;
}

.progress-answered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.25), rgba(6, 182, 212, 0.25));
    transition: width 0.2s ease;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2563eb, #06b6d4);
    transition: width 0.2s ease;
}

.progress-meta {
    justify-content: space-between;
    margin-top: 10px;
    color: #475569;
}

.question-stack {
    display: grid;
    gap: 18px;
}

.question-card {
    border: none;
    border-radius: 16px;
    padding: 28px 24px;
    background: #ffffff;
}

.question-prompt {
    font-size: 1.35rem;
    line-height: 1.5;
    margin: 0 0 8px;
}

.question-number,
.eyebrow {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #2563eb;
    font-weight: 700;
}

.choice-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.choice-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    font-size: 1.05rem;
    transition: background 0.15s, border-color 0.15s;
}

.choice-option:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.choice-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.choice-option:has(input:checked) {
    background: #dbeafe;
    border-color: #2563eb;
}

.choice-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.test-cancel {
    text-align: right;
    margin-top: 24px;
}

.cancel-link {
    color: #94a3b8;
    font-size: 0.85rem;
    text-decoration: none;
}

.cancel-link:hover {
    color: #64748b;
    text-decoration: underline;
}

.link-button {
    border: 0;
    background: transparent;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.radar-card {
    text-align: center;
    margin-bottom: 24px;
}

.radar-title {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.radar-wrap {
    max-width: 500px;
    margin: 0 auto;
}

.radar-chart-wrap {
    max-width: 520px;
    margin: 0 auto;
}

.polar-label-links {
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    margin: 12px 0 8px;
    font-size: 0.95rem;
}

.polar-label-link {
    text-decoration: none;
    font-weight: 600;
}

.polar-label-link:hover {
    text-decoration: underline;
}

/* --- Dimension chapter layout --- */
.dimension-chapter {
    margin-bottom: 12px;
}

.dimension-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.dimension-score {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
}

.level-badge {
    display: inline-flex;
    align-items: center;
    margin: 10px 0;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.level-badge.small {
    padding: 3px 10px;
    font-size: 0.78rem;
}

.level-low {
    background: #fef3c7;
    color: #92400e;
}

.level-neutral {
    background: #f1f5f9;
    color: #475569;
}

.level-high {
    background: #dbeafe;
    color: #1e40af;
}

.meter {
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    margin: 12px 0 6px;
}

/* Facet bar chart */
.facet-barchart-wrap {
    overflow-x: auto;
    margin: 24px auto 18px;
    text-align: center;
}

.facet-barchart {
    display: inline-block;
    max-width: 100%;
    height: auto;
}

/* Facet detail list */
.facet-detail-list {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.facet-detail {
    border-top: 1px solid #e2e8f0;
    padding-top: 14px;
    display: grid;
    grid-template-columns: 135px 1fr;
    gap: 28px;
    align-items: start;
}

.facet-detail-chart {
    display: flex;
    align-items: center;
    justify-content: center;
}

.facet-mini-chart {
    width: 100%;
    max-width: 135px;
    height: auto;
    display: block;
}

.facet-detail-text {
    min-width: 0;
}

.facet-detail-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.facet-detail-head h3 {
    margin: 0;
    font-size: 1rem;
}

/* Expandable description */
/* polar chart link styling handled by .polar-label-link */

svg a text:hover {
    text-decoration: underline;
}

.meter.small {
    height: 8px;
}

.meter span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #22c55e);
}

/* (facet display handled by .facet-detail-list) */

.history-list,
.clean-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.clean-list li {
    padding: 8px 0;
    border-top: 1px solid #e2e8f0;
}

.clean-list li:first-child {
    padding-top: 0;
    border-top: 0;
}

.clean-numbered {
    margin: 0;
    padding-left: 22px;
}

.clean-numbered li + li {
    margin-top: 8px;
}

.history-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-top: 1px solid #e2e8f0;
}

.history-list li:first-child {
    border-top: 0;
    padding-top: 0;
}

.history-summary {
    color: #0f172a;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-top: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.data-table thead th {
    border-top: 0;
    color: #64748b;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.data-table input[type="text"],
.data-table select {
    min-width: 120px;
    padding: 10px;
}

/* Peer assessment / Fremdbeurteilung */
.share-link-box {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.share-link-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    font-family: monospace;
    font-size: 0.9rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #1e293b;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    text-decoration: none;
    flex-shrink: 0;
}

.icon-btn:hover {
    color: #1d4ed8;
    border-color: #93c5fd;
    background: #eff6ff;
}

.icon-btn.copied {
    color: #16a34a;
    border-color: #86efac;
    background: #f0fdf4;
}

.peer-test-intro {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.peer-comparison-section {
    margin-top: 24px;
}

/* radar legend kept for backward compatibility */
.radar-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 12px 0 8px;
    font-size: 0.9rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.peer-comparison-table td,
.peer-comparison-table th {
    text-align: center;
}

.peer-comparison-table td:first-child,
.peer-comparison-table th:first-child {
    text-align: left;
}

.diff-positive {
    color: #16a34a;
    font-weight: 600;
}

.diff-negative {
    color: #dc2626;
    font-weight: 600;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* Danger button */
.button-danger {
    background: #dc2626;
}

.button-danger:hover {
    background: #b91c1c;
}

/* Delete data section */
.delete-data-section {
    margin-top: 32px;
    border-top: 2px solid #fee2e2;
}

/* Modal dialog */
.modal-dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    max-width: 480px;
    width: calc(100% - 40px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
}

.modal-content {
    padding: 28px 28px 24px;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #991b1b;
}

.modal-content ul {
    margin: 12px 0;
    padding-left: 20px;
}

.modal-content ul li {
    margin-bottom: 4px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Admin questions editor */
.question-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    resize: vertical;
    background: #fff;
    min-height: 64px;
}

.question-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.q3rd-input.q3rd-valid {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.q3rd-wrap {
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

.q3rd-wrap .question-textarea {
    flex: 1;
}

.copy-prompt-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin-top: 2px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.copy-prompt-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.questions-table td {
    vertical-align: top;
}

.questions-table th:nth-child(4),
.questions-table td:nth-child(4),
.questions-table th:nth-child(5),
.questions-table td:nth-child(5) {
    width: 42%;
}

/* --- Peer toggle --- */
.peer-toggle-card {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    margin-bottom: 20px;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
}

.toggle-hint {
    font-weight: 400;
    font-size: 0.85rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background 0.2s;
    cursor: pointer;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #3b82f6;
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* --- Bar chart legend --- */
.barchart-legend {
    display: flex;
    gap: 18px;
    margin-top: 8px;
    font-size: 0.82rem;
    color: #475569;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 10px;
    border-radius: 2px;
    background: #64748b;
    margin-right: 4px;
    vertical-align: middle;
}

/* Peer overlay visibility toggle */
.peer-overlay-hidden .peer-overlay {
    display: none !important;
}

svg .peer-overlay {
    transition: opacity 0.2s;
}

.peer-overlay-hidden svg .peer-overlay {
    display: initial !important;
    opacity: 0 !important;
    pointer-events: none;
}

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.pagination-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    background: #2563eb;
    color: #fff;
    border-radius: 10px;
}

@media (max-width: 900px) {
    .hero,
    .info-grid,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .hero-meta {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-header,
    .history-list li,
    .dimension-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .site-header .container,
    .page-header,
    .lookup-row,
    .button-row,
    .test-actions,
    .nav-links {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-copy h1 {
        font-size: 1.9rem;
    }

    .hero-meta,
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .data-table {
        min-width: 720px;
    }

    .facet-detail {
        grid-template-columns: 1fr;
    }

    .facet-mini-chart {
        max-width: 105px;
    }
}
