/* ==========================================================================
   ストイック暗記フラッシュカード専用スタイルシート
   - アニメーション・トランジション完全ゼロ (0.00秒 DOM切替)
   - iOS Safari / PC 1画面完結レイアウト
   - AES-GCM復号認証モーダル＆クラウド同期インジケーター対応
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: none !important;
  animation: none !important;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #0b1120;
  color: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.45;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   パスワード復号＆同期認証モーダル
   ========================================================================== */

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(11, 17, 32, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-icon {
  font-size: 1.35rem;
}

.auth-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8fafc;
}

.auth-desc {
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.45;
}

.auth-input {
  width: 100%;
  padding: 11px 12px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #f8fafc;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.auth-input:focus {
  border-color: #3b82f6;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #cbd5e1;
  cursor: pointer;
}

.auth-remember input {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
}

.auth-error {
  padding: 8px 10px;
  border-radius: 6px;
  background: #7f1d1d;
  border: 1px solid #ef4444;
  color: #fecaca;
  font-size: 0.82rem;
  font-weight: 700;
}

.auth-submit-btn {
  padding: 12px;
  border-radius: 8px;
  background: #2563eb;
  border: 1px solid #60a5fa;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
}

/* ==========================================================================
   ① デッキ選択＆フィルタ画面（ホーム）
   ========================================================================== */

.home-header {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  padding: max(10px, env(safe-area-inset-top)) 16px 0;
  flex-shrink: 0;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 860px;
  margin: 0 auto 10px;
}

.title-group {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.app-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #f8fafc;
}

.course-overall-stats {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
}

.header-sync-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 999px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  white-space: nowrap;
}

.sync-badge.compact {
  padding: 3px 8px;
  font-size: 0.72rem;
}

.sync-badge.synced {
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(22, 101, 52, 0.25);
}

.sync-badge.syncing {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(30, 58, 138, 0.3);
}

.sync-badge.offline {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(120, 53, 15, 0.3);
}

.pw-btn {
  padding: 4px 8px;
  font-size: 0.78rem;
  border-radius: 6px;
  background: #1e293b;
  border: 1px solid #334155;
}

.course-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 860px;
  margin: 0 auto;
}

.course-tab {
  padding: 10px 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #94a3b8;
  background: #1e293b;
  border-radius: 8px 8px 0 0;
  border: 1px solid #334155;
  border-bottom: none;
  text-align: center;
}

.course-tab.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
}

.home-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 892px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e2e8f0;
}

.section-note {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
  padding: 2px 8px;
  border-radius: 999px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
}

.filter-start-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: left;
  border: 1px solid #334155;
  background: #1e293b;
}

.filter-start-btn:active {
  filter: brightness(1.15);
}

.filter-start-btn.primary {
  background: #1d4ed8;
  border-color: #3b82f6;
  color: #ffffff;
}

.filter-start-btn.danger {
  background: #7f1d1d;
  border-color: #dc2626;
  color: #fecaca;
}

.filter-start-btn.challenge {
  background: #78350f;
  border-color: #f59e0b;
  color: #fef3c7;
}

.filter-start-btn.standard {
  background: #1e293b;
  border-color: #475569;
  color: #f1f5f9;
}

.filter-count {
  font-size: 0.82rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  white-space: nowrap;
}

.subtype-filter-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #1e293b;
}

.subtype-label-title {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 8px;
  font-weight: 600;
}

.subtype-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.subtype-btn {
  padding: 7px 11px;
  border-radius: 6px;
  background: #1e293b;
  border: 1px solid #334155;
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.subtype-btn:active {
  background: #334155;
}

.sub-cnt {
  color: #93c5fd;
  font-size: 0.78rem;
}

/* 章別リスト */
.chapter-bulk-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 6px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
}

.mini-btn.danger-outline {
  color: #fca5a5;
  border-color: #7f1d1d;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
}

.chapter-row.unchecked {
  opacity: 0.55;
}

.chapter-check-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-checkbox {
  width: 20px;
  height: 20px;
  accent-color: #2563eb;
  cursor: pointer;
}

.chapter-info {
  min-width: 0;
  cursor: pointer;
}

.chapter-title-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.chapter-code {
  font-size: 0.92rem;
  font-weight: 800;
  color: #f8fafc;
}

.chapter-sub {
  font-size: 0.78rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-stats-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  color: #cbd5e1;
  margin-bottom: 5px;
}

.stat-pill-perfect { color: #4ade80; font-weight: 700; }
.stat-pill-vague   { color: #facc15; font-weight: 700; }
.stat-pill-forgot  { color: #f87171; font-weight: 700; }
.stat-pill-unseen  { color: #94a3b8; }

.progress-track {
  width: 100%;
  height: 7px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #22c55e;
}

.chapter-single-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chapter-play-btn {
  padding: 7px 11px;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 6px;
  background: #2563eb;
  color: #ffffff;
  white-space: nowrap;
}

.chapter-play-all-btn {
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 5px;
  background: #334155;
  color: #cbd5e1;
  white-space: nowrap;
}

/* ==========================================================================
   ② フラッシュカード高速周回画面（1画面完結・スクロール不要）
   ========================================================================== */

#screen-study {
  max-width: 860px;
  margin: 0 auto;
  background: #0b1120;
}

.study-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

.exit-btn {
  padding: 6px 12px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #e2e8f0;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
}

.study-progress-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.progress-fraction {
  font-size: 0.96rem;
  color: #f8fafc;
}

.progress-queue {
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #38bdf8;
}

/* カード＆解答本体 */
.study-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
}

/* 表面エリア */
.card-front {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 12px 14px;
  flex-shrink: 0;
}

.card-badges-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.badges-left, .badges-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 800;
  border-radius: 5px;
}

.subtype-badge {
  background: #1e3a8a;
  color: #93c5fd;
  border: 1px solid #3b82f6;
}

.challenge-badge {
  background: #78350f;
  color: #fde68a;
  border: 1px solid #f59e0b;
}

.status-badge {
  background: #1e293b;
  color: #94a3b8;
  font-size: 0.72rem;
}

.card-id-label {
  font-size: 0.72rem;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.card-prompt {
  font-size: 1.12rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.45;
  margin-bottom: 10px;
  white-space: pre-line;
  user-select: text;
  -webkit-user-select: text;
}

.card-hint-box {
  background: #1e293b;
  border-left: 3px solid #64748b;
  color: #cbd5e1;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 0.84rem;
  line-height: 1.38;
}

.hint-prefix {
  font-weight: 700;
  color: #94a3b8;
  margin-right: 4px;
}

/* 裏面（解答）エリア */
.card-back {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 必須キーワードバッジ（最優先視認：アンバー/ゴールド系ピル型バッジ） */
.keypoints-section {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
}

.keypoints-header {
  font-size: 0.72rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.keypoints-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keypoint-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 9999px;
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
  color: #0f172a;
  font-size: 0.92rem;
  font-weight: 900;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* 正解 */
.answer-section {
  padding: 2px 2px;
}

.answer-header {
  font-size: 0.75rem;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 4px;
}

.card-answer {
  font-size: 1.02rem;
  font-weight: 700;
  color: #f8fafc;
  white-space: pre-line;
  line-height: 1.48;
  user-select: text;
  -webkit-user-select: text;
}

/* 解説＆ページ数 */
.explanation-section {
  border-top: 1px solid #1e293b;
  padding-top: 8px;
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.4;
}

.card-page {
  display: inline-block;
  font-weight: 800;
  color: #cbd5e1;
  background: #1e293b;
  padding: 1px 7px;
  border-radius: 4px;
  margin-right: 6px;
}

/* 下部固定コントローラー（親指エリア固定） */
.study-bottom-bar {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #0f172a;
  border-top: 1px solid #1e293b;
  flex-shrink: 0;
}

.show-answer-btn {
  width: 100%;
  height: 58px;
  border-radius: 10px;
  background: #2563eb;
  border: 1px solid #60a5fa;
  color: #ffffff;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.show-answer-btn:active {
  background: #1d4ed8;
}

.judge-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  height: 58px;
}

.judge-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 4px 6px;
  font-weight: 900;
}

.judge-main {
  font-size: 0.98rem;
  line-height: 1.2;
}

.judge-sub {
  font-size: 0.7rem;
  opacity: 0.88;
  font-weight: 700;
}

.judge-forgot {
  background: #991b1b;
  border: 1px solid #ef4444;
  color: #fef2f2;
}

.judge-vague {
  background: #854d0e;
  border: 1px solid #eab308;
  color: #fefce8;
}

.judge-perfect {
  background: #166534;
  border: 1px solid #22c55e;
  color: #f0fdf4;
}

@media (max-width: 480px) {
  .card-prompt {
    font-size: 1.02rem;
  }
  .card-answer {
    font-size: 0.95rem;
  }
  .keypoint-pill {
    font-size: 0.85rem;
    padding: 3px 10px;
  }
}
