* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: #f0f4ff; color: #1a1a2e; min-height: 100vh; }

.header { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: white; padding: 20px 24px; display: flex; align-items: center; gap: 16px; }
.header h1 { font-size: 1.4rem; font-weight: 700; }
.header .subtitle { font-size: 0.85rem; opacity: 0.8; }

.nav { display: flex; background: white; border-bottom: 2px solid #e5e7eb; }
.nav button { flex: 1; padding: 14px; border: none; background: none; cursor: pointer; font-size: 0.9rem; font-weight: 600; color: #6b7280; transition: all 0.2s; }
.nav button.active { color: #4f46e5; border-bottom: 3px solid #4f46e5; margin-bottom: -2px; }
.nav button:hover:not(.active) { background: #f9fafb; color: #374151; }

.container { max-width: 640px; margin: 0 auto; padding: 24px 16px; }

.quiz-controls { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.quiz-controls select, .quiz-controls button { padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.875rem; }
.quiz-controls button { background: #4f46e5; color: white; border-color: #4f46e5; cursor: pointer; font-weight: 600; }
.quiz-controls button:hover { background: #4338ca; }

.progress-bar { background: #e5e7eb; border-radius: 99px; height: 8px; margin-bottom: 8px; }
.progress-fill { background: linear-gradient(90deg, #4f46e5, #7c3aed); height: 100%; border-radius: 99px; transition: width 0.4s; }
.progress-text { font-size: 0.8rem; color: #6b7280; margin-bottom: 20px; }

.card { background: white; border-radius: 16px; padding: 36px 28px; text-align: center; box-shadow: 0 4px 20px rgba(79,70,229,0.08); min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card .word { font-size: 2.2rem; font-weight: 800; color: #1a1a2e; margin-bottom: 8px; }
.card .hint { font-size: 0.85rem; color: #9ca3af; margin-bottom: 28px; }
.card .part-of-speech { display: inline-block; background: #ede9fe; color: #6d28d9; font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; margin-bottom: 12px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 8px; }
.option-btn { padding: 14px; border: 2px solid #e5e7eb; border-radius: 12px; background: #f9fafb; cursor: pointer; font-size: 0.9rem; transition: all 0.15s; text-align: left; }
.option-btn:hover:not(:disabled) { border-color: #4f46e5; background: #ede9fe; }
.option-btn.correct { border-color: #10b981; background: #d1fae5; color: #065f46; font-weight: 700; }
.option-btn.wrong { border-color: #ef4444; background: #fee2e2; color: #991b1b; }
.option-btn:disabled { cursor: default; }

.type-input-wrap { width: 100%; margin-top: 16px; display: flex; gap: 8px; }
.type-input { flex: 1; padding: 12px 16px; border: 2px solid #e5e7eb; border-radius: 12px; font-size: 1rem; outline: none; transition: border 0.2s; }
.type-input:focus { border-color: #4f46e5; }
.submit-btn { padding: 12px 20px; background: #4f46e5; color: white; border: none; border-radius: 12px; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.submit-btn:hover { background: #4338ca; }

.feedback { margin-top: 16px; padding: 12px 16px; border-radius: 12px; font-size: 0.9rem; font-weight: 600; display: none; }
.feedback.show { display: block; }
.feedback.correct { background: #d1fae5; color: #065f46; }
.feedback.wrong { background: #fee2e2; color: #991b1b; }

.next-btn { margin-top: 20px; padding: 12px 32px; background: #4f46e5; color: white; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; display: none; }
.next-btn.show { display: block; }
.next-btn:hover { background: #4338ca; }

.result-card { background: white; border-radius: 16px; padding: 36px; text-align: center; box-shadow: 0 4px 20px rgba(79,70,229,0.08); }
.result-card .score { font-size: 3.5rem; font-weight: 800; color: #4f46e5; }
.result-card p { color: #6b7280; margin: 8px 0 24px; }
.result-card button { padding: 12px 28px; background: #4f46e5; color: white; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; }

.wrong-list { display: flex; flex-direction: column; gap: 12px; }
.wrong-item { background: white; border-radius: 12px; padding: 16px 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); display: flex; justify-content: space-between; align-items: center; }
.wrong-item .wword { font-size: 1.1rem; font-weight: 700; }
.wrong-item .wmean { color: #6b7280; font-size: 0.9rem; }
.wrong-item .wcount { background: #fee2e2; color: #991b1b; font-size: 0.75rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.empty-state { text-align: center; padding: 60px 20px; color: #9ca3af; }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

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

.speak-btn { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0 4px; vertical-align: middle; opacity: 0.6; transition: opacity 0.15s; }
.speak-btn:hover { opacity: 1; }

.fb-result { font-weight: 700; margin-bottom: 8px; }
.fb-example { margin-top: 10px; padding: 10px 14px; background: rgba(255,255,255,0.5); border-radius: 10px; text-align: left; border-left: 3px solid currentColor; }
.fb-ex-en { display: block; font-size: 0.9rem; font-style: italic; margin-bottom: 4px; }
.fb-ex-ko { display: block; font-size: 0.8rem; opacity: 0.8; }

/* ===== AI 기능 UI ===== */
.header { justify-content: space-between; }
.settings-btn { background: rgba(255,255,255,0.2); border: none; color: white; font-size: 1.2rem; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.settings-btn:hover { background: rgba(255,255,255,0.35); }

.ai-btn { padding: 12px 20px; background: #4f46e5; color: white; border: none; border-radius: 10px; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.ai-btn:hover { background: #4338ca; }

.tip-btn { background: #fef3c7; border: none; cursor: pointer; font-size: 1rem; width: 32px; height: 32px; border-radius: 8px; }
.tip-btn:hover { background: #fde68a; }

.wrong-item-wrap { background: white; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); overflow: hidden; }
.wrong-item-wrap .wrong-item { box-shadow: none; border-radius: 0; }
.tip-box { display: none; padding: 0 20px; }
.tip-box.show { display: block; padding: 0 20px 14px; }
.tip-row { font-size: 0.85rem; color: #374151; margin-top: 6px; line-height: 1.5; }
.tip-row b { color: #6d28d9; margin-right: 6px; }
.tip-loading { color: #9ca3af; font-size: 0.85rem; padding: 8px 0; }
.tip-error { color: #991b1b; font-size: 0.8rem; padding: 8px 0; }

.analyze-card { background: white; border-radius: 14px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-top: 16px; }
.analyze-summary { font-size: 0.95rem; line-height: 1.6; color: #1a1a2e; }
.weak-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.weak-tag { background: #fee2e2; color: #991b1b; font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.analyze-advice { margin-top: 12px; padding: 10px 14px; background: #ede9fe; border-radius: 10px; font-size: 0.85rem; color: #5b21b6; }
.rec-card { background: white; border-radius: 14px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-top: 14px; }
.rec-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; }
.rec-words { font-size: 0.88rem; color: #4f46e5; font-weight: 600; line-height: 1.6; margin-bottom: 14px; }
.ai-empty { text-align: center; color: #9ca3af; padding: 40px 20px; }

/* 설정 모달 */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { background: white; border-radius: 16px; padding: 24px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 1.2rem; margin-bottom: 8px; }
.modal-desc { font-size: 0.82rem; color: #6b7280; line-height: 1.5; margin-bottom: 18px; }
.field-label { display: block; font-size: 0.8rem; font-weight: 700; color: #374151; margin: 14px 0 6px; }
.provider-tabs { display: flex; gap: 8px; }
.provider-tab { flex: 1; padding: 10px; border: 2px solid #e5e7eb; background: #f9fafb; border-radius: 10px; cursor: pointer; font-size: 0.82rem; font-weight: 600; color: #6b7280; }
.provider-tab.active { border-color: #4f46e5; background: #ede9fe; color: #4f46e5; }
.key-input { width: 100%; padding: 12px 14px; border: 2px solid #e5e7eb; border-radius: 10px; font-size: 0.9rem; outline: none; }
.key-input:focus { border-color: #4f46e5; }
.modal-help { font-size: 0.78rem; color: #9ca3af; margin-top: 10px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .ai-btn { flex: 1; }
.cancel-btn { padding: 12px 20px; background: #f3f4f6; color: #374151; border: none; border-radius: 10px; font-weight: 600; cursor: pointer; }
