:root {
    --bg-color: #121214;
    --card-bg: #1a1a1e;
    --text-color: #e1e1e6;
    --text-muted: #a8a8b3;
    --primary: #04d361;
    --primary-hover: #00b347;
    --error: #f75a68;
    --code-bg: #202024;
    --border: #29292e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    padding: 10px;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

header {
    margin-bottom: 20px;
}

h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

/* Kopfzeile: Überschrift und Ein-/Ausklapp-Icon auf gleicher, vertikal
   zentrierter Ebene */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    /* Gleicher rechter Abstand wie main (20px), damit der Chevron rechts
       exakt auf einer Linie mit dem Bookmark-Icon liegt */
    padding-right: 20px;
}

/* Gemeinsamer visueller Stil für alle Chevron-Icons (Auswahlblock-Toggle
   und Themen-Dropdown); die eigentliche Drehung wird je Element separat
   gesteuert, damit beide unabhängig voneinander animieren können. */
.chevron-svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease;
}

.chevron-icon {
    transform: rotate(180deg); /* Default (ausgeklappt): zeigt nach oben */
}

/* Eingeklappt: 180°-Drehung zurück, zeigt nach unten */
#setup-toggle-btn[aria-expanded="false"] .chevron-icon {
    transform: rotate(0deg);
}

/* Chevron im Themen-Dropdown: gleiche 180°-Drehbewegung wie beim
   Auswahlblock-Toggle, gesteuert über den Fokus-Zustand des <select> */
.select-wrapper {
    position: relative;
}

.select-chevron {
    position: absolute;
    top: 50%;
    /* 5px + das 15px-Padding von .setup-panel-body ergeben zusammen 20px
       zum äußeren Kartenrand, exakt wie beim Bookmark-Icon */
    right: 5px;
    color: var(--text-muted);
    pointer-events: none;
    transform: translateY(-50%) rotate(0deg); /* geschlossen: zeigt nach unten */
}

/* Gesteuert per JS (nicht :focus), damit sich der Chevron auch beim erneuten
   Klick wieder zurückdreht, wenn das native Dropdown dadurch schließt */
.select-wrapper.select-open .select-chevron {
    transform: translateY(-50%) rotate(180deg); /* geöffnet: zeigt nach oben */
}

#progress-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--primary);
    transition: width 0.3s ease;
}

main {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.badge {
    align-self: flex-start;
    background-color: var(--border);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

/* Zeile für Topic-Badge und Merken-Icon: beide starten mit gleichem Abstand
   nach oben (main-padding) und nach rechts (main-padding) */
.topic-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.icon-btn {
    /* appearance:none ist nötig, damit Edge/Chromium unter Windows dieses
       <button>-Element nicht mit nativer Fluent-Optik (weißer Hintergrund,
       Rand) überzeichnet, obwohl background/border bereits zurückgesetzt sind. */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.icon-btn:hover {
    color: var(--primary);
}

.bookmark-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linejoin: round;
    transition: fill 0.15s, stroke 0.15s;
}

#bookmark-btn.active {
    color: var(--primary);
}

#bookmark-btn.active .bookmark-icon {
    fill: var(--primary);
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.5;
    white-space: pre-line;
}

.option-btn {
    white-space: pre-line;
}

pre {
    background-color: var(--code-bg);
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--primary);
}

code {
    font-family: "Fira Code", Consolas, Monaco, monospace;
    font-size: 0.9rem;
    color: #e1e1e6;
    white-space: pre-wrap;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.option-btn {
    background-color: var(--code-bg);
    border: 1px solid var(--border);
    color: var(--text-color);
    padding: 15px;
    border-radius: 6px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background-color: #202028;
}

.option-btn.correct {
    background-color: rgba(4, 211, 97, 0.15);
    border-color: var(--primary);
    color: #04d361;
}

.option-btn.wrong {
    background-color: rgba(247, 90, 104, 0.15);
    border-color: var(--error);
    color: var(--error);
}

.feedback-panel {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#feedback-title {
    font-weight: bold;
    font-size: 1.1rem;
}

#feedback-explanation {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.primary-btn {
    background-color: var(--primary);
    color: #000;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

.secondary-btn {
    background-color: var(--code-bg);
    color: var(--text-color);
    border: 1px solid var(--primary);
    padding: 12px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
}

.secondary-btn:hover:not(:disabled) {
    background-color: var(--border);
}

.secondary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--border);
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* --- Übersicht der gemerkten Fragen (eine Frage je Ansicht, mit Blättern) --- */
.bookmarks-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.bookmark-counter {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.bookmark-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.bookmark-nav .secondary-btn {
    flex: 1;
}

#bookmark-view {
    /* Kein eigener Scroll-Bereich: der Block wächst mit dem Inhalt,
       die Seite scrollt als Ganzes. */
}

.bookmark-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}

.bookmark-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bookmark-item-header .icon-btn {
    font-size: 1.1rem;
}

.bookmark-question {
    font-size: 1rem;
    line-height: 1.4;
    white-space: pre-line;
}

.bookmark-item pre {
    padding: 10px;
}

.bookmark-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bookmark-option {
    padding: 8px 10px;
    border-radius: 4px;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    white-space: pre-line;
}

.bookmark-option.correct {
    border-color: var(--primary);
    color: var(--primary);
    background-color: rgba(4, 211, 97, 0.1);
}

.bookmark-explanation {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

footer {
    margin-top: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.stats-grid {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.stat-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
}

/* --- Kontrollzentrum (Themen- & Bereichsauswahl) --- */
/* Standard: ausgeklappt, voller Rahmen um den Block */
.setup-panel {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 20px;
}

.setup-panel-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
}

/* Eingeklappt: weder Rand noch Hintergrund sichtbar, der Inhalt entfällt komplett */
.setup-panel.collapsed {
    border: none;
    background-color: transparent;
}

.setup-panel.collapsed .setup-panel-body {
    display: none;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: bold;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-inputs span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Styling für Dropdown und Zahlenfelder */
.setup-panel select,
.setup-panel input[type="number"] {
    background-color: var(--code-bg);
    border: 1px solid var(--border);
    color: var(--text-color);
    padding: 10px;
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
}

.setup-panel select:focus,
.setup-panel input[type="number"]:focus {
    border-color: var(--primary);
}

/* Native Browser-Pfeilspitze ausblenden, Platz für den eigenen Chevron schaffen */
.setup-panel select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 36px;
}

/* Spezifische Breite für die Bereichs-Eingabefelder */
.range-inputs input[type="number"] {
    flex: 1;
    text-align: center;
}
