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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: #f8f9fa;
    min-height: 100vh;
    padding: 20px;
    color: #1a1a1a;
}

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

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

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.95rem;
    color: #6b7280;
    font-weight: 400;
}

.client-id-display {
    margin-top: 12px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    background: white;
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.85rem;
}

.client-id-label {
    color: #6b7280;
    font-weight: 500;
}

#client-id-value {
    color: #1a1a1a;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9rem;
    cursor: help;
}

.test-type-selector {
    margin-top: 16px;
    display: inline-flex;
    align-items: center;
    background: white;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.button-group {
    display: inline-flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.btn-group-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #1a1a1a;
    background: white;
    border: none;
    border-right: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.btn-group-btn:last-child {
    border-right: none;
}

.btn-group-btn:hover {
    background: #f3f4f6;
    color: #1a1a1a;
}

.btn-group-btn.active {
    background: #1a1a1a;
    color: white;
}

.btn-group-btn.active:hover {
    background: #1a1a1a;
    color: white;
}

.dataset-selector {
    margin-top: 16px;
    display: inline-flex;
    gap: 10px;
    align-items: center;
    background: white;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.dataset-selector label {
    font-size: 0.9rem;
    color: #1a1a1a;
    font-weight: 500;
}

.dataset-selector select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
    color: #1a1a1a;
    cursor: pointer;
    min-width: 160px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 8px;
    margin-bottom: 40px;
    background: white;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #1a1a1a;
    background: #f3f4f6;
}

.tab-btn.active {
    background: #1a1a1a;
    color: white;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Controls */
.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.controls select {
    flex: 1;
    min-width: 180px;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    color: #1a1a1a;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.inline-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #1a1a1a;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
}

.inline-toggle input {
    width: 16px;
    height: 16px;
}

.controls select:hover {
    border-color: #d1d5db;
}

.controls select:focus {
    outline: none;
    border-color: #1a1a1a;
}

/* Flashcard */
.flashcard-container {
    perspective: 1000px;
}

.flashcard {
    width: 100%;
    min-height: 320px;
    cursor: default;
    margin-bottom: 24px;
    background: white;
    border-radius: 12px;
    padding: 40px 32px;
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    text-align: center;
}

.toggle-group {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 8px;
}

.toggle-btn {
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f8fafc;
    color: #1f2937;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.toggle-btn.active {
    background: #1a1a1a;
    color: white;
    border-color: #1a1a1a;
}

.card-section {
    width: 100%;
}

.hidden {
    display: none !important;
}

.word-with-speaker {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.flashcard h2 {
    font-size: 2.3rem;
    margin: 0;
    color: #1a1a1a;
    font-weight: 600;
    letter-spacing: -1px;
}

.flashcard .example-heading {
    margin-top: 8px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6b7280;
}

.korean-text {
    font-size: 1.15rem;
    opacity: 0.9;
    margin-top: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
}

#meaning-section .korean-text {
    font-size: 2.3rem;
    font-weight: 600;
    line-height: 1.2;
}

.example-with-speaker {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.example-with-speaker .example {
    margin: 0;
}

.speaker-btn-small {
    width: 32px;
    height: 32px;
}

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

.example.korean-text {
    margin-top: 12px;
    font-size: 1.05rem;
    opacity: 0.85;
}

.hint {
    color: #9ca3af;
    font-size: 0.85rem;
    margin-top: 16px;
    font-weight: 400;
}

.badge-row {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

.difficulty-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.speaker-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.speaker-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.speaker-btn:active {
    transform: scale(0.95);
}

.speaker-btn svg {
    width: 18px;
    height: 18px;
}

.difficulty-easy {
    background: #ecfdf5;
    color: #065f46;
}

.difficulty-medium {
    background: #fff7ed;
    color: #9a3412;
}

.difficulty-hard {
    background: #fef2f2;
    color: #991b1b;
}

.example {
    opacity: 0.9;
    font-size: 1.3rem;
    line-height: 1.8;
}

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

.card-counter {
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 80px;
    text-align: center;
}

.complete-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #1a1a1a;
    background: #f8fafc;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.complete-toggle input {
    width: 18px;
    height: 18px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.btn-primary {
    background: #1a1a1a;
    color: white;
    border-color: #1a1a1a;
}

.btn-primary:hover {
    background: #2d2d2d;
    border-color: #2d2d2d;
}

.btn-secondary {
    background: white;
    color: #1a1a1a;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Quiz */
.quiz-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

#quiz-setup {
    text-align: center;
}

#quiz-setup h2 {
    color: #1a1a1a;
    margin-bottom: 8px;
    font-size: 1.5rem;
    font-weight: 600;
}

#quiz-setup p {
    color: #6b7280;
    margin-bottom: 32px;
    font-size: 0.95rem;
}

#quiz-setup label {
    display: block;
    margin-bottom: 8px;
    color: #1a1a1a;
    font-weight: 500;
    font-size: 0.9rem;
}

#quiz-setup select {
    width: 100%;
    max-width: 280px;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 24px;
    cursor: pointer;
}

#quiz-setup select:focus {
    outline: none;
    border-color: #1a1a1a;
}

.quiz-header {
    margin-bottom: 32px;
}

.quiz-progress {
    width: 100%;
    height: 4px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: #1a1a1a;
    transition: width 0.3s ease;
    width: 0%;
}

.quiz-counter {
    text-align: center;
    color: #6b7280;
    font-weight: 500;
    font-size: 0.85rem;
}

.quiz-question h2 {
    color: #1a1a1a;
    font-size: 2rem;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.quiz-question > p {
    text-align: center;
    color: #6b7280;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.option {
    padding: 16px 18px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    font-size: 0.95rem;
}

.option:hover {
    border-color: #1a1a1a;
    background: #f9fafb;
}

.option.selected {
    border-color: #1a1a1a;
    background: #1a1a1a;
    color: white;
}

.option.correct {
    border-color: #059669;
    background: #059669;
    color: white;
}

.option.incorrect {
    border-color: #dc2626;
    background: #dc2626;
    color: white;
}

.option.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

#next-question {
    display: block;
    margin: 0 auto;
}

/* Quiz Results */
#quiz-results {
    text-align: center;
}

#quiz-results h2 {
    color: #1a1a1a;
    margin-bottom: 32px;
    font-size: 1.5rem;
    font-weight: 600;
}

.results-summary {
    margin: 40px 0;
}

.score-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: #1a1a1a;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-text {
    font-size: 2.5rem;
    font-weight: 600;
    color: white;
}

.score-detail {
    font-size: 1rem;
    color: #6b7280;
}

/* Word List */
.word-list {
    display: grid;
    gap: 16px;
}

.word-item {
    background: white;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: border-color 0.2s ease;
}

.word-item:hover {
    border-color: #d1d5db;
}

.word-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.word-item-header h3 {
    color: #1a1a1a;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.word-item-meta {
    display: flex;
    gap: 8px;
}

.badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-difficulty {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-category {
    background: #1a1a1a;
    color: white;
}

.word-item p {
    color: #1a1a1a;
    line-height: 1.7;
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.word-item .example {
    color: #6b7280;
    font-style: italic;
    border-left: 2px solid #e5e7eb;
    padding-left: 16px;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    header {
        margin-bottom: 32px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .flashcard {
        height: 320px;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 32px 24px;
    }

    .flashcard-front h2 {
        font-size: 2rem;
    }

    .quiz-container {
        padding: 24px;
    }

    .quiz-question h2 {
        font-size: 1.5rem;
    }

    .score-circle {
        width: 140px;
        height: 140px;
    }

    .score-text {
        font-size: 2rem;
    }

    .word-item {
        padding: 20px;
    }

    .word-item-header h3 {
        font-size: 1.2rem;
    }
}

