:root {
    --bg: #faf8f3;
    --bg-secondary: #f3efe7;
    --surface: #ffffff;
    --surface-hover: #f5f2ec;
    --border: #e5ded0;
    --border-light: #f0ebe0;
    --text: #2d2416;
    --text-secondary: #6b5f4f;
    --text-tertiary: #9b8d7a;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --transition: 0.2s ease;
    --base-font-size: 16px;
    
    --accent: #5b8c9b;
    --accent-hover: #4a7683;
    --danger: #c25b5b;
    --danger-hover: #a54545;
    --success: #6b9b6d;
    --warning: #d4a44c;
    --missed: #8b7355;
    --streak: #e08a3a;
    
    --fajr: #5b7eb5; --fajr-bg: #f3f6fb;
    --dhuhr: #d4a44c; --dhuhr-bg: #fdf8f0;
    --asr: #d4855e; --asr-bg: #fdf5f0;
    --maghrib: #8b5e7d; --maghrib-bg: #fbf4f7;
    --isha: #4a658a; --isha-bg: #f2f5fa;
}

[data-theme="dark"] {
    --bg: #1a1815;
    --bg-secondary: #22201c;
    --surface: #282620;
    --surface-hover: #302d27;
    --border: #3d3a33;
    --border-light: #35322c;
    --text: #e8e0d0;
    --text-secondary: #a09888;
    --text-tertiary: #776f60;
    --shadow: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
    --accent: #7da0b2;
    --accent-hover: #6b8ea0;
    --danger: #d47575;
    --success: #7db57f;
    --missed: #b8a080;
    --streak: #e89a4a;
    --fajr: #7b9ccd; --fajr-bg: #252d3b;
    --dhuhr: #e0b868; --dhuhr-bg: #363025;
    --asr: #e09a76; --asr-bg: #362c26;
    --maghrib: #b87da3; --maghrib-bg: #322a30;
    --isha: #6b86a8; --isha-bg: #252d38;
}

/* Farbenblind: Rot/Grün-Schwäche (Protanopie) */
[data-colorblind="protanopia"] {
    --success: #4a90d9;
    --danger: #d9a04a;
}

/* Farbenblind: Grün-Schwäche (Deuteranopie) */
[data-colorblind="deuteranopia"] {
    --success: #4a90d9;
    --danger: #d9a04a;
}

/* Farbenblind: Blau/Gelb-Schwäche (Tritanopie) */
[data-colorblind="tritanopia"] {
    --success: #5b9b9b;
    --danger: #d97575;
}

/* Farbenblind: Kein Farbsehen (Achromatopsie) */
[data-colorblind="achromatopsia"] {
    --success: #888888;
    --danger: #555555;
    --accent: #777777;
    --warning: #999999;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: var(--base-font-size);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

.container { max-width: 560px; margin: 0 auto; padding: 16px 12px 40px; }

/* ========== HEADER ========== */
.header-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.header-top h1 { font-size: 1.4rem; font-weight: 700; }
.subtitle { font-size: 0.8rem; color: var(--text-secondary); }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: all var(--transition); color: var(--text); }
.icon-btn:hover { background: var(--surface-hover); }

/* ========== CARDS ========== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 8px; }
.card-header h2 { font-size: 0.95rem; font-weight: 600; }

/* ========== STATS ========== */
.stats-row { display: flex; align-items: center; margin-bottom: 12px; }
.stat-item { flex: 1; text-align: center; }
.stat-number { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-missed { color: var(--missed); }
.stat-completed { color: var(--success); }
.stat-remaining { color: var(--danger); }
.stat-desc { font-size: 0.68rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-divider { width: 1px; height: 32px; background: var(--border-light); flex-shrink: 0; }

/* ========== PROGRESS ========== */
.progress-header { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.75rem; color: var(--text-secondary); }
.progress-percent { font-weight: 600; }
.progress-bar { background: var(--bg-secondary); border-radius: 10px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; background: var(--success); transition: width 0.5s ease; }

/* ========== BUTTONS ========== */
.btn-primary { width: 100%; padding: 10px 16px; border: none; border-radius: var(--radius-sm); background: var(--accent); color: #fff; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { width: auto; padding: 8px 14px; font-size: 0.78rem; }
.btn-text { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.78rem; padding: 8px; width: 100%; border-radius: var(--radius-xs); }
.btn-text:hover { background: var(--surface-hover); }
.btn-outline { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 0.78rem; color: var(--text); display: flex; align-items: center; justify-content: center; gap: 6px; transition: all var(--transition); }
.btn-outline:hover { background: var(--surface-hover); border-color: var(--accent); }
.btn-danger { width: 100%; padding: 9px 14px; border: none; border-radius: var(--radius-sm); background: var(--danger); cursor: pointer; font-size: 0.8rem; color: #fff; display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 6px; transition: all var(--transition); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger-outline { width: 100%; padding: 9px 14px; border: 1px solid var(--danger); border-radius: var(--radius-sm); background: transparent; cursor: pointer; font-size: 0.8rem; color: var(--danger); display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 6px; transition: all var(--transition); }
.btn-danger-outline:hover { background: #fdf0f0; }
[data-theme="dark"] .btn-danger-outline:hover { background: #3d2828; }

/* ========== LOGIN ========== */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 500; }
.login-card { background: var(--surface); border-radius: var(--radius); padding: 28px 22px; width: 90%; max-width: 360px; text-align: center; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.login-logo { font-size: 2.8rem; margin-bottom: 4px; }
.login-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 18px; }
.login-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 8px; background: var(--bg); color: var(--text); font-family: inherit; transition: border-color var(--transition); }
.login-input:focus { outline: none; border-color: var(--accent); }
.login-message { margin-top: 8px; font-size: 0.75rem; min-height: 18px; }
.password-field { position: relative; margin-bottom: 8px; }
.password-field .login-input { margin-bottom: 0; padding-right: 42px; }
.password-generate-btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 6px; width: 32px; height: 32px; cursor: pointer; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; transition: all var(--transition); color: var(--text); }
.password-generate-btn:hover { background: var(--surface-hover); }

/* ========== GEBETE ========== */
.prayer-grid { display: flex; flex-direction: column; gap: 10px; }
.prayer-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; transition: all var(--transition); background: var(--surface); }
.prayer-row:hover { border-color: var(--accent); }
.prayer-row-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.prayer-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.95rem; flex-shrink: 0; }
.prayer-name { font-weight: 600; font-size: 0.88rem; flex: 1; }
.prayer-progress-mini { font-size: 0.7rem; color: var(--text-tertiary); }
.prayer-inputs { display: flex; gap: 8px; margin-bottom: 8px; }
.prayer-input-group { flex: 1; }
.prayer-input-group label { display: block; font-size: 0.65rem; color: var(--text-tertiary); margin-bottom: 2px; text-transform: uppercase; }
.prayer-input-group input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: 0.82rem; text-align: center; background: var(--bg); color: var(--text); font-family: inherit; }
.prayer-input-group input:focus { outline: none; border-color: var(--accent); }
.prayer-actions { display: flex; gap: 6px; }
.prayer-btn-small { flex: 1; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface); cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; color: var(--text); transition: all var(--transition); }
.prayer-btn-small:hover { background: var(--surface-hover); }
.prayer-btn-small.plus:hover { border-color: var(--success); color: var(--success); }
.prayer-btn-small.minus:hover { border-color: var(--danger); color: var(--danger); }
.fajr-icon { background: var(--fajr-bg); } .dhuhr-icon { background: var(--dhuhr-bg); } .asr-icon { background: var(--asr-bg); } .maghrib-icon { background: var(--maghrib-bg); } .isha-icon { background: var(--isha-bg); }

/* ========== TEMPLATES ========== */
.templates-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.template-btn { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: all var(--transition); }
.template-btn:hover { background: var(--surface-hover); border-color: var(--accent); }
.template-icon { font-size: 1.1rem; }
.template-label { font-weight: 600; font-size: 0.78rem; color: var(--text); }
.template-custom { border-style: dashed; }

/* ========== SETTINGS PANEL ========== */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 400; display: flex; justify-content: flex-end; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.settings-overlay.active { opacity: 1; pointer-events: all; }
.settings-panel { background: var(--surface); width: 100%; max-width: 380px; height: 100vh; overflow-y: auto; padding: 20px; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform 0.25s ease; }
.settings-overlay.active .settings-panel { transform: translateX(0); }
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border-light); }
.settings-header h2 { font-size: 1.1rem; font-weight: 600; }

.settings-section { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--border-light); }
.settings-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.settings-section h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-secondary); margin-bottom: 12px; font-weight: 600; }
.settings-row { margin-bottom: 10px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-row label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }

.settings-input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: 0.84rem; background: var(--bg); color: var(--text); font-family: inherit; transition: border-color var(--transition); }
.settings-input:focus { outline: none; border-color: var(--accent); }
select.settings-input { cursor: pointer; }

/* Checkbox */
.checkbox-row { margin-bottom: 0; }
.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.84rem; color: var(--text); padding: 5px 0; transition: color var(--transition); }
.checkbox-label:hover { color: var(--accent); }
.checkbox-label input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); }

/* Toggle Group */
.toggle-group { display: flex; gap: 3px; background: var(--bg-secondary); border-radius: var(--radius-xs); padding: 3px; }
.toggle-option { flex: 1; padding: 7px 4px; border: none; border-radius: 5px; cursor: pointer; font-size: 0.72rem; font-weight: 500; transition: all var(--transition); background: transparent; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; gap: 4px; }
.toggle-option.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.toggle-option:hover:not(.active) { color: var(--text); }

/* About */
.about-info { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.7; }
.about-info strong { color: var(--text); }
.about-info a { color: var(--accent); text-decoration: none; font-weight: 500; }
.about-info a:hover { text-decoration: underline; }
#app-version { font-weight: 600; color: var(--text); background: var(--bg-secondary); padding: 2px 8px; border-radius: 10px; font-size: 0.78rem; }

/* Gebetszeiten */
.prayer-times-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 10px; }
.time-slot { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--bg-secondary); border-radius: var(--radius-xs); border: 1px solid var(--border-light); }
.time-label { font-size: 0.8rem; font-weight: 500; }
.time-value { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.next-prayer { text-align: center; padding: 8px 12px; background: var(--bg-secondary); border-radius: var(--radius-xs); font-size: 0.78rem; color: var(--text-secondary); border: 1px solid var(--border-light); }
.next-prayer strong { color: var(--accent); }
.location-name { font-size: 0.72rem; color: var(--text-tertiary); }

/* Badges */
.header-badges { display: flex; gap: 6px; }
.motivation-badge { font-size: 0.7rem; font-weight: 600; padding: 3px 8px; border-radius: 12px; background: #fde8e8; color: var(--danger); }
.motivation-badge.level-25 { background: #fdf0e6; color: #d4855e; }
.motivation-badge.level-50 { background: #fdf6e9; color: #d4a44c; }
.motivation-badge.level-75 { background: #eaf5e4; color: #8bbd6e; }
.motivation-badge.level-100 { background: #e0f0e0; color: var(--success); }
[data-theme="dark"] .motivation-badge { background: #3d2828; }
[data-theme="dark"] .motivation-badge.level-25 { background: #3d2d24; }
[data-theme="dark"] .motivation-badge.level-50 { background: #3d3524; }
[data-theme="dark"] .motivation-badge.level-75 { background: #2a3628; }
[data-theme="dark"] .motivation-badge.level-100 { background: #283628; }
.streak-badge { font-size: 0.7rem; font-weight: 600; padding: 3px 8px; border-radius: 12px; background: #fef5eb; color: var(--streak); }
[data-theme="dark"] .streak-badge { background: #3d3024; }

/* Misc */
.prediction-banner { margin-top: 10px; padding: 8px 12px; background: var(--bg-secondary); border-radius: var(--radius-xs); font-size: 0.76rem; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; border: 1px solid var(--border-light); }
.date-range { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.date-field { flex: 1; }
.date-field label { display: block; font-size: 0.73rem; color: var(--text-secondary); margin-bottom: 3px; font-weight: 500; }
.date-field input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: 0.84rem; background: var(--bg); color: var(--text); font-family: inherit; }
.date-field input:focus { outline: none; border-color: var(--accent); }
.date-arrow { font-size: 1rem; color: var(--text-tertiary); padding-top: 16px; }
.calc-result { background: var(--bg-secondary); border-radius: var(--radius-xs); padding: 10px 12px; margin-bottom: 10px; font-size: 0.78rem; color: var(--text-secondary); }
.calc-result strong { color: var(--text); }

/* Toast & Modal */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: #333; color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 0.8rem; font-weight: 500; opacity: 0; transition: all 0.3s ease; pointer-events: none; z-index: 600; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 500; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; width: 90%; max-width: 360px; box-shadow: var(--shadow-lg); text-align: center; border: 1px solid var(--border); }
.modal-icon { font-size: 2.2rem; margin-bottom: 8px; }
.modal-message { font-size: 0.85rem; color: var(--text); margin-bottom: 14px; }
.modal-body { margin-bottom: 12px; text-align: left; }
.modal-actions { display: flex; gap: 8px; }
.modal-btn { flex: 1; padding: 9px; border-radius: var(--radius-xs); font-size: 0.8rem; font-weight: 500; cursor: pointer; border: none; transition: all var(--transition); }
.modal-btn-cancel { background: var(--bg-secondary); color: var(--text); }
.modal-btn-cancel:hover { background: var(--border); }
.modal-btn-confirm { background: var(--accent); color: #fff; }
.modal-btn-confirm:hover { opacity: 0.9; }
.modal-btn-danger { background: var(--danger); color: #fff; }
.modal-btn-danger:hover { opacity: 0.9; }

.setting-actions { display: flex; gap: 8px; }
.settings-danger { border-bottom: none !important; }

@media (max-width: 480px) {
    .container { padding: 10px 8px 32px; }
    .card { padding: 14px 12px; }
    .stat-number { font-size: 1.3rem; }
    .settings-panel { max-width: 100%; }
}

/* ========== SELECTBOXEN ========== */
select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b5f4f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px !important;
    padding-right: 35px !important;
    background-color: var(--bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 10px 35px 10px 12px !important;
    font-size: 0.85rem !important;
    font-family: inherit !important;
    color: var(--text) !important;
    cursor: pointer !important;
    width: 100% !important;
    transition: border-color 0.2s ease !important;
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a09888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
}

select:hover {
    border-color: var(--accent) !important;
}

select:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(91, 140, 155, 0.2) !important;
}

/* Für Firefox */
select.settings-input::-ms-expand {
    display: none;
}

/* Option-Styling */
select.settings-input option {
    background: var(--surface);
    color: var(--text);
    padding: 10px;
    font-size: 0.84rem;
}

select.settings-input option:hover {
    background: var(--accent);
    color: #fff;
}

/* Speziell für die Accessibility-Selects */
#accessibility-colorblind,
#accessibility-fontsize,
#settings-language {
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px 36px 10px 12px;
    font-size: 0.84rem;
    font-weight: 500;
}

#accessibility-colorblind:hover,
#accessibility-fontsize:hover,
#settings-language:hover {
    border-color: var(--accent);
    background-color: var(--surface-hover);
}