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

[x-cloak] {
    display: none !important;
}

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-secondary: #64748b;
    --color-success: #22c55e;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: 150ms ease;
}

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }

p {
    margin-bottom: 1em;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--color-primary-dark);
}

/* Code styling */
code {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

pre {
    font-family: var(--font-mono);
    white-space: pre;
    margin: 0.5rem 0;
}

pre code {
    font-size: inherit;
}

.code-list {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.code-list li {
    margin-bottom: 0.25rem;
}

.code-list code {
    display: inline-block;
    background: none;
    padding: 0;
}

/* Pseudocode block */
pre.pseudocode {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
}

/* Header & Navigation */
header {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--color-text-muted);
    font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--color-primary);
}

.auth-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Main Content */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-dark);
}

.btn-secondary {
    background-color: var(--color-secondary);
    color: white;
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: inherit;
    padding: 0;
}

.btn-link:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.error {
    color: var(--color-error);
    font-size: 0.875rem;
    padding: 0.5rem;
    background-color: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--color-text-muted);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

/* Auth Section */
.auth-section {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.auth-section h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-section form button {
    width: 100%;
    margin-top: 0.5rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Exam List */
.exam-list-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.exam-list-header h2 {
    margin: 0;
}

.exam-search-input {
    flex: 1;
    max-width: 320px;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.exam-search-input:focus {
    border-color: var(--primary);
}

.exam-search-input::placeholder {
    color: var(--text-muted, #999);
}

.exam-list-section h2 {
    margin-bottom: 1.5rem;
}

.exam-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.exam-detail-header h1 {
    margin: 0;
}

/* Dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 100;
    padding: 4px 0;
    max-height: 400px;
    overflow-y: auto;
}
.dropdown-menu a {
    display: block;
    padding: 6px 14px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.875rem;
}
.dropdown-menu a:hover {
    background: var(--color-bg);
}

.delete-exam-btn {
    margin-top: 0.5rem;
}

.exam-empty-hint {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    max-width: 480px;
}

.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.exam-card {
    display: block;
    padding: 1.25rem;
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

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

.exam-card h3 {
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.exam-meta {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.exam-points {
    font-size: 0.875rem;
    color: var(--color-primary);
    font-weight: 500;
    margin-top: 0.5rem;
}

.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
    width: 1.25rem;
    height: 1.25rem;
    background-color: var(--color-success);
    color: white;
    font-weight: bold;
    font-size: 0.75rem;
    border-radius: 50%;
    vertical-align: middle;
}

.unverified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
    min-width: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    background-color: #ef4444;
    color: #ffffff;
    font-weight: bold;
    font-size: 1rem;
    border-radius: 50%;
    vertical-align: middle;
    line-height: 1;
}

/* Exam card with session - new structure */
.exam-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.exam-card.has-session {
    border-color: var(--color-success);
    background: linear-gradient(135deg, var(--color-surface) 0%, rgba(74, 144, 226, 0.05) 100%);
}

.exam-session-status {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.session-badge {
    display: inline-block;
    background-color: var(--color-success);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    width: fit-content;
}

.session-badge.submitted {
    background-color: var(--color-primary);
}

.session-score {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
}

.session-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.session-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-continue {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition);
}

.btn-continue:hover {
    background-color: var(--color-primary-dark);
}

.btn-new-attempt {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-new-attempt:hover {
    background-color: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

/* Exam Detail */
.exam-detail-section {
    max-width: 800px;
}

.back-link {
    display: inline-block;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
}

.back-link:hover {
    color: var(--color-primary);
}

.exam-situation {
    background-color: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-secondary);
    margin: 1.5rem 0;
    line-height: 1.6;
}

.exam-situation h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: var(--color-text);
}

.aufgaben-list {
    margin-top: 2rem;
}

.aufgaben-list h3 {
    margin-bottom: 1rem;
}

.aufgabe-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: all var(--transition);
}

.aufgabe-card:hover {
    border-color: var(--color-primary);
    background-color: rgba(37, 99, 235, 0.02);
}

.aufgabe-number {
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
}

.aufgabe-title {
    flex: 1;
    color: var(--color-text);
}

.aufgabe-points {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Aufgabe View */
.aufgabe-section {
    max-width: 1400px;
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Exam layout with sidebar navigation */
.exam-layout {
    position: relative;
    overflow: visible;
}

.exam-nav {
    display: block;
    position: fixed;
    left: 1rem;
    top: 5rem;
    bottom: 1rem;
    width: 90px;
    padding: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.6875rem;
    z-index: 100;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nav-aufgabe {
    display: block;
    margin-bottom: 0.75rem;
}

.nav-aufgabe:last-child {
    margin-bottom: 0;
}

.nav-aufgabe-link {
    display: block;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.625rem;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.nav-aufgabe-link:hover {
    color: var(--color-primary);
}

.nav-subtasks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem;
}

.nav-subtask-link {
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.0625rem 0.125rem;
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
}

.nav-subtask-link:hover {
    color: var(--color-primary);
    background: var(--color-bg);
}

.exam-content {
    margin-left: 105px;
    min-width: 0;
    overflow: hidden;
}

/* Submit button */
.exam-submit {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--color-border);
    text-align: center;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1.125rem;
}

/* Presentation template (Folienbereich + Notizbereich) */
.presentation-template {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-top: 1rem;
    background: var(--color-surface);
    overflow: hidden;
}

.folienbereich,
.notizbereich {
    padding: 1rem;
}

.folienbereich {
    border-bottom: 1px solid var(--color-border);
}

.template-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.template-content {
    padding-left: 0.5rem;
}

.sample-line {
    font-style: italic;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.folien-input {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.375rem 0.5rem;
    margin-bottom: 0.375rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.folien-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.botschaften-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.botschaft-input {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    resize: vertical;
}

.botschaft-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Hide nav on small screens */
@media (max-width: 900px) {
    .exam-nav {
        display: none;
    }

    .exam-content {
        margin-left: 0;
    }
}

.aufgabe-context {
    background-color: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-primary);
    margin-bottom: 2rem;
    overflow: hidden;
}

.aufgabe-block {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--color-border);
}

.aufgabe-block:first-of-type {
    margin-top: 2rem;
    padding-top: 0;
    border-top: none;
}

.aufgabe-block h2 {
    margin-bottom: 1rem;
}

.aufgabe-points-inline {
    font-weight: 400;
    font-size: 1rem;
    color: var(--color-text-muted);
}

.subtasks {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.subtask-wrapper {
    background-color: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
    max-width: 100%;
}

.subtask-container {
    /* Inner container for answer inputs */
}

.subtask-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.subtask-id {
    display: block;
    width: 100%;
    font-size: 6px;
    color: #ccc;
    margin-bottom: 2px;
    font-weight: normal;
}

.subtask-label {
    font-weight: 600;
    color: var(--color-primary);
    flex: 1;
}

.subtask-points {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.subtask-text {
    margin-bottom: 1rem;
    line-height: 1.6;
    overflow-x: auto;
}

.subtask-text ol,
.subtask-text ul {
    margin: 0.5rem 0 1rem 0;
    padding-left: 1.5rem;
}

.subtask-text ol {
    list-style-type: decimal;
}

.subtask-text ul {
    list-style-type: disc;
}

.subtask-text li {
    margin-bottom: 0.25rem;
}

/* PuTTY-style connection window */
.putty-window {
    max-width: 450px;
    margin: 1rem 0;
    border: 1px solid #888;
    border-radius: 0;
    background: #f0f0f0;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 13px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

.putty-titlebar {
    background: linear-gradient(180deg, #0a246a 0%, #0a246a 100%);
    color: white;
    padding: 4px 8px;
    font-weight: bold;
    font-size: 12px;
}

.putty-content {
    padding: 12px;
}

.putty-section {
    margin-bottom: 12px;
}

.putty-label {
    margin-bottom: 6px;
    color: #000;
}

.putty-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.putty-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.putty-field label {
    font-size: 12px;
    color: #000;
}

.putty-host-input {
    width: 260px;
    padding: 3px 4px;
    border: 1px solid #7f9db9;
    font-size: 13px;
    font-family: inherit;
}

.putty-port {
    width: 70px;
}

.putty-port-input {
    width: 60px;
    padding: 3px 4px;
    border: 1px solid #7f9db9;
    font-size: 13px;
    font-family: inherit;
    text-align: center;
}

.putty-radio-group {
    display: flex;
    gap: 16px;
    margin-top: 4px;
}

.putty-radio {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 13px;
}

.putty-radio input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

/* Windows-style IP Configuration dialog */
.win-ip-dialog {
    max-width: 420px;
    margin: 1rem 0;
    border: 1px solid #888;
    background: #f0f0f0;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 13px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

.win-ip-titlebar {
    background: linear-gradient(180deg, #0078d4 0%, #0066b8 100%);
    color: white;
    padding: 6px 10px;
    font-weight: 600;
    font-size: 12px;
}

.win-ip-content {
    padding: 16px;
}

.win-ip-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 13px;
}

.win-ip-radio input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.win-ip-fields {
    margin-left: 22px;
    margin-top: 12px;
}

.win-ip-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.win-ip-label {
    width: 120px;
    font-size: 13px;
    color: #000;
}

.win-ip-input-group {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #7f9db9;
    padding: 2px;
}

.win-ip-octet {
    width: 36px;
    border: none;
    text-align: center;
    font-size: 13px;
    font-family: inherit;
    padding: 3px 2px;
    outline: none;
}

.win-ip-octet:focus {
    background: #cce4f7;
}

.win-ip-dot {
    color: #000;
    font-weight: bold;
    user-select: none;
}

/* Exam tables in prompts */
.exam-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9375rem;
}

.exam-table th,
.exam-table td {
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.75rem;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.exam-table th {
    background-color: var(--color-bg);
    font-weight: 600;
}

.exam-table td:first-child {
    background-color: var(--color-bg);
}

.exam-table td:not(:first-child) {
    text-align: center;
}

.exam-table td:empty {
    background-color: #fefce8;
}

/* Input cells in exam tables - inputs fill entire cell */
.exam-table td.input-cell {
    padding: 0 !important;
    overflow: hidden;
    vertical-align: top;
    background-color: #f0f9ff;
    border: 1.5px solid #93c5fd !important;
    height: 1px;
}

/* All inputs/textareas inside input-cells fill the cell with internal padding */
.exam-table .input-cell input[type="text"],
.exam-table .input-cell textarea,
.exam-table .input-cell .table-calc-input,
.exam-table .input-cell .table-text-input {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 2rem;
    max-width: 100%;
    box-sizing: border-box;
    border: none;
    border-radius: 0;
    padding: 0.375rem 0.5rem;
    margin: 0;
    background-color: transparent;
    font-style: italic;
    color: #1e40af;
    font-size: inherit;
    font-family: inherit;
    resize: none;
}

.exam-table .input-cell input[type="text"]:focus,
.exam-table .input-cell textarea:focus,
.exam-table .input-cell .table-calc-input:focus,
.exam-table .input-cell .table-text-input:focus {
    outline: none;
    background-color: #dbeafe;
}

/* Standalone table-calc-input (outside input-cell context) */
.table-calc-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    text-align: left;
    background: white;
}

.table-calc-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.table-calc-input::placeholder {
    color: #94a3b8;
    font-size: 0.75rem;
}

/* Rechenweg section embedded in prompt */
.rechenweg-section {
    margin: 1rem 0;
}

.rechenweg-section label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.rechenweg-input {
    width: 100%;
    max-width: 600px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: inherit;
    resize: vertical;
}

.rechenweg-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Calculation table - compact auto-width */
table.exam-table.calculation-table {
    width: auto;
    table-layout: auto;
}

table.exam-table.calculation-table th,
table.exam-table.calculation-table td:not(.input-cell) {
    white-space: nowrap;
    padding: 0.375rem 0.5rem;
    min-width: 0;
}

table.exam-table.calculation-table td:nth-child(2) {
    white-space: normal;
    word-break: break-word;
}

table.exam-table.calculation-table td:first-child {
    background-color: var(--color-bg);
}

/* Calculation table input cells - sizing constraints only */
table.exam-table.calculation-table .input-cell {
    min-width: 80px;
    max-width: 150px;
}

table.exam-table.calculation-table .input-cell input,
table.exam-table.calculation-table .input-cell .table-calc-input {
    min-height: 2.5rem;
    text-align: center;
}

/* Compact columns - shrink columns to fit content */
table.exam-table.compact-cols {
    table-layout: auto !important;
    width: auto !important;
}

table.exam-table.compact-cols td,
table.exam-table.compact-cols th {
    text-align: center;
    padding: 0.25rem 0.35rem !important;
    white-space: nowrap;
}

table.exam-table.compact-cols td:first-child,
table.exam-table.compact-cols th:first-child {
    text-align: left;
    padding-left: 0.5rem !important;
}

table.exam-table.compact-cols .input-cell {
    min-width: 0 !important;
    max-width: none !important;
    width: 3em !important;
    padding: 0 !important;
}

table.exam-table.compact-cols .input-cell input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 0.25rem !important;
    text-align: center;
    box-sizing: border-box;
}

/* Narrow label table - first column minimal width */
.narrow-label-table {
    table-layout: auto;
}

.narrow-label-table td:first-child {
    width: 1%;
    white-space: nowrap;
    padding-right: 1rem;
}

/* Security table with checkboxes */
.security-table {
    font-size: 0.875rem;
    table-layout: fixed;
    width: 100%;
}

.security-table th {
    text-align: center;
    font-size: 0.75rem;
    padding: 0.25rem;
}

.security-table th:first-child,
.security-table td:first-child {
    text-align: left;
    width: 25%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Checkbox column headers - minimal width, centered horizontally */
.security-table th:nth-child(2),
.security-table th:nth-child(3),
.security-table th:nth-child(4) {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    white-space: nowrap;
    height: 90px;
    width: 2.5rem;
    vertical-align: bottom;
    padding: 0;
    /* In vertical-rl mode, line-height controls horizontal position */
    line-height: 2.5rem;
    box-sizing: border-box;
}

.security-table th:last-child {
    text-align: left;
}

.security-table td:first-child {
    font-size: 0.8125rem;
}

.security-table td.checkbox-cell {
    text-align: center;
    padding: 0;
    width: 2.5rem;
    background-color: #fefce8;
}

.security-table .checkbox-cell input[type="checkbox"],
.security-table .checkbox-cell input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--color-primary);
}

/* Tables with input cells - use auto layout for smart column sizing */
/* IMPORTANT: Exclude tables with specific layout classes (security-table, schutzbedarf-table, calculation-table, etc.) */
.exam-table:has(.input-cell):not(.security-table):not(.schutzbedarf-table):not(.label-input-table):not(.calculation-table):not(.vorteile-nachteile-table):not(.wrap-labels):not(.auth-methods-table):not(.fehler-table) {
    table-layout: auto;
    width: 100%;
}

/* Cells without inputs shrink to fit their content */
/* IMPORTANT: Exclude tables with specific layout classes */
.exam-table:has(.input-cell):not(.security-table):not(.schutzbedarf-table):not(.label-input-table):not(.calculation-table):not(.vorteile-nachteile-table):not(.wrap-labels):not(.auth-methods-table):not(.fehler-table) th:not(.input-cell),
.exam-table:has(.input-cell):not(.security-table):not(.schutzbedarf-table):not(.label-input-table):not(.calculation-table):not(.vorteile-nachteile-table):not(.wrap-labels):not(.auth-methods-table):not(.fehler-table) td:not(.input-cell) {
    width: 1%;
    white-space: nowrap;
}

/* Input cells expand to fill remaining space */
.exam-table:has(.input-cell):not(.security-table):not(.schutzbedarf-table):not(.label-input-table):not(.calculation-table):not(.vorteile-nachteile-table):not(.wrap-labels):not(.auth-methods-table):not(.fehler-table) .input-cell {
    width: auto;
}

/* Override for tables where label text needs wrapping */
.exam-table.wrap-labels {
    table-layout: fixed;
    width: 100%;
}

/* First column (labels) gets 33%, remaining columns share the rest */
.exam-table.wrap-labels th:first-child,
.exam-table.wrap-labels td:first-child {
    width: 33%;
    white-space: normal;
}

/* All cells need white-space: normal for wrapping */
.exam-table.wrap-labels th,
.exam-table.wrap-labels td {
    white-space: normal;
}

/* Weighted comparison table with sub-columns per company */
.weighted-comparison {
    font-size: 0.8rem;
}

.weighted-comparison th,
.weighted-comparison td {
    padding: 0.35rem 0.4rem;
    text-align: center;
}

.weighted-comparison th:first-child,
.weighted-comparison td:first-child {
    text-align: left;
}

.weighted-comparison .table-calc-input {
    width: 100%;
    min-width: 35px;
    padding: 0.2rem;
    font-size: 0.8rem;
}

.table-text-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: white;
    resize: vertical;
}

.table-text-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.table-text-input::placeholder {
    color: #94a3b8;
}

/* Table select dropdown */
.table-select {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

.table-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Radio button group in prompts */
.radio-group {
    display: flex;
    gap: 1.5rem;
    margin: 0.75rem 0;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.radio-option input[type="radio"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--color-primary);
}

/* Inline free text input in prompts */
.free-text-input {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    background-color: #fefce8;
}

.free-text-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Numbered input list (e.g., "1. ___ 2. ___ 3. ___") */
.numbered-inputs {
    margin: 0.5rem 0;
}

.numbered-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.input-number {
    font-weight: 500;
    min-width: 1.5rem;
}

.step-input {
    flex: 1;
    max-width: 400px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background-color: #fefce8;
}

.step-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Struktogramm (Nassi-Shneiderman diagram) */
.struktogramm {
    max-width: 500px;
    margin: 1rem 0;
    border: 2px solid #000;
    background: white;
}

.strukt-row {
    border-bottom: 1px solid #000;
    min-height: 2.5rem;
    display: flex;
    align-items: stretch;
}

.strukt-row:last-child {
    border-bottom: none;
}

.strukt-loop {
    border-bottom: 1px solid #000;
    display: flex;
    flex-direction: column;
}

.strukt-loop:last-child {
    border-bottom: none;
}

/* Test-first loop: L-shaped structure with condition at top */
.strukt-loop-header {
    min-height: 2.5rem;
    display: flex;
    align-items: stretch;
    position: relative;
}

/* The L-shape corner piece: only at bottom-left of condition row */
.strukt-loop-header::before {
    content: '';
    display: block;
    width: 1.5rem;
    min-width: 1.5rem;
    background: white;
    border-bottom: 1px solid #000;
}

/* Draw just the vertical part of the L (bottom half only) */
.strukt-loop-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 1.5rem;
    height: 50%;
    border-right: 1px solid #000;
    box-sizing: border-box;
}

.strukt-loop-header .strukt-input {
    border-bottom: 1px solid #000;
}

.strukt-loop-body {
    display: flex;
}

/* Vertical continuation bar on left side of loop body */
.strukt-loop-body::before {
    content: '';
    display: block;
    width: 1.5rem;
    min-width: 1.5rem;
    background: white;
    border-right: 1px solid #000;
}

.strukt-loop-body-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.strukt-loop-body-content > .strukt-row,
.strukt-loop-body-content > .strukt-loop {
    border-bottom: 1px solid #000;
}

.strukt-loop-body-content > *:last-child {
    border-bottom: none;
}

.strukt-input {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.5rem;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    border: none;
    border-radius: 0;
    background-color: #fefce8;
    box-sizing: border-box;
}

.strukt-input:focus {
    outline: none;
    background-color: #fef9c3;
}

.strukt-header {
    background: #1e40af;
    color: white;
    font-weight: 600;
    padding: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Simple struktogramm - just stacked boxes */
.struktogramm.simple {
    width: 100%;
    max-width: 100%;
}

.struktogramm.simple .strukt-row {
    min-height: 2rem;
}

.strukt-row.prefilled {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
    background: white;
}

/* Manual/reference section - compact styling */
.manual-section {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--color-text-muted);
    margin: 0.5rem 0;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    white-space: pre;
    overflow-x: auto;
}

.manual-section p {
    margin: 0.25rem 0 0 0;
}

/* Prose section - styled text that should wrap (e.g., English manual text) */
.prose-section {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text-muted);
    margin: 0.5rem 0;
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-radius: var(--radius-sm);
    white-space: normal;
}

.prose-section em {
    font-style: italic;
}

/* Compact reference table */
.compact-table {
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin: 0.25rem 0;
}

.compact-table th,
.compact-table td {
    padding: 0.125rem 0.75rem 0.125rem 0;
    text-align: left;
    border: none;
}

.compact-table th {
    font-weight: 600;
    color: var(--color-text);
}

.compact-table td:first-child {
    font-family: var(--font-mono);
}

/* Code correction table */
.code-correction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: fixed;
}

.code-correction-table th,
.code-correction-table td {
    border: 1px solid var(--color-border);
    padding: 0.375rem 0.5rem;
    text-align: left;
    vertical-align: middle;
}

.code-correction-table th {
    background-color: var(--color-bg);
    font-weight: 600;
}

.code-correction-table th:first-child,
.code-correction-table th:last-child {
    width: calc(50% - 1rem);
}

.code-correction-table td:first-child,
.code-correction-table td:last-child {
    width: calc(50% - 1rem);
}

.code-correction-table td:first-child {
    background-color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.code-correction-table td:first-child code {
    display: block;
}

.code-correction-table td:last-child {
    padding: 0.25rem;
}

.code-correction-table textarea {
    width: 100%;
    min-height: 1.5rem;
    padding: 0.25rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    resize: none;
    overflow: hidden;
    line-height: 1.4;
}

.code-correction-table textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    background: white;
}

.code-correction-table textarea.has-content {
    background: #fefce8;
}

.code-correction-table .copy-cell {
    width: 2rem;
    padding: 0.25rem;
    text-align: center;
    background-color: var(--color-bg);
    border-left: none;
    border-right: none;
}

.code-correction-table th:nth-child(2) {
    width: 2rem;
    border-left: none;
    border-right: none;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s;
}

.copy-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* Answer Inputs */
.answer-input {
    margin-top: 1rem;
}

.answer-input textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    resize: vertical;
    font-family: var(--font-sans);
}

.answer-input textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.code-input {
    font-family: var(--font-mono) !important;
    font-size: 0.875rem;
    background-color: #1e293b;
    color: #e2e8f0;
    border: none;
}

.choice-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.choice-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition);
}

.choice-label:hover {
    background-color: rgba(37, 99, 235, 0.05);
}

.choice-label input {
    accent-color: var(--color-primary);
}

.fill-blank-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fill-blank-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.fill-blank-item {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
}

.fill-blank-label {
    font-weight: 600;
    min-width: 1.5rem;
    padding-top: 0.5rem;
}

/* Long labels - vertical layout */
.fill-blank-item.fill-blank-long {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
}

.fill-blank-item.fill-blank-long .fill-blank-label {
    padding-top: 0;
}

.fill-blank-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: inherit;
    resize: vertical;
}

.fill-blank-item:not(.fill-blank-long) .fill-blank-input {
    max-width: 300px;
}

.calculation-input {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.calculation-input label {
    font-weight: 500;
}

.calculation-input input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
}

.calculation-input .result-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.calculation-input .result-row label {
    margin: 0;
}

.calculation-input .result-row input {
    flex: 1;
    max-width: 200px;
}

.result-unit {
    font-weight: 500;
    color: var(--color-text-muted);
}

.table-input table {
    width: 100%;
    border-collapse: collapse;
}

.table-input th,
.table-input td {
    border: 1px solid var(--color-border);
    padding: 0.5rem;
}

.table-input th {
    background-color: var(--color-bg);
    font-weight: 500;
    text-align: left;
}

.table-input td input {
    width: 100%;
    border: none;
    padding: 0.25rem;
    font-size: 0.875rem;
}

.table-input td input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.diagram-input {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.diagram-note {
    font-style: italic;
    color: var(--color-text-muted);
    margin: 0;
}

.diagram-placeholder {
    background-color: var(--color-warning);
    color: #78350f;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin: 0;
}

.diagram-input textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    resize: vertical;
}

/* Network Topology Diagram */
.network-prefix {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: #f1f5f9;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

/* Database schema table */
/* Entity-Relationship Diagram (Chen Notation) - SVG Based */
.erm-editor {
    background: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin: 1rem 0;
    position: relative;
    overflow: auto;
    max-height: 600px;
}

.erm-editor svg {
    display: block;
    font-family: var(--font-sans);
}

.erm-editor .erm-attr-ellipse {
    cursor: pointer;
}

.erm-editor .erm-attr-ellipse:hover {
    fill: #f0f9ff;
}

.erm-editor .erm-editable {
    cursor: pointer;
}

.erm-editor .erm-editable:hover {
    fill: #3b82f6;
}

.erm-editor .erm-cardinality.erm-editable:hover {
    fill: #3b82f6;
}

.erm-editor .erm-add-entity-btn rect:hover {
    fill: #bae6fd;
}

/* Context menu for attributes */
.erm-context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 0.25rem 0;
    z-index: 1000;
    min-width: 180px;
}

.erm-context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.erm-context-menu-item:hover {
    background: #f1f5f9;
}

.erm-context-menu-item.danger {
    color: var(--color-error);
}

.db-schema {
    width: auto;
    display: inline-table;
    border: 2px solid #3b82f6;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.db-schema th {
    background: #3b82f6;
    color: white;
    font-weight: 600;
    padding: 0.4rem 1rem;
}

.db-schema td {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.3rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.db-schema tr:last-child td {
    border-bottom: none;
}

/* CLI Command Input */
.cli-input {
    background: #1e293b;
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin: 0.75rem 0;
}

.cli-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.cli-prompt {
    color: #22c55e;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
}

.cli-command {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid #475569;
    color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

.cli-command:focus {
    outline: none;
    border-bottom-color: #22c55e;
}

.cli-command::placeholder {
    color: #64748b;
    font-style: italic;
}

.network-topology {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 1rem;
    background: linear-gradient(to bottom, #f0f9ff 0%, #f8fafc 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin: 1rem 0;
}

.network-device {
    background: var(--color-surface);
    border: 2px solid #94a3b8;
    border-radius: var(--radius-md);
    padding: 0.75rem;
    min-width: 180px;
    text-align: center;
    position: relative;
}

.network-device.router {
    border-color: #2563eb;
    background: linear-gradient(to bottom, #eff6ff, #dbeafe);
}

.network-device.switch {
    border-color: #7c3aed;
    background: linear-gradient(to bottom, #f5f3ff, #ede9fe);
}

.network-device.endpoint {
    border-color: #059669;
    background: linear-gradient(to bottom, #ecfdf5, #d1fae5);
}

.device-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.device-name {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.device-info {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--color-text-muted);
}

.device-info .label {
    color: var(--color-text);
    font-family: var(--font-sans);
}

.device-info .value {
    color: #1e40af;
}

.device-info .field {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0.25rem 0;
    justify-content: center;
}

.device-info input {
    width: 100%;
    max-width: 200px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fefce8;
}

.device-info input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Connection lines */
.network-connection {
    width: 2px;
    height: 24px;
    background: #94a3b8;
    position: relative;
}

.network-connection.vertical {
    width: 2px;
    height: 24px;
}

/* Horizontal bus for multiple endpoints */
.network-bus {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
    padding-top: 24px;
    width: 100%;
}

.network-bus::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 24px;
    background: #94a3b8;
}

.network-endpoints {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: nowrap;
    padding-top: 24px;
    position: relative;
}

/* Horizontal bus line spanning all endpoints */
.network-endpoints::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #94a3b8;
}

.network-endpoints .network-device {
    position: relative;
    min-width: 160px;
    flex: 1;
    max-width: 220px;
}

.network-device .value {
    font-size: 0.7rem;
    word-break: break-all;
}

.network-endpoints .network-device::before {
    content: '';
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 24px;
    background: #94a3b8;
}

/* Modern chip-based matching input */
.matching-input {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.matching-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
}

.matching-item:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.matching-item.matched {
    border-color: var(--color-primary);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.03) 0%, rgba(79, 70, 229, 0.08) 100%);
}

.matching-item-label {
    font-weight: 500;
    font-size: 1rem;
    color: var(--color-text);
    flex: 1;
}

.matching-chips {
    display: flex;
    gap: 0.5rem;
}

.matching-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.matching-chip:hover:not(.disabled):not(.selected) {
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: scale(1.08);
}

.matching-chip:active:not(.disabled) {
    transform: scale(0.95);
}

.matching-chip.selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

.matching-chip.used {
    opacity: 0.35;
    cursor: not-allowed;
    background: var(--color-border);
    border-color: transparent;
}

.matching-chip.used:hover {
    transform: none;
}

.matching-chip:disabled {
    cursor: default;
    opacity: 0.7;
}

.matching-chip:disabled:hover {
    transform: none;
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.matching-chip:disabled.selected {
    opacity: 1;
}

/* Progress indicator */
.matching-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.matching-progress-dots {
    display: flex;
    gap: 0.375rem;
}

.matching-progress-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background: var(--color-border);
    transition: all 0.2s ease;
}

.matching-progress-dot.filled {
    background: var(--color-primary);
    box-shadow: 0 0 6px rgba(79, 70, 229, 0.5);
}

/* Embedded SVG inputs */
.svg-input {
    width: 100%;
    padding: 4px 8px;
    font-size: 12px;
    text-align: center;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    transition: border-color 0.2s ease;
}

.svg-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.svg-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

/* Footer */
footer {
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 640px) {
    nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .aufgabe-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .matching-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .matching-chips {
        justify-content: center;
    }

    .matching-chip {
        width: 3rem;
        height: 3rem;
        font-size: 1.2rem;
    }
}

/* Solutions display */
.solution-display {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: #fef2f2;
    border-left: 3px solid #dc2626;
    border-radius: var(--radius-sm);
    line-height: 1.4;           /* Increased for better readability with multi-line */
    white-space: pre-line;      /* Make \n render as line breaks in HTML */
}

.solution-display ul,
.solution-display ol {
    margin: 0.2rem 0 !important;
    padding-left: 1.5rem !important;
    margin-left: 1rem !important;
    list-style-position: inside !important;
}

.solution-display li {
    margin: 0;
    padding: 0;
}

.solution-display strong {
    display: block;
    margin-top: 0.4rem;
}

.solution-display strong:first-child {
    margin-top: 0;
}

.solution-display::before {
    content: 'Lösung:';
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.solution-inline {
    color: #dc2626;
    font-size: 0.875rem;
    margin-left: 0.75rem;
    font-weight: 500;
}

.solution-inline::before {
    content: '(';
}

.solution-inline::after {
    content: ')';
}

/* Grading notes in solutions */
.grading-notes {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #dc2626;
    font-size: 0.8rem;
    color: #991b1b;
}

/* Show solutions button */
.btn-solutions {
    background-color: #f59e0b;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition);
}

.btn-solutions:hover {
    background-color: #d97706;
}

.btn-solutions:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.btn-solutions.active {
    background-color: #dc2626;
}

.exam-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Table checkbox/radio validation */
.checkbox-cell.correct {
    background-color: rgba(34, 197, 94, 0.2);
}

.checkbox-cell.correct input[type="checkbox"],
.checkbox-cell.correct input[type="radio"] {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

.checkbox-cell.incorrect {
    background-color: rgba(239, 68, 68, 0.2);
}

.checkbox-cell.incorrect input[type="checkbox"],
.checkbox-cell.incorrect input[type="radio"] {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* Inline field solutions */
.inline-solution {
    color: #dc2626;
    font-size: 0.8125rem;
    margin-top: 0.5rem;
    padding: 0.375rem 0.5rem;
    background-color: #fef2f2;
    border-left: 2px solid #dc2626;
    border-radius: var(--radius-sm);
}

/* Table solutions displayed below tables with text inputs */
.table-solution {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    line-height: 1.6;
}

/* Vorteile/Nachteile table styling */
.vorteile-nachteile-table {
    table-layout: fixed;
}

.vorteile-nachteile-table .label-cell {
    width: 120px;
    vertical-align: top;
    padding: 0.5rem;
}

/* Ergebnis table styling (calculation results) */
.ergebnis-table {
    table-layout: fixed;
}

.ergebnis-table .label-cell {
    width: 180px;
    vertical-align: top;
    padding: 0.5rem;
}

/* Schutzbedarf table styling */
.schutzbedarf-table {
    table-layout: fixed;
    width: 100%;
}

.schutzbedarf-table th:first-child,
.schutzbedarf-table td:first-child {
    width: 20%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.schutzbedarf-table .narrow-col {
    width: 10%;
    white-space: nowrap;
    text-align: center;
    font-size: 0.75rem;
}

.schutzbedarf-table .input-cell .table-text-input {
    min-height: 3rem;
    resize: vertical;
}

.schutzbedarf-table td {
    vertical-align: top;
}

/* JavaScript will handle setting textarea height to match cell height */

/* Full-width textarea in table cells */
.table-text-input.full-width {
    width: 100%;
    box-sizing: border-box;
    min-height: 3rem;
}

/* Authentication methods table (Fingerabdrucksensor/Passwort/Chipkarte) */
.auth-methods-table {
    table-layout: fixed;
    width: 100%;
}

.auth-methods-table th,
.auth-methods-table td {
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* First column: fit "Sicherheits-" */
.auth-methods-table colgroup .col1,
.auth-methods-table th:first-child,
.auth-methods-table td:first-child {
    width: 6em;
}

/* Second column: fit "Fingerabdrucksensor" */
.auth-methods-table colgroup .col2,
.auth-methods-table th:nth-child(2),
.auth-methods-table td:nth-child(2) {
    width: 10em;
}

/* Third and fourth columns: equal share of remaining space (auto) */

/* UML Use Case Diagram Editor - SVG Based */
.usecase-editor {
    background: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
}

.usecase-editor svg {
    display: block;
    font-family: var(--font-sans);
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

.usecase-editor .uml-actor,
.usecase-editor .uml-usecase {
    cursor: pointer;
}

.usecase-editor .uml-actor:hover circle,
.usecase-editor .uml-usecase:hover ellipse {
    fill: #f0f9ff;
}

.usecase-editor .association-line:hover,
.usecase-editor .include-relationship:hover line {
    stroke-width: 3;
}

.usecase-editor .add-actor-btn:hover ellipse,
.usecase-editor .add-usecase-btn:hover ellipse {
    fill: #bfdbfe;
}

/* Context menu for use case editor */
.usecase-context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 0.25rem 0;
    z-index: 1000;
    min-width: 160px;
}

.usecase-context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.usecase-context-menu-item:hover {
    background: #f1f5f9;
}

.usecase-context-menu-item.danger {
    color: var(--color-error);
}

.usecase-context-menu-item.disabled {
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.usecase-context-menu-item.disabled:hover {
    background: transparent;
}

/* Use case diagram instructions */
.usecase-instructions {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f0f9ff;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
}

.usecase-instructions ul {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
}

.usecase-instructions li {
    margin-bottom: 0.125rem;
}

.usecase-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.usecase-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.usecase-legend-item .given-indicator {
    width: 12px;
    height: 12px;
    border: 2px solid #16a34a;
    border-radius: 50%;
}

.usecase-legend-item .added-indicator {
    width: 12px;
    height: 12px;
    border: 2px solid #1e3a5f;
    border-radius: 50%;
}

.usecase-instructions {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.usecase-instructions strong {
    color: #0369a1;
}

.usecase-instructions ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.25rem;
}

.usecase-instructions li {
    margin: 0.25rem 0;
    color: var(--color-text-muted);
}

/* Read-only usecase solution diagram */
.usecase-solution-readonly {
    pointer-events: none;
    opacity: 0.95;
}

.usecase-solution-readonly .uml-actor,
.usecase-solution-readonly .uml-usecase {
    cursor: default !important;
}

.usecase-solution-diagram {
    margin-top: 1rem;
}

/* Editable solution diagram (admin mode) */
.usecase-solution-editable {
    border: 2px dashed #dc2626;
}

.edit-mode .usecase-solution-diagram {
    background-color: #fef9c3 !important;
    border-color: #facc15 !important;
}

/* Gantt Diagram Editor */
.gantt-editor {
    background: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.gantt-editor svg {
    display: block;
    font-family: var(--font-sans);
}

.gantt-editor .gantt-bar-draggable {
    cursor: move;
}

.gantt-editor .gantt-bar-draggable:hover {
    filter: brightness(1.1);
}

.gantt-editor .gantt-placeholder {
    cursor: grab;
}

.gantt-editor .gantt-placeholder:active {
    cursor: grabbing;
}

/* UML Class Diagram Editor */
.class-diagram-editor {
    background: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.class-diagram-editor svg {
    display: block;
    font-family: var(--font-sans);
}

.class-diagram-editor input,
.class-diagram-editor select {
    font-family: var(--font-sans);
    border-radius: 2px;
}

.class-diagram-editor .uml-class rect {
    transition: fill 0.2s;
}

.class-diagram-editor .uml-class:hover rect:first-of-type {
    fill: #f8fafc;
}

/* =============================================================================
   EXERCISES (Uebungen)
   ============================================================================= */

.exercises-section {
    max-width: 1000px;
}

.exercises-intro {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

/* Exercise stats summary */
.exercise-stats-summary {
    display: flex;
    gap: 2rem;
    padding: 1.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Topic grid */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.topic-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition);
    border-left: 4px solid transparent;
}

.topic-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Mastery level colors */
.topic-card.mastery-novice {
    border-left-color: var(--color-border);
}

.topic-card.mastery-learning {
    border-left-color: var(--color-warning);
}

.topic-card.mastery-proficient {
    border-left-color: var(--color-primary);
}

.topic-card.mastery-mastered {
    border-left-color: var(--color-success);
}

.topic-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.topic-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.mastery-badge {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mastery-badge.mastered {
    background: var(--color-success);
    color: white;
}

.topic-description {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    min-height: 2.5rem;
}

.topic-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.topic-counts {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.subtask-count {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.practiced-count {
    font-size: 0.75rem;
    color: var(--color-primary);
    font-weight: 500;
}

.topic-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-bar {
    width: 60px;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    transition: width 0.3s ease;
}

.progress-bar.progress-good .progress-fill {
    background: #22c55e;
}

.progress-bar.progress-ok .progress-fill {
    background: #f59e0b;
}

.progress-bar.progress-poor .progress-fill {
    background: #ef4444;
}

.progress-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

/* Exercise practice section */
.exercise-practice-section {
    max-width: 800px;
}

.exercise-content h2 {
    margin-bottom: 0.25rem;
}

.exercise-info {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.exercise-subtasks {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.exercise-subtask {
    display: flex;
    gap: 1rem;
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.subtask-number {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    min-width: 2rem;
}

.exercise-subtask .subtask-content {
    flex: 1;
}

.exercise-actions {
    margin-top: 2rem;
    text-align: center;
}

/* Exercise results */
.exercise-results {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.exercise-results h3 {
    margin-bottom: 1.5rem;
}

.result-summary {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.result-score {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.score-earned {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.score-divider {
    font-size: 1.5rem;
    color: var(--color-text-muted);
}

.score-max {
    font-size: 1.5rem;
    color: var(--color-text-muted);
}

.score-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-left: 0.5rem;
}

.result-percentage {
    font-size: 2rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
}

.result-excellent {
    background: #dcfce7;
    color: #166534;
}

.result-good {
    background: #dbeafe;
    color: #1e40af;
}

.result-okay {
    background: #fef3c7;
    color: #92400e;
}

.result-poor {
    background: #fee2e2;
    color: #991b1b;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.no-subtasks {
    text-align: center;
    padding: 3rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
}

.no-subtasks p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

/* One-by-one exercise flow */
.exercise-header {
    margin-bottom: 2rem;
}

.exercise-header h2 {
    margin-bottom: 1rem;
}

.exercise-progress {
    background: var(--color-surface);
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.exercise-progress .progress-text {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.exercise-progress .progress-bar {
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.exercise-progress .progress-fill {
    height: 100%;
    background: var(--color-primary);
    transition: width 0.3s ease;
}

.current-exercise {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.current-exercise .subtask-container {
    margin-bottom: 1.5rem;
}

.current-exercise .subtask-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.current-exercise .subtask-label {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-primary);
}

.current-exercise .subtask-points {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

.subtask-id-badge {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: monospace;
}

.subtask-id-input {
    width: 5rem;
    font-size: 0.75rem;
    font-family: monospace;
    padding: 0.1rem 0.3rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.current-exercise .subtask-text {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.current-exercise .answer-input {
    margin-top: 1.5rem;
}

.current-exercise .choice-label.disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Exercise feedback after answering */
.exercise-feedback {
    border-top: 1px solid var(--color-border);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

.feedback-result {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.feedback-result.correct {
    background: #dcfce7;
    color: #166534;
}

.feedback-result.incorrect {
    background: #fee2e2;
    color: #991b1b;
}

.feedback-result.review {
    background: #fef3c7;
    color: #92400e;
}

.exercise-solution {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.exercise-solution strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text-secondary);
}

.exercise-solution ul,
.exercise-solution ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.exercise-solution li {
    margin-bottom: 0.25rem;
}

.exercise-solution .solution-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.exercise-solution .solution-table td {
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    vertical-align: top;
}

.exercise-solution pre {
    background: var(--color-bg);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.85rem;
}

.feedback-icon {
    font-size: 1.5rem;
    font-weight: 700;
    width: 2rem;
    text-align: center;
}

.feedback-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.feedback-text span:first-child {
    font-weight: 600;
}

.feedback-score {
    font-size: 0.875rem;
    opacity: 0.9;
}

.llm-feedback {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: left;
}

.feedback-result.correct .llm-feedback {
    background: rgba(255, 255, 255, 0.2);
}

.feedback-result.incorrect .llm-feedback {
    background: rgba(255, 255, 255, 0.2);
}

.exercise-actions.post-answer {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Exercise summary */
.exercise-summary {
    max-width: 600px;
    margin: 0 auto;
}

.exercise-summary h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.summary-stats {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    margin-bottom: 2rem;
}

.summary-score {
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.summary-score .score-big {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
}

.summary-score .score-value {
    font-size: 3rem;
    font-weight: 700;
}

.summary-score .score-divider {
    font-size: 2rem;
    opacity: 0.6;
}

.summary-score .score-max {
    font-size: 2rem;
    opacity: 0.6;
}

.summary-score .score-percentage {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.summary-score .score-label {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

.summary-details {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.detail-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.detail-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.summary-results {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.summary-results h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.result-item.correct {
    background: #dcfce7;
}

.result-item.incorrect {
    background: #fee2e2;
}

.result-item.review {
    background: #fef3c7;
}

.result-item.skipped {
    background: #f1f5f9;
    opacity: 0.7;
}

.result-status {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.result-number {
    font-weight: 600;
    min-width: 1.5rem;
}

.result-label {
    flex: 1;
}

.result-score {
    font-size: 0.875rem;
    font-weight: 600;
}

.summary-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .exercise-stats-summary {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .stat-item {
        flex: 1 1 40%;
    }

    .topic-grid {
        grid-template-columns: 1fr;
    }

    .exercise-subtask {
        flex-direction: column;
    }

    .result-summary {
        flex-direction: column;
        gap: 1rem;
    }
}

/* =============================================================================
   DEPRECATED CONTENT STYLING
   Topics removed from AP1 as of 2025 (e.g., SQL, RAID, Struktogramm)
   ============================================================================= */

.subtask-deprecated {
    position: relative;
    opacity: 0.7;
    border-left: 4px solid var(--color-warning);
}

.subtask-deprecated::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 10px,
        rgba(245, 158, 11, 0.03) 10px,
        rgba(245, 158, 11, 0.03) 20px
    );
    pointer-events: none;
    z-index: 0;
}

.deprecated-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--color-warning);
    color: #78350f;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.deprecated-badge::before {
    content: '\26A0'; /* Warning triangle */
}

.deprecated-notice {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.deprecated-notice strong {
    display: block;
    margin-bottom: 0.25rem;
}

/* Deprecated in exam navigation */
.nav-subtask-link.deprecated {
    opacity: 0.6;
    text-decoration: line-through;
}

/* Deprecated in topic list */
.topic-card.has-deprecated {
    border-color: var(--color-warning);
}

.topic-deprecated-count {
    font-size: 0.75rem;
    color: var(--color-warning);
    margin-left: 0.5rem;
}

/* =============================================================================
   SOLUTION FEEDBACK
   ============================================================================= */

.solution-wrapper {
    position: relative;
}

.solution-feedback {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    color: #6b7280;
    transition: all var(--transition);
}

.feedback-btn:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.feedback-btn.feedback-up:hover,
.feedback-btn.feedback-up.active {
    color: #16a34a;
    border-color: #16a34a;
    background: #f0fdf4;
}

.feedback-btn.feedback-down:hover,
.feedback-btn.feedback-down.active {
    color: #dc2626;
    border-color: #dc2626;
    background: #fef2f2;
}

.feedback-btn.active {
    font-weight: 600;
}

.feedback-btn svg {
    width: 16px;
    height: 16px;
}

/* Feedback comment form */
.feedback-form {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
}

.feedback-textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    box-sizing: border-box;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.feedback-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Inline table solution feedback */
.table-solution.inline-solution {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: #fef2f2;
    border-left: 3px solid #dc2626;
    border-radius: var(--radius-sm);
}

.table-solution .solution-content {
    white-space: pre-line;
}

.table-solution .solution-content::before {
    content: 'Lösung:';
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.table-solution .solution-feedback {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.table-solution .feedback-form-container {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: white;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
}

/* =============================================================================
   EXERCISE CONTENT TAGS (Original/Modifiziert)
   ============================================================================= */

.exercise-tags {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.exercise-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.exercise-tag.topic-tag {
    background: #dbeafe;
    color: #1e40af;
}

.exercise-tag.tag-original {
    background: #fef3c7;
    color: #92400e;
}

.exercise-tag.tag-modified {
    background: #dcfce7;
    color: #166534;
}

/* Exercise header with tags replaces plain label */
.exercise-header-tags {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Ranking order component */
.ranking-order {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.ranking-order strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.ranking-items {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: grab;
    user-select: none;
    transition: all 0.15s ease;
}

.ranking-item:hover {
    border-color: var(--color-primary);
    background: #f0f9ff;
}

.ranking-item.dragging {
    opacity: 0.5;
    border-color: var(--color-primary);
    background: #dbeafe;
}

.ranking-item:active {
    cursor: grabbing;
}

.ranking-handle {
    color: #94a3b8;
    font-size: 0.875rem;
}

/* =============================================================================
   EXAM DOCUMENT (Invoice, Letter, etc.) displayed in aufgabe context
   ============================================================================= */

.exam-document {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: white;
    margin: 1rem 0;
    overflow: hidden;
}

.exam-document-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.exam-document-toolbar .doc-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.exam-document-toolbar .btn-open-window {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-primary);
    background: white;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.exam-document-toolbar .btn-open-window:hover {
    background: var(--color-primary);
    color: white;
}

/* Invoice (Rechnung) styling */
.rechnung {
    padding: 2rem;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 700px;
    margin: 0 auto;
}

.rechnung-header {
    margin-bottom: 1.5rem;
}

.rechnung-sender {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-text-muted);
    padding-bottom: 0.25rem;
    margin-bottom: 1rem;
}

.rechnung-recipient {
    font-weight: 500;
    line-height: 1.6;
}

.rechnung-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.5rem 0;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.rechnung-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 1.5rem 0 1rem;
}

.rechnung-items {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.85rem;
    table-layout: fixed;
}

.rechnung-items th {
    background: #f8fafc;
    font-weight: 600;
    text-align: left;
    padding: 0.5rem;
    border-bottom: 2px solid var(--color-border);
}

.rechnung-items td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.rechnung-items th:first-child,
.rechnung-items td:first-child {
    width: 3rem;
    text-align: center;
}

.rechnung-items th:nth-child(4),
.rechnung-items td:nth-child(4),
.rechnung-items th:nth-child(5),
.rechnung-items td:nth-child(5) {
    text-align: right;
}

.rechnung-items th:last-child,
.rechnung-items td:last-child {
    width: 3rem;
    text-align: center;
}

.rechnung-ust-legend {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0.25rem 0 1rem;
}

.rechnung-totals {
    width: 50%;
    margin-left: auto;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.rechnung-totals td {
    padding: 0.25rem 0.5rem;
}

.rechnung-totals td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.rechnung-totals .total-row {
    font-weight: 700;
    border-top: 2px solid var(--color-text);
}

.rechnung-totals .total-row td {
    padding-top: 0.5rem;
}

.rechnung-payment {
    margin: 1.5rem 0;
    padding: 0.75rem 1rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.6;
}

.rechnung-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.rechnung-qr {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    overflow: hidden;
}

.rechnung-qr svg {
    display: block;
    width: 80px;
    height: 80px;
}

.rechnung-bank {
    line-height: 1.6;
}

/* ========== Activity Diagram Editor ========== */

.activity-editor {
    background: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
}

.activity-svg-wrapper {
    overflow: auto;
    max-height: 75vh;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: white;
}

/* Shared diagram zoom toolbar styles */
.diagram-zoom-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: rgba(248, 250, 252, 0.95);
    border-bottom: 1px solid var(--color-border);
}

.diagram-zoom-toolbar button {
    width: 28px;
    height: 28px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diagram-zoom-toolbar button:hover {
    background: #f1f5f9;
}

.diagram-zoom-label {
    font-size: 0.75rem;
    line-height: 28px;
    min-width: 40px;
    text-align: center;
    color: var(--color-text-muted);
}

.activity-editor svg {
    display: block;
    font-family: var(--font-sans);
}

.activity-editor .uml-activity:hover .activity-clickable {
    fill: #f0f9ff;
}

.activity-editor .uml-decision:hover .decision-clickable {
    fill: #f0f9ff;
}

.activity-editor .transition-line:hover {
    stroke-width: 3;
}

.activity-editor .guard-label:hover rect {
    stroke: #3b82f6;
}

.activity-context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 0.25rem 0;
    z-index: 1000;
    min-width: 160px;
}

.activity-context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.activity-context-menu-item:hover {
    background: #f1f5f9;
}

.activity-instructions {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f0f9ff;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
}

.activity-instructions ul {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
}

.activity-instructions li {
    margin-bottom: 0.125rem;
}

/* Activity Legend (collapsible symbol reference) */
.activity-legend {
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: white;
}

.activity-legend summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    user-select: none;
}

.activity-legend .legend-sections {
    padding: 0 0.75rem 0.75rem;
}

.activity-legend .legend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.activity-legend .legend-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.activity-legend .legend-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    min-width: 100px;
}

.activity-legend .legend-card-wide {
    min-width: 220px;
}

.activity-legend .legend-card svg {
    display: block;
}

.activity-legend .legend-card-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text);
    text-align: center;
}

.activity-legend .legend-card-note {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    text-align: center;
    font-style: italic;
}

/* Dangling transition (semi-transparent) */
.activity-dangling {
    opacity: 0.4;
}

.activity-dangling:hover {
    opacity: 0.7;
}

/* Connecting mode: highlight potential targets */
.activity-connecting-target polygon,
.activity-connecting-target rect,
.activity-connecting-target circle {
    filter: drop-shadow(0 0 4px #3b82f6);
}

/* Swimlane styles */
.activity-editor [data-type="swimlane-separator"] { cursor: col-resize; }
.activity-editor [data-type="swimlane-header"] { cursor: move; }
.activity-editor [data-type="swimlane-label"] { cursor: move; }

/* =============================================================================
   ADMIN MODE - Table Column Resizer
   ============================================================================= */

/* Admin mode toggle button */
.admin-toggle {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

.admin-toggle.active {
    background-color: var(--color-warning);
    color: white;
}

/* Edit mode body class */
body.edit-mode {
    /* Subtle indicator that edit mode is active */
}

body.edit-mode::before {
    content: 'EDIT MODE';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-warning);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.125rem 1rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 9999;
}

/* Column resize handle */
.col-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

.col-resize-handle:hover,
.col-resize-handle:active {
    background: var(--color-primary);
    opacity: 0.5;
}

/* Row resize handle */
.row-resize-handle {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -4px;
    height: 8px;
    cursor: row-resize;
    background: transparent;
    z-index: 10;
    user-select: none;
    -webkit-user-select: none;
}

.row-resize-handle:hover,
.row-resize-handle:active {
    background: var(--color-primary);
    opacity: 0.5;
}

/* Body class during resize */
body.resizing {
    cursor: col-resize !important;
    user-select: none;
}

body.resizing * {
    cursor: col-resize !important;
}

/* Save button container */
.table-save-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.table-save-btn {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
}

.table-save-btn .save-icon {
    margin-right: 0.25rem;
}

/* Notification */
.layout-notification {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.layout-notification.success {
    background-color: var(--color-success);
    color: white;
}

.layout-notification.error {
    background-color: var(--color-error);
    color: white;
}

.layout-notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Edit mode table styling */
body.edit-mode .exam-table {
    border: 2px dashed var(--color-warning);
}

body.edit-mode .exam-table thead th,
body.edit-mode .exam-table thead td {
    background-color: rgba(245, 158, 11, 0.1);
}

/* =============================================================================
   ADMIN MODE - Text Editor
   ============================================================================= */

/* Edit button on text areas */
.text-edit-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 28px;
    height: 28px;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition), background var(--transition);
    z-index: 10;
}

.text-edit-btn:hover {
    opacity: 1;
    background: var(--color-bg);
}

.text-edit-btn svg {
    width: 14px;
    height: 14px;
}

/* Show edit button in edit mode on hover */
body.edit-mode .subtask-text:hover .text-edit-btn,
body.edit-mode .solution-display:hover .text-edit-btn {
    display: flex;
}

/* Text editor wrapper */
.text-editor-wrapper {
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    overflow: hidden;
}

/* Editor toolbar */
.text-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.toolbar-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
}

.toolbar-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.toolbar-btn:hover {
    background: var(--color-bg);
}

.toolbar-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.toolbar-btn.active:hover {
    background: var(--color-primary-dark, #1a5fb4);
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
}

.valign-group {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* Editor resize handles for tables */
.editor-col-resize-handle:hover {
    background: var(--color-primary);
    opacity: 0.5;
}

.editor-row-resize-handle:hover {
    background: var(--color-primary);
    opacity: 0.5;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 0.25rem;
}

/* Editable content area */
.text-editor-content {
    min-height: 100px;
    padding: 1rem;
    outline: none;
    line-height: 1.6;
}

.text-editor-content:focus {
    background: rgba(37, 99, 235, 0.02);
}

/* Editor action buttons */
.text-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* Highlight editable areas in edit mode */
body.edit-mode .subtask-text,
body.edit-mode .solution-display {
    position: relative;
}

body.edit-mode .subtask-text:hover,
body.edit-mode .solution-display:hover {
    outline: 2px dashed rgba(245, 158, 11, 0.5);
    outline-offset: 2px;
}

/* Edit-only elements - hidden by default, shown in edit mode */
.edit-only {
    display: none !important;
}

body.edit-mode .edit-only {
    display: inline-flex !important;
}

/* Reorder buttons for aufgaben and subtasks */
.reorder-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1.2;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: all 0.15s;
}
.reorder-btn:hover {
    background: var(--color-hover);
    color: var(--color-text);
}
.reorder-aufgabe-btn {
    font-size: 0.9rem;
    padding: 2px 6px;
    font-weight: bold;
}
.reorder-subtask-btn {
    font-size: 0.7rem;
    padding: 1px 4px;
}
.reorder-aufgabe, .reorder-subtask {
    display: inline-flex;
    gap: 2px;
    margin-right: 6px;
}

/* Edit Solutions button in exam cards */
.edit-solutions-btn {
    margin-top: 0.75rem;
    width: 100%;
    justify-content: center;
}

/* Solutions Editor View */
.solutions-editor-view {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.solutions-header {
    margin-bottom: 2rem;
}

.solutions-header h1 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.solutions-intro {
    color: var(--color-text-muted);
    margin-bottom: 0;
}

.solution-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.solution-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.solution-item-title {
    font-weight: 600;
    font-size: 1rem;
}

.subtask-id-badge {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}

.solution-item-prompt {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

.solution-json-wrapper {
    margin-top: 1rem;
}

.solution-json-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.solution-json {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.8rem;
    max-height: 300px;
    overflow-y: auto;
}

.solution-empty {
    color: var(--color-text-muted);
    font-style: italic;
    padding: 1rem;
    text-align: center;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

/* Ensure usecase editor in solutions view has proper styling */
.solutions-editor-view .usecase-editor {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

.solutions-editor-view .usecase-editor svg {
    background: #fafafa;
}

/* ========================================
   Settings Overlay
   ======================================== */

.settings-btn {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
}

.settings-btn:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.settings-btn:hover svg {
    transform: rotate(45deg);
}

.settings-btn svg {
    transition: transform 0.3s ease;
}

.settings-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.settings-panel {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: settings-slide-in 0.2s ease-out;
}

@keyframes settings-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.settings-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.settings-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.settings-close:hover:not(:disabled) {
    color: var(--color-text);
    background: var(--color-bg);
}

.settings-close:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.settings-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.settings-section-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.settings-hint {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--color-border);
    padding: 0.4rem;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover:not(:disabled) {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon svg.spin {
    animation: spin 1s linear infinite;
}

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

/* Model list */
.model-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-list.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--color-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.model-option:hover {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.model-option.selected {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.model-option.active {
    background: rgba(34, 197, 94, 0.08);
}

.model-option.active.selected {
    border-color: var(--color-success);
}

.model-option input[type="radio"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    position: relative;
}

.model-option input[type="radio"]:checked {
    border-color: var(--color-primary);
    background: var(--color-primary);
}

.model-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.model-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.model-name {
    font-weight: 500;
    color: var(--color-text);
}

.model-size {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.model-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-success);
    background: rgba(34, 197, 94, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Cloud provider list */
.provider-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.provider-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.provider-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.provider-option:hover {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.provider-option.active {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.provider-option input[type="radio"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.provider-option input[type="radio"]:checked {
    border-color: var(--color-primary);
    background: var(--color-primary);
}

.provider-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: white;
}

.provider-name {
    font-weight: 500;
    color: var(--color-text);
    flex: 1;
}

.provider-expanded {
    padding-left: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.model-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.4rem 0;
    border-left: 2px solid var(--color-border);
    padding-left: 0.75rem;
    margin-bottom: 0.25rem;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background var(--transition);
}

.model-option:hover {
    background: var(--color-surface);
}

.model-option.active {
    background: rgba(37, 99, 235, 0.08);
    color: var(--color-primary);
    font-weight: 500;
}

.model-option input[type="radio"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.model-option input[type="radio"]:checked {
    border-color: var(--color-primary);
    background: var(--color-primary);
}

.model-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
}

.key-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.key-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: monospace;
}

.key-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Model loading state */
.model-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.model-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.model-loading p {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.model-loading-hint {
    font-size: 0.8rem !important;
    color: var(--color-text-muted);
    opacity: 0.8;
    max-width: 280px;
    line-height: 1.4;
}

.no-models {
    color: var(--color-text-muted);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

/* Settings Accordion */
.settings-accordion-item {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    transition: border-color var(--transition);
    overflow: hidden;
}

.settings-accordion-item.accordion-active {
    border-color: var(--color-primary);
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-text);
    text-align: left;
    transition: background var(--transition);
}

.accordion-header:hover {
    background: var(--color-surface);
}

.accordion-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all var(--transition);
}

.accordion-radio.checked {
    border-color: var(--color-primary);
    background: var(--color-primary);
}

.accordion-radio.checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.accordion-title {
    font-weight: 600;
    flex-shrink: 0;
}

.accordion-hint {
    flex: 1;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.accordion-chevron {
    flex-shrink: 0;
    color: var(--color-text-muted);
    transition: transform 0.2s ease;
}

.accordion-chevron.open {
    transform: rotate(180deg);
}

.accordion-body {
    padding: 0 1rem 1rem;
}

/* Local model list inside accordion (re-style for full-width cards) */
.local-model-list {
    border-left: none;
    padding-left: 0;
    gap: 0.5rem;
}

.local-model-list .model-option {
    padding: 0.875rem 1rem;
    background: var(--color-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-size: inherit;
}

.local-model-list .model-option:hover {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.local-model-list .model-option.selected {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.local-model-list .model-option.active {
    background: rgba(34, 197, 94, 0.08);
}

.local-model-list .model-option.active.selected {
    border-color: var(--color-success);
}

.local-model-list .model-option input[type="radio"] {
    width: 18px;
    height: 18px;
}

.local-model-list .model-option input[type="radio"]:checked::after {
    width: 6px;
    height: 6px;
}

/* Cloud subsections */
.cloud-subsection {
    margin-bottom: 1rem;
}

.cloud-subsection:last-child {
    margin-bottom: 0;
}

.cloud-subsection-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .settings-panel {
        max-height: 100vh;
        border-radius: 0;
    }

    .settings-overlay {
        padding: 0;
    }

    .model-option {
        padding: 0.75rem;
    }
}

/* ========================================
   LLM Feedback Section (Exercises)
   ======================================== */

.llm-feedback-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.llm-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: 0 0 0.75rem 0;
    line-height: 1.4;
}

.llm-disclaimer svg {
    flex-shrink: 0;
    margin-top: 0.1rem;
    opacity: 0.7;
}

.llm-feedback-actions {
    display: flex;
    gap: 0.5rem;
}

/* Reuse existing feedback-btn styles, ensure they work in this context */
.llm-feedback-section .feedback-btn {
    background: rgba(255, 255, 255, 0.8);
}

.llm-feedback-section .feedback-form {
    margin-top: 0.75rem;
}

/* ========================================
   Toast Notifications (macOS-style)
   ======================================== */

.notification-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 400px;
}

.notification {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: rgba(30, 41, 59, 0.95);
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    pointer-events: auto;
    animation: notification-slide-in 0.3s ease-out;
    font-size: 0.9rem;
}

.notification.fade-out {
    animation: notification-slide-out 0.3s ease-in forwards;
}

@keyframes notification-slide-in {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notification-slide-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.notification-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.notification.success .notification-icon {
    color: var(--color-success);
}

.notification.error .notification-icon {
    color: var(--color-error);
}

.notification.info .notification-icon {
    color: var(--color-primary);
}

.notification-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
    line-height: 1.3;
}

.notification-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Responsive */
@media (max-width: 480px) {
    .notification-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

    .notification {
        font-size: 0.85rem;
    }
}

/* =============================================================================
   ADMIN PAGE
   ============================================================================= */

.admin-link {
    color: var(--color-warning);
    font-weight: 500;
}

.admin-link:hover {
    color: #d97706;
}

.admin-section {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-section h2 {
    margin-bottom: 1.5rem;
}

.admin-shared-key-panel {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--color-primary);
}

.admin-shared-key-panel h3 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

/* List of existing shared keys */
.shared-keys-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 1rem;
}

.shared-key-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.85rem;
}

.shared-key-item .key-model {
    color: var(--color-text-secondary);
    font-size: 0.8em;
}

/* Add new key form */
.shared-key-add-form {
    border-top: 1px solid var(--color-border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.shared-key-form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.key-provider-select {
    padding: 6px 8px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 0.875rem;
    flex: 0 0 auto;
}

.shared-key-add-form .model-list {
    margin-bottom: 8px;
}

/* Provider badge (used in shared key items and user assignment) */
.provider-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    background: var(--color-primary);
    color: #fff;
    white-space: nowrap;
}

.provider-badge.sm {
    font-size: 0.7em;
    padding: 1px 5px;
}

.key-hint-display {
    font-family: monospace;
    color: #fbbf24;
    font-size: 0.85em;
}

.key-hint-display.sm {
    font-size: 0.8em;
}

/* User edit: shared key assignment checkboxes */
.shared-key-assignment {
    margin-top: 8px;
}

.assignment-label {
    font-size: 0.8em;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.shared-key-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    padding: 4px 0;
}

/* Settings: shared key picker */
.shared-key-picker {
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin: 4px 0 8px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.shared-key-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 0.875rem;
}

.shared-key-radio:hover {
    background: rgba(255,255,255,0.06);
}

.shared-key-radio.active {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
}

.shared-badge {
    font-size: 0.7em;
    color: var(--color-text-secondary);
    font-style: italic;
    margin-left: auto;
}

.btn-xs {
    padding: 1px 6px;
    font-size: 0.75rem;
    line-height: 1.4;
}

.admin-layout {
    display: block;
}

/* User List */
.admin-user-list {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.admin-user-list h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.admin-table th {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.admin-table tbody tr {
    transition: background 0.15s ease;
}

.admin-table tbody tr:hover {
    background: var(--color-bg);
}

.role-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.role-badge.admin {
    background: #fef3c7;
    color: #92400e;
}

.role-badge.student {
    background: #e0e7ff;
    color: #3730a3;
}

.role-badge.superadmin {
    background: #fce7f3;
    color: #9d174d;
}


.admin-info-note {
    color: #64748b;
    font-size: 0.875rem;
    font-style: italic;
}

.access-count {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Edit Modal */
.edit-modal {
    max-width: 600px;
    width: 95%;
    max-height: 85vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.edit-modal .edit-panel-content {
    overflow-y: auto;
    flex: 1;
}

.edit-modal-quick-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    gap: 0.75rem;
}

.quick-actions-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quick-actions-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
}

.edit-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.edit-modal-actions .btn {
    width: auto;
}

.edit-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.edit-panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.btn-close {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    font-size: 1.25rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.edit-panel-content {
    padding: 1.5rem;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.edit-section {
    margin-bottom: 1.5rem;
}

.edit-section h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.section-header h4 {
    margin-bottom: 0;
}

.section-actions {
    display: flex;
    gap: 0.5rem;
}

.section-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.checkbox-label:hover {
    background: var(--color-bg);
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.exam-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.exam-checkbox {
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
}

.exam-checkbox.is-public {
    background: #f0fdf4;
}

.exam-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    background: #dcfce7;
    color: #166534;
    border-radius: 9999px;
    margin-left: auto;
}

.edit-panel-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.edit-panel-footer .success {
    color: var(--color-success);
    font-size: 0.85rem;
    margin: 0;
}

.edit-panel-footer .error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin: 0;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.blocked {
    background: #fee2e2;
    color: #991b1b;
}

/* Blocked row styling */
.admin-table tbody tr.blocked {
    background: #fef2f2;
}

.admin-table tbody tr.blocked:hover {
    background: #fee2e2;
}

/* Online LED indicator */
.online-led {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 4px #22c55e;
    margin-right: 6px;
    vertical-align: middle;
}

.current-exam-label {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    margin-top: 2px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* Button variants for admin */
.btn-warning {
    background: #fbbf24;
    color: #78350f;
    border: none;
}

.btn-warning:hover:not(:disabled) {
    background: #f59e0b;
}

.btn-success {
    background: #10b981;
    color: white;
    border: none;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Confirmation Dialog */
.confirm-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.confirm-dialog {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.confirm-dialog h4 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.confirm-dialog p {
    margin: 0 0 0.75rem 0;
    color: var(--color-text-muted);
}

.confirm-dialog .confirm-warning {
    color: #dc2626;
    font-weight: 500;
    font-size: 0.9rem;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.confirm-actions .btn {
    min-width: 100px;
}

/* ==========================================================================
   PROGRESSIVE GRADING UI
   ========================================================================== */

/* Grading progress header - sticky at top during grading */
.grading-header {
    background: var(--bg-card, #fff);
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    position: sticky;
    top: 1rem;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.grading-header h3 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
}

.grading-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary, #f0f0f0);
    border-radius: 4px;
    overflow: hidden;
}

.grading-progress-fill {
    height: 100%;
    background: var(--primary-color, #4a90d9);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.grading-progress-text {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
}

/* Final score summary */
.grading-summary {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
    text-align: center;
}

.grading-summary-score {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary, #333);
}

.grading-summary-percent {
    font-size: 1.1rem;
    margin-left: 0.5rem;
    color: var(--text-secondary, #666);
}

.grading-unavailable-notice {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--warning-bg, #fff8e1);
    border: 1px solid var(--warning-border, #ffe082);
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-primary, #333);
}

.grading-unavailable-notice p {
    margin: 0 0 0.5rem 0;
}

.grading-unavailable-notice button {
    margin-top: 0.25rem;
}

/* Per-subtask grading result badge */
.grading-result {
    margin-top: 0.75rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.grading-in-progress {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-secondary, #666);
    border: 1px dashed var(--border-color, #ccc);
}

.grading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.grading-spinner::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color, #ccc);
    border-top-color: var(--primary-color, #4a90d9);
    border-radius: 50%;
    animation: grading-spin 0.8s linear infinite;
}

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

.grading-correct {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    color: #2e7d32;
}

.grading-partial {
    background: #fff8e1;
    border: 1px solid #ffc107;
    color: #f57f17;
}

.grading-wrong {
    background: #ffebee;
    border: 1px solid #f44336;
    color: #c62828;
}

.grading-result-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.grading-score {
    font-weight: 600;
}

.grading-feedback {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Grading debug panel (admin only) */
.grading-debug-panel {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.8rem;
}

.grading-debug-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-weight: 600;
}

.grading-debug-prompt {
    margin-top: 0.5rem;
}

.grading-debug-prompt pre {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0.25rem 0 0;
    padding: 0.5rem;
    background: #0f172a;
    border-radius: 4px;
    color: #cbd5e1;
    max-height: 300px;
    overflow-y: auto;
}

/* Per-subtask eval button */
.btn-eval-subtask {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    margin-right: 0.5rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    vertical-align: middle;
}

.btn-eval-subtask:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.btn-eval-subtask:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Disable inputs during grading (but not in review mode where editing is allowed) */
.grading-mode:not(.review-mode) .answer-input {
    pointer-events: none;
    opacity: 0.7;
}

/* =============================================================================
   Subtask context menu (export/import)
   ============================================================================= */

.subtask-context-menu {
    position: fixed;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    min-width: 220px;
    padding: 0.25rem 0;
}

.subtask-context-menu button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text);
}

.subtask-context-menu button:hover {
    background: var(--color-primary-light, #e8f0fe);
}

.context-menu-divider {
    border-top: 1px solid var(--color-border);
    margin: 0.25rem 0;
}

.subtask-context-menu button.ctx-danger {
    color: #d32f2f;
}

.subtask-context-menu button.ctx-danger:hover {
    background: #fde8e8;
}

/* =============================================================================
   Import dialog modal
   ============================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.modal-content h3 {
    margin: 0 0 1rem;
}

.import-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.import-dropzone.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light, #e8f0fe);
}

.import-dropzone p {
    margin: 0 0 0.75rem;
    color: var(--color-text-muted);
}

.import-mode-select {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.import-mode-select label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.import-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}
