* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f8;
    --bg-tertiary: #f9f9f9;
    --text-primary: #333;
    --text-secondary: #555;
    --text-muted: #666;
    --border-color: #ddd;
    --border-light: #eee;
    --input-bg: #fff;
    --input-border: #ccc;
    --card-bg: #fff;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
}

body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #252525;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #909090;
    --border-color: #404040;
    --border-light: #353535;
    --input-bg: #2d2d2d;
    --input-border: #505050;
    --card-bg: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Nawigacja */
.navbar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-brand .logo-text {
    text-decoration: none;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

.nav-brand .logo-text:hover {
    color: #6f42c1;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-primary);
    padding: 0.5rem;
    transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #6f42c1;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    color: #6f42c1;
    transform: scale(1.1);
}

.theme-toggle .theme-icon {
    display: block;
}

body.dark-mode .theme-toggle .sun-icon {
    display: none;
}

body.dark-mode .theme-toggle .moon-icon {
    display: block !important;
}

/* Sekcja hero */
.hero {
    padding: 4rem 0;
    background-color: var(--bg-tertiary);
    transition: background-color 0.3s ease;
}

.hero-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.hero-text {
    flex: 1;
}

.hero-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #007bff;
    color: white;
    border: none;
}

.btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.4);
}

.btn-secondary {
    background-color: var(--card-bg);
    color: #007bff;
    border: 1px solid #007bff;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    border-color: #0056b3;
    color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.2);
}

.btn:hover {
    opacity: 1;
}

.hero-visual {
    flex: 1;
}

/* Sekcja główna*/
.app-section {
    padding: 2rem 0;
    padding-top: 5rem; /* Dodatkowy padding dla sticky navbar */
    /* Widoczna domyślnie */
}

.container-fluid {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
}

.cipher-sidebar {
    width: 300px;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.cipher-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.cipher-item:hover {
    background-color: var(--bg-tertiary);
}

.cipher-item-info h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.cipher-item-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.difficulty {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.difficulty.easy {
    background-color: #28a745;
    color: white;
}

.difficulty.medium {
    background-color: #ffc107;
    color: black;
}

.difficulty.hard {
    background-color: #dc3545;
    color: white;
}

.cipher-info-box {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.main-workspace {
    flex: 1;
    padding: 1rem;
}

.workspace-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.current-cipher-name {
    font-size: 1.5rem;
}

/* Przyciski ikonowe - zunifikowane style */
.btn-icon {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--shadow);
}

.btn-icon:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px var(--shadow);
}

.btn-icon svg {
    display: block;
    width: 20px;
    height: 20px;
}

.btn-icon-sm {
    padding: 0.375rem;
}

.btn-icon-sm svg {
    width: 18px;
    height: 18px;
}

.workspace-container {
    display: flex;
    gap: 1rem;
}

.workspace-column {
    flex: 1;
}

.workspace-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 1rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.3s ease;
}

.card-header h3 {
    font-size: 1.2rem;
}

.cipher-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-radius: 4px;
    resize: vertical;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.settings-container {
    padding: 1rem;
}

.action-buttons-container {
    display: flex;
    gap: 1rem;
}

.btn-lg {
    padding: 1rem 2rem;
}

.viz-controls {
    display: flex;
    gap: 0.5rem;
}

.output-area {
    padding: 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 1rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.export-buttons {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* Przyciski eksportu */
#export-txt,
#export-pdf {
    transition: all 0.2s ease;
    position: relative;
}

#export-txt:hover,
#export-pdf:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

#export-txt.loading,
#export-pdf.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Spinner dla eksportu */
.export-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,123,255,0.3);
    border-top-color: #007bff;
    border-radius: 50%;
    animation: export-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes export-spin {
    to { transform: rotate(360deg); }
}

/* Interfejs analizy częstości */
.freq-analysis-controls {
    display: none; /* przełączane z JS */
}

#freq-analysis-btn {
    transition: all 0.2s ease;
}

#freq-analysis-btn:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

#freq-analysis-close {
    transition: all 0.2s ease;
}

#freq-analysis-close:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220,53,69,0.3);
}

.freq-analysis-controls #freq-analysis-btn {
    margin-top: 6px;
}
#freq-analysis-close {
    margin-top: 6px;
}
#freq-analysis-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 1px 0 var(--shadow);
    max-height: 420px;
    overflow: auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.btn-outline {
    background: none;
    border: 1px solid #007bff;
    color: #007bff;
    transition: all 0.2s ease;
}

.btn-outline:hover {
    background: #007bff;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

/* Przyciski Zamknij w sekcjach */
#quiz-close,
#docs-close {
    transition: all 0.2s ease;
}

#quiz-close:hover,
#docs-close:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220,53,69,0.3);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Sekcja tutorial */
#tutorial {
    display: none; /* Ukryj domyślnie */
}

#tutorial.active {
    display: block; /* Pokaż po kliknięciu w nawigację */
}

/* Sekcja ostzegawcza */
.warning-banner {
    background-color: #fff3cd;
    padding: 1rem;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode .warning-banner {
    background-color: #664d03;
    color: #fff3cd;
}

.warning-banner p {
    font-size: 0.9rem;
    margin: 0;
}

/* Stopka */
.footer {
    background-color: var(--bg-secondary);
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.footer-content {
    display: flex;
    gap: 2rem;
    justify-content: space-between;
}

.footer-section {
    flex: 1;
}

.footer-section:first-child {
    flex: 2;
}

.footer-resources {
    flex: 1;
    margin-left: auto;
    max-width: 300px;
}

.footer-section h4 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    text-decoration: none;
    color: #007bff;
    transition: all 0.2s ease;
}

.footer-section a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.footer-bottom {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* =====================================================
   ROZSZERZENIA - SPA + WIZUALIZACJA CEZARA
   ===================================================== */

/* Ulepszenia SPA */
html {
    scroll-behavior: smooth;
}

.nav-link.active {
    background-color: rgba(0, 123, 255, 0.1);
    border-radius: 4px;
    font-weight: bold;
}

/* Zawartość wizualizacji */
.visualization-content {
    margin-top: 1rem;
    padding: 1rem;
}

.viz-progress {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.progress-bar {
    flex: 1;
    min-width: 200px;
    height: 8px;
    background-color: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.step-counter {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.current-step {
    color: #007bff;
    font-weight: bold;
}

/* Przycisk tabeli substytucji */
.table-viz-btn {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(111, 66, 193, 0.3);
    flex-shrink: 0;
    margin-left: auto;
}

.table-viz-btn svg {
    display: block;
    width: 16px;
    height: 16px;
}

.table-viz-btn:hover {
    background: linear-gradient(135deg, #5a32a3, #4a2889);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(111, 66, 193, 0.4);
}

.table-viz-btn:active {
    transform: translateY(0);
}

/* Obszar wizualizacji */
.visualization-area {
    min-height: 300px;
    max-height: 550px;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--card-bg);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.viz-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    text-align: center;
    transition: color 0.3s ease;
}

.placeholder-icon {
    margin-bottom: 1rem;
    opacity: 0.4;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.placeholder-icon svg {
    width: 64px;
    height: 64px;
}

/* Zawartość kroku */
.viz-step-content {
    animation: none;
    will-change: auto;
    opacity: 1;
    transform: none;
}

.step-header h4 {
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border-light);
    font-size: 0.95rem;
    transition: color 0.3s ease, border-color 0.3s ease;
}

/* Transformacja znaków */
.char-transformation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.char-box {
    text-align: center;
    padding: 0.8rem;
    border-radius: 8px;
    min-width: 120px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: none;
}

.char-box.original {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 2px solid #2196f3;
}

.char-box.transformed {
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
    border: 2px solid #9c27b0;
}

.char-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: color 0.3s ease;
}

.char-display {
    font-size: 1.8rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    margin: 0.3rem 0;
    line-height: 1;
}

.char-box.original .char-display {
    color: #1976d2;
}

.char-box.transformed .char-display {
    color: #7b1fa2;
}

.char-position {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    transition: color 0.3s ease;
}

/* Strzałka transformacji */
.transform-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.shift-info {
    background-color: #ffc107;
    color: #856404;
    padding: 0.2rem 0.6rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 42px;
    text-align: center;
}

.arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

/* Referencja alfabetu */
.alphabet-reference {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    border: 2px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* =====================================================
   WIZUALIZACJA SZYFRU PŁOTOWEGO
   ===================================================== */

.rail-fence-grid {
    display: inline-block;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.rail-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    align-items: center;
}

.rail-row:last-child {
    margin-bottom: 0;
}

.rail-cell {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.rail-cell:not(.filled) {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.rail-cell.filled {
    color: #1976d2;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 2px solid #2196f3;
}

.rail-cell.highlight {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border: 3px solid #ff9800;
    color: #e65100;
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.6);
    animation: railPulse 0.6s ease-in-out;
}

.rail-cell.read {
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
    border: 2px solid #9c27b0;
    color: #7b1fa2;
    opacity: 0.7;
}

@keyframes railPulse {
    0%, 100% {
        transform: scale(1.15);
        box-shadow: 0 0 20px rgba(255, 152, 0, 0.6);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 30px rgba(255, 152, 0, 0.8);
    }
}

.rail-number {
    min-width: 70px;
    font-weight: 600;
    font-size: 0.8rem;
    color: white;
    text-align: center;
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid #5a32a3;
    margin-left: 8px;
    box-shadow: 0 2px 6px rgba(111, 66, 193, 0.3);
}

@media (max-width: 768px) {
    .rail-cell {
        width: 26px;
        height: 26px;
        font-size: 0.875rem;
    }
    
    .rail-fence-grid {
        padding: 0.75rem;
    }
    
    .rail-number {
        min-width: 60px;
        font-size: 0.75rem;
    }
}

/* Referencja alfabetu */
.alphabet-reference {
    margin-top: 0.8rem;
    padding: 0.8rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    display: none; /* Ukryj domyślnie */
    max-width: 100%;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.alphabet-reference.show {
    display: block; /* Pokaż po wybraniu szyfru Cezara */
}

.alphabet-reference h4 {
    margin-bottom: 0.6rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: color 0.3s ease;
}

.alphabet-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    max-width: 100%;
}

.alphabet-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--card-bg);
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    will-change: auto;
    flex-shrink: 0;
}

/* Podświetlanie alfabetu */
.alphabet-highlight {
    margin-top: 1.5rem;
    padding: 0.8rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.alphabet-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0;
}

.alphabet-label {
    font-size: 0.7rem;
    color: #495057;
    font-weight: 600;
    min-width: 75px;
    flex-shrink: 0;
}

/* Informacja o identycznych literach - usunięta, niepotrzebna */

.alphabet-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.alphabet-letter.original-highlight {
    background: linear-gradient(135deg, #2196f3, #1976d2) !important;
    color: white !important;
    border-color: #1565c0 !important;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    z-index: 1;
    position: relative;
}

.alphabet-letter.transformed-highlight {
    background: linear-gradient(135deg, #9c27b0, #7b1fa2) !important;
    color: white !important;
    border-color: #6a1b9a !important;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3);
    z-index: 1;
    position: relative;
}

/* Gdy oryginalna i zaszyfrowana litera są takie same */
.alphabet-letter.original-highlight.transformed-highlight {
    background: linear-gradient(135deg, #2196f3, #9c27b0) !important;
    color: white !important;
    border: 3px solid #ffc107 !important;
    transform: scale(1.2);
    box-shadow: 0 6px 16px rgba(156, 39, 176, 0.4), 0 6px 16px rgba(33, 150, 243, 0.4);
    z-index: 2;
    position: relative;
    animation: pulseGlow 1s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { 
        transform: scale(1.2);
        box-shadow: 0 6px 16px rgba(156, 39, 176, 0.4), 0 6px 16px rgba(33, 150, 243, 0.4);
    }
    50% { 
        transform: scale(1.25);
        box-shadow: 0 8px 20px rgba(156, 39, 176, 0.6), 0 8px 20px rgba(33, 150, 243, 0.6);
    }
}

/* Ulepszone przyciski kontrolne */
#prev-step, #play-viz, #next-step {
    background-color: var(--bg-secondary);
    border: 2px solid #007bff;
    color: #007bff;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#prev-step:hover, #play-viz:hover, #next-step:hover {
    background-color: #007bff;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2);
}

/* Powiadomienia */
.spa-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #007bff;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    animation: slideInNotification 0.3s ease-out;
    max-width: 300px;
    font-size: 0.9rem;
}

.spa-notification.success {
    background-color: #28a745;
}

.spa-notification.warning {
    background-color: #ffc107;
    color: #212529;
}

.spa-notification.error {
    background-color: #dc3545;
}

.spa-notification.fade-out {
    animation: slideOutNotification 0.3s ease-in;
}

/* Animacje */
@keyframes fadeInStep {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInNotification {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutNotification {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsywność */
@media (max-width: 768px) {
    .char-transformation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .transform-arrow {
        transform: rotate(90deg);
    }
    
    .alphabet-display, .alphabet-letters {
        justify-content: flex-start;
    }
    
    .alphabet-letter {
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }
    
    .char-display {
        font-size: 2rem;
    }
    
    .viz-progress {
        flex-direction: column;
        gap: 0.8rem;
        align-items: stretch;
    }
    
    .progress-bar {
        min-width: 100%;
    }
    
    .step-counter {
        text-align: center;
    }
    
    .table-viz-btn {
        width: 100%;
        justify-content: center;
    }
    
    .alphabet-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .visualization-area {
        padding: 0.8rem;
    }
    
    .char-box {
        min-width: 100px;
        padding: 1rem;
    }
    
    .alphabet-letter {
        width: 20px;
        height: 20px;
        font-size: 0.6rem;
    }
}

/* =====================================================
   WIZUALIZACJA TABELOWA VIGENÈRE (TABELA SUBSTYTUCJI) - MODAL
   ===================================================== */

/* Modal Overlay */
.table-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Content */
.table-modal-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px var(--shadow-hover);
    animation: slideDown 0.3s ease-out;
    transition: background-color 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal Header */
.table-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-bottom: 2px solid #e9ecef;
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    border-radius: 12px 12px 0 0;
    flex-wrap: wrap;
}

.table-modal-header h3 {
    color: white;
    margin: 0;
    font-size: 1rem;
    flex-shrink: 0;
}

.modal-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
    justify-content: center;
}

.modal-controls .btn-icon {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
}

.modal-controls .btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
    color: white;
}

.modal-step-counter {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.modal-step-counter span {
    font-weight: bold;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Modal Body */
.table-modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
}

.tabula-recta-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.table-header-info {
    margin-bottom: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid #6f42c1;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.table-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    text-align: center;
    transition: color 0.3s ease;
}

.table-operation {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.65rem;
}

.table-operation span {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.table-operation strong {
    color: #6f42c1;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
}

.tabula-recta-scroll {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    padding: 0;
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.tabula-recta {
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    margin: 0 auto;
    background-color: var(--card-bg);
    width: 98%;
    height: 98%;
    font-size: clamp(0.45rem, 1vw, 0.65rem);
    table-layout: fixed;
    transition: background-color 0.3s ease;
}

.tabula-recta th,
.tabula-recta td {
    text-align: center;
    border: 1px solid var(--border-light);
    padding: 0;
    transition: all 0.2s ease;
    width: calc(100% / 36);
    height: auto;
    overflow: hidden;
    line-height: 1;
}

.corner-cell {
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    position: sticky;
    left: 0;
    top: 0;
    z-index: 3;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-cell {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 2px solid var(--border-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.row-header {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 2px solid var(--border-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.table-cell {
    background-color: var(--card-bg);
    color: var(--text-muted);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Podświetlenia */
.highlight-col {
    background: linear-gradient(180deg, #e3f2fd, #bbdefb) !important;
    color: #1976d2 !important;
    font-weight: bold;
    border: 2px solid #2196f3 !important;
}

.highlight-row {
    background: linear-gradient(90deg, #f3e5f5, #e1bee7) !important;
    color: #7b1fa2 !important;
    font-weight: bold;
    border: 2px solid #9c27b0 !important;
}

.in-col {
    background-color: #e3f2fd !important;
    color: #1976d2;
    font-weight: 500;
}

.in-row {
    background-color: #f3e5f5 !important;
    color: #7b1fa2;
    font-weight: 500;
}

.intersection {
    background: linear-gradient(135deg, #ffc107, #ff9800) !important;
    color: #000000 !important;
    font-weight: bold;
    font-size: clamp(0.5rem, 1vw, 0.75rem) !important;
    border: 2px solid #f57c00 !important;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.6);
    z-index: 10;
    position: relative;
    animation: pulseIntersection 1.5s ease-in-out infinite;
}

@keyframes pulseIntersection {
    0%, 100% {
        transform: scale(1.15);
        box-shadow: 0 2px 8px rgba(255, 152, 0, 0.6);
    }
    50% {
        transform: scale(1.25);
        box-shadow: 0 3px 12px rgba(255, 152, 0, 0.8);
    }
}

/* Legenda */
.table-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 0.8rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.legend-color.intersection {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    border: 2px solid #f57c00;
}

.legend-color.in-row {
    background-color: #f3e5f5;
    border: 1px solid #9c27b0;
}

.legend-color.in-col {
    background-color: #e3f2fd;
    border: 1px solid #2196f3;
}

/* Responsywność dla tabeli i modala */
@media (max-width: 768px) {
    .table-modal-content {
        width: 98vw;
        height: 95vh;
    }
    
    .table-modal-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .table-modal-header h3 {
        font-size: 1.1rem;
        width: 100%;
        text-align: center;
    }
    
    .modal-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .modal-step-counter {
        font-size: 0.8rem;
    }
    
    .table-modal-body {
        padding: 1rem;
    }
    
    .table-operation {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
    
    .table-legend {
        flex-direction: column;
        gap: 0.8rem;
    }
}

@media (max-width: 480px) {
    .table-modal-header h3 {
        font-size: 1rem;
    }
    
    .modal-close-btn {
        width: 35px;
        height: 35px;
        font-size: 1.5rem;
    }
}

/* =====================================================
   WIZUALIZACJA VIGENÈRE
   ===================================================== */

.vigenere-viz {
    animation: none;
    will-change: auto;
}

/* Wyświetlanie słowa kluczowego */
.vigenere-key-display {
    background: var(--bg-secondary);
    border: 2px solid #6f42c1;
    border-radius: 8px;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    transition: background-color 0.3s ease;
}

.key-info {
    text-align: center;
}

.key-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: color 0.3s ease;
}

.key-sequence {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.key-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.key-letter.active {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    color: white;
    border-color: #5a32a3;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.4);
    z-index: 2;
    position: relative;
}

/* Strzałka z informacją o kluczu */
.vigenere-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.key-char-display {
    background: var(--bg-secondary);
    border: 2px solid #6f42c1;
    border-radius: 8px;
    padding: 0.6rem;
    text-align: center;
    min-width: 90px;
    transition: background-color 0.3s ease;
}

.key-char-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
    font-weight: 600;
    transition: color 0.3s ease;
}

.key-char-value {
    font-size: 1.4rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: #6f42c1;
    margin: 0.2rem 0;
}

.key-shift-value {
    font-size: 0.7rem;
    color: #495057;
    margin-top: 0.2rem;
    font-weight: 500;
}

/* Podgląd tablicy Vigenère'a - WYŁĄCZONY */
.vigenere-table-preview {
    display: none; /* Ukryte */
}

/* Responsywność dla Vigenère */
@media (max-width: 768px) {
    .vigenere-key-display {
        padding: 1rem;
    }
    
    .key-letter {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .key-char-display {
        min-width: 100px;
        padding: 0.8rem;
    }
    
    .key-char-value {
        font-size: 1.5rem;
    }
    
    .vigenere-arrow {
        transform: rotate(90deg);
        margin: 1.5rem 0;
    }
    
    .vigenere-table-preview {
        padding: 1rem;
    }
    
    .table-explanation {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .key-sequence {
        gap: 0.3rem;
    }
    
    .key-letter {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .vigenere-key-display {
        padding: 0.8rem;
    }
    
    .key-char-display {
        min-width: 80px;
        padding: 0.6rem;
    }
}

/* ======= QUIZY ======== */
.quiz-section {
    padding: 80px 0;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    min-height: 100vh;
    display: none; /* Ukryj domyślnie */
    transition: background-color 0.3s ease, color 0.3s ease;
}

.quiz-section.active {
    display: block; /* Pokaż po kliknięciu w nawigację */
}

/* ======= DOKUMENTACJA I TUTORIAL (docs-panel) ======== */
.docs-panel-section {
    padding: 80px 0;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    min-height: 100vh;
    display: none; /* Ukryj domyślnie */
    transition: background-color 0.3s ease, color 0.3s ease;
}

.docs-panel-section.active {
    display: block; /* Pokaż po kliknięciu w nawigację */
}

#docs-panel {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

#docs-panel .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

#docs-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
    line-height: 1.8;
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

#docs-content h1, 
#docs-content h2, 
#docs-content h3 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

#docs-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid #007bff;
    padding-bottom: 0.5rem;
}

#docs-content h2 {
    font-size: 1.5rem;
}

#docs-content h3 {
    font-size: 1.2rem;
}

#docs-content code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #d63384;
    transition: background-color 0.3s ease;
}

#docs-content pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Dark mode dla bloków kodu */
body.dark-mode #docs-content pre {
    background: #1e1e1e;
    border-color: #404040;
}

#docs-content pre code {
    background: transparent;
    padding: 0;
    color: var(--text-primary);
}

#docs-content ul, 
#docs-content ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

#docs-content li {
    margin-bottom: 0.5rem;
}

#docs-content a {
    color: #007bff;
    text-decoration: none;
}

#docs-content a:hover {
    text-decoration: underline;
}

#docs-content blockquote {
    border-left: 4px solid #007bff;
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-style: italic;
}

#docs-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

#docs-content table th,
#docs-content table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
    transition: border-color 0.3s ease;
}

#docs-content table th {
    background: var(--bg-secondary);
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: bold;
    transition: color 0.3s ease;
}

.section-subtitle {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 3rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.quiz-categories {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 3rem;
}

.quiz-category-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 280px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow);
}

.quiz-category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border-color: #007bff;
}

.quiz-category-card h3 {
    margin: 0.5rem 0;
    font-size: 1.5rem;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.quiz-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.quiz-question {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    line-height: 1.6;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-option {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.quiz-option:hover {
    background: var(--bg-tertiary);
    border-color: #007bff;
}

.quiz-option.selected {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.quiz-option.correct { background: rgba(34,197,94,0.3); border-color: #22c55e; }
.quiz-option.incorrect { background: rgba(239,68,68,0.3); border-color: #ef4444; }

.quiz-controls {
    margin-top: 3rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.quiz-result {
    text-align: center;
    padding: 3rem;
    font-size: 1.3rem;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

#score-display {
    font-size: 3.5rem;
    font-weight: bold;
    color: #28a745;
}

.progress-bar-small {
    width: 200px;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    margin-left: 1rem;
    transition: background-color 0.3s ease;
}

.progress-bar-small .progress-fill {
    height: 100%;
    background: #007bff;
    transition: width 0.4s ease;
}

.answers-review {
    margin-top: 2rem;
    text-align: left;
}

.answers-review h4 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.answer-item {
    padding: 1rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    margin-bottom: 0.75rem;
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
}

.answer-item:hover {
    background: var(--bg-tertiary);
}

.answer-item.correct {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.answer-item.incorrect {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.answer-item .question-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.answer-item .answer-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
    opacity: 0.95;
}

.answer-item .answer-row .label {
    font-weight: 600;
    min-width: 120px;
}

.answer-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #e9ecef;
    margin-left: 0.4rem;
    color: #495057;
    font-weight: 600;
}

#specific-quizzes {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 3rem;
    animation: fadeIn 0.4s ease-in-out;
}

#specific-quizzes .quiz-category-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#specific-quizzes .quiz-category-card:hover {
    box-shadow: 0 4px 12px var(--shadow-hover);
    transform: translateY(-5px);
    border-color: #007bff;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* =============================
   NOWA WIZUALIZACJA ENIGMY - 3 ODDZIELNE ROTORY + REFLEKTOR
   ============================= */
.enigma-visualization {
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    max-width: 900px;
    margin: 0 auto;
    border: 1px solid var(--border-color);
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* SVG linie sygnału */
.enigma-signal-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.enigma-signal-lines polyline {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.enigma-signal-lines circle {
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2));
}

/* Główny layout - rotory i IO obok siebie */
.enigma-main-layout {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    margin: 0.3rem 0;
}

.enigma-rotors-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Wyświetlacz wejścia/wyjścia - pionowy, z prawej strony */
.enigma-io-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.enigma-input,
.enigma-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.io-label {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.io-value {
    font-family: 'Courier New', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    min-width: 50px;
    text-align: center;
}

.input-value {
    color: #ffffff;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.output-value {
    color: #ffffff;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Plugboard */
.enigma-plugboard {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    align-items: center;
    padding: 0.3rem;
    margin-bottom: 0.2rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    flex-wrap: wrap;
    transition: background-color 0.3s ease;
}

.plug-pair {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid transparent;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.plug-pair.active {
    background: #3b82f6;
    border-color: #60a5fa;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.no-plug {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    transition: color 0.3s ease;
}

/* Układ rotorów - w rzędzie */
.enigma-rotors-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    margin: 0.3rem 0;
}

/* Reflektor - osobny rząd pod rotorami */
.enigma-reflector-row {
    display: flex;
    justify-content: center;
    margin-top: 0.3rem;
    margin-bottom: 0.4rem;
}

/* Kontener pojedynczego rotora */
.enigma-rotor-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.enigma-rotor-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.1rem;
}

/* Koło rotora */
.enigma-rotor-wheel {
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 2px solid #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.05));
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.2), inset 0 2px 6px rgba(0, 0, 0, 0.05);
}

.rotor-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
}

.rotor-rotated {
    animation: rotorRotate 0.5s ease;
}

@keyframes rotorRotate {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4); }
    100% { transform: scale(1); }
}

/* Litery na rotorze */
.rotor-letter {
    position: absolute;
    left: 50%;
    top: 50%;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Litera wejściowa (czerwona) */
.rotor-letter.letter-input {
    color: #ffffff;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
    width: 22px;
    height: 22px;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6), 0 3px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Litera wyjściowa (zielona) */
.rotor-letter.letter-output {
    color: #ffffff;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
    width: 22px;
    height: 22px;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6), 0 3px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Podświetlenie aktywnych liter na rotorze (jasnoniebieski) */
.rotor-letter.letter-active {
    color: #1e40af;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
    width: 22px;
    height: 22px;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 9;
}

/* Oznaczenie notch (kabr) na literze */
.notch-marker {
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.5rem;
    color: #f59e0b;
    opacity: 0.8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Informacja o notch w etykiecie rotora */
.rotor-notch-info {
    font-size: 0.7rem;
    color: #f59e0b;
    font-weight: 600;
    margin-left: 0.2rem;
}

/* Notyfikacja o zamianie plugboard */
.plugboard-change-notice {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem;
    margin: 0.2rem 0;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-left: 3px solid #3b82f6;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #1e40af;
}

.notice-icon {
    font-size: 0.9rem;
}

.notice-text {
    font-weight: 500;
    line-height: 1.2;
}

.notice-text strong {
    font-weight: 700;
    color: #1e3a8a;
}

/* Informacja o mechanizmie obrotów */
.rotation-mechanism-info {
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem;
    margin: 0.2rem 0;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
    font-size: 0.7rem;
    color: #92400e;
}

.info-icon {
    font-size: 0.85rem;
    margin-top: 0.05rem;
}

.info-text {
    font-weight: 500;
    line-height: 1.3;
}

/* Pozycja rotora pod kołem */
.enigma-rotor-position {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: #1e40af;
    background: #dbeafe;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 2px solid #3b82f6;
    min-width: 35px;
    text-align: center;
    transition: all 0.3s ease;
}

.position-changed {
    animation: positionBlink 0.5s ease;
}

@keyframes positionBlink {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); background: #fef3c7; border-color: #f59e0b; color: #92400e; }
}

/* Reflektor (mniejszy) */
.enigma-reflector-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.enigma-reflector-wheel {
    position: relative;
    width: 75px;
    height: 75px;
    border-radius: 50%;
    border: 2px solid #8b5cf6;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(124, 58, 237, 0.1));
    box-shadow: 0 3px 8px rgba(139, 92, 246, 0.25), inset 0 2px 6px rgba(0, 0, 0, 0.05);
}

.reflector-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

.reflector-letter {
    position: absolute;
    left: 50%;
    top: 50%;
    font-family: 'Courier New', monospace;
    font-size: 0.55rem;
    color: #6b21a8;
    font-weight: 600;
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center;
    transition: all 0.3s ease;
}

/* Podświetlenie odbicia w reflektorze (żółty) */
.reflector-letter.letter-reflected {
    color: #92400e;
    background: linear-gradient(135deg, #fef08a, #fde047);
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.65rem;
    width: 17px;
    height: 17px;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.6), 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Ścieżka sygnału */
.enigma-signal-path {
    margin-top: 0.4rem;
    padding: 0.4rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.signal-path-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    font-weight: 600;
    transition: color 0.3s ease;
}

.signal-steps {
    display: flex;
    gap: 0.25rem;
    padding: 0.2rem 0;
    flex-wrap: nowrap;
}

.signal-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.25rem 0.35rem;
    border-radius: 6px;
    min-width: 60px;
    max-width: 80px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.signal-step.signal-forward {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid #ef4444;
}

.signal-step.signal-return {
    background: rgba(16, 185, 129, 0.2);
    border: 2px solid #10b981;
}

.signal-step.signal-reflection {
    background: rgba(250, 204, 21, 0.2);
    border: 2px solid #facc15;
}

.signal-stage {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    transition: color 0.3s ease;
}

.signal-transform {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.signal-letter {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.2);
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    min-width: 26px;
    text-align: center;
    border: 2px solid #60a5fa;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.signal-letter.reflected {
    background: linear-gradient(135deg, #fef08a, #fde047);
    border-color: #facc15;
    color: #854d0e;
    box-shadow: 0 2px 8px rgba(250, 204, 21, 0.4);
    font-weight: 800;
}

.signal-arrow {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Responsywność */
@media (max-width: 768px) {
    .enigma-rotors-row {
        gap: 0.75rem;
    }
    
    .enigma-rotor-wheel {
        width: 130px;
        height: 130px;
    }
    
    .enigma-reflector-wheel {
        width: 90px;
        height: 90px;
    }
    
    .rotor-letter {
        font-size: 0.7rem;
    }
    
    .reflector-letter {
        font-size: 0.55rem;
    }
}

/* ============================================
   STYLE PANELU ANALIZY CZĘSTOŚCI
   ============================================ */

#freq-analysis-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#freq-analysis-panel table {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#freq-analysis-panel th,
#freq-analysis-panel td {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

#freq-analysis-panel .freq-bar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Przesłoń style wstawione w panelu analizy częstości dla trybu ciemnego */
#freq-analysis-panel [style*="background:#fafafa"],
#freq-analysis-panel [style*="background:#fff"],
#freq-analysis-panel [style*="background: #fafafa"],
#freq-analysis-panel [style*="background: #fff"] {
    background: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

#freq-analysis-panel [style*="border:1px solid #eee"],
#freq-analysis-panel [style*="border: 1px solid #eee"] {
    border-color: var(--border-color) !important;
}

#freq-analysis-panel [style*="color:#333"],
#freq-analysis-panel [style*="color: #333"],
#freq-analysis-panel [style*="color:#444"],
#freq-analysis-panel [style*="color: #444"] {
    color: var(--text-primary) !important;
}

#freq-analysis-panel [style*="color:#666"],
#freq-analysis-panel [style*="color: #666"] {
    color: var(--text-muted) !important;
}

#freq-analysis-panel [style*="color:#a33"],
#freq-analysis-panel [style*="color: #a33"] {
    color: #ef4444 !important;
}
