/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #22c55e;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --radius: 16px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  padding-bottom: 70px;
}

a { text-decoration: none; color: inherit; }

/* ===== App Container ===== */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Header ===== */
.header {
  background: var(--primary);
  color: white;
  padding: 48px 20px 24px;
  text-align: center;
  border-radius: 0 0 24px 24px;
  margin: 0 -16px;
}

.header h1 { font-size: 28px; font-weight: 700; }
.header .subtitle { color: var(--primary-light); margin-top: 4px; font-size: 16px; }

.header.with-back {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
}

.back-btn { font-size: 24px; color: white; }
.header-info { font-size: 14px; color: var(--primary-light); }

/* ===== Progress ===== */
.progress-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--gray-600);
}

.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-detail {
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 8px;
}

/* ===== Features Grid ===== */
.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.feature-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.feature-card:active { transform: scale(0.96); }
.feature-card .icon { font-size: 40px; display: block; margin-bottom: 8px; }
.feature-card h2 { font-size: 16px; color: var(--gray-800); margin-bottom: 4px; }
.feature-card p { font-size: 12px; color: var(--gray-400); }

/* ===== Buttons ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  flex: 1;
  padding: 16px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--gray-600);
  cursor: pointer;
}

.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Tab Bar ===== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  max-width: 480px;
  margin: 0 auto;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
  color: var(--gray-400);
  padding: 4px 12px;
}

.tab span { font-size: 10px; margin-top: 2px; }
.tab.active { color: var(--primary); }
.tab:first-child { font-size: 20px; }

/* ===== Word Card (Learn) ===== */
.word-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
}

.word-card {
  background: white;
  border-radius: 24px;
  padding: 40px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  width: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.word-card .hint { font-size: 12px; color: var(--gray-400); margin-bottom: 16px; }

.word-text {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.word-phonetic { font-size: 18px; color: var(--gray-400); margin-bottom: 24px; }

.word-meaning { animation: fadeIn 0.3s ease; }

.meaning-text { font-size: 28px; font-weight: 600; color: var(--gray-800); margin-bottom: 16px; }

.example-box {
  background: var(--gray-50);
  border-radius: 12px;
  padding: 16px;
}

.example-text { font-size: 16px; color: var(--primary); font-style: italic; }

.tap-hint { font-size: 14px; color: var(--primary); margin-top: 24px; }

.hidden { display: none; }

.nav-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 24px;
}

/* ===== Chat ===== */
.scene-bar {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  overflow-x: auto;
}

.scene-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}

.scene-btn.active { background: var(--primary); color: white; }

.chat-messages {
  flex: 1;
  padding: 16px 0;
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
}

.message { display: flex; margin-bottom: 12px; }
.message.user { justify-content: flex-end; }
.message.ai { justify-content: flex-start; }

.bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
}

.message.user .bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.ai .bubble {
  background: white;
  border: 1px solid var(--gray-200);
  border-bottom-left-radius: 4px;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 0;
}

.chat-input input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 24px;
  font-size: 16px;
  outline: none;
}

.chat-input input:focus { border-color: var(--primary); }

.btn-send {
  padding: 14px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  cursor: pointer;
}

/* ===== Stories (Read) ===== */
.story-list { padding: 16px 0; }

.story-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.story-card h3 { font-size: 18px; margin-bottom: 4px; }
.story-level {
  display: inline-block;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.story-content {
  font-size: 15px;
  line-height: 1.8;
  color: var(--gray-800);
  margin-bottom: 12px;
}

.story-translation {
  font-size: 14px;
  color: var(--gray-600);
  background: var(--gray-50);
  padding: 12px;
  border-radius: 8px;
  display: none;
}

.story-translation.show { display: block; }

.toggle-translation {
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
}

/* ===== Test ===== */
.test-container { padding: 24px 0; }

.question-card {
  background: white;
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.question-word { font-size: 42px; font-weight: 700; color: var(--primary-dark); }
.question-hint { font-size: 12px; color: var(--gray-400); margin-bottom: 8px; }

.options { display: flex; flex-direction: column; gap: 10px; }

.option-btn {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.option-btn:active { transform: scale(0.98); }
.option-btn.correct { background: #f0fdf4; border-color: var(--success); color: #166534; }
.option-btn.wrong { background: #fef2f2; border-color: var(--danger); color: #991b1b; }
.option-btn.disabled { pointer-events: none; opacity: 0.6; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: white;
  border-radius: 24px;
  padding: 40px;
  text-align: center;
  max-width: 320px;
  width: 90%;
}

.result-emoji { font-size: 64px; margin-bottom: 16px; }
.result-score { font-size: 48px; font-weight: 700; color: var(--primary); margin: 16px 0; }
.result-msg { color: var(--gray-600); margin-bottom: 24px; }

/* ===== Profile ===== */
.profile-card {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.avatar {
  width: 80px;
  height: 80px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 12px;
  cursor: pointer;
  transition: transform 0.2s;
}

.avatar.clickable:hover {
  transform: scale(1.1);
}

.avatar.clickable::after {
  content: '✏️';
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 14px;
}

.user-id {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.profile-card h2 { font-size: 20px; margin-bottom: 4px; }
.join-date { font-size: 14px; color: var(--gray-400); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-num { display: block; font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--gray-400); }

.settings-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
}

.setting-item:last-child { border-bottom: none; }
.setting-item .arrow { color: var(--gray-400); }

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
