:root {
    --bg-color: #ffffff;
    --text-color: #212529;
    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --primary-light: #e7f1ff;
    --error: #dc3545;
    --success: #198754;
    --border: #ced4da;
    --focus-ring: #86b7fe;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
}

header, main, footer {
    max-width: 800px;
    margin: 0 auto;
}

h1, h2, h3 { color: #000; }
hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }

/* Tabs */
.tabs { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 2px solid var(--border); padding-bottom: 10px; }
.tabs button { padding: 10px 20px; cursor: pointer; border: 2px solid transparent; background: #f8f9fa; font-size: 1.1rem; border-radius: 4px; font-weight: bold;}
.tabs button.active { background: var(--primary); color: white; }

.view.hidden { display: none; }

/* Formulare & Eingaben */
.converter-inputs { display: flex; gap: 20px; margin-bottom: 30px; }
.input-group { display: flex; flex-direction: column; flex: 1; }
label { font-weight: bold; margin-bottom: 5px; }
input[type="text"], select { padding: 10px; font-size: 1.25rem; border: 2px solid var(--border); border-radius: 4px; font-family: monospace; }
input.invalid { border-color: var(--error); background-color: #f8d7da; }
.error-text { color: var(--error); font-size: 0.9rem; min-height: 1.5em; margin-top: 4px; display: block; font-weight: bold;}

/* Tastatur-Fokus (WCAG) */
input:focus-visible, select:focus-visible, button:focus-visible {
    outline: 3px solid var(--focus-ring); outline-offset: 2px; border-color: var(--primary);
}

/* Bitgewichte */
.bit-weights { display: flex; gap: 10px; margin-bottom: 20px; }
.bit-btn { 
    flex: 1; padding: 15px 5px; border: 2px solid var(--primary); background: white; 
    cursor: pointer; display: flex; flex-direction: column; align-items: center; 
    border-radius: 6px; transition: background 0.1s;
}
.bit-btn[data-state="1"] { background: var(--primary); color: white; }
.weight-label { font-size: 0.9rem; opacity: 0.9; }
.bit-value { font-size: 1.8rem; font-weight: bold; margin-top: 5px; }

/* Quiz */
.quiz-controls { margin-bottom: 20px; }
.quiz-task { border: 2px solid var(--border); padding: 20px; border-radius: 8px; background: #f8f9fa; }
#quiz-question { font-size: 1.5rem; margin-top: 0; }
.quiz-actions { margin-top: 15px; display: flex; gap: 10px; }
.quiz-actions button { padding: 10px 20px; font-size: 1rem; cursor: pointer; background: var(--primary); color: white; border: none; border-radius: 4px; font-weight: bold;}
.quiz-actions button:disabled { background: var(--border); cursor: not-allowed; color: #666; }
#btn-check { background: var(--success); }

#quiz-feedback { margin-top: 20px; font-weight: bold; font-size: 1.3rem; }
.feedback-success { color: var(--success); }
.feedback-error { color: var(--error); }

/* Referenz Tabelle */
table { width: 100%; border-collapse: collapse; margin-top: 15px; font-family: monospace; font-size: 1.1rem; }
th, td { border: 1px solid var(--border); padding: 10px; text-align: center; }
th { background: #e9ecef; font-family: sans-serif; }

footer { margin-top: 50px; font-size: 0.9rem; color: #6c757d; text-align: center; }

/* Responsive Best-Effort (<= 768px) */
@media (max-width: 768px) {
    .converter-inputs { flex-direction: column; gap: 10px; }
    .bit-weights { flex-wrap: wrap; }
    .bit-btn { flex: 1 1 20%; }
}