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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: #1e293b;
  min-height: 100vh;
  background: #f4f5fb;
  background-image:
    radial-gradient(ellipse 700px 450px at 5% 15%, rgba(99,102,241,0.09) 0%, transparent 100%),
    radial-gradient(ellipse 550px 400px at 92% 25%, rgba(139,92,246,0.07) 0%, transparent 100%),
    radial-gradient(ellipse 600px 500px at 80% 75%, rgba(79,70,229,0.05) 0%, transparent 100%),
    radial-gradient(ellipse 400px 350px at 20% 70%, rgba(165,180,252,0.06) 0%, transparent 100%);
  background-attachment: fixed;
  position: relative;
}

/* Decorative floating dots */
body::before, body::after {
  content: ''; position: fixed; pointer-events: none; z-index: 0;
  border-radius: 50%; opacity: 0.15;
}
body::before {
  width: 120px; height: 120px; background: #a5b4fc;
  top: 8%; left: 3%; animation: floatA 18s ease-in-out infinite;
}
body::after {
  width: 80px; height: 80px; background: #c084fc;
  bottom: 12%; right: 4%; animation: floatB 22s ease-in-out infinite;
}

@keyframes floatA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -30px) scale(1.08); }
  66% { transform: translate(-10px, 20px) scale(0.95); }
}
@keyframes floatB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-25px, 15px) scale(1.05); }
  66% { transform: translate(15px, -20px) scale(0.92); }
}

#app {
  max-width: 800px; margin: 0 auto; min-height: 100vh;
  position: relative; z-index: 1; padding-bottom: 48px;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }

.card {
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  border-radius: 16px; padding: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  margin: 16px; transition: box-shadow 0.2s;
  border: 1px solid rgba(255,255,255,0.6);
}
.card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.07); }

.login-card {
  max-width: 400px; margin: 120px auto 60px; text-align: center;
  animation: slideUp 0.45s ease;
  position: relative;
}
.login-card h1 {
  font-size: 30px; margin-bottom: 4px; color: #0f172a;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle { color: #64748b; font-size: 14px; margin-bottom: 28px; }

.tab-bar {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: #f1f5f9; border-radius: 12px; padding: 4px;
}
.tab-btn {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: transparent; cursor: pointer; font-size: 15px;
  color: #64748b; font-weight: 500; transition: all 0.2s;
}
.tab-btn.active { background: #fff; color: #0f172a; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.form-tab { display: none; }
.form-tab.active { display: flex; flex-direction: column; gap: 14px; }

input[type="text"], input[type="password"], input[type="number"], select {
  padding: 12px 16px; border: 1.5px solid #e2e8f0; border-radius: 12px;
  font-size: 15px; width: 100%; outline: none; background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s; color: #1e293b;
}
input:focus, select:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
input::placeholder { color: #94a3b8; }
.input { padding: 12px 16px; border: 1.5px solid #e2e8f0; border-radius: 12px; font-size: 15px; outline: none; background: #fff; transition: border-color 0.2s, box-shadow 0.2s; color: #1e293b; box-sizing:border-box; }
.input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 22px; border: 1.5px solid #e2e8f0; border-radius: 12px;
  background: #fff; cursor: pointer; font-size: 15px; font-weight: 500;
  color: #475569; transition: all 0.18s; gap: 6px; text-decoration: none;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; border: none;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, #4f46e5, #4338ca); box-shadow: 0 4px 14px rgba(99,102,241,0.35); }
.btn-danger { color: #ef4444; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; border-color: #ef4444; }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.error-msg { color: #ef4444; font-size: 13px; min-height: 20px; }

.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(241,245,249,0.8);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(16px); background: rgba(255,255,255,0.85);
  -webkit-backdrop-filter: blur(16px);
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }
.user-display { font-weight: 600; font-size: 15px; color: #0f172a; }

.badge {
  display: inline-block; padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: #eef2ff; color: #4f46e5;
}

.dashboard-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.stat-card {
  background: rgba(255,255,255,0.9); backdrop-filter: blur(4px);
  border-radius: 14px; padding: 18px 12px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.2s; border: 1px solid rgba(255,255,255,0.5);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-number { font-size: 28px; font-weight: 700; color: #4f46e5; letter-spacing: -1px; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 4px; }

/* ── Home cards ── */
.home-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  padding: 16px; max-width: 800px; margin: 0 auto;
}
.home-card {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(6px);
  border-radius: 20px; padding: 26px 12px 22px;
  text-decoration: none; color: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: all 0.28s cubic-bezier(0.34,1.56,0.64,1);
  border: 1px solid rgba(255,255,255,0.7);
  position: relative; overflow: hidden;
}
.home-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: 20px 20px 0 0;
  transition: height 0.25s;
}
.home-card:hover::before { height: 4px; }
.home-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 32px rgba(79,70,229,0.12);
  border-color: rgba(165,180,252,0.4);
  background: rgba(255,255,255,1);
}

/* Unique accent colors for each card */
.home-card:nth-child(1)::before { background: linear-gradient(90deg, #6366f1, #818cf8); }
.home-card:nth-child(2)::before { background: linear-gradient(90deg, #ec4899, #f472b6); }
.home-card:nth-child(3)::before { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }
.home-card:nth-child(4)::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.home-card:nth-child(5)::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.home-card:nth-child(6)::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.home-card:nth-child(7)::before { background: linear-gradient(90deg, #06b6d4, #22d3ee); }
.home-card:nth-child(8)::before { background: linear-gradient(90deg, #84cc16, #a3e635); }

.home-card:nth-child(1) .home-icon { background: linear-gradient(135deg, #eef2ff, #c7d2fe); }
.home-card:nth-child(2) .home-icon { background: linear-gradient(135deg, #fce7f3, #fbcfe8); }
.home-card:nth-child(3) .home-icon { background: linear-gradient(135deg, #ccfbf1, #99f6e4); }
.home-card:nth-child(4) .home-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.home-card:nth-child(5) .home-icon { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.home-card:nth-child(6) .home-icon { background: linear-gradient(135deg, #fee2e2, #fecaca); }
.home-card:nth-child(7) .home-icon { background: linear-gradient(135deg, #cffafe, #a5f3fc); }
.home-card:nth-child(8) .home-icon { background: linear-gradient(135deg, #ecfccb, #d9f99d); }

.home-icon {
  font-size: 32px; margin-bottom: 12px;
  width: 64px; height: 64px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.home-card:hover .home-icon { transform: scale(1.12) rotate(-3deg); }
.home-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: #0f172a; }
.home-desc { font-size: 11px; color: #94a3b8; line-height: 1.4; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: #475569; }

.unit-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.unit-checkbox {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1.5px solid #e2e8f0; border-radius: 10px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.2s; color: #475569; background: #fff;
}
.unit-checkbox:hover { border-color: #c7d2fe; background: #f8faff; }
.unit-checkbox.selected {
  background: #4f46e5; color: #fff; border-color: #4f46e5;
  box-shadow: 0 2px 8px rgba(79,70,229,0.25);
}
.unit-checkbox input { display: none; }

/* ── Study area ── */
.study-area {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 400px; padding: 32px 24px;
  text-align: center; animation: fadeIn 0.3s ease;
}
.study-word { font-size: 40px; font-weight: 700; margin-bottom: 12px; color: #0f172a; letter-spacing: -0.5px; }
.study-phonetic { font-size: 18px; color: #64748b; margin-bottom: 8px; }
.study-meaning { font-size: 26px; color: #334155; margin-bottom: 16px; font-weight: 600; }
.study-pos { font-size: 14px; color: #94a3b8; margin-bottom: 8px; }
.study-example {
  font-size: 16px; color: #64748b; font-style: italic;
  margin-bottom: 28px; max-width: 500px; line-height: 1.6;
}
.study-input {
  font-size: 24px; padding: 14px 24px;
  border: 2px solid #e2e8f0; border-radius: 14px;
  text-align: center; width: 320px; max-width: 92%;
  outline: none; margin-bottom: 16px; transition: all 0.2s;
  background: #fff; color: #1e293b;
}
.study-input:focus { border-color: #6366f1; box-shadow: 0 0 0 4px rgba(99,102,241,0.12); }
.study-input.correct { color: #16a34a; border-color: #16a34a; background: #f0fdf4; }
.study-input.wrong { color: #dc2626; border-color: #dc2626; background: #fef2f2; }

.choice-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  max-width: 520px; width: 100%; margin: 20px auto;
}
.choice-btn {
  padding: 18px; border: 2px solid #e2e8f0; border-radius: 14px;
  background: #fff; cursor: pointer; font-size: 16px; font-weight: 500;
  transition: all 0.2s; text-align: center; color: #1e293b;
}
.choice-btn:hover { border-color: #a5b4fc; background: #f8faff; transform: translateY(-1px); }
.choice-btn.correct { border-color: #16a34a; background: #f0fdf4; color: #16a34a; }
.choice-btn.wrong { border-color: #dc2626; background: #fef2f2; color: #dc2626; }
.choice-btn.disabled { pointer-events: none; opacity: 0.7; }

.study-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 10px 16px 18px;
  background: rgba(255,255,255,0.88); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(241,245,249,0.6);
}
.progress-bar {
  height: 6px; background: #f1f5f9; border-radius: 3px;
  overflow: hidden; max-width: 800px; margin: 0 auto;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #4f46e5); transition: width 0.4s ease; border-radius: 3px; }

.result-card { max-width: 480px; margin: 60px auto; text-align: center; animation: slideUp 0.4s ease; }
.result-card h2 { font-size: 24px; color: #0f172a; margin-bottom: 20px; }
.result-stats {
  display: flex; justify-content: center; gap: 32px;
  margin: 24px 0; font-size: 16px; color: #475569;
}
.wrong-list { text-align: left; max-height: 240px; overflow-y: auto; }
.wrong-list-item {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px;
  animation: fadeIn 0.3s ease;
}
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.text-center { text-align: center; }
.text-muted { color: #94a3b8; font-size: 13px; }

.review-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.review-stage {
  display: flex; justify-content: space-between;
  padding: 10px 14px; background: #f8fafc; border-radius: 10px;
  margin-bottom: 6px; font-size: 14px; border: 1px solid #f1f5f9;
}
.review-stage-label { color: #64748b; }
.review-stage-count { font-weight: 600; color: #1e293b; }
hr { border: none; border-top: 1px solid #f1f5f9; margin: 20px 0; }

.book-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border: 1px solid #f1f5f9; border-radius: 14px;
  margin-bottom: 10px; transition: all 0.2s;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(4px);
}
.book-card:hover { background: #fafbff; border-color: #e0e7ff; }
.book-card-name { font-size: 15px; font-weight: 600; color: #0f172a; }
.book-card-count { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.book-card-actions { display: flex; gap: 6px; }

.edit-word-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px;
  animation: fadeIn 0.2s ease;
}
.edit-word-item:last-child { border-bottom: none; }
.edit-word-info { flex: 1; line-height: 1.6; }
.edit-word-actions { display: flex; gap: 4px; flex-shrink: 0; }
.edit-word-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ev-word-deleted { opacity: 0.35; text-decoration: line-through; }
.ev-word-added { background: #f0fdf4; border-radius: 8px; padding: 10px; margin: -10px 0; }

.detail-card { max-width: 600px; margin: 40px auto; text-align: center; animation: slideUp 0.35s ease; }
.detail-card hr { margin: 24px 0; }
.detail-card #detail-dict { text-align: left; }
.dict-section {
  margin-bottom: 20px; padding: 16px;
  background: rgba(248,250,252,0.8); backdrop-filter: blur(4px);
  border-radius: 12px; border: 1px solid #f1f5f9;
}
.dict-pos { font-size: 12px; font-weight: 700; color: #6366f1; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.dict-def { font-size: 15px; color: #1e293b; margin-bottom: 4px; line-height: 1.6; }
.dict-example { font-size: 14px; color: #64748b; font-style: italic; padding-left: 14px; margin-bottom: 4px; border-left: 3px solid #c7d2fe; }
.detail-card .study-word { font-size: 44px; }
.detail-card .study-phonetic { font-size: 20px; color: #64748b; margin-bottom: 8px; }
.detail-card .study-pos { font-size: 15px; color: #94a3b8; margin-bottom: 8px; }
.detail-card .study-meaning { font-size: 28px; color: #334155; margin: 16px 0; }
.detail-card .study-example { font-size: 17px; color: #64748b; font-style: italic; margin-bottom: 32px; }

#settings-area .card { animation: slideUp 0.3s ease; }

/* Homepage bottom filler to eliminate blank space */
#screen-home.active {
  min-height: calc(100vh - 60px);
  display: flex; flex-direction: column;
}
#screen-home.active .card:last-of-type {
  margin-bottom: 40px;
}

@media (max-width: 640px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .choice-grid { grid-template-columns: 1fr; }
  .result-stats { flex-direction: column; gap: 10px; }
  .study-word { font-size: 28px; }
  .study-input { width: 100%; }
  .login-card { margin: 60px 16px 40px; }
  .home-icon { width: 54px; height: 54px; font-size: 28px; }
  .detail-card .study-word { font-size: 32px; }
  .edit-word-inputs { grid-template-columns: 1fr; }
}

/* Modal / Overlay dialog */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-dialog {
  background: #fff; border-radius: 16px; width: 90%; max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: slideUp 0.25s ease;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 0; font-size: 18px;
}
.modal-body { padding: 16px 24px 24px; }
.notif-badge { display:inline-block; background:#ef4444; color:#fff; font-size:11px; min-width:18px; height:18px; border-radius:9px; text-align:center; line-height:18px; vertical-align:top; margin-left:4px; }
