* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.mode-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-btn, .manage-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background: rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mode-btn:hover, .manage-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.mode-btn.active {
    background: white;
    color: #667eea;
}

.flashcard-container {
    display: block;
    position: relative;
}

.flashcard {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 800px;
    min-height: 600px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.flag-btn {
    background: none;
    border: 2px solid #ffc107;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flag-btn:hover {
    background: #ffc107;
    transform: scale(1.1);
}

.flag-btn.flagged {
    background: #ffc107;
    border-color: #e0a800;
}

.progress {
    font-weight: 600;
    color: #6c757d;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

#toggle-label {
    font-size: 0.9rem;
    color: #6c757d;
    white-space: nowrap;
}

.card-content {
    padding: 40px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.question {
    font-size: 3rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 30px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.input-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#answer-input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1.1rem;
    transition: border-color 0.3s ease;
}

#answer-input:focus {
    outline: none;
    border-color: #667eea;
}

#check-btn {
    padding: 15px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

#check-btn:hover {
    background: #5a6fd8;
}

.result {
    padding: 15px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.result.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.result.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.card-navigation {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

#prev-btn, #next-btn {
    padding: 10px 20px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#prev-btn:hover:not(:disabled), #next-btn:hover:not(:disabled) {
    background: #e9ecef;
}

#prev-btn:disabled, #next-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background-color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 15px 15px 0 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: white;
    color: #6c757d;
    border: 2px solid #6c757d;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.back-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(108, 117, 125, 0.3);
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 20px;
}

.add-word-section {
    margin-bottom: 30px;
}

.add-word-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.form-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.form-group input {
    flex: 1;
    min-width: 150px;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.add-word-circle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: #28a745;
    border: 2px solid #28a745;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.add-word-circle-btn:hover {
    background: #28a745;
    color: white;
    transform: scale(1.1);
}

.add-word-circle-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.3);
}

/* Bulk Import Section */
.bulk-import-section {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px dashed #dee2e6;
}

.bulk-import-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1rem;
}

.import-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#bulk-import-text {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#bulk-import-text:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.import-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.import-btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.3s ease;
}

.import-btn:hover {
    background: #0056b3;
}

.import-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.import-status {
    font-size: 0.9rem;
    font-weight: 500;
}

.import-status.success {
    color: #28a745;
}

.import-status.error {
    color: #dc3545;
}

.import-status.warning {
    color: #ffc107;
}

.word-list-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.word-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 5px;
}

.word-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
    gap: 15px;
}

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

.word-number {
    color: #8b8b8b;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 25px;
    text-align: right;
    flex-shrink: 0;
}

.word-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.japanese {
    font-weight: 600;
    font-size: 1.1rem;
    color: #2c3e50;
}

.english {
    color: #6c757d;
}

.delete-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: white;
    color: #dc3545;
    border: 2px solid #dc3545;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.delete-btn:hover {
    background: #dc3545;
    color: white;
    transform: scale(1.1);
}

.delete-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.3);
}

.reset-btn {
    padding: 8px 16px;
    background: #ffc107;
    color: #212529;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 15px;
    transition: background 0.3s ease;
}

.reset-btn:hover {
    background: #e0a800;
}

/* Flagged Vocabs Sidebar */
.flagged-sidebar {
    width: 250px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: calc(50% + 400px + 30px);
    top: 10%;
    height: 80%;
    z-index: 100;
}

.flagged-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 0;
}

.flagged-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background 0.3s ease;
    position: relative;
}

.flagged-item:hover {
    background: #f8f9fa;
}

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

.flagged-japanese {
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
    margin-bottom: 4px;
}

.flagged-english {
    color: #6c757d;
    font-size: 0.9rem;
}

.remove-flag-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.flagged-item:hover .remove-flag-btn {
    opacity: 1;
}

.flagged-actions {
    padding: 15px;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flagged-action-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.flagged-action-btn:first-child {
    background: #007bff;
    color: white;
}

.flagged-action-btn:first-child:hover {
    background: #0056b3;
}

.flagged-action-btn:nth-child(2) {
    background: #28a745;
    color: white;
}

.flagged-action-btn:nth-child(2):hover {
    background: #218838;
}

.flagged-action-btn.clear-btn {
    background: #dc3545;
    color: white;
}

.flagged-action-btn.clear-btn:hover {
    background: #c82333;
}

/* Word Bank Sidebar */
.wordbank-sidebar {
    width: 250px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    right: calc(50% + 400px + 30px);
    top: 10%;
    height: 80%;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 20px 20px 0 0;
}

.sidebar-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}


.sidebar-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.wordbank-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 0;
}

.wordbank-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-bottom: 8px;
    border: 2px solid transparent;
}

.wordbank-item:hover {
    background: #f8f9fa;
}

.wordbank-item.active {
    background: #e3f2fd;
    border-color: #667eea;
}

.wordbank-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wordbank-name {
    font-weight: 600;
    color: #2c3e50;
}

.wordbank-count {
    font-size: 0.9rem;
    color: #6c757d;
}


/* Updated Modal Styles for Word Banks */
.current-wordbank-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.current-wordbank-section h3 {
    margin-bottom: 15px;
}

.current-wordbank-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.wordbank-edit-btn {
    padding: 10px 20px;
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.wordbank-edit-btn:hover {
    background: #667eea;
    color: white;
}

.wordbank-edit-btn.current {
    background: #667eea;
    color: white;
}

.word-count-badge {
    background: #e9ecef;
    color: #6c757d;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
}

.other-wordbanks-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.other-wordbanks-list {
    margin-bottom: 20px;
}

.other-wordbank-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 10px;
}

.switch-btn {
    padding: 6px 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
    margin-left: auto;
}

.switch-btn:hover {
    background: #218838;
}

.create-btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.create-btn:hover {
    background: #0056b3;
}

/* Word Bank Edit Modal */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.wordbank-name-section {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.wordbank-name-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.wordbank-name-section input {
    width: 70%;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin-right: 10px;
}

.save-btn {
    padding: 8px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.save-btn:hover {
    background: #218838;
}

.wordbank-actions {
    margin-top: 20px;
    padding: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    position: sticky;
    bottom: 0;
    z-index: 10;
    border-radius: 0 0 15px 15px;
}

.delete-wordbank-btn {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.delete-wordbank-btn:hover {
    background: #c82333;
}

.save-edits-btn {
    padding: 12px 24px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: background 0.3s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.save-edits-btn:hover {
    background: #218838;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

@media (max-width: 1200px) {
    .wordbank-sidebar {
        right: 20px;
    }
}

@media (max-width: 768px) {
    
    .header-controls {
        flex-direction: column;
    }
    
    .mode-selector {
        justify-content: center;
    }
    
    .form-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-group input {
        min-width: auto;
        margin-bottom: 10px;
    }
    
    .add-word-circle-btn {
        align-self: center;
        margin-top: 10px;
    }
    
    .input-section {
        flex-direction: column;
    }
    
    .question {
        font-size: 2rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .container {
        margin: 0 20px;
    }
    
    .wordbank-sidebar {
        position: static;
        transform: none;
        width: 100%;
        margin-bottom: 20px;
        min-height: auto;
    }
    
    .flashcard {
        min-height: 500px;
    }
    
    .flagged-sidebar {
        position: static;
        transform: none;
        width: 100%;
        margin-bottom: 20px;
        height: auto;
        order: 2;
    }
}