/* =========================================================
   PASS準1 — Apple風 Glassmorphism スタイルシート
========================================================= */

:root {
  --bg-0: #eef1f6;
  --bg-1: #e4e9f2;
  --ink-900: #1d1d1f;
  --ink-700: #3a3a3d;
  --ink-500: #6e6e73;
  --ink-300: #a1a1a6;
  --accent: #0a84ff;
  --accent-2: #5e5ce6;
  --green: #34c759;
  --red: #ff453a;
  --amber: #ff9f0a;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px rgba(31, 38, 60, 0.12);

  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;

  --header-h: 72px;
  --mobile-tab-h: 64px;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  color: var(--ink-900);
  background: linear-gradient(160deg, var(--bg-0), var(--bg-1));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; }
h1, h2, h3, p, ul { margin: 0; }
button, select, input { outline: none; }
a { color: inherit; text-decoration: none; }

/* ---------- 背景の光の玉（装飾） ---------- */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
}
.orb-a { width: 420px; height: 420px; background: #a7c7ff; top: -120px; left: -100px; }
.orb-b { width: 480px; height: 480px; background: #d7b8ff; top: 30%; right: -160px; }
.orb-c { width: 380px; height: 380px; background: #b8f0d0; bottom: -140px; left: 20%; }

/* ---------- Glassmorphism 基本パネル ---------- */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--glass-shadow);
}

.glass-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(14px);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-900);
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.glass-btn:hover { background: rgba(255,255,255,0.75); transform: translateY(-1px); }
.glass-btn.primary { background: var(--accent); color: #fff; border-color: transparent; justify-content: center; font-weight: 600; }
.glass-btn.primary:hover { background: #0a74e0; }
.glass-btn.danger { color: var(--red); }

/* ================= トップバー ================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(255,255,255,0.5);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.5px;
}
.brand-mark-accent { opacity: 0.7; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
.brand-name em { font-style: normal; color: var(--accent); font-weight: 800; }

.tabbar { display: flex; gap: 6px; background: rgba(120,120,128,0.08); padding: 5px; border-radius: 14px; }
.tab-btn {
  display: flex; align-items: center; gap: 8px;
  border: none; background: transparent;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  color: var(--ink-500);
  cursor: pointer;
  transition: all .2s ease;
}
.tab-btn i { font-size: 14px; }
.tab-btn.active { background: #fff; color: var(--ink-900); box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.tab-btn:hover:not(.active) { color: var(--ink-900); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(120,120,128,0.1);
  color: var(--ink-700);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s ease;
}
.icon-btn:hover { background: rgba(120,120,128,0.2); }

.tabbar-mobile { display: none; }

/* ---------- データメニュー ---------- */
.data-menu {
  position: fixed;
  top: 76px; right: 24px;
  width: 300px;
  padding: 20px;
  z-index: 120;
}
.data-menu h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.data-menu-desc { font-size: 12.5px; color: var(--ink-500); margin-bottom: 14px; line-height: 1.5; }
.overlay-scrim { position: fixed; inset: 0; z-index: 110; background: transparent; }

/* ================= メイン & ビュー切替 ================= */
#app { max-width: 1200px; margin: 0 auto; padding: 0 28px 60px; min-height: calc(100vh - var(--header-h)); }
.view { display: none; animation: fadeUp .5s ease; }
.view.active { display: block; }
.view-inner { padding-top: 36px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.6px; }
.page-sub { font-size: 15px; color: var(--ink-500); margin-top: 6px; }
.page-head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

/* ================= ① ダッシュボード ================= */
.overall-progress {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 28px 32px;
  margin-bottom: 34px;
}
.overall-ring { width: 96px; height: 96px; flex-shrink: 0; border-radius: 50%; }
.overall-label { font-size: 13px; color: var(--ink-500); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.overall-numbers { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; margin-top: 4px; }
.overall-sub { font-size: 13px; color: var(--ink-500); margin-top: 2px; }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}
.chapter-card {
  position: relative;
  padding: 24px;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  overflow: hidden;
}
.chapter-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(31,38,60,0.16); }
.chapter-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.chapter-type-chip {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 100px;
  background: rgba(10,132,255,0.12); color: var(--accent);
  text-transform: uppercase; letter-spacing: .4px;
}
.chapter-type-chip.phrase { background: rgba(94,92,230,0.12); color: var(--accent-2); }
.chapter-title { font-size: 20px; font-weight: 800; margin-top: 14px; }
.chapter-range { font-size: 13px; color: var(--ink-500); margin-top: 2px; }
.chapter-ring-wrap { position: absolute; right: 20px; bottom: 20px; width: 56px; height: 56px; }
.chapter-percent { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: var(--ink-900); }

/* ================= ② カード ================= */
.scope-select select {
  padding: 10px 16px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.6); font-size: 14px; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(10px);
}

.card-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 20px;
}
.stage-nav {
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  color: var(--ink-700);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s ease, background .2s ease;
}
.stage-nav:hover { background: #fff; transform: scale(1.06); }
.stage-nav:active { transform: scale(0.94); }

.card-viewport { width: min(560px, 82vw); height: 360px; perspective: 1600px; }
.flip-card { width: 100%; height: 100%; cursor: pointer; position: relative; }
.flip-card-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }

.flip-card.fly-left .flip-card-inner { animation: flyLeft .38s ease forwards; }
.flip-card.fly-right .flip-card-inner { animation: flyRight .38s ease forwards; }
@keyframes flyLeft { to { transform: translateX(-140%) rotate(-8deg); opacity: 0; } }
@keyframes flyRight { to { transform: translateX(140%) rotate(8deg); opacity: 0; } }

.flip-card.shake { animation: shakeAnim .4s ease; }
@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

.flip-face {
  position: absolute; inset: 0;
  border-radius: var(--radius-lg);
  backface-visibility: hidden;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}
.flip-back { transform: rotateY(180deg); }

.card-index {
  position: absolute; top: 20px; left: 24px;
  font-size: 12px; font-weight: 700; color: var(--ink-300); letter-spacing: .5px;
}
.card-chip {
  position: absolute; top: 20px; right: 24px;
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 100px;
  background: rgba(10,132,255,0.12); color: var(--accent);
}
.card-word { font-size: clamp(30px, 6vw, 46px); font-weight: 800; letter-spacing: -1px; color: var(--ink-900); }
.card-word-small { font-size: 22px; font-weight: 700; color: var(--ink-500); margin-bottom: 12px; }
.card-meaning { font-size: clamp(20px, 4vw, 26px); font-weight: 600; line-height: 1.6; color: var(--ink-900); max-width: 420px; }
.flip-hint { position: absolute; bottom: 20px; font-size: 12px; color: var(--ink-300); display: flex; align-items: center; gap: 6px; }

.card-sort-row { display: flex; justify-content: center; gap: 16px; margin-top: 30px; }
.sort-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 30px;
  border-radius: 100px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}
.sort-btn:hover { transform: translateY(-2px); }
.sort-btn.review { color: var(--amber); }
.sort-btn.review:hover { background: rgba(255,159,10,0.15); }
.sort-btn.learned { color: var(--green); }
.sort-btn.learned:hover { background: rgba(52,199,89,0.15); }

.key-hint { text-align: center; font-size: 12.5px; color: var(--ink-300); margin-top: 22px; }

/* glow / feedback effects reused in cards & tests */
.glow-correct { box-shadow: 0 0 0 4px rgba(52,199,89,0.35), var(--glass-shadow) !important; }

/* ================= ③ テスト ================= */
.test-setup { max-width: 560px; margin: 0 auto; padding: 30px; }
.setup-row { margin-bottom: 22px; }
.setup-row label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-500); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .4px; }
.setup-row select {
  width: 100%; padding: 12px 16px; border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08); background: rgba(255,255,255,0.6);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.mode-toggle { display: flex; gap: 10px; }
.mode-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.4); cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-500);
  transition: all .2s ease;
}
.mode-btn.active { background: var(--ink-900); color: #fff; border-color: transparent; }

.test-stage { max-width: 560px; margin: 20px auto 0; }
.test-progressbar { height: 6px; border-radius: 100px; background: rgba(0,0,0,0.08); overflow: hidden; }
.test-progressbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0%; transition: width .3s ease; }
.test-counter { text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-500); margin: 10px 0 20px; }

.quiz-card { padding: 40px 32px; text-align: center; transition: box-shadow .3s ease; }
.quiz-word { font-size: clamp(28px, 6vw, 40px); font-weight: 800; letter-spacing: -0.8px; margin-bottom: 30px; }

.quiz-options { display: grid; gap: 12px; }
.quiz-option {
  padding: 16px 20px; text-align: left;
  border-radius: 14px; border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.5);
  font-size: 15px; font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
}
.quiz-option:hover { background: rgba(255,255,255,0.85); transform: translateX(2px); }
.quiz-option.correct { background: rgba(52,199,89,0.18); border-color: var(--green); color: #1c7a34; font-weight: 700; }
.quiz-option.wrong { background: rgba(255,69,58,0.15); border-color: var(--red); color: #b3261e; font-weight: 700; }
.quiz-option.disabled { pointer-events: none; opacity: .6; }

.self-check { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.self-btn {
  padding: 14px 30px; border-radius: 100px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px;
  transition: transform .15s ease;
}
.self-btn:hover { transform: translateY(-2px); }
.self-btn.reveal { background: var(--ink-900); color: #fff; }
.self-meaning { font-size: 20px; font-weight: 600; color: var(--ink-900); }
.self-actions { display: flex; gap: 14px; }
.self-btn.correct { background: rgba(52,199,89,0.18); color: #1c7a34; }
.self-btn.wrong { background: rgba(255,69,58,0.15); color: #b3261e; }

.test-result { text-align: center; padding: 40px; }
.test-result .result-score { font-size: 48px; font-weight: 800; color: var(--accent); }
.test-result .result-label { font-size: 14px; color: var(--ink-500); margin-top: 6px; }
.test-result .glass-btn { margin-top: 26px; max-width: 240px; margin-left: auto; margin-right: auto; }

/* ================= ④ 辞書 ================= */
.dict-layout {
  display: grid;
  grid-template-columns: 380px 24px 1fr;
  grid-template-rows: 1fr;
  gap: 0;
  margin-top: 30px;
  height: calc(100vh - var(--header-h) - 60px);
  min-height: 560px;
}
.dict-list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding-right: 12px; }
.dict-toolbar { margin-bottom: 14px; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 14px;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  margin-bottom: 12px;
}
.search-box i { color: var(--ink-300); }
.search-box input { border: none; background: transparent; flex: 1; font-size: 15px; color: var(--ink-900); }

.dict-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 7px 14px; border-radius: 100px; border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.4); font-size: 12.5px; font-weight: 600; color: var(--ink-500);
  cursor: pointer; transition: all .2s ease;
}
.filter-chip.active { background: var(--ink-900); color: #fff; border-color: transparent; }

.dict-list { flex: 1; min-height: 0; overflow-y: auto; border-radius: var(--radius-md); }
.dict-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: 14px; cursor: pointer;
  transition: background .15s ease;
  scroll-margin-top: 10px;
}
.dict-item:hover { background: rgba(255,255,255,0.5); }
.dict-item.active { background: rgba(10,132,255,0.12); }
.dict-item-status { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--ink-300); }
.dict-item-status.learned { background: var(--green); }
.dict-item-status.review { background: var(--amber); }
.dict-item-word { font-weight: 700; font-size: 15.5px; min-width: 120px; }
.dict-item-meaning { font-size: 13px; color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dict-empty-msg { text-align: center; color: var(--ink-300); padding: 40px 0; font-size: 14px; }
.dict-group-label {
  font-size: 12px; font-weight: 800; color: var(--ink-300); letter-spacing: 1px;
  padding: 14px 16px 6px; text-transform: uppercase;
}

.dict-az {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}
.dict-az button {
  border: none; background: transparent; color: var(--ink-300);
  font-size: 10.5px; font-weight: 700; cursor: pointer; padding: 2px 4px; border-radius: 4px;
}
.dict-az button:hover, .dict-az button.active { color: var(--accent); background: rgba(10,132,255,0.1); }

.dict-detail-pane { position: relative; padding-left: 12px; min-width: 0; min-height: 0; }
.dict-detail-empty {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink-300); gap: 12px;
}
.dict-detail-empty i { font-size: 40px; }
.dict-detail { height: 100%; overflow-y: auto; padding: 40px; animation: fadeUp .35s ease; }

.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.detail-word { font-size: 38px; font-weight: 800; letter-spacing: -0.8px; }
.detail-no { font-size: 13px; color: var(--ink-300); font-weight: 700; margin-bottom: 6px; }
.detail-status-actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-status-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.5); cursor: pointer; color: var(--ink-500);
  display: flex; align-items: center; justify-content: center; transition: all .2s ease;
}
.detail-status-btn.learned.active { background: var(--green); color: #fff; border-color: transparent; }
.detail-status-btn.review.active { background: var(--amber); color: #fff; border-color: transparent; }

.detail-meaning { font-size: 22px; font-weight: 600; margin-top: 20px; line-height: 1.7; }
.detail-chapter-tag {
  display: inline-block; margin-top: 18px;
  font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 100px;
  background: rgba(94,92,230,0.12); color: var(--accent-2);
}

/* ---------- モバイル用ボトムシート ---------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 200; opacity: 0; transition: opacity .3s ease; }
.bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 201;
  max-height: 78vh; overflow-y: auto;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(30px) saturate(180%);
  border-radius: 26px 26px 0 0;
  padding: 10px 26px 34px;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
}
.bottom-sheet.open { transform: translateY(0); }
.sheet-scrim.open { opacity: 1; }
.sheet-handle { width: 44px; height: 5px; border-radius: 100px; background: rgba(0,0,0,0.15); margin: 6px auto 16px; }

/* ================= トースト ================= */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(29,29,31,0.9); color: #fff; padding: 12px 22px; border-radius: 100px;
  font-size: 13.5px; font-weight: 600; z-index: 500; opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= レスポンシブ ================= */
@media (max-width: 860px) {
  .dict-layout { grid-template-columns: 1fr 20px; }
  .dict-detail-pane { display: none; }
}

@media (max-width: 720px) {
  .tabbar { display: none; }
  .topbar-inner { padding: 0 18px; }
  .tabbar-mobile {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    height: var(--mobile-tab-h);
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid rgba(255,255,255,0.5);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-btn-m {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: none; background: transparent; color: var(--ink-300); font-size: 10.5px; font-weight: 600; cursor: pointer;
  }
  .tab-btn-m i { font-size: 18px; }
  .tab-btn-m.active { color: var(--accent); }
  #app { padding: 0 16px 90px; }
  .view-inner { padding-top: 22px; }
  .page-head h1 { font-size: 26px; }
  .overall-progress { flex-direction: row; padding: 20px; gap: 18px; }
  .overall-ring { width: 72px; height: 72px; }
  .overall-numbers { font-size: 24px; }
  .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .chapter-card { padding: 18px; }
  .card-viewport { width: 88vw; height: 320px; }
  .data-menu { right: 12px; left: 12px; width: auto; }
  .dict-layout { height: auto; min-height: 0; }
  .dict-list { max-height: calc(100vh - 300px); }
}
