* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f1117; color: #e2e8f0; min-height: 100vh; }
.header { background: linear-gradient(135deg, #1a1f2e, #16213e); padding: 24px 20px; text-align: center; border-bottom: 1px solid #2d3748; }
.header h1 { font-size: 1.5rem; font-weight: 700; color: #63b3ed; letter-spacing: 0.5px; }
.header .subtitle { font-size: 0.85rem; color: #718096; margin-top: 4px; }
.container { max-width: 720px; margin: 0 auto; padding: 20px 16px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 10px; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: none; border: 1px solid #2d3748; background: #1a202c; color: #e2e8f0; transition: all 0.2s; }
.btn:hover { background: #2d3748; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #2c4a7c; border-color: #63b3ed; color: #fff; }
.btn-primary:hover { background: #3a5e9c; }
.btn-secondary { background: #3d2a0a; border-color: #f6ad55; color: #f6ad55; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-xs { padding: 4px 10px; font-size: 0.75rem; }

.card { background: #1a202c; border: 1px solid #2d3748; border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: #4a5568; margin-bottom: 12px; }
.muted { color: #718096; font-size: 0.9rem; }
.small { font-size: 0.75rem; }
.error { color: #fc8181; }
.stat-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; }
.period { font-weight: 700; color: #e2e8f0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 0.65rem; font-weight: 700; margin-left: 4px; }
.badge.weekly, .badge.W { background: #2c4a7c; color: #63b3ed; }
.badge.monthly, .badge.M { background: #44337a; color: #b794f4; }

.attempt { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #252d3a; gap: 10px; }
.attempt:last-child { border-bottom: none; }
.att-left { flex: 1; min-width: 0; }
.att-right { display: flex; align-items: center; gap: 10px; }
.score { font-size: 1rem; font-weight: 700; }
.level { font-size: 0.75rem; font-weight: 600; }

/* Take page */
.take-header { position: sticky; top: 0; background: #16213e; border-bottom: 1px solid #2d3748; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; z-index: 10; }
.timer { font-family: 'SF Mono', Monaco, monospace; font-size: 1.4rem; font-weight: 700; color: #f6ad55; padding: 4px 12px; background: #1a202c; border-radius: 8px; }
.timer.warn { color: #fc8181; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.progress { font-size: 0.9rem; color: #a0aec0; }

.question-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; margin-bottom: 20px; padding: 12px; background: #1a202c; border-radius: 10px; }
.q-dot { aspect-ratio: 1; border-radius: 6px; background: #2d3748; color: #718096; font-size: 0.72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 1px solid transparent; }
.q-dot.answered { background: #2a5e3b; color: #68d391; }
.q-dot.flagged { background: #44337a; color: #b794f4; }
.q-dot.current { border-color: #63b3ed; box-shadow: 0 0 0 2px rgba(99,179,237,0.3); }

.question-card { background: #1a202c; border: 1px solid #2d3748; border-radius: 14px; padding: 22px; margin-bottom: 16px; }
.q-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 0.7rem; color: #4a5568; text-transform: uppercase; letter-spacing: 1px; }
.q-cat { padding: 3px 10px; border-radius: 8px; font-weight: 700; }
.q-cat.vocab { background: #1a3a5c; color: #63b3ed; }
.q-cat.kanji { background: #3d2a0a; color: #f6ad55; }
.q-cat.grammar { background: #2d1f4a; color: #b794f4; }
.q-cat.reading { background: #1a2e2c; color: #81e6d9; }
.q-passage { background: #0f1117; border-left: 3px solid #81e6d9; padding: 14px 16px; border-radius: 6px; margin-bottom: 16px; line-height: 1.8; font-size: 1rem; color: #cbd5e0; }
.q-question { font-size: 1.15rem; line-height: 1.6; margin-bottom: 18px; font-weight: 500; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 2px solid #2d3748; border-radius: 10px; cursor: pointer; transition: all 0.15s; background: #0f1117; }
.choice:hover { border-color: #4a5568; background: #1a202c; }
.choice.selected { border-color: #63b3ed; background: #1a2e44; }
.choice .letter { width: 28px; height: 28px; border-radius: 50%; background: #2d3748; color: #a0aec0; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.choice.selected .letter { background: #63b3ed; color: #0f1117; }
.choice .text { flex: 1; font-size: 0.95rem; line-height: 1.5; }

.bottom-actions { display: flex; justify-content: space-between; gap: 8px; padding: 14px 0; }

/* Result page */
.result-summary { background: linear-gradient(135deg, #1a2535, #16213e); border-radius: 16px; padding: 24px; text-align: center; margin-bottom: 20px; border: 1px solid #2d3748; }
.result-score { font-size: 3rem; font-weight: 800; margin-bottom: 6px; }
.result-pct { font-size: 1.1rem; color: #a0aec0; margin-bottom: 12px; }
.result-level { display: inline-block; padding: 8px 20px; border-radius: 20px; font-size: 0.9rem; font-weight: 700; }
.result-time { font-size: 0.85rem; color: #718096; margin-top: 12px; }
.review-q { background: #1a202c; border: 1px solid #2d3748; border-left: 4px solid #4a5568; border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.review-q.correct { border-left-color: #68d391; }
.review-q.wrong { border-left-color: #fc8181; }
.review-q.skipped { border-left-color: #f6ad55; }
.review-choices { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.review-choice { padding: 8px 12px; border-radius: 6px; background: #0f1117; font-size: 0.88rem; display: flex; gap: 10px; align-items: center; }
.review-choice.is-correct { background: #1f3a26; color: #68d391; font-weight: 600; }
.review-choice.is-user-wrong { background: #3a1f1f; color: #fc8181; }
.review-explain { background: #0f1117; padding: 12px 14px; border-radius: 6px; margin-top: 10px; font-size: 0.88rem; line-height: 1.6; color: #cbd5e0; border-left: 3px solid #b794f4; }

/* Settings page */
.setting-group { background: #1a202c; border: 1px solid #2d3748; border-radius: 12px; padding: 16px 20px; margin-bottom: 16px; }
.setting-group h3 { font-size: 0.85rem; color: #63b3ed; margin-bottom: 12px; font-weight: 700; }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; gap: 12px; }
.setting-row label { font-size: 0.9rem; flex: 1; }
.setting-row input { width: 100px; padding: 6px 10px; background: #0f1117; border: 1px solid #2d3748; border-radius: 6px; color: #e2e8f0; text-align: right; font-size: 0.9rem; }
.setting-row input[type="checkbox"] { width: auto; }
