@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&display=swap');

/* ── カラーパレット ─────────────────────────── */
:root {
  --bg:            #FAF7F4;
  --surface:       #FFFFFF;
  --surface2:      #F8F1ED;
  --primary:       #D4877A;
  --primary-dark:  #BF6B5E;
  --primary-light: #F5DDD9;
  --secondary:     #C4A882;
  --accent:        #EDD5CC;
  --text:          #4A3728;
  --text-mid:      #7D6355;
  --muted:         #B5A097;
  --border:        #EDE0D8;
  --success:       #9DC4A0;
  --success-bg:    #EBF5EC;
  --warning:       #E8C98A;
  --warning-bg:    #FDF5E4;
  --danger:        #E08888;
  --danger-bg:     #FAEAEA;
  --shadow:        rgba(180,130,110,0.12);
  --shadow-md:     rgba(180,130,110,0.20);
}

/* ── ベース ────────────────────────────────── */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

body {
  font-family: 'Nunito', 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  padding-bottom: 88px;
  -webkit-font-smoothing: antialiased;
}

/* ── ヘッダー ───────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250,247,244,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 { font-size: 19px; font-weight: 800; color: var(--text); }
.header-right {
  font-size: 14px; font-weight: 700; color: var(--primary);
  background: var(--primary-light);
  padding: 5px 12px; border-radius: 20px;
}

/* ── ページ ─────────────────────────────────── */
.page { display:none; padding:20px 16px; }
.page.active { display:block; }

/* ── カード ─────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: 20px; padding: 18px 16px; margin-bottom: 14px;
  box-shadow: 0 2px 12px var(--shadow);
  border: 1px solid var(--border);
}

/* ── ヒーローカード ─────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, #EDD5CC 0%, #E0BDB0 60%, #CFA090 100%);
  border-radius: 24px; padding: 24px 20px; margin-bottom: 16px;
  position: relative; overflow: hidden;
  box-shadow: 0 6px 24px rgba(180,100,80,0.22);
}
.hero-card::before {
  content: ''; position: absolute;
  top: -40px; right: -30px; width: 130px; height: 130px;
  background: rgba(255,255,255,0.14); border-radius: 50%;
}
.hero-card::after {
  content: ''; position: absolute;
  bottom: -25px; left: 10px; width: 90px; height: 90px;
  background: rgba(255,255,255,0.09); border-radius: 50%;
}
.hero-card h2 { font-size: 20px; font-weight: 900; color: #fff; margin-bottom: 4px; }
.hero-card p  { font-size: 13px; color: rgba(255,255,255,0.85); margin-bottom: 16px; }
.hero-due {
  background: rgba(255,255,255,0.25); border-radius: 16px;
  padding: 12px 16px; display: flex; align-items: center; gap: 14px;
}
.hero-due .num  { font-size: 38px; font-weight: 900; color: #fff; line-height: 1; }
.hero-due .label { font-size: 14px; color: rgba(255,255,255,0.92); font-weight: 700; }

/* ── 統計グリッド ──────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.stat-card {
  background: var(--surface); border-radius: 18px;
  padding: 16px 14px; text-align: center;
  box-shadow: 0 2px 10px var(--shadow); border: 1px solid var(--border);
}
.stat-card .num   { font-size: 26px; font-weight: 900; color: var(--primary); margin-bottom: 4px; }
.stat-card .label { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ── ボタン ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; border-radius: 16px;
  font-family: inherit; font-weight: 700; cursor: pointer;
  transition: all 0.18s; font-size: 15px; padding: 13px 20px;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 4px 16px rgba(180,80,70,0.30);
}
.btn-secondary { background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); }
.btn-success {
  background: linear-gradient(135deg, #9DC4A0, #7FB385);
  color: #fff; box-shadow: 0 4px 12px rgba(100,160,100,0.25);
}
.btn-ghost { background: transparent; color: var(--text-mid); border: 1.5px solid var(--border); }
.btn-full { width: 100%; }

/* ── フラッシュカード ──────────────────────── */
.flashcard {
  background: var(--surface); border-radius: 24px;
  padding: 32px 20px 28px; margin-bottom: 16px;
  box-shadow: 0 6px 28px var(--shadow-md);
  border: 1.5px solid var(--border);
  cursor: pointer; transition: transform 0.15s;
  min-height: 290px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; position: relative;
}
.flashcard:active { transform: scale(0.98); }
.flashcard-front, .flashcard-back { width: 100%; }
.flashcard-back { display: none; }
.flashcard.flipped .flashcard-front { display: none; }
.flashcard.flipped .flashcard-back { display: block; }

.word     { font-size: 34px; font-weight: 900; color: var(--text); margin-bottom: 6px; line-height: 1.2; }
.phonetic { font-size: 16px; color: var(--muted); margin-bottom: 14px; font-style: italic; }
.katakana { font-size: 15px; color: var(--secondary); font-weight: 600; margin-bottom: 10px; }
.meaning-ja { font-size: 22px; font-weight: 800; color: var(--primary); margin: 12px 0 6px; }
.meaning-en { font-size: 14px; color: var(--text-mid); margin-bottom: 10px; line-height: 1.5; }
.example-en {
  font-size: 13px; color: var(--muted); font-style: italic;
  background: var(--surface2); border-radius: 12px;
  padding: 10px 12px; margin-top: 8px; line-height: 1.6;
}
.tap-hint { font-size: 12px; color: var(--muted); margin-top: 20px; font-weight: 600; }
.level-badge {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; background: var(--surface2); color: var(--muted);
}

/* ── 発音ボタン ────────────────────────────── */
.listen-row { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.listen-btn {
  background: var(--primary-light); color: var(--primary-dark);
  border: none; border-radius: 12px; padding: 8px 16px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.listen-btn:active { transform: scale(0.95); background: var(--accent); }

/* ── 評価ボタン ────────────────────────────── */
.rating-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rating-btn {
  border: none; border-radius: 18px; padding: 14px 8px;
  font-size: 12px; font-family: inherit; font-weight: 700;
  cursor: pointer; line-height: 1.5; transition: all 0.15s;
}
.rating-btn:active { transform: scale(0.96); }
.rating-btn small { font-weight: 500; opacity: 0.8; }
.rating-forgot  { background: var(--danger-bg);  color: var(--danger); }
.rating-hazy    { background: var(--warning-bg); color: #B88A30; }
.rating-perfect { background: var(--success-bg); color: #4A8A52; }

/* ── プログレスバー ────────────────────────── */
.review-progress { margin-bottom: 16px; }
.review-progress-bar {
  height: 6px; background: var(--border); border-radius: 6px;
  overflow: hidden; margin-bottom: 8px;
}
.review-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #E8A598);
  border-radius: 6px; transition: width 0.4s ease;
}
.review-progress-info {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); font-weight: 600;
}

/* ── 通知バナー ────────────────────────────── */
.notif-banner {
  display: none; background: linear-gradient(135deg, var(--primary-light), var(--accent));
  padding: 12px 16px; align-items: center; justify-content: space-between; gap: 12px;
}
.notif-banner.show { display: flex; }
.notif-banner p { font-size: 13px; color: var(--text); font-weight: 600; }
.notif-banner button {
  background: var(--primary); color: #fff; border: none;
  border-radius: 10px; padding: 7px 14px; font-size: 13px;
  font-weight: 700; cursor: pointer; font-family: inherit; flex-shrink: 0;
}

/* ── 入力フォーム ───────────────────────────── */
.input-group { margin-bottom: 14px; }
.input-group label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--muted); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
input[type="text"], textarea {
  width: 100%; border: 1.5px solid var(--border);
  border-radius: 14px; padding: 12px 14px;
  font-size: 15px; font-family: inherit;
  color: var(--text); background: var(--surface);
  outline: none; transition: border-color 0.2s;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
input::placeholder { color: var(--muted); }

.search-row { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-end; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }

/* ── 検索結果エリア ─────────────────────────── */
.lookup-result {
  background: var(--surface); border: 1.5px solid var(--primary-light);
  border-radius: 20px; padding: 18px 16px; margin-top: 16px; display: none;
}
.lookup-result.visible { display: block; }

/* ── 単語リスト ────────────────────────────── */
.search-input-wrap { position: relative; margin-bottom: 12px; }
.search-input-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; stroke: var(--muted);
}
.search-input-wrap input { padding-left: 40px; }

.filter-row {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 6px 14px; font-size: 12px;
  font-weight: 700; color: var(--muted); cursor: pointer;
  font-family: inherit; white-space: nowrap; transition: all 0.15s;
}
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.word-item {
  background: var(--surface); border-radius: 18px;
  padding: 14px 16px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px var(--shadow); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s;
}
.word-item:active { transform: scale(0.99); }
.word-item-left { flex: 1; min-width: 0; }
.word-item-word { font-size: 16px; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.word-item-meaning { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.word-item-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── 設定 ────────────────────────────────── */
.settings-section {
  background: var(--surface); border-radius: 20px; padding: 18px 16px;
  margin-bottom: 14px; box-shadow: 0 2px 10px var(--shadow); border: 1px solid var(--border);
}
.settings-section h3 {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px;
}
.settings-row { display: flex; flex-direction: column; gap: 12px; }
.settings-item { display: flex; align-items: center; gap: 12px; }
.settings-item .icon { font-size: 22px; flex-shrink: 0; }
.settings-item .info { flex: 1; }
.settings-item .info .title { font-size: 14px; font-weight: 700; color: var(--text); }
.settings-item .info .sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── トグル ─────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 26px; transition: 0.3s; cursor: pointer;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; left: 3px; top: 3px;
  transition: 0.3s; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── ボトムナビ ────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex; padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 6px 4px;
  background: none; border: none; font-family: inherit;
  font-size: 10px; font-weight: 700; color: var(--muted);
  cursor: pointer; transition: color 0.15s; position: relative;
}
.nav-item svg { width: 22px; height: 22px; stroke-width: 2; transition: stroke 0.15s; }
.nav-item.active { color: var(--primary); }
.nav-item.active svg { stroke: var(--primary); }
.nav-badge {
  position: absolute; top: 2px; right: calc(50% - 18px);
  background: var(--primary); color: #fff;
  font-size: 9px; font-weight: 800;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ── モーダル ───────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(74,55,40,0.35); backdrop-filter: blur(4px);
  z-index: 200; align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  width: 100%; max-height: 82vh; overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── トースト ───────────────────────────────── */
.toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff;
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 700;
  opacity: 0; transition: all 0.3s;
  z-index: 300; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 完了画面 ───────────────────────────────── */
.session-complete { text-align: center; padding: 40px 20px; }
.session-complete .big-emoji { font-size: 64px; margin-bottom: 16px; }
.session-complete h2 { font-size: 24px; font-weight: 900; margin-bottom: 8px; }
.session-complete p  { color: var(--muted); font-size: 15px; margin-bottom: 24px; line-height: 1.6; }

/* ── 忘却曲線ステップ ──────────────────────── */
.curve-steps { display: flex; justify-content: space-between; gap: 6px; margin-top: 12px; }
.curve-step {
  flex: 1; text-align: center; background: var(--surface2);
  border-radius: 14px; padding: 10px 4px;
}
.curve-step .step-emoji { font-size: 20px; margin-bottom: 4px; }
.curve-step .step-day   { font-size: 11px; font-weight: 800; color: var(--text); }

/* ── Firebase ───────────────────────────────── */
.firebase-input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-size: 13px; font-family: inherit;
  color: var(--text); background: var(--bg); outline: none; margin-bottom: 8px;
}
.firebase-input:focus { border-color: var(--primary); }
.firebase-setup { width: 100%; margin-top: 12px; }

a { color: var(--primary); }
