/* =========================================================
   自律神経バランスケア スタイルシート
   モバイル優先・落ち着いた配色（セージグリーン×ソフトベージュ）
   ========================================================= */

:root {
  --primary: #4f7c72;
  --primary-dark: #3d625a;
  --primary-light: #e8f1ee;
  --accent: #c9a26b;
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #2f3b38;
  --text-sub: #6b7a76;
  --danger: #b3574f;
  --danger-light: #f9ecea;
  --border: #e3e0d8;
  --shadow: 0 2px 10px rgba(47, 59, 56, 0.08);
  --radius: 16px;
  --nav-height: 64px;
  --header-height: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

/* ---------- ヘッダー ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  display: flex;
  align-items: center;
}
.header-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { font-size: 26px; }
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.brand-sub { font-size: 10px; color: var(--text-sub); letter-spacing: 0.05em; }

.emergency-btn {
  flex-shrink: 0;
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #e8c9c5;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.emergency-btn:active { opacity: 0.7; }

/* ---------- メイン ---------- */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.view { display: none; animation: fadeIn 0.25s ease; }
.view.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-title { font-size: 20px; margin-bottom: 6px; }
.view-desc { font-size: 13px; color: var(--text-sub); margin-bottom: 16px; }
.section-title { font-size: 15px; margin: 22px 0 10px; }

/* ---------- カード・ボタン ---------- */
.hero-card, .card, .info-card, .knowledge-card, .form-card,
.breath-session-card, .relax-block, .history-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.hero-card {
  background: linear-gradient(135deg, #5b8d82 0%, #4f7c72 55%, #467067 100%);
  color: #fff;
  padding: 22px 18px;
}
.hero-card .today-label { font-size: 12px; opacity: 0.85; }
.hero-card .greeting { font-size: 22px; margin: 4px 0 6px; }
.hero-card .hero-text { font-size: 13px; opacity: 0.92; margin-bottom: 14px; }
.streak-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.streak-badge {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.btn-block:first-of-type { margin-top: 0; }

/* ---------- ホーム: おすすめリスト ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.recommend-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border: none;
  text-align: left;
  font-family: inherit;
  width: 100%;
}
.recommend-card:active { opacity: 0.8; }
.rec-icon { font-size: 28px; flex-shrink: 0; }
.rec-body { flex: 1; min-width: 0; }
.rec-title { font-size: 14px; font-weight: 700; }
.rec-desc { font-size: 12px; color: var(--text-sub); }

/* ---------- ホーム: クイックメニュー ---------- */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.quick-card:active { opacity: 0.8; }
.quick-icon { font-size: 28px; }
.quick-title { font-size: 14px; font-weight: 700; }
.quick-desc { font-size: 11px; color: var(--text-sub); }

.disclaimer-mini {
  margin-top: 18px;
  font-size: 11px;
  color: var(--text-sub);
  text-align: center;
}

/* ---------- セルフチェック ---------- */
.progress-bar {
  background: #e6e3db;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  background: var(--primary);
  height: 100%;
  width: 0%;
  transition: width 0.25s ease;
}
.counter-text { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; text-align: right; }
.question-area { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.question-text { font-size: 16px; font-weight: 700; margin-bottom: 16px; line-height: 1.5; }
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-btn {
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.option-btn.selected { border-color: var(--primary); background: var(--primary-light); font-weight: 700; }

.result-type-card {
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
  text-align: center;
}
.result-type-card.balanced { background: #eaf4e4; color: #3c6b35; }
.result-type-card.sympathetic { background: #fdeee8; color: #a05a2c; }
.result-type-card.parasympathetic { background: #e8eef7; color: #3b5f8a; }
.result-type-card.mixed { background: #f4edf7; color: #6b4a86; }
.result-type-name { font-size: 18px; font-weight: 700; }
.result-type-sub { font-size: 12px; margin-top: 2px; }

.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.score-box {
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  background: var(--primary-light);
}
.score-box .score-label { font-size: 11px; color: var(--text-sub); }
.score-box .score-value { font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.score-box .score-range { font-size: 10px; color: var(--text-sub); }

.advice-box { background: #fbfaf6; border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 10px 0; font-size: 13px; }
.advice-box h4 { font-size: 13px; margin-bottom: 6px; }

.history-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 240px; overflow-y: auto; }
.history-item {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 4px rgba(47, 59, 56, 0.06);
}
.history-badge { border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700; }

.chart-canvas { width: 100%; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); margin-top: 8px; }

/* ---------- 呼吸法 ---------- */
.breath-selector { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 14px; }
.breath-option {
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.breath-option.active { border-color: var(--primary); background: var(--primary-light); }
.breath-name { display: block; font-size: 15px; font-weight: 700; }
.breath-desc { display: block; font-size: 11px; color: var(--text-sub); margin-top: 2px; }

.breath-session-card { text-align: center; }
.breath-circle-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 260px;
}
.breath-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7fa89e, #4f7c72);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 30px rgba(79, 124, 114, 0.35);
}
.breath-circle.inhale { transform: scale(1.25); }
.breath-circle.hold { transform: scale(1.25); background: radial-gradient(circle at 35% 30%, #8fb3a9, #5b8d82); }
.breath-circle.exhale { transform: scale(0.82); }
.breath-circle.idle { transform: scale(1); }
.breath-phase { font-size: 15px; font-weight: 700; }
.breath-count { font-size: 40px; font-weight: 700; line-height: 1.1; }

.breath-timer-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: 14px 0 6px;
  text-align: left;
}
.breath-timer-select label { font-size: 12px; color: var(--text-sub); display: block; margin-bottom: 2px; }
.breath-timer-select select {
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-family: inherit;
  background: #fff;
}
.breath-cycle-count { font-size: 13px; color: var(--text-sub); font-weight: 700; }

/* ---------- 情報カード共通 ---------- */
.info-list { padding-left: 20px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.info-card h3, .knowledge-card h3, .form-card h3, .form-card-title { font-size: 14px; margin-bottom: 8px; }

/* ---------- リラクゼーション ---------- */
.relax-block { margin-bottom: 16px; }
.sound-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sound-card {
  background: #fbfaf6;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.sound-card.active { border-color: var(--primary); background: var(--primary-light); }
.sound-icon { font-size: 26px; }

.volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 4px;
  font-size: 13px;
}
.volume-row input[type="range"] { flex: 1; accent-color: var(--primary); }
#soundVolumeLabel { min-width: 38px; text-align: right; font-size: 12px; color: var(--text-sub); }

.meditation-select { display: flex; gap: 8px; margin-bottom: 10px; }
.med-option {
  flex: 1;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
}
.med-option.active { border-color: var(--primary); background: var(--primary-light); }
.meditation-display {
  font-size: 44px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.06em;
  color: var(--primary-dark);
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}

.pmr-area { text-align: center; padding: 10px 0; }
.pmr-part { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.pmr-phase { font-size: 13px; color: var(--text-sub); min-height: 20px; }
.pmr-count { font-size: 36px; font-weight: 700; color: var(--primary-dark); min-height: 52px; font-variant-numeric: tabular-nums; }

/* ---------- 生活記録 ---------- */
.log-date-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
}
.date-nav {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  font-size: 16px;
  cursor: pointer;
  color: var(--primary);
}
.log-date-display { text-align: center; }
.log-date-display span { display: block; font-size: 12px; color: var(--text-sub); }
.log-date-input {
  border: none;
  background: transparent;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  text-align: center;
  cursor: pointer;
}

.log-form { display: flex; flex-direction: column; gap: 12px; }
.form-card { padding: 16px; }
.form-card-title { font-size: 14px; margin-bottom: 10px; }

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.field-row:last-child { margin-bottom: 0; }
.field-row.column { flex-direction: column; align-items: stretch; }
.field-row label { font-size: 13px; min-width: 92px; color: var(--text-sub); }
.field-row.column label { min-width: 0; }
.field-row input[type="number"],
.field-row input[type="date"],
.field-row select {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  min-width: 0;
}
.field-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.unit { font-size: 13px; color: var(--text-sub); }

.star-rating { display: flex; gap: 6px; }
.star-rating button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.star-rating button.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

.symptom-fieldset { border: none; margin-top: 4px; }
.symptom-fieldset legend { font-size: 13px; color: var(--text-sub); margin-bottom: 8px; }
.symptom-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.symptom-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  user-select: none;
}
.symptom-chip:has(input:checked) { border-color: var(--primary); background: var(--primary-light); font-weight: 700; }
.symptom-chip input { accent-color: var(--primary); }

.field-row textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.chart-legend { display: flex; gap: 16px; justify-content: center; font-size: 11px; color: var(--text-sub); margin-top: 6px; }
.chart-note { text-align: center; font-size: 10px; color: var(--text-sub); margin-top: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot-sleep { background: var(--primary); }
.dot-stress { background: var(--accent); }

/* ---------- 知識 ---------- */
.knowledge-card { margin-bottom: 14px; }
.knowledge-card h3 { font-size: 15px; margin-bottom: 10px; }
.knowledge-card p { font-size: 13px; margin-bottom: 8px; }

.ans-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.ans-box { border-radius: 12px; padding: 12px; font-size: 12px; }
.ans-box h4 { font-size: 13px; margin-bottom: 4px; }
.ans-box p { font-size: 11px; margin: 0; }
.ans-box.sympathetic { background: #fdeee8; }
.ans-box.sympathetic h4 { color: #a05a2c; }
.ans-box.parasympathetic { background: #e8eef7; }
.ans-box.parasympathetic h4 { color: #3b5f8a; }

.method-list { padding-left: 20px; font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.method-list li::marker { color: var(--primary); font-weight: 700; }

.warning-card { border: 1.5px solid #e8c9c5; background: #fffafa; }
.warning-card h3 { color: var(--danger); }
.warning-note { font-size: 12px; color: var(--danger); font-weight: 700; }

/* ---------- ボトムナビ ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  max-width: 720px;
  margin: 0 auto;
}
.nav-item {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-sub);
  font-size: 10px;
}
.nav-icon { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--primary); font-weight: 700; }
.nav-item.active .nav-icon { transform: translateY(-1px); }

/* ---------- モーダル ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(30, 40, 37, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: #fff;
  border-radius: 18px;
  padding: 22px 18px 18px;
  max-width: 420px;
  width: 100%;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-content h2 { font-size: 17px; margin-bottom: 8px; }
.modal-content p { font-size: 13px; margin-bottom: 8px; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-sub);
  line-height: 1;
}

.hidden { display: none !important; }

/* ---------- トースト通知 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateX(-50%) translateY(12px);
  background: rgba(47, 59, 56, 0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 86vw;
  text-align: center;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- タブレット・PC ---------- */
@media (min-width: 600px) {
  .breath-selector { grid-template-columns: repeat(3, 1fr); }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .sound-grid { grid-template-columns: repeat(4, 1fr); }
  .app-main { padding: 24px 24px 40px; }
  .view-title { font-size: 24px; }
}

/* ---------- ダークモード（簡易対応） ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f2624;
    --card: #2a3330;
    --text: #e8eeeb;
    --text-sub: #9fb0aa;
    --border: #3a4541;
    --primary-light: #31423d;
    --primary-dark: #7fa89e;
  }
  .hero-card { background: linear-gradient(135deg, #3d625a, #35574f); }
  .btn-outline { background: var(--card); }
  .breath-option, .sound-card, .option-btn, .med-option,
  .field-row input, .field-row select, .field-row textarea,
  .star-rating button, .symptom-chip, .breath-timer-select select {
    background: var(--card);
    color: var(--text);
  }
  .advice-box { background: var(--card); }
  .score-box { background: var(--primary-light); }
  .modal-content { background: var(--card); color: var(--text); }
  .warning-card { background: #332826; }
  .result-type-card.balanced { background: #2a3a26; color: #b5d6a8; }
  .result-type-card.sympathetic { background: #3a2a22; color: #e0b08a; }
  .result-type-card.parasympathetic { background: #222e3a; color: #a8c4e0; }
  .result-type-card.mixed { background: #30263a; color: #c4a8d6; }
}
