/* =============================================================================
   Schiedsrichter Quiz — Main Stylesheet
   Mobile-first, CSS custom properties, no frameworks
   ============================================================================= */

/* --- Custom Properties ---------------------------------------------------- */
:root {
    /* Option B — Navy & Red Pop */
    --primary:        #1e3a5f;   /* Navy — buttons, links, headings */
    --primary-light:  #2d5485;   /* lighter navy for hover */
    --primary-dark:   #162d4a;   /* deep navy for sidebar */
    --accent:         #e11d48;   /* Red Pop — highlights, active states, badges */
    --accent-dark:    #be1239;   /* darker red for hover */
    --accent-light:   #fde8ec;   /* very light red for tinted backgrounds */
    --bg:             #f0f4f8;
    --card-bg:        #ffffff;
    --text:           #1e293b;
    --text-light:     #64748b;
    --text-on-primary:#ffffff;
    --success:        #16a34a;
    --success-light:  #dcfce7;
    --error:          #dc2626;
    --error-light:    #fee2e2;
    --warning:        #d97706;
    --warning-light:  #fef3c7;
    --info:           #0369a1;
    --info-light:     #e0f2fe;
    --border:         #e2e8f0;
    --border-dark:    #cbd5e1;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:      0 4px 10px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:      0 12px 30px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.08);
    --radius-sm:      4px;
    --radius-md:      8px;
    --radius-lg:      12px;
    --radius-xl:      16px;
    --nav-width:      250px;
    --header-height:  56px;
    --max-app-width:  1920px;
    --app-offset:     max(0px, calc(50vw - calc(var(--max-app-width) / 2)));
    --transition:     0.2s ease;
    --font-base:      'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* --- Reset ----------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-base);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
h1,h2,h3,h4,h5,h6 { line-height: 1.25; font-weight: 600; }

/* --- Layout Shell --------------------------------------------------------- */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Mobile Toggle -------------------------------------------------------- */
.mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 14px;
    left: calc(var(--app-offset) + 14px);
    z-index: 300;
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: background var(--transition);
}
.mobile-toggle:hover { background: var(--primary-light); }
@media (min-width: 1024px) { .mobile-toggle { display: none; } }

.header-user {
    position: relative;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
}

.header-avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 999px;
    padding: 4px 10px 4px 4px;
    color: #fff;
    cursor: pointer;
    transition: background var(--transition);
    font-family: inherit;
    font-size: 0.875rem;
}
.header-avatar-btn:hover {
    background: rgba(255,255,255,0.16);
}

.header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    flex-shrink: 0;
    color: #fff;
}

.header-username {
    color: rgba(255,255,255,0.92);
    font-weight: 500;
    white-space: nowrap;
    display: none;
}
@media (min-width: 480px) {
    .header-username { display: block; }
}

.header-chevron {
    color: rgba(255,255,255,0.6);
    flex-shrink: 0;
    transition: transform var(--transition);
}
.header-avatar-btn[aria-expanded="true"] .header-chevron {
    transform: rotate(180deg);
}

/* --- User Dropdown -------------------------------------------------------- */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 190px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
    overflow: hidden;
    z-index: 300;
    animation: dropdownFadeIn 0.15s ease;
}
.user-dropdown.is-open { display: block; }

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition);
}
.user-dropdown-item:hover {
    background: var(--bg);
}
.user-dropdown-item svg {
    color: var(--text-light);
    flex-shrink: 0;
}

.user-dropdown-item--danger { color: var(--error); }
.user-dropdown-item--danger svg { color: var(--error); }
.user-dropdown-item--danger:hover { background: var(--error-light); }

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 2px 0;
}

/* --- Navigation ----------------------------------------------------------- */
.app-nav {
    position: fixed;
    top: 0;
    left: var(--app-offset);
    bottom: 0;
    width: var(--nav-width);
    background: var(--primary-dark);
    color: var(--text-on-primary);
    overflow: hidden;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    flex-direction: column;
}

/* --- Nav Logo ------------------------------------------------------------- */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.nav-logo-icon { font-size: 1.4rem; }
.nav-logo-text {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.01em;
}

/* --- Nav Scroll area ------------------------------------------------------ */
.nav-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}
.nav-scroll::-webkit-scrollbar { width: 4px; }
.nav-scroll::-webkit-scrollbar-track { background: transparent; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* --- Nav User area -------------------------------------------------------- */
.nav-user {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 8px;
    position: relative;
}
.nav-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition);
    text-align: left;
}
.nav-user-btn:hover { background: rgba(255,255,255,0.10); }
.nav-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}
.nav-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.nav-user-name {
    font-size: 0.825rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-user-role {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.45);
}
.nav-user-chevron {
    color: rgba(255,255,255,0.4);
    flex-shrink: 0;
    transition: transform var(--transition);
}
.nav-user-btn[aria-expanded="true"] .nav-user-chevron { transform: rotate(180deg); }

.nav-user-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% - 4px);
    left: 8px;
    right: 8px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
    overflow: hidden;
    z-index: 10;
    animation: slideUp 0.15s ease;
}
.nav-user-dropdown.is-open { display: block; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nav-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition);
}
.nav-user-dropdown-item:hover { background: var(--bg); }
.nav-user-dropdown-item svg { color: var(--text-light); flex-shrink: 0; }
.nav-user-dropdown-item--danger { color: var(--error); }
.nav-user-dropdown-item--danger svg { color: var(--error); }
.nav-user-dropdown-item--danger:hover { background: var(--error-light); }
.nav-user-dropdown-divider { height: 1px; background: var(--border); margin: 2px 0; }

.app-nav.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
}

.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 140;
}

.nav-overlay.is-visible { display: block; }

.nav-section-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.35);
    padding: 14px 16px 4px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 12px 7px 16px;
    color: rgba(255,255,255,0.70);
    font-size: 0.875rem;
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-right: 10px;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), transform var(--transition);
    cursor: pointer;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: calc(100% - 10px);
    text-align: left;
}

.nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.95);
    text-decoration: none;
    transform: translateX(2px);
}

.nav-item.is-active {
    background: linear-gradient(90deg, rgba(0,163,224,0.22) 0%, rgba(0,163,224,0.06) 100%);
    color: #fff;
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-item .nav-icon {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 16px;
}

.nav-footer {
    margin-top: auto;
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* --- Main Content --------------------------------------------------------- */
.app-main {
    margin-left: var(--app-offset);
    margin-right: var(--app-offset);
    padding: 70px 16px 24px; /* top: clearance for mobile toggle button */
    min-height: 100vh;
    position: relative;
}

.page {
    display: none;
    animation: fadeIn 0.2s ease;
}

.page.is-active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* --- Cards (Bento-Box style) ---------------------------------------------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: 0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.07);
    border: 1px solid rgba(0,0,0,.06);
    position: relative;
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.09), 0 8px 28px rgba(0,0,0,.10);
    transform: translateY(-1px);
}

/* Navy top stripe on cards */
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid rgba(0,0,0,.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.card-body {
    padding: 22px 24px;
}

.card-footer {
    padding: 14px 24px;
    border-top: 1px solid rgba(0,0,0,.05);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), box-shadow var(--transition),
                transform var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.3;
    font-family: inherit;
    user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn-block { width: 100%; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 1px 4px rgba(30,58,95,0.25);
}
.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
    box-shadow: 0 3px 10px rgba(30,58,95,0.30);
    text-decoration: none;
    color: #fff;
    transform: translateY(-1px);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(225,29,72,0.25);
}
.btn-accent:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: 0 3px 10px rgba(225,29,72,0.30);
    text-decoration: none;
    color: #fff;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-outline-accent {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline-accent:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}
.btn-danger:hover {
    background: #c62828;
    border-color: #c62828;
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--border);
    color: var(--text);
    text-decoration: none;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-light);
    transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--border); color: var(--text); }

/* --- Forms ---------------------------------------------------------------- */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--error);
    margin-left: 3px;
}

.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,163,224,0.15);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-light); }

.form-input.has-error,
.form-select.has-error { border-color: var(--error); }

.form-input.has-error:focus,
.form-select.has-error:focus { box-shadow: 0 0 0 3px rgba(244,67,54,0.12); }

.form-error {
    font-size: 0.8rem;
    color: var(--error);
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 5px;
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23757575' d='M1 0l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 0;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.form-check-label {
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

/* --- Alerts --------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    border: 1px solid transparent;
    margin-bottom: 16px;
}

.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

.alert-success {
    background: var(--success-light);
    color: #2e7d32;
    border-color: #c8e6c9;
}

.alert-error {
    background: var(--error-light);
    color: #c62828;
    border-color: #ffcdd2;
}

.alert-warning {
    background: var(--warning-light);
    color: #e65100;
    border-color: #ffe0b2;
}

.alert-info {
    background: var(--info-light);
    color: #1565c0;
    border-color: #bbdefb;
}

/* --- Tables --------------------------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--card-bg);
}

thead th {
    background: #f1f5f9;
    color: #374151;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(239,51,64,0.03); }

tbody td {
    padding: 12px 16px;
    color: var(--text);
    vertical-align: middle;
}

.table-empty {
    text-align: center;
    color: var(--text-light);
    padding: 40px 16px;
}

/* --- Badges --------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: #2e7d32; }
.badge-error   { background: var(--error-light);   color: #c62828; }
.badge-warning { background: var(--warning-light);  color: #e65100; }
.badge-info    { background: var(--info-light);     color: #1565c0; }
.badge-primary { background: rgba(239,51,64,0.1);   color: var(--primary); }
.badge-neutral { background: var(--bg);            color: var(--text-light); border: 1px solid var(--border); }

/* --- Modal ---------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 400;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.15s ease;
}

.modal-overlay.is-open {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: color var(--transition), background var(--transition);
}

.modal-close:hover { color: var(--text); background: var(--border); }

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* --- Loading -------------------------------------------------------------- */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.75);
    z-index: 500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.loading-overlay.is-visible {
    display: flex;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2.5px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, #f0f0f0 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* --- Toast ---------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    background: #323232;
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 500;
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    max-width: 480px;
    min-width: 280px;
    border-left: 4px solid #fff;
}

.toast.is-hiding {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
    from { transform: translateY(-16px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

@keyframes toastOut {
    to { transform: translateY(-16px); opacity: 0; }
}

.toast-success { background: #1b5e20; border-left-color: var(--success); }
.toast-error   { background: #b71c1c; border-left-color: #ef9a9a; }
.toast-warning { background: #e65100; border-left-color: var(--warning); }
.toast-info    { background: #0082B3; border-left-color: var(--accent); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast-message { flex: 1; }
.toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}
.toast-close:hover { color: #fff; }

/* --- Quiz Progress -------------------------------------------------------- */
.quiz-progress {
    margin-bottom: 20px;
}

.quiz-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.quiz-progress-bar-track {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.quiz-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #33C0F0);
    border-radius: 999px;
    transition: width 0.4s ease;
    min-width: 8px;
}

.quiz-progress-bar-fill.is-complete {
    background: linear-gradient(90deg, var(--success), #81c784);
}

/* --- Quiz Question -------------------------------------------------------- */
.quiz-question-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 20px;
}

.quiz-question-header {
    background: var(--primary);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.quiz-question-number {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 500;
}

.quiz-question-prefix {
    font-size: 0.75rem;
    background: var(--accent);
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.quiz-question-category {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.15);
    padding: 3px 10px;
    border-radius: 999px;
}

.quiz-question-type {
    font-size: 0.72rem;
    background: var(--accent);
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 700;
}

.quiz-question-body {
    padding: 20px;
}

.quiz-question-text {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 20px;
}

.quiz-question-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 14px;
    font-style: italic;
}

/* --- Quiz Answers --------------------------------------------------------- */
.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-option {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition),
                box-shadow var(--transition);
    background: var(--card-bg);
    user-select: none;
}

.answer-option:hover:not(.is-disabled) {
    border-color: var(--accent);
    background: rgba(0,163,224,0.05);
    box-shadow: var(--shadow-sm);
}

.answer-option.is-selected {
    border-color: var(--accent);
    background: rgba(0,163,224,0.09);
    box-shadow: 0 0 0 3px rgba(0,163,224,0.15);
}

.answer-option.is-correct {
    border-color: var(--success);
    background: var(--success-light);
}

.answer-option.is-wrong {
    border-color: var(--error);
    background: var(--error-light);
}

.answer-option.is-missed {
    border-color: var(--success);
    background: rgba(76,175,80,0.06);
    border-style: dashed;
}

.answer-option.is-disabled { cursor: default; }

.answer-indicator {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
    transition: all var(--transition);
    background: #fff;
}

.answer-option.is-selected .answer-indicator {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.answer-option.is-correct .answer-indicator {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.answer-option.is-wrong .answer-indicator {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

/* MC checkbox style */
.answer-indicator.is-checkbox {
    border-radius: var(--radius-sm);
}

.answer-text {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
}

.answer-feedback {
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: auto;
    flex-shrink: 0;
}

.answer-feedback.correct { color: var(--success); }
.answer-feedback.wrong   { color: var(--error); }

/* --- Quiz Actions --------------------------------------------------------- */
.quiz-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* --- Quiz Timer ----------------------------------------------------------- */
.quiz-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(0,163,224,0.08);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid rgba(0,163,224,0.2);
}

.quiz-timer .timer-icon { font-size: 1rem; }
.quiz-timer.is-warning  { color: var(--warning); background: var(--warning-light); border-color: var(--warning); }
.quiz-timer.is-critical { color: var(--error);   background: var(--error-light);   border-color: var(--error);
                          animation: timerPulse 0.8s ease infinite; }

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.04); }
}

/* --- Quiz Rule Reference -------------------------------------------------- */
.rule-refs-skip {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.rule-reference {
    margin-top: 16px;
    background: rgba(239,51,64,0.03);
    border: 1px solid rgba(239,51,64,0.12);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.rule-reference-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    margin-bottom: 6px;
}

.rule-reference-text {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.75;
    text-align: justify;
    hyphens: auto;              /* automatische Silbentrennung — braucht lang="de" auf <html> */
    overflow-wrap: break-word;  /* Sicherheitsnetz für lange Komposita */
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* --- Quiz Result ---------------------------------------------------------- */
.quiz-result {
    text-align: center;
}

.result-score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 8px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    position: relative;
}

.result-score-circle.is-excellent { border-color: var(--success); }
.result-score-circle.is-good      { border-color: var(--primary); }
.result-score-circle.is-poor      { border-color: var(--error); }

.result-score-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.result-score-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
}

.result-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 24px 0;
}

.result-stat {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 14px 10px;
    text-align: center;
    border: 1px solid var(--border);
}

.result-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
}

.result-stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
}

.result-question-list {
    text-align: left;
    margin-top: 24px;
}

.result-question-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.result-question-item:last-child { border-bottom: none; }

.result-question-status {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.result-question-status.correct { background: var(--success-light); color: var(--success); }
.result-question-status.wrong   { background: var(--error-light);   color: var(--error); }

/* --- Ranking -------------------------------------------------------------- */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    transition: background var(--transition);
}

.ranking-item:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.ranking-item:last-child  { border-bottom: none; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.ranking-item:hover       { background: rgba(239,51,64,0.03); }

.ranking-item.is-me {
    background: rgba(239,51,64,0.06);
    border-left: 3px solid var(--primary);
}

.ranking-position {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: var(--bg);
    color: var(--text-light);
    border: 2px solid var(--border);
}

.ranking-position.gold   { background: #ffd700; color: #7a5a00; border-color: #f5c800; }
.ranking-position.silver { background: #e8e8e8; color: #5a5a5a; border-color: #d0d0d0; }
.ranking-position.bronze { background: #cd7f32; color: #fff;    border-color: #b8682a; }

.ranking-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-points {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    white-space: nowrap;
}

.ranking-points-label {
    font-size: 0.7rem;
    color: var(--text-light);
    font-weight: 400;
}

/* --- Stat Cards ----------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: 0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.07);
    border: 1px solid rgba(0,0,0,.06);
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.09), 0 8px 28px rgba(0,0,0,.10);
    transform: translateY(-2px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
}

.stat-card.accent::before  { background: linear-gradient(90deg, #00A3E0, #CCF0FF); }
.stat-card.success::before { background: linear-gradient(90deg, #4caf50, #a5d6a7); }
.stat-card.error::before   { background: linear-gradient(90deg, #f44336, #ef9a9a); }

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.stat-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 3px;
}

.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--error); }

/* --- Pagination ----------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.pagination-btn:hover:not(:disabled):not(.is-active) {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(0,163,224,0.06);
}

.pagination-btn.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Auth Pages ----------------------------------------------------------- */
.auth-page {
    min-height: calc(100vh - var(--header-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.auth-card-header {
    background: var(--primary);
    color: #fff;
    padding: 28px 28px 24px;
    text-align: center;
}

.auth-logo {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.auth-card-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-card-subtitle {
    font-size: 0.85rem;
    opacity: 0.75;
}

.auth-card-body {
    padding: 28px;
}

.auth-card-footer {
    padding: 16px 28px 24px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
    border-top: 1px solid var(--border);
}

.auth-card-footer a {
    color: var(--primary);
    font-weight: 600;
}

/* --- Dashboard ------------------------------------------------------------ */
.dashboard-greeting {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.dashboard-date {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 24px;
}

.quiz-mode-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.quiz-mode-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--border);
    padding: 22px 20px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition),
                transform var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.quiz-mode-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quiz-mode-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.quiz-mode-icon.training { background: rgba(0,163,224,0.12); }
.quiz-mode-icon.public   { background: rgba(239,51,64,0.12); }
.quiz-mode-icon.test     { background: rgba(107,26,26,0.1); }

.quiz-mode-info { flex: 1; }
.quiz-mode-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; color: var(--text); }
.quiz-mode-desc  { font-size: 0.82rem; color: var(--text-light); line-height: 1.4; }

/* --- Chip / Tag ----------------------------------------------------------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--border);
    color: var(--text);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.chip.is-selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.chip:hover:not(.is-selected) { border-color: var(--primary); color: var(--primary); }

/* --- Chip Multiselect (Template-Edit-Seite) -------------------------------- */
.chip-multiselect {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.chip-multiselect .chip {
    border: 1.5px solid var(--border-color, #cbd5e0);
    border-radius: 20px;
    background: transparent;
    color: var(--text-primary, #1a202c);
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.15s;
}

.chip-multiselect .chip:hover {
    border-color: var(--accent);
    background: rgba(0, 163, 224, 0.06);
}

.chip-multiselect .chip.chip-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 500;
}

/* --- Empty State ---------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state-text  { font-size: 0.875rem; }

/* --- Section Heading ------------------------------------------------------ */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
}

/* --- Utility -------------------------------------------------------------- */
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mt-3  { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-light); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent-dark); }
.font-bold    { font-weight: 700; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

/* =============================================================================
   Tablet (768px+)
   ============================================================================= */
@media (min-width: 768px) {
    :root {
        --header-height: 64px;
    }

    .app-main {
        padding: 28px 28px;
    }

    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .quiz-mode-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .result-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* header-username is always visible inside avatar-btn */

    .modal { max-width: 560px; }

    .auth-card-header { padding: 36px 36px 28px; }
    .auth-card-body   { padding: 36px; }
    .auth-card-footer { padding: 18px 36px 28px; }
}

/* =============================================================================
   Desktop (1024px+)
   ============================================================================= */
@media (min-width: 1024px) {
    .app-nav {
        transform: translateX(0) !important;
        box-shadow: none !important;
    }

    .nav-overlay { display: none !important; }

    .app-main {
        margin-left: calc(var(--app-offset) + var(--nav-width));
        padding: 36px 40px;
    }

    .page-title { font-size: 1.6rem; }
}

/* =============================================================================
   Wide Desktop (1280px+)
   ============================================================================= */
@media (min-width: 1280px) {
    .app-main {
        padding: 36px 48px;
    }
}

/* =============================================================================
   Print Styles
   ============================================================================= */
@media print {
    .app-header,
    .app-nav,
    .nav-overlay,
    .hamburger,
    .app-footer,
    .toast-container,
    .modal-overlay,
    .loading-overlay,
    .btn,
    .pagination { display: none !important; }

    .app-main {
        margin: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    body { font-size: 12pt; color: #000; }
    a { color: #000; text-decoration: underline; }
}

/* =============================================================================
   Compatibility shims — pages.js uses these class names
   ============================================================================= */

/* form-control = alias for form-input */
.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,163,224,0.15);
}
.form-control-sm { padding: 5px 8px; font-size: 0.8rem; }

/* btn-full = btn-block alias */
.btn-full { width: 100%; }

/* btn-xs */
.btn-xs { padding: 4px 10px; font-size: 0.78rem; }

/* ==========================================================================
   Auth — Split Layout (Login / Register)
   ========================================================================== */
.auth-split {
    display: flex;
    min-height: calc(100vh - 60px);
}

.auth-brand {
    display: none;
    flex: 1;
    background: var(--primary);
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
}
.auth-brand-inner { color: #fff; max-width: 340px; }
.auth-brand-logo { font-size: 3.5rem; margin-bottom: 16px; }
.auth-brand-title { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }
.auth-brand-sub { font-size: 0.95rem; opacity: 0.75; line-height: 1.6; margin-bottom: 32px; }
.auth-brand-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.auth-badge {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--bg);
}
.auth-form-box { width: 100%; max-width: 400px; }
.auth-form-title { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.auth-form-sub { font-size: 0.9rem; color: var(--text-light); margin-bottom: 28px; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.auth-guest-btn {
    color: var(--text-light);
    font-size: 0.875rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-bottom: 4px;
    background: transparent;
    width: 100%;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.auth-guest-btn:hover { background: var(--card-bg); border-color: var(--primary-light); color: var(--primary); }

.auth-switch { text-align: center; font-size: 0.875rem; color: var(--text-light); margin-top: 20px; }
.auth-switch a { color: var(--accent); font-weight: 600; }

@media (min-width: 768px) {
    .auth-brand { display: flex; }
    .auth-form-side { flex: 0 0 460px; }
}

/* Legacy compat — register page still uses auth-wrapper */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 24px 16px;
}
.auth-logo { text-align: center; margin-bottom: 16px; }
.logo-icon { font-size: 2.5rem; }
.auth-title { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.auth-subtitle { font-size: 0.875rem; color: var(--text-light); margin-top: 4px; }
.auth-switch-old { text-align: center; font-size: 0.875rem; color: var(--text-light); margin-top: 16px; }

/* loading-container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    gap: 12px;
}
.loading-text { color: var(--text-light); font-size: 0.9rem; }

/* error-card */
.error-card {
    background: var(--error-light);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--error);
}
.error-icon { font-size: 1.2rem; flex-shrink: 0; }

/* quiz answer feedback */
.feedback-banner {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 12px;
}
.feedback-correct { background: var(--success-light); color: var(--success); }
.feedback-wrong   { background: var(--error-light);   color: var(--error);   }
.feedback-icon { font-size: 1.2rem; }

/* answer option states for pages.js quiz */
.answer-option.answer-correct { background: var(--success-light) !important; border-color: var(--success) !important; }
.answer-option.answer-wrong   { background: var(--error-light)   !important; border-color: var(--error)   !important; }

.answer-options { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.answer-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border-dark);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.answer-option:hover { border-color: var(--accent); background: rgba(0,163,224,0.06); }
.answer-input { flex-shrink: 0; margin-top: 2px; accent-color: var(--primary); }
.answer-text { flex: 1; }

/* quiz result detail */
.result-summary-card {
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}
.score-good   { background: var(--success-light); border: 2px solid var(--success); }
.score-medium { background: var(--warning-light); border: 2px solid var(--warning); }
.score-bad    { background: var(--error-light);   border: 2px solid var(--error);   }

.result-score { margin-bottom: 12px; }
.result-score-value { display: block; font-size: 3rem; font-weight: 800; }
.result-score-fraction { font-size: 1rem; color: var(--text-light); }
.result-meta { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }
.result-meta-item { display: flex; flex-direction: column; align-items: center; }
.meta-label { font-size: 0.78rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.05em; }
.meta-value { font-size: 1.1rem; font-weight: 700; }

.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }

.result-questions-section { margin-top: 8px; }
.result-questions-list { display: flex; flex-direction: column; gap: 12px; }
.result-question-item {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--border);
}
.result-q-correct { border-left-color: var(--success); background: var(--success-light); }
.result-q-wrong   { border-left-color: var(--error);   background: var(--error-light);   }
.result-q-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.result-q-number { font-size: 0.78rem; color: var(--text-light); }
.result-q-icon { font-size: 1rem; }
.result-q-text { font-weight: 500; margin-bottom: 8px; }
.result-answers-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.answer-result-item { font-size: 0.875rem; padding: 4px 0; }
.answer-result-item.answer-correct { color: var(--success); font-weight: 600; }
.answer-result-item.answer-wrong   { color: var(--error);   text-decoration: line-through; }

.rule-references { margin-top: 10px; }
.rule-references.compact { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-ref-item { margin-bottom: 8px; }
.rule-ref-number { font-weight: 700; font-size: 0.8rem; color: var(--primary); }
.rule-ref-text { font-size: 0.85rem; color: var(--text-light); margin-top: 2px; }
.rule-ref-pill {
    display: inline-block;
    background: var(--info-light);
    color: var(--info);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ranking page */
.ranking-page { max-width: 700px; margin: 0 auto; }
.my-rank-card {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
}
.my-rank-info { display: flex; flex-direction: column; }
.my-rank-label { font-size: 0.75rem; opacity: 0.75; }
.my-rank-value { font-size: 1.4rem; font-weight: 700; }
.ranking-current-user { background: var(--info-light); font-weight: 600; }

/* data-table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { padding: 10px 12px; text-align: left; background: #f1f5f9; color: #374151; border-bottom: 2px solid var(--border); font-weight: 600; white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.question-text-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-cell { white-space: nowrap; }
.log-table .log-row { cursor: pointer; }
.log-table .log-row:hover td { background: var(--info-light); }
.log-time { font-size: 0.78rem; white-space: nowrap; }
.log-message-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-context-json { background: var(--bg); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 0.8rem; max-height: 300px; overflow-y: auto; }
.log-detail-message { margin-bottom: 12px; }

/* filter bar */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar-wrap { flex-wrap: wrap; }
.filter-input { flex: 1; min-width: 160px; }
.filter-select { min-width: 140px; }
.filter-date  { min-width: 130px; }

/* stat bars (admin stats) */
.stats-section { padding: 20px; margin-bottom: 16px; }
.stat-bars { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.stat-bar-row { display: flex; align-items: center; gap: 12px; }
.stat-bar-label { min-width: 140px; font-size: 0.875rem; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar-track { flex: 1; height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.5s ease; }
.stat-bar-fill-alt { background: var(--accent); }
.stat-bar-value { min-width: 70px; font-size: 0.78rem; color: var(--text-light); text-align: right; }

/* quiz cards (dashboard) */
.quiz-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.quiz-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.quiz-card-body { padding: 16px; flex: 1; }
.quiz-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.quiz-card-desc { font-size: 0.85rem; color: var(--text-light); margin-bottom: 8px; }
.quiz-card-meta { font-size: 0.78rem; color: var(--text-light); display: flex; gap: 12px; }
.quiz-card-footer { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg); display: flex; justify-content: flex-end; }

/* test list (dashboard) */
.test-list { display: flex; flex-direction: column; gap: 10px; }
.test-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); flex-wrap: wrap; }
.test-item-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.test-item-title { font-weight: 500; }

/* checkbox grid */
.checkbox-grid { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; padding: 4px 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { accent-color: var(--primary); }
.cat-count { color: var(--text-light); font-size: 0.8rem; }
.hint { color: var(--text-light); font-size: 0.8rem; }
.form-label-main { font-weight: 600; font-size: 0.9rem; display: block; margin-bottom: 4px; }

/* admin question edit modal */
.answer-edit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.answer-edit-row input[type="checkbox"] { flex-shrink: 0; accent-color: var(--success); }

/* form-row — horizontal field groups */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

/* import page */
.import-card { padding: 20px; }
.import-desc { color: var(--text-light); margin-bottom: 16px; font-size: 0.9rem; }
.upload-zone {
    position: relative;
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone-drag { border-color: var(--accent); background: var(--info-light); }
.upload-zone-inner { pointer-events: none; }
.upload-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-zone-text { font-weight: 500; margin-bottom: 4px; }
.upload-zone-hint { font-size: 0.8rem; color: var(--text-light); }
.upload-file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.selected-file-info { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--info-light); border-radius: var(--radius-md); margin-bottom: 12px; }
.file-icon { font-size: 1.2rem; }
.btn-icon { background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 1rem; padding: 2px 6px; border-radius: var(--radius-sm); }
.btn-icon:hover { color: var(--error); background: var(--error-light); }
.remove-file-btn { margin-left: auto; }
.import-result { margin-top: 16px; }
.import-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.import-stat-item { text-align: center; padding: 14px; border-radius: var(--radius-md); }
.import-stat-success { background: var(--success-light); }
.import-stat-warning { background: var(--warning-light); }
.import-stat-error   { background: var(--error-light);   }
.import-stat-value { display: block; font-size: 1.6rem; font-weight: 700; }
.import-stat-label { font-size: 0.8rem; color: var(--text-light); }
.import-errors { margin-top: 10px; }

/* confirm modal */
.confirm-quote { background: var(--bg); border-left: 3px solid var(--border-dark); padding: 8px 12px; margin: 10px 0; font-style: italic; border-radius: var(--radius-sm); }
.confirm-warning { color: var(--error); font-size: 0.875rem; }

/* admin page layout */
.admin-page { max-width: 1100px; margin: 0 auto; }

/* quiz play page */
.quiz-play { max-width: 700px; margin: 0 auto; }

.quiz-abort-row {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}

.btn-quiz-abort {
    font-size: 0.78rem;
    color: var(--text-light);
    padding: 4px 12px;
    opacity: 0.7;
    transition: opacity 0.15s, color 0.15s;
}
.btn-quiz-abort:hover {
    opacity: 1;
    color: var(--error);
}
.quiz-report-row {
    display: flex;
    justify-content: flex-end;
    padding: 6px 0 2px;
}

.btn-report-question {
    font-size: 0.75rem;
    color: var(--text-light, #94a3b8);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}
.btn-report-question:hover {
    opacity: 1;
    color: var(--warning, #f59e0b);
}

/* ============================================================
   Offline UI — badge, cache row, modal banner, result note
   ============================================================ */
.badge-offline {
    display: inline-block;
    background: #f59e0b;
    color: #1c1917;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
}
.offline-modal-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(245,158,11,0.12);
    border: 1px solid rgba(245,158,11,0.4);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 14px;
}
.offline-cache-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.82rem;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.cache-status { font-size: 0.82rem; }
.cache-status--ok    { color: #22c55e; }
.cache-status--empty { color: var(--text-light); }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }
.offline-result-note {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 16px 0;
    color: var(--text-light);
    font-size: 0.875rem;
    text-align: center;
}
.offline-result-note p { margin: 0; }

/* Dashboard Offline-Download Banner */
.offline-dl-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--card-bg);
    border: 1px solid rgba(0,163,224,0.3);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}
.offline-dl-banner-text {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}
.offline-dl-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}
.offline-dl-banner-text strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
.offline-dl-banner-text p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.4;
}
@media (max-width: 480px) {
    .offline-dl-banner { flex-direction: column; align-items: flex-start; }
    .offline-dl-banner .btn { width: 100%; }
}

.offline-cache-status-bar {
    font-size: 0.8rem;
    color: #22c55e;
    margin-bottom: 16px;
    padding: 6px 0;
}

.quiz-progress { margin-bottom: 16px; }
.quiz-progress-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.quiz-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #33C0F0); border-radius: 999px; transition: width 0.4s ease; }
.quiz-progress-info { display: flex; align-items: center; justify-content: space-between; font-size: 0.875rem; color: var(--text-light); }
.question-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.question-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.question-type-badge { font-size: 0.75rem; }
.question-category { font-size: 0.8rem; color: var(--text-light); }
.question-text { font-size: 1rem; font-weight: 500; line-height: 1.5; margin-bottom: 8px; }
.question-hint { font-size: 0.8rem; color: var(--text-light); margin-bottom: 4px; }
.quiz-feedback { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; margin-top: 16px; }
.timer-warning { color: var(--error) !important; }

/* history page */
.history-page { max-width: 900px; margin: 0 auto; }

/* profile page */
.profile-page { max-width: 600px; margin: 0 auto; }
.profile-section { margin-bottom: 16px; }
.form-static { padding: 8px 0; }

/* dashboard */
.dashboard { max-width: 900px; margin: 0 auto; }
.dashboard-section { margin-bottom: 24px; }
.section-footer { margin-top: 12px; text-align: center; }

/* badge variants used by pages.js */
.badge-danger   { background: var(--error-light);   color: var(--error);   }
.badge-success  { background: var(--success-light); color: #2e7d32; }
.badge-xs { font-size: 0.65rem; padding: 1px 6px; }

/* --- Secondary Rule Reference color variants -------------------------------- */
.rule-reference--orange { border-left-color: #f97316; background: rgba(249,115,22,0.04); }
.rule-reference--orange .rule-reference-label { color: #f97316; }
.rule-reference--purple { border-left-color: #9333ea; background: rgba(147,51,234,0.04); }
.rule-reference--purple .rule-reference-label { color: #9333ea; }
.rule-reference--green  { border-left-color: #16a34a; background: rgba(22,163,74,0.04); }
.rule-reference--green  .rule-reference-label { color: #16a34a; }
.rule-reference--teal   { border-left-color: #0d9488; background: rgba(13,148,136,0.04); }
.rule-reference--teal   .rule-reference-label { color: #0d9488; }
.rule-reference--rose   { border-left-color: #e11d48; background: rgba(225,29,72,0.04); }
.rule-reference--rose   .rule-reference-label { color: #e11d48; }

/* Inline ref highlight spans inside primary rule text */
.ref-inline { font-weight: 600; border-radius: 3px; padding: 1px 3px; }
.ref-inline--primary { color: var(--primary); background: rgba(239,51,64,0.10); }
.ref-inline--orange  { color: #f97316; background: rgba(249,115,22,0.12); }
.ref-inline--purple  { color: #9333ea; background: rgba(147,51,234,0.12); }
.ref-inline--green   { color: #16a34a; background: rgba(22,163,74,0.12); }
.ref-inline--teal    { color: #0d9488; background: rgba(13,148,136,0.12); }
.ref-inline--rose    { color: #e11d48; background: rgba(225,29,72,0.12); }

/* --- Regelwerk page --------------------------------------------------------- */
/* Bricht aus dem app-main-Padding heraus und füllt die volle Breite */
.regelwerk-breakout {
    margin-left:  -16px;
    margin-right: -16px;
    padding-left:  16px;
    padding-right: 16px;
}
@media (min-width: 768px) {
    .regelwerk-breakout {
        margin-left:  -36px;
        margin-right: -36px;
        padding-left:  36px;
        padding-right: 36px;
    }
}
@media (min-width: 1280px) {
    .regelwerk-breakout {
        margin-left:  -48px;
        margin-right: -48px;
        padding-left:  48px;
        padding-right: 48px;
    }
}

.regelwerk-layout {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 24px;
    align-items: start;
}

.regelwerk-sidebar {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 0;
    scrollbar-width: thin;
}

.regelwerk-toc { display: flex; flex-direction: column; }

.regelwerk-toc-link {
    display: block;
    padding: 6px 16px;
    font-size: 0.82rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.regelwerk-toc-link:hover { background: var(--bg); color: var(--primary); }

.regelwerk-toc-sep {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-light);
    padding: 10px 16px 4px;
}

.regelwerk-content { min-width: 0; }

.regelwerk-rule-section {
    margin-bottom: 32px;
    scroll-margin-top: 72px;
}

.regelwerk-rule-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.regelwerk-paragraph {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    scroll-margin-top: 80px;
    transition: background 0.3s;
}
.regelwerk-paragraph:hover { background: var(--bg); }
.regelwerk-paragraph.rw-highlight { background: rgba(0,163,224,0.12); }

/* Regelwerk — Bildergalerie */
.rw-gallery {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 0 0 12px;
    margin-bottom: 20px;
    scrollbar-width: thin;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.rw-gallery-item {
    flex-shrink: 0;
    scroll-snap-align: start;
    cursor: zoom-in;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    transition: box-shadow 0.15s;
    max-width: 260px;
}
.rw-gallery-item:hover { box-shadow: var(--shadow-md); border-color: var(--primary-light); }
.rw-gallery-item img {
    max-height: 220px;
    width: auto;
    max-width: 240px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}
.rw-gallery-item figcaption {
    font-size: 0.72rem;
    color: var(--text-light);
    text-align: center;
    line-height: 1.3;
}

/* Regelwerk — Lightbox */
#rw-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0,0,0,0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 24px;
}
#rw-lightbox figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 0;
    max-width: 90vw;
    max-height: 90vh;
}
#rw-lightbox img {
    max-width: 88vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
#rw-lightbox figcaption {
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
    text-align: center;
}

/* Handzeichen Rule 18 — etwas kleiner da viele Bilder */
.regelwerk-rule-section:has(.rw-gallery [src*="regel_18"]) .rw-gallery-item img {
    max-height: 180px;
}

@media (max-width: 640px) {
    .rw-gallery-item { max-width: 200px; }
    .rw-gallery-item img { max-height: 160px; }
}

.regelwerk-para-ref {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(239,51,64,0.08);
    border-radius: 4px;
    padding: 2px 8px;
    letter-spacing: 0.02em;
}

.regelwerk-para-text {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text);
    text-align: justify;
    hyphens: auto;
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.regelwerk-ref-link {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px dotted var(--primary);
    text-decoration: none;
}
.regelwerk-ref-link:hover { color: var(--accent-dark); border-bottom-color: var(--accent-dark); }

/* ============================================================
   Question Picker (Admin: Quiz-Vorlagen & Tests)
   ============================================================ */
.q-picker { margin-top: 8px; }
.q-picker-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.q-picker-toolbar .form-control { flex: 1; min-width: 120px; }
.q-picker-badge {
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
}
.q-picker-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fafafa;
}
.q-picker-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.1s;
}
.q-picker-item:last-child { border-bottom: none; }
.q-picker-item:hover { background: rgba(0,163,224,0.08); }
.q-picker-item input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.q-picker-item-text { font-size: 0.85rem; line-height: 1.4; color: var(--text); }
.q-picker-item-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.q-picker-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.q-mode-section { display: none; }
.q-mode-section.active { display: block; }

@media (max-width: 768px) {
    .regelwerk-layout {
        grid-template-columns: 1fr;
    }
    .regelwerk-sidebar {
        position: static;
        max-height: 200px;
    }

    /* Grössere Touch-Targets für Inline-Refs */
    .regelwerk-ref-link {
        padding: 2px 1px;
    }

    /* Regelreferenz-Karten im Training: weniger Innenabstand */
    .rule-reference {
        padding: 12px 13px;
    }

    /* Inline-Ref-Spans: leicht grösser für Touch */
    .ref-inline {
        padding: 2px 4px;
    }
}

/* ============================================================
   News-Seite
   ============================================================ */
.news-card-img {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    display: block;
}

.news-card-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
}

.news-card-date { font-weight: 500; }

.news-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text-primary, #1e293b);
    line-height: 1.3;
}

.news-card-content {
    font-size: 0.9rem;
    color: var(--text-secondary, #475569);
    line-height: 1.65;
    margin-bottom: 14px;
    white-space: pre-wrap;
}

.news-card-source {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary, #3b82f6);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--primary, #3b82f6);
    border-radius: 20px;
    transition: background 0.15s, color 0.15s;
}
.news-card-source:hover {
    background: var(--primary);
    color: #fff;
}

/* --- App Footer ----------------------------------------------------------- */
.app-footer {
    text-align: center;
    padding: 14px 16px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--primary);
    margin-left: var(--app-offset);
    margin-right: var(--app-offset);
    opacity: 0.65;
    letter-spacing: 0.02em;
    border-top: 1px solid var(--border);
    margin-top: 32px;
    background: var(--card-bg);
}

/* On desktop the footer sits inside the content area offset by the sidebar */
@media (min-width: 1024px) {
    .app-footer {
        margin-left: calc(var(--app-offset) + var(--nav-width));
    }
}

