/* =====================================================================
   PYOL マインドミラー 公開ページ CSS（モバイルファースト・完全レスポンシブ）
   ===================================================================== */

/* ベースリセット & ボックスモデル */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;                       /* iOSのズーム発火を防ぐ16px基準 */
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Meiryo", sans-serif;
  background: #F4F6F8;
  color: #212121;
  line-height: 1.7;
  font-size: 16px;
  min-height: 100vh;
  min-height: 100dvh;                    /* iOSビューポート対応 */
  padding-bottom: env(safe-area-inset-bottom);
  /* PWA bottom-nav 分のスペース確保 */
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* PCではボトムナビ分のpaddingを除去 */
@media (min-width: 768px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

a { color: #1E3A5F; text-decoration: none; }
a:hover { text-decoration: underline; }
a:active { opacity: 0.7; }

img, svg { max-width: 100%; height: auto; }

/* =====================================================================
   ヘッダー（上部固定）
   ===================================================================== */
header.site {
  background: #1E3A5F;
  color: white;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

header.site .container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  gap: 12px;
  position: relative;
}

header.site .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 700;
  font-size: 15px;
}
header.site .brand:hover { text-decoration: none; }
header.site .brand .mark {
  width: 26px; height: 26px;
  border: 2px solid white;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}
header.site .brand .mark::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 7px; height: 7px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* PC のヘッダーナビ（スマホは非表示でボトムナビへ） */
header.site nav {
  display: none;
}
@media (min-width: 768px) {
  header.site nav { display: flex; gap: 4px; align-items: center; }
  header.site nav a {
    color: white;
    padding: 8px 14px;
    font-size: 13px;
    opacity: 0.9;
    border-radius: 6px;
    transition: background 0.15s, opacity 0.15s;
  }
  header.site nav a:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
  }
  header.site nav a.active {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
  }
}

/* =====================================================================
   ボトムナビゲーション（モバイル専用）
   ===================================================================== */
nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #E0E0E0;
  display: flex;
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
}

nav.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  color: #6C757D;
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  min-height: 56px;
  transition: color 0.15s;
}
nav.bottom-nav a:hover { text-decoration: none; }
nav.bottom-nav a:active { background: rgba(30, 58, 95, 0.05); }

nav.bottom-nav a .icon {
  font-size: 22px;
  margin-bottom: 2px;
  line-height: 1;
}
nav.bottom-nav a.active {
  color: #1E3A5F;
  font-weight: 700;
}
nav.bottom-nav a.active .icon { filter: drop-shadow(0 0 0 #1E3A5F); }

@media (min-width: 768px) {
  nav.bottom-nav { display: none; }
}

/* =====================================================================
   メインコンテンツ
   ===================================================================== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}
@media (min-width: 768px) {
  main { padding: 32px 24px; }
}

h1 { color: #1E3A5F; font-size: 24px; margin-bottom: 12px; font-weight: 700; line-height: 1.4; }
h2 { color: #1E3A5F; font-size: 18px; margin: 20px 0 10px; font-weight: 700; line-height: 1.5; }
h3 { color: #1E3A5F; font-size: 16px; margin: 14px 0 8px; font-weight: 600; }
p { margin-bottom: 12px; line-height: 1.8; }

@media (min-width: 768px) {
  h1 { font-size: 28px; margin-bottom: 16px; }
  h2 { font-size: 20px; }
  h3 { font-size: 17px; }
}

/* =====================================================================
   カード
   ===================================================================== */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  padding: 16px;
  margin-bottom: 14px;
}
@media (min-width: 768px) {
  .card { padding: 20px; margin-bottom: 16px; }
}

/* =====================================================================
   フォーム
   ===================================================================== */
.input-group { margin-bottom: 14px; }

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #444;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="tel"], input[type="url"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 14px 12px;
  border: 1px solid #DDD;
  border-radius: 8px;
  font-size: 16px;                       /* iOSズーム防止のため16px必須 */
  font-family: inherit;
  background: white;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1E3A5F;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}
textarea { resize: vertical; min-height: 120px; }

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23666' d='M0 0l6 8 6-8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* チェックボックス・ラジオの大きさ */
input[type="checkbox"], input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: #1E3A5F;
  cursor: pointer;
}

/* =====================================================================
   ボタン
   ===================================================================== */
.btn {
  display: inline-block;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  font-family: inherit;
  text-align: center;
  min-height: 48px;                      /* タップ最小サイズ */
  line-height: 1.4;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.primary { background: #1E3A5F; color: white; }
.btn.primary:hover { background: #2D4D7F; text-decoration: none; }

.btn.secondary {
  background: white;
  color: #1E3A5F;
  border: 2px solid #1E3A5F;
}
.btn.secondary:hover { background: #F4F6F8; text-decoration: none; }

.btn.danger { background: #D32F2F; color: white; }
.btn.danger:hover { background: #B71C1C; text-decoration: none; }

.btn.large {
  width: 100%;
  padding: 16px 24px;
  font-size: 17px;
  min-height: 56px;
}

.btn.small {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
}

/* =====================================================================
   バッジ
   ===================================================================== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.danger { background: #FFEBEE; color: #C62828; }
.badge.warning { background: #FFF3E0; color: #E65100; }
.badge.safe { background: #E8F5E9; color: #2E7D32; }
.badge.neutral { background: #ECEFF1; color: #455A64; }
.badge.info { background: #E3F2FD; color: #1565C0; }

/* =====================================================================
   アラート
   ===================================================================== */
.alert {
  padding: 14px 16px;
  border-radius: 8px;
  margin: 14px 0;
  font-size: 14px;
  line-height: 1.7;
}
.alert h3 { margin-top: 0; margin-bottom: 8px; color: inherit; font-size: 15px; }
.alert p { margin-bottom: 6px; }
.alert.danger { background: #FFEBEE; border-left: 4px solid #D32F2F; color: #C62828; }
.alert.warning { background: #FFF3E0; border-left: 4px solid #F57C00; color: #E65100; }
.alert.safe { background: #E8F5E9; border-left: 4px solid #388E3C; color: #2E7D32; }
.alert.neutral { background: #ECEFF1; border-left: 4px solid #607D8B; color: #455A64; }

/* =====================================================================
   チェックリスト
   ===================================================================== */
.check-item {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 56px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.check-item:hover { background: #F8F9FA; }
.check-item:active { background: #EEF1F4; }
.check-item input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin-top: 1px;
  cursor: pointer;
  flex-shrink: 0;
}
.check-item label { margin: 0; cursor: pointer; flex: 1; font-weight: 400; font-size: 15px; line-height: 1.6; }
.check-item .cat {
  font-size: 11px;
  color: #999;
  margin-left: 8px;
  white-space: nowrap;
}

/* =====================================================================
   ローダー
   ===================================================================== */
.loader {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid #E0E0E0;
  border-top-color: #1E3A5F;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   ヒーロー / CTA
   ===================================================================== */
.hero {
  background: linear-gradient(135deg, #0F1F33 0%, #1E3A5F 100%);
  color: white;
  padding: 36px 16px;
  text-align: center;
  margin: -20px -16px 20px;               /* mainのpaddingを打ち消す */
  border-radius: 0 0 16px 16px;
}
.hero h1 { color: white; font-size: 26px; margin-bottom: 8px; }
.hero .tagline { font-size: 16px; opacity: 0.9; }
@media (min-width: 768px) {
  .hero { padding: 56px 24px; margin: -32px -24px 32px; }
  .hero h1 { font-size: 34px; }
  .hero .tagline { font-size: 18px; }
}

.cta {
  background: #1E3A5F;
  color: white;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  margin-top: 24px;
}
.cta h3 { color: white; font-size: 16px; }
.cta p { color: rgba(255, 255, 255, 0.9); margin-bottom: 14px; font-size: 14px; }

/* =====================================================================
   教材リスト
   ===================================================================== */
.lesson-list { list-style: none; padding: 0; }
.lesson-list li {
  background: white;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  min-height: 64px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.lesson-list li:hover { transform: translateX(2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.lesson-list li:active { transform: scale(0.99); }
.lesson-list .num {
  width: 38px; height: 38px;
  background: #1E3A5F;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.lesson-list .title { font-weight: 700; margin-bottom: 2px; font-size: 15px; }
.lesson-list .meta { font-size: 12px; color: #666; }

/* =====================================================================
   結果カード
   ===================================================================== */
.result-stage {
  text-align: center;
  padding: 28px 16px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.result-stage .label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 8px;
}
.result-stage .stage {
  font-size: 22px;
  font-weight: 700;
  color: white;
  margin-bottom: 10px;
  line-height: 1.4;
}
.result-stage .desc {
  color: rgba(255, 255, 255, 0.95);
  font-size: 14px;
  line-height: 1.7;
}
.result-stage.danger { background: #D32F2F; }
.result-stage.warning { background: #F57C00; }
.result-stage.safe { background: #388E3C; }
@media (min-width: 768px) {
  .result-stage .stage { font-size: 26px; }
  .result-stage .desc { font-size: 15px; }
}

/* =====================================================================
   フッター
   ===================================================================== */
footer.site {
  background: #1E3A5F;
  color: white;
  padding: 28px 16px;
  text-align: center;
  font-size: 13px;
  opacity: 0.95;
  margin-top: 32px;
}
footer.site a { color: white; opacity: 0.85; margin: 0 8px; display: inline-block; padding: 6px 4px; }
footer.site a:active { opacity: 1; }
footer.site .copy { font-size: 11px; opacity: 0.6; margin-top: 14px; }

/* =====================================================================
   PWA インストールバナー
   ===================================================================== */
#install-banner {
  position: fixed;
  bottom: 80px;
  left: 12px;
  right: 12px;
  background: #1E3A5F;
  color: white;
  border-radius: 12px;
  padding: 14px 16px;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 80;
  font-size: 14px;
  animation: slideUp 0.3s ease-out;
}
#install-banner.show { display: flex; }
#install-banner .text { flex: 1; }
#install-banner .text strong { display: block; margin-bottom: 2px; }
#install-banner button {
  background: white;
  color: #1E3A5F;
  border: 0;
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
#install-banner .close {
  background: transparent;
  color: white;
  opacity: 0.6;
  padding: 8px;
  font-size: 18px;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@media (min-width: 768px) {
  #install-banner { bottom: 24px; right: 24px; left: auto; max-width: 360px; }
}

/* =====================================================================
   モーダル（ログイン・確認等の共通）
   ===================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 31, 51, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: modalFadeIn 0.2s ease-out;
}
@media (min-width: 480px) {
  .modal-backdrop { align-items: center; }
}
.modal-backdrop.show { display: flex; }
@keyframes modalFadeIn {
  from { background: rgba(15, 31, 51, 0); backdrop-filter: blur(0); }
  to   { background: rgba(15, 31, 51, 0.55); backdrop-filter: blur(6px); }
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: modalSlideUp 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes modalSlideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal h2 {
  color: #1E3A5F;
  font-size: 20px;
  margin-bottom: 4px;
  margin-top: 0;
}
.modal .modal-subtitle {
  font-size: 13px;
  color: #666;
  margin-bottom: 16px;
}
.modal .close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 0;
  font-size: 28px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal .close-btn:hover { background: #F4F6F8; color: #555; }
.modal .modal-footer-links {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
}
.modal .modal-footer-links a { margin: 0 8px; }

/* ヘッダー右上の認証ボタン */
.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 0;
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s;
}
.auth-btn:hover { background: rgba(255, 255, 255, 0.25); }
.auth-btn:active { transform: scale(0.96); }
.auth-btn .auth-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  color: #1E3A5F;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
}

/* ユーザーメニュー（ドロップダウン） */
.user-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  min-width: 200px;
  margin-top: 8px;
  padding: 8px;
  z-index: 200;
  display: none;
  animation: modalSlideUp 0.18s ease-out;
}
.user-menu.show { display: block; }
.user-menu .menu-header {
  padding: 8px 12px 12px;
  border-bottom: 1px solid #EEE;
  margin-bottom: 4px;
}
.user-menu .menu-header .name { font-weight: 700; color: #1E3A5F; font-size: 14px; }
.user-menu .menu-header .email { font-size: 11px; color: #888; }
.user-menu a, .user-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  color: #1E3A5F;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.user-menu a:hover, .user-menu button:hover {
  background: #F4F6F8;
  text-decoration: none;
}
.user-menu .danger { color: #C62828; }

/* =====================================================================
   その他ユーティリティ
   ===================================================================== */
.text-muted { color: #666; }
.text-center { text-align: center; }
.text-small { font-size: 13px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.no-margin { margin: 0; }

details summary {
  cursor: pointer;
  color: #1E3A5F;
  font-weight: 600;
  padding: 8px 0;
  min-height: 32px;
}
details summary:hover { text-decoration: underline; }

table { width: 100%; border-collapse: collapse; }
table th, table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #EEE;
  font-size: 14px;
}
table th { background: #F8F9FA; font-weight: 600; font-size: 13px; }

/* スクロール最適化 */
* { -webkit-overflow-scrolling: touch; }

/* フォーカスリング */
:focus-visible {
  outline: 3px solid #4A6FA5;
  outline-offset: 2px;
}
