:root {
    --bg-deep: #0d1117;
    --bg-card: #161b22;
    --cos-blue: #5b9bd5;
    --sin-red: #e06666;
    --tan-purple: #b388ff;
    --csc-pink: #ea9999;
    --sec-light-blue: #6fa8dc;
    --cot-light-purple: #c9a3ff;
    --accent: #ff3131;
    --text-primary: #ffffff;
    --text-secondary: #8b949e;
    --highlight-bg: rgba(91, 155, 213, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Color coding classes */
.color-cos, .cos { color: var(--cos-blue); font-weight: 600; }
.color-sin, .sin { color: var(--sin-red); font-weight: 600; }
.color-tan, .tan { color: var(--tan-purple); font-weight: 600; }
.color-csc, .csc { color: var(--csc-pink); font-weight: 600; }
.color-sec, .sec { color: var(--sec-light-blue); font-weight: 600; }
.color-cot, .cot { color: var(--cot-light-purple); font-weight: 600; }

header {
    background: var(--bg-card);
    padding: 1.5rem 1rem;
    border-bottom: 2px solid var(--cos-blue);
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
}

.main-nav {
    margin-bottom: 0.75rem;
}

.secondary-nav {
    padding-top: 0.75rem;
    border-top: 1px solid var(--text-secondary);
}

.secondary-nav.hidden {
    display: none;
}

nav button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--text-secondary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
}

nav button.active {
    background: var(--cos-blue);
    color: var(--bg-deep);
    border-color: var(--cos-blue);
}

nav button.saved-btn {
    margin-left: auto;
    border-color: var(--sin-red);
    color: var(--sin-red);
}

nav button.saved-btn:hover {
    background: var(--sin-red);
    color: var(--bg-deep);
}

#preset-dropdown {
    background: var(--bg-deep);
    color: var(--text-primary);
    border: 1px solid var(--tan-purple);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    font-family: inherit;
    font-size: inherit;
}

#preset-dropdown:hover {
    background: var(--tan-purple);
    color: var(--bg-deep);
}

#preset-dropdown option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.help-section ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.help-section li {
    margin-bottom: 0.3rem;
}

.external-link {
    color: var(--cos-blue);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid var(--cos-blue);
    transition: all 0.3s;
}

.external-link:hover {
    color: var(--tan-purple);
    border-bottom-color: var(--tan-purple);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.modal-actions button {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

#download-txt-btn {
    background: var(--cos-blue);
    color: var(--bg-deep);
}

#download-csv-btn {
    background: var(--tan-purple);
    color: var(--bg-deep);
}

#download-txt-btn:hover,
#download-csv-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#clear-saved-btn {
    background: var(--accent);
    color: var(--text-primary);
}

.legend {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--cos-blue);
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    z-index: 100;
}

.view {
    display: none;
    padding: 1rem;
}

.view.active {
    display: block;
}

#identities-list {
    display: grid;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.identity-item {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--cos-blue);
}

.identity-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.identity-header input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.identity-name {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    color: var(--text-secondary);
}

.identity-formula {
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    margin: 0.75rem 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.identity-details {
    display: none;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--text-secondary);
}

.identity-details.visible {
    display: block;
}

.identity-section {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--highlight-bg);
    border-radius: 4px;
    border-left: 3px solid var(--cos-blue);
}

.identity-section h4 {
    color: var(--cos-blue);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.identity-section p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.7;
}

#quiz-view {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

#quiz-view.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    background: var(--bg-deep);
    z-index: 1000;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#quiz-view.fullscreen #quiz-controls {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.3;
    transition: opacity 0.3s;
}

#quiz-view.fullscreen #quiz-controls:hover {
    opacity: 1;
}

#quiz-view.fullscreen #quiz-settings {
    position: absolute;
    top: 4rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.3;
    transition: opacity 0.3s;
}

#quiz-view.fullscreen #quiz-settings:hover {
    opacity: 1;
}

#quiz-view.fullscreen #quiz-card {
    min-height: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#fullscreen-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-secondary);
    font-size: 0.85rem;
    opacity: 0.5;
    text-align: center;
}

#quiz-view.fullscreen #fullscreen-hint {
    opacity: 0;
}

body.fullscreen-mode header {
    display: none;
}

body.fullscreen-mode .legend {
    display: none;
}

#quiz-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

#quiz-controls button {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--cos-blue);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    font-weight: 500;
}

#quiz-controls button:hover {
    background: var(--cos-blue);
    color: var(--bg-deep);
}

#quiz-controls .exit-btn {
    border-color: var(--accent);
    color: var(--accent);
}

#quiz-controls .exit-btn:hover {
    background: var(--accent);
    color: var(--text-primary);
}

#quiz-settings {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

#quiz-card {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 12px;
    min-height: 450px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: all 0.3s;
}

.card-name {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s;
}

.card-formula {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(88, 166, 255, 0.3);
}

.card-description,
.card-usage,
.card-example {
    color: var(--text-secondary);
    max-width: 650px;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s;
    line-height: 1.8;
    font-size: 1rem;
}

.card-name.visible,
.card-formula.visible,
.card-description.visible,
.card-usage.visible,
.card-example.visible {
    opacity: 1;
    transform: translateY(0);
}

#help-view {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

#help-view h2 {
    margin-bottom: 1.5rem;
    color: var(--cos-blue);
    font-size: 1.8rem;
}

#help-view h3 {
    color: var(--tan-purple);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.help-section {
    background: var(--bg-card);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--cos-blue);
}

.help-section p {
    margin-bottom: 0.75rem;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
}

.modal.active {
    display: block;
}

.modal-content {
    background-color: var(--bg-card);
    margin: 5% auto;
    padding: 2rem;
    border: 2px solid var(--sin-red);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h2 {
    color: var(--sin-red);
    margin-bottom: 1.5rem;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--text-primary);
}

#saved-list {
    margin: 1rem 0;
}

.saved-item {
    background: var(--bg-deep);
    padding: 1rem;
    margin: 0.75rem 0;
    border-radius: 6px;
    border-left: 4px solid var(--sin-red);
}

.saved-item-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.saved-item-formula {
    font-family: 'Courier New', monospace;
    color: var(--cos-blue);
    font-size: 1.1rem;
    font-weight: 600;
}

#clear-saved-btn {
    background: var(--accent);
    color: var(--text-primary);
}

.notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 1.5rem 2.5rem;
    border-radius: 12px;
    border: 2px solid var(--cos-blue);
    font-size: 1.2rem;
    font-weight: 600;
    z-index: 2000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.notification.show {
    transform: translate(-50%, -50%) scale(1);
}

.notification.success {
    border-color: var(--cos-blue);
}

.notification.saved {
    border-color: var(--sin-red);
}

.notification.copied {
    border-color: var(--tan-purple);
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    nav {
        gap: 0.3rem;
    }
    
    nav button {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .main-nav {
        margin-bottom: 0.5rem;
    }
    
    .secondary-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .secondary-nav button {
        width: 100%;
    }
    
    #preset-dropdown {
        width: 100%;
    }
    
    .legend {
        bottom: 0.5rem;
        right: 0.5rem;
        font-size: 0.7rem;
        gap: 0.3rem;
        padding: 0.4rem 0.6rem;
        flex-wrap: wrap;
    }
    
    #quiz-card {
        padding: 2rem 1rem;
        min-height: 350px;
    }
    
    .card-name {
        font-size: 1.3rem;
    }
    
    .card-formula {
        font-size: 1.6rem;
    }
    
    #quiz-controls {
        gap: 0.5rem;
    }
    
    #quiz-controls button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}