:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1a2332;
    --muted: #5c6b7a;
    --border: #dde3ea;
    --primary: #0d6e6e;
    --primary-hover: #0a5757;
    --danger: #b42318;
    --success: #067647;
    --warning: #b54708;
    --warning-bg: #fffaeb;
    --success-bg: #ecfdf3;
    --error-bg: #fef3f2;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(960px, calc(100% - 2rem)); margin: 0 auto; }
.main { padding: 1.5rem 0 3rem; }
.public-main { padding: 2rem 0 3rem; max-width: 560px; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); font-size: 1.1rem; }
.nav { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: 0.95rem; }
.nav a:hover { color: var(--text); }
.nav a.btn-primary,
.nav a.btn-primary:hover { color: #fff; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.6rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.panel-header h2 { margin: 0; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}
.stat-label { display: block; color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; }

.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { text-align: left; padding: 0.65rem 0.4rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--surface);
    color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: #e8eef0; color: var(--text); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.75rem; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }

.stack { display: flex; flex-direction: column; gap: 0.25rem; }
.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-weight: 500;
    cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
    width: auto;
    margin-top: 0.2rem;
    accent-color: var(--primary);
}
.result-thanks {
    margin: 1.25rem 0;
    font-size: 1.05rem;
    line-height: 1.5;
}
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #eef2f6;
    color: var(--muted);
}
.badge-published { background: #dcfae6; color: var(--success); }
.badge-draft { background: #f2f4f7; color: var(--muted); }

.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #abefc6; }
.alert-error { background: var(--error-bg); color: var(--danger); border-color: #fecdca; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fedf89; }

.copy-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.copy-row input { flex: 1; min-width: 200px; }

.auth-page { display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #e8f2f2, #f4f6f8 50%, #eef1f5); }
.auth-wrap { width: min(400px, calc(100% - 2rem)); padding: 2rem 0; }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }

.home-hero {
    text-align: center;
    padding: 4rem 1rem;
    max-width: 520px;
    margin: 0 auto;
}
.home-hero h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }

.question-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fafbfc;
}
.question-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.type-fieldset { border: none; padding: 0; margin: 0 0 0.75rem; }
.type-fieldset legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.radio-inline { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 500; margin-right: 1rem; }
.radio-row { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; margin-bottom: 0.4rem; }
.mc-option-row {
    display: grid;
    grid-template-columns: 80px 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}
.mc-option-row input[type="text"] { margin: 0; }
.opt-label { font-size: 0.85rem; color: var(--muted); }

.question-preview { margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.question-preview ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.question-preview li.correct { color: var(--success); font-weight: 600; }

.quiz-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
}
.quiz-title { margin: 0 0 0.5rem; font-size: 1.75rem; text-align: center; }
.quiz-desc { text-align: center; color: var(--muted); }
.quiz-kicker { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.5rem; text-align: center; }
.question-text { font-size: 1.25rem; margin: 1rem 0; }

.progress-row { margin-bottom: 1rem; }
.progress-bar {
    height: 6px;
    background: #e8eef0;
    border-radius: 999px;
    margin-top: 0.4rem;
    overflow: hidden;
}
.progress-bar span {
    display: block;
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
}

.option-choice {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    background: #fff;
}
.option-choice:has(input:checked) {
    border-color: var(--primary);
    background: #f0fafa;
}
.option-choice input { margin-top: 0.2rem; }

.result-card { text-align: center; }
.score-big { font-size: 2.75rem; font-weight: 700; margin: 1rem 0 0.25rem; color: var(--primary); }
.score-pct { font-size: 1.4rem; color: var(--muted); margin-bottom: 1.25rem; }
.result-stats {
    list-style: none;
    padding: 0;
    margin: 0 auto 1rem;
    max-width: 280px;
    text-align: left;
}
.result-stats li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.site-footer {
    margin-top: auto;
    padding: 0.75rem 0 1rem;
    text-align: center;
    font-size: 0.7rem;
    color: var(--muted);
}
.site-footer a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }
main { flex: 1; }

.quiz-nav {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
}
.quiz-nav .btn { min-width: 7rem; }
.quiz-nav-spacer { flex: 1; }

@media (max-width: 720px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .mc-option-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
    .table { display: block; overflow-x: auto; }
}
