/* style.css — 九大受験プロトタイプ
 * コンセプト「花が育つ」。ローズピンク基調。大胆なのは花びらメーターだけで、他は静かに整える。
 * 文字サイズは 13 / 15 / 17 / 20 / 26 / 40px の6段階だけ。
 * 外部フォント・CDNは使用しない。
 */

:root {
  color-scheme: light;

  --rose: #D6336C;
  --rose-deep: #A61E4D;
  --sakura: #FFE3EC;
  --sakura-pale: #FFF5F8;
  --edge: #F3CAD6;
  --ink: #3A2430;
  --ink-soft: #7A5C68;
  --honey: #F2A93B;
  --honey-text: #8A5200;
  --honey-bg: #FFF3D6;
  --leaf: #1F8F6B;
  --leaf-text: #146B50;
  --leaf-bg: #E4F6EE;
  --apricot: #B45309;
  --apricot-text: #94400A;
  --apricot-bg: #FFF0DC;
  --white: #FFFFFF;

  --fs-13: 13px;
  --fs-15: 15px;
  --fs-17: 17px;
  --fs-20: 20px;
  --fs-26: 26px;
  --fs-40: 40px;

  --font-body: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;
  --font-display: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "M PLUS Rounded 1c", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;

  --radius-card: 20px;
  --radius-choice: 16px;
  --radius-pill: 999px;
  --tabbar-h: 64px;
  --max-width: 560px;
  --shadow-rose: 0 10px 28px rgba(166, 30, 77, 0.28);
  --shadow-tab: 0 -4px 16px rgba(166, 30, 77, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sakura-pale);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-17);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

#app {
  padding-top: env(safe-area-inset-top, 0px);
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, select { font-family: inherit; }

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: var(--rose-deep); }

/* フォーカス可視化（アクセシビリティ） */
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--rose-deep);
  outline-offset: 2px;
}
.hero button:focus-visible { outline-color: #FFFFFF; }
main:focus { outline: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.num { font-family: var(--font-display); font-weight: 400; }
.icon { display: inline-flex; flex: none; vertical-align: middle; }

/* ---------------------------------------------------------------------- */
/* レイアウト */
/* ---------------------------------------------------------------------- */
.main {
  flex: 1;
  padding: 16px;
}
.app-with-tabbar .main {
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--white);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  padding: 20px;
}

.screen-title {
  font-size: var(--fs-20);
  font-weight: 700;
  line-height: 1.5;
}

.sub-title {
  font-size: var(--fs-17);
  font-weight: 700;
  margin-bottom: 8px;
}
.card .sub-title { margin-top: 20px; }
.card .sub-title:first-child { margin-top: 0; }

.lead-text { font-size: var(--fs-17); }
.lead-muted { color: var(--ink-soft); font-size: var(--fs-15); }
.center { display: flex; justify-content: center; }
.center-lead { text-align: center; font-size: var(--fs-26); line-height: 1.4; }
.center-text { text-align: center; }
.empty-message { color: var(--ink-soft); margin-bottom: 16px; }

.top-bar { display: flex; justify-content: flex-end; padding: 8px 8px 0; }
.top-link, .back-link {
  background: none;
  border: none;
  color: var(--rose-deep);
  font-size: var(--fs-15);
  min-height: 48px;
  padding: 0 12px;
  text-decoration: underline;
  cursor: pointer;
  align-self: flex-start;
}

/* ---------------------------------------------------------------------- */
/* ボタン */
/* ---------------------------------------------------------------------- */
.btn {
  border-radius: var(--radius-pill);
  border: 2px solid var(--edge);
  background: var(--white);
  color: var(--ink);
  padding: 10px 20px;
  font-size: var(--fs-17);
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  min-height: 52px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }

.btn-primary { background: var(--rose); border-color: var(--rose); color: #FFFFFF; }
.btn-primary:active:not(:disabled) { background: var(--rose-deep); border-color: var(--rose-deep); }

.btn-secondary { background: var(--white); border-color: var(--rose-deep); color: var(--rose-deep); }
.btn-secondary:active { background: var(--sakura); }

.btn-danger { background: var(--white); border-color: var(--apricot); color: var(--apricot-text); }

.btn-hero { background: #FFFFFF; border-color: #FFFFFF; color: var(--rose-deep); margin-top: 16px; }
.btn-hero:active { background: var(--sakura); }

.btn-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.card > .btn-block, .card > .btn-stack { margin-top: 20px; }
.card > .btn-block + .btn-block { margin-top: 12px; }

/* ---------------------------------------------------------------------- */
/* 設問 */
/* ---------------------------------------------------------------------- */
.step-count { font-size: var(--fs-13); color: var(--ink-soft); }
.card .step-count { margin-bottom: 8px; }
.question-unit { font-size: var(--fs-13); color: var(--ink-soft); margin-bottom: 8px; }

.question-prompt {
  font-size: var(--fs-20);
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 20px;
}

.solution-box,
.explanation-box {
  background: var(--sakura);
  border-radius: var(--radius-choice);
  padding: 16px;
  font-size: var(--fs-17);
  white-space: pre-wrap;
}
.explanation-box { margin-bottom: 20px; }
.solution-box { margin-bottom: 20px; }

.choice-list { display: flex; flex-direction: column; gap: 12px; }

.btn-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: var(--radius-choice);
  border: 2px solid var(--edge);
  background: var(--white);
  color: var(--ink);
  font-weight: 400;
}
.btn-choice:disabled { opacity: 1; cursor: default; color: var(--ink-soft); }
.btn-choice-correct, .btn-choice-correct:disabled {
  border-color: var(--leaf);
  background: var(--leaf-bg);
  color: var(--leaf-text);
  font-weight: 700;
}
.btn-choice-wrong, .btn-choice-wrong:disabled {
  border-color: var(--apricot);
  background: var(--apricot-bg);
  color: var(--apricot-text);
  font-weight: 700;
}

.answer-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.text-input {
  border: 2px solid var(--edge);
  border-radius: var(--radius-choice);
  padding: 10px 14px;
  font-size: var(--fs-20);
  min-height: 52px;
  flex: 1;
  min-width: 120px;
  background: var(--white);
  color: var(--ink);
}
.text-input-small { max-width: 88px; min-width: 64px; text-align: center; }
.btn-grade { flex: none; }
.fraction-slash { font-size: var(--fs-26); color: var(--ink-soft); }

.token-hint { color: var(--ink-soft); font-size: var(--fs-15); margin-bottom: 8px; }
.token-pool, .token-assembled {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  min-height: 56px;
}
.token-assembled {
  border: 2px dashed var(--edge);
  border-radius: var(--radius-choice);
  padding: 8px;
}
.btn-token {
  font-size: var(--fs-17);
  font-weight: 400;
  padding: 8px 16px;
  min-height: 48px;
  background: var(--white);
}
.btn-token-assembled { background: var(--sakura); border-color: var(--rose); }
.token-pool + .btn-grade { margin-top: 4px; }

.feedback {
  margin-top: 16px;
  border-radius: var(--radius-choice);
  padding: 16px;
  animation: pop 0.22s ease-out;
}
.feedback:empty { display: none; }
.feedback-correct { background: var(--leaf-bg); border: 1px solid var(--leaf); }
.feedback-incorrect { background: var(--apricot-bg); border: 1px solid var(--apricot); }
.feedback-result {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-20);
  font-weight: 700;
  margin-bottom: 8px;
}
.feedback-correct .feedback-result { color: var(--leaf-text); }
.feedback-incorrect .feedback-result { color: var(--apricot-text); }
.feedback-explanation { font-size: var(--fs-17); color: var(--ink); white-space: pre-wrap; }
.feedback-note { font-size: var(--fs-15); color: var(--ink); margin-top: 8px; }

.next-row { margin-top: 16px; }
.btn-next { scroll-margin-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px); }

@keyframes pop {
  from { transform: scale(0.97); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------------- */
/* 進捗バー・チップ */
/* ---------------------------------------------------------------------- */
.bar {
  height: 12px;
  background: var(--sakura);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.bar-thin { height: 8px; }
.bar-fill {
  height: 100%;
  background: var(--rose);
  border-radius: var(--radius-pill);
  transition: width 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.chip {
  display: inline-block;
  font-size: var(--fs-13);
  line-height: 1.5;
  padding: 2px 12px;
  border-radius: var(--radius-pill);
  background: var(--sakura);
  color: var(--rose-deep);
}
.chip-honey { background: var(--honey-bg); color: var(--honey-text); }
.chip-done { background: var(--leaf-bg); color: var(--leaf-text); }
.chip-now { background: var(--rose); color: #FFFFFF; }

/* ---------------------------------------------------------------------- */
/* 6ステップの道のり */
/* ---------------------------------------------------------------------- */
.path { display: flex; margin: 16px 0 4px; }
.path-step {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.path-step + .path-step::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--edge);
}
.path-step.path-done + .path-step::before { background: var(--rose); }
.path-dot {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--edge);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
}
.path-done .path-dot { background: var(--rose); border-color: var(--rose); }
.path-now .path-dot { border-color: var(--rose); border-width: 4px; }
.path-label { font-size: var(--fs-13); color: var(--ink-soft); line-height: 1.4; }
.path-now .path-label { color: var(--rose-deep); font-weight: 700; }

.path-on-rose .path-step + .path-step::before { background: rgba(255, 255, 255, 0.45); }
.path-on-rose .path-step.path-done + .path-step::before { background: #FFFFFF; }
.path-on-rose .path-dot { background: var(--rose); border-color: rgba(255, 255, 255, 0.6); }
.path-on-rose .path-done .path-dot { background: #FFFFFF; border-color: #FFFFFF; color: var(--rose-deep); }
.path-on-rose .path-now .path-dot { border-color: #FFFFFF; }
.path-on-rose .path-label { color: #FFFFFF; }

/* ---------------------------------------------------------------------- */
/* はじめの画面・診断結果 */
/* ---------------------------------------------------------------------- */
.screen-intro { gap: 20px; padding-top: 8px; }
.intro-title { font-size: var(--fs-26); font-weight: 700; line-height: 1.5; }
.intro-title span { display: inline-block; }
.intro-text { font-size: var(--fs-17); color: var(--ink); }
.result-title { font-size: var(--fs-26); font-weight: 700; line-height: 1.5; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--edge); }
.plain-list li:last-child { border-bottom: none; }

/* ---------------------------------------------------------------------- */
/* 今日 */
/* ---------------------------------------------------------------------- */
.today-head { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.greeting { font-size: var(--fs-26); font-weight: 700; line-height: 1.3; }
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-15);
  background: var(--sakura);
  color: var(--rose-deep);
}
.streak-honey { background: var(--honey-bg); color: var(--honey-text); }
.streak-honey .icon { color: var(--honey); }

.week { display: flex; justify-content: space-between; width: 100%; max-width: 360px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 36px; }
.day-petal { fill: var(--sakura); stroke: var(--edge); stroke-width: 1.5; }
.day-on { fill: var(--rose); stroke: var(--rose); }
.day-today { stroke: var(--rose-deep); stroke-width: 3; }
.day-future { opacity: 0.45; }
.day-label { font-size: var(--fs-13); color: var(--ink-soft); line-height: 1.4; }
.day-is-today .day-label { color: var(--rose-deep); font-weight: 700; }

.hero {
  background: var(--rose);
  color: #FFFFFF;
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-rose);
}
.hero-kind { font-size: var(--fs-13); }
.hero-title { font-size: var(--fs-20); font-weight: 700; line-height: 1.5; margin-top: 4px; }
.hero-sub { font-size: var(--fs-15); margin-top: 2px; }

.goal { display: flex; flex-direction: column; gap: 8px; }
.goal-label { font-size: var(--fs-15); color: var(--ink); }
.goal-done { display: flex; align-items: center; gap: 8px; color: var(--leaf-text); font-weight: 700; }
.goal-done .icon { color: var(--leaf); }

.rest-list {
  background: var(--white);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.rest-list li + li { border-top: 1px solid var(--edge); }
.rest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}
.rest-row .icon { color: var(--ink-soft); }
.rest-main { display: flex; flex-direction: column; min-width: 0; }
.rest-title { font-size: var(--fs-17); }
.rest-sub { font-size: var(--fs-13); color: var(--ink-soft); }
.dots { display: flex; gap: 4px; margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--edge); }

.held-note { font-size: var(--fs-13); color: var(--ink-soft); }

.reach-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  color: var(--ink);
  cursor: pointer;
  min-height: 100px;
}
.reach-card > .icon { color: var(--ink-soft); }
.reach-card .flower { flex: none; }
.reach-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.reach-card-level { font-size: var(--fs-17); font-weight: 700; line-height: 1.4; }
.reach-card-level .num { font-size: var(--fs-20); }
.reach-next { font-size: var(--fs-13); color: var(--ink-soft); line-height: 1.5; }
.reach-large .reach-next, .done-card .reach-next { text-align: center; font-size: var(--fs-15); }

.done-card { display: flex; flex-direction: column; gap: 16px; }
.done-title { font-size: var(--fs-20); font-weight: 700; line-height: 1.5; }
.done-card .btn-block { margin-top: 0; }

/* ---------------------------------------------------------------------- */
/* 単元一覧 */
/* ---------------------------------------------------------------------- */
.subject { display: flex; flex-direction: column; gap: 12px; }
.subject-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.subject-title { font-size: var(--fs-20); font-weight: 700; }
.subject-count { font-size: var(--fs-15); color: var(--ink-soft); }
.subject-count .num { font-size: var(--fs-20); color: var(--rose-deep); }

.unit-list {
  background: var(--white);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.unit-list li + li { border-top: 1px solid var(--edge); }
.unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}
.unit-main { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.unit-name { font-size: var(--fs-17); line-height: 1.5; }
.unit-note { font-size: var(--fs-13); color: var(--ink-soft); line-height: 1.5; }
.unit-status {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-15);
  white-space: nowrap;
}
.unit-status-passed { color: var(--leaf-text); font-weight: 700; }
.unit-status-passed .icon { color: var(--leaf); }
.unit-status-go { color: var(--rose-deep); font-weight: 700; }
.unit-status-lock { color: var(--ink-soft); }

.seg { display: inline-flex; gap: 2px; }
.seg-cell { width: 6px; height: 16px; border-radius: 2px; background: var(--sakura); }
.seg-on { background: var(--rose); }

/* ---------------------------------------------------------------------- */
/* 単元・確認テスト結果 */
/* ---------------------------------------------------------------------- */
.unit-header { display: flex; flex-direction: column; gap: 4px; }
.unit-header-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.unit-header-step { font-size: var(--fs-15); color: var(--ink-soft); }

.result-label { font-size: var(--fs-13); color: var(--ink-soft); margin-top: -12px; }
.result-card { display: flex; flex-direction: column; gap: 16px; }
.result-card .btn-block { margin-top: 0; }
.result-score { font-family: var(--font-display); font-size: var(--fs-26); line-height: 1.4; }

.stamps { display: flex; gap: 12px; }
.stamp {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px dashed var(--edge);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stamp-on { background: var(--rose); border: 2px solid var(--rose); color: #FFFFFF; }

/* ---------------------------------------------------------------------- */
/* 復習 */
/* ---------------------------------------------------------------------- */
.review-count { font-size: var(--fs-26); line-height: 1.4; }
.review-list { margin: 12px 0 4px; }
.review-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--edge); }
.review-list li:last-child { border-bottom: none; }
.review-n { color: var(--ink-soft); font-size: var(--fs-15); white-space: nowrap; }

/* ---------------------------------------------------------------------- */
/* 進捗 */
/* ---------------------------------------------------------------------- */
.reach-large { display: flex; flex-direction: column; gap: 16px; }
.tier-line { text-align: center; font-size: var(--fs-15); color: var(--ink-soft); }
.reach-note { font-size: var(--fs-13); color: var(--ink-soft); }

.levels { border-top: 1px solid var(--edge); padding-top: 4px; }
.levels-summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
  font-size: var(--fs-17);
  color: var(--rose-deep);
  font-weight: 700;
}
.levels-summary::-webkit-details-marker { display: none; }
.levels-summary::after {
  content: "";
  width: 10px;
  height: 10px;
  margin: 0 6px 4px 0;
  border-right: 2px solid var(--rose-deep);
  border-bottom: 2px solid var(--rose-deep);
  transform: rotate(45deg);
}
.levels[open] > .levels-summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
.lv-row { padding: 12px 0; border-top: 1px solid var(--edge); display: flex; flex-direction: column; gap: 2px; }
.lv-row-now { background: var(--sakura-pale); margin: 0 -12px; padding: 12px; border-radius: var(--radius-choice); }
.lv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lv-no { font-size: var(--fs-20); color: var(--rose-deep); }
.lv-name { font-size: var(--fs-17); font-weight: 700; }
.lv-need { font-size: var(--fs-13); color: var(--ink-soft); }
.lv-tier { font-size: var(--fs-15); font-weight: 700; }
.lv-univ { font-size: var(--fs-15); }
.lv-msg { font-size: var(--fs-13); color: var(--ink-soft); }

.records, .weekly { display: flex; flex-direction: column; gap: 4px; }
.rec-list { background: var(--white); border: 1px solid var(--edge); border-radius: var(--radius-card); padding: 4px 16px; }
.rec-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--edge); font-size: var(--fs-15); }
.rec-row:last-child { border-bottom: none; }
.rec-row dt { color: var(--ink-soft); }
.rec-row dd { font-size: var(--fs-17); text-align: right; }
.weekly-history li { padding: 8px 0; border-bottom: 1px solid var(--edge); font-size: var(--fs-15); }
.weekly .btn-block { margin-top: 12px; }
.detail-status { font-size: var(--fs-15); margin-bottom: 8px; }
.detail-status .num { font-size: var(--fs-20); color: var(--rose-deep); }

/* ---------------------------------------------------------------------- */
/* 設定 */
/* ---------------------------------------------------------------------- */
.field-label { display: block; margin-bottom: 16px; font-size: var(--fs-15); color: var(--ink-soft); }
.minutes-select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  font-size: var(--fs-17);
  border: 2px solid var(--edge);
  border-radius: var(--radius-choice);
  min-height: 52px;
  background: var(--white);
  color: var(--ink);
}
.field-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.field-row label { font-size: var(--fs-17); }
.field-hint { font-size: var(--fs-13); color: var(--ink-soft); margin-left: 4px; }
.check { width: 24px; height: 24px; accent-color: var(--rose); flex: none; }
.data-note { font-size: var(--fs-15); color: var(--ink-soft); }

/* ---------------------------------------------------------------------- */
/* 下部タブバー */
/* ---------------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--white);
  border-top: 1px solid var(--edge);
  box-shadow: var(--shadow-tab);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar-list { display: flex; max-width: var(--max-width); margin: 0 auto; }
.tabbar-list li { flex: 1; }
.tab-btn {
  position: relative;
  width: 100%;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px 0;
}
.tab-label { font-size: var(--fs-13); line-height: 1.3; }
.tab-btn-active { color: var(--rose-deep); }
.tab-btn-active .tab-label { font-weight: 700; }
.tab-btn-active .icon { background: var(--sakura); border-radius: var(--radius-pill); padding: 2px 14px; box-sizing: content-box; }
.tab-btn .icon { padding: 2px 14px; box-sizing: content-box; }
.tab-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--rose);
  color: #FFFFFF;
  font-size: var(--fs-13);
  line-height: 20px;
  text-align: center;
}

/* ---------------------------------------------------------------------- */
/* 花びらメーター */
/* ---------------------------------------------------------------------- */
.flower { display: block; max-width: 100%; height: auto; overflow: visible; }
.pt-base { fill: var(--sakura); }
.pt-fill {
  fill: var(--rose);
  transform-origin: 100px 84px;
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.pt-edge { fill: none; stroke: var(--edge); stroke-width: 1.5; }
.flower-small .pt-edge { stroke-width: 4; }
.pt-soon { stroke-dasharray: 4 3; }
.flower-small .pt-soon { stroke-dasharray: 8 6; }
.pt-goal { stroke: var(--honey); stroke-width: 3.5; stroke-dasharray: none; }
.flower-small .pt-goal { stroke-width: 7; }
.pt-dot { fill: var(--honey); }
.fl-center { fill: #FFFFFF; stroke: var(--edge); stroke-width: 1.5; }
.fl-lv { font-family: var(--font-body); font-size: 14px; fill: var(--ink-soft); }
.fl-num { font-family: var(--font-display); font-weight: 400; font-size: 36px; fill: var(--rose-deep); }
.fl-num-small { font-size: 64px; }

/* ---------------------------------------------------------------------- */
/* トーストとお祝い */
/* ---------------------------------------------------------------------- */
#toast-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: var(--ink);
  color: #FFFFFF;
  font-size: var(--fs-15);
  line-height: 1.5;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 20px rgba(58, 36, 48, 0.25);
  text-align: center;
}

#celebrate-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.celebrate {
  position: absolute;
  inset: 0;
  background: var(--sakura-pale);
  overflow-y: auto;
  display: flex;
  pointer-events: auto;
  -webkit-overflow-scrolling: touch;
}
.celebrate-panel {
  margin: auto;
  width: 100%;
  max-width: 480px;
  padding: calc(32px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.celebrate-title { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-26); line-height: 1.4; color: var(--rose-deep); }
.cel-unit { font-size: var(--fs-20); font-weight: 700; }
.cel-flower { display: flex; justify-content: center; }
.cel-plus { font-family: var(--font-display); font-size: var(--fs-26); color: var(--honey-text); line-height: 1.4; }
.cel-levelup { font-family: var(--font-display); font-size: var(--fs-20); color: var(--rose-deep); line-height: 1.5; }
.cel-note { font-size: var(--fs-15); color: var(--ink); }
.celebrate-action { width: 100%; margin-top: 8px; }
.confirm-message { font-size: var(--fs-20); line-height: 1.7; text-align: left; }
.confirm-actions { display: flex; flex-direction: column; gap: 12px; }

.petal-rain {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 101;
}
.petal {
  position: absolute;
  top: -24px;
  width: 12px;
  height: 16px;
  border-radius: 80% 0 80% 0;
  animation: petal-fall 2.4s ease-in forwards;
}
.petal-rain-short .petal { animation-duration: 1.8s; }
.petal-c0 { background: var(--rose); }
.petal-c1 { background: var(--sakura); border: 1px solid var(--edge); }
.petal-c2 { background: var(--honey); }

@keyframes petal-fall {
  from { transform: translate(0, 0) rotate(var(--rot, 0deg)); opacity: 1; }
  to { transform: translate(var(--drift, 0px), 105vh) rotate(calc(var(--rot, 0deg) + 360deg)); opacity: 0.9; }
}

/* ---------------------------------------------------------------------- */
/* 動きを減らす設定 */
/* ---------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .petal-rain { display: none; }
  .bar-fill, .pt-fill { transition: none; }
  .feedback { animation: none; }
}

/* ---------------------------------------------------------------------- */
/* 狭い画面（320px幅まで崩さない） */
/* ---------------------------------------------------------------------- */
@media (max-width: 360px) {
  .main { padding: 12px; }
  .card, .hero { padding: 16px; }
  .path-label { font-size: var(--fs-13); }
  .reach-card { gap: 12px; padding: 12px; }
  .btn { padding: 10px 16px; }
  .unit-row, .rest-row { padding: 12px; }
  .text-input-small { max-width: 72px; }
}

/* ---------------------------------------------------------------------- */
/* 全教科対応：読み込み・ヒント・図・新しい問題形式・教科の折りたたみ */
/* ---------------------------------------------------------------------- */
.loading-note { text-align: center; color: var(--ink-soft); }

.btn-hint { margin: -8px 0 16px; min-height: 44px; font-size: var(--fs-15); }
.hint-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hint-list:empty { display: none; }
.hint-item {
  background: var(--honey-bg);
  color: var(--ink);
  border-radius: var(--radius-choice);
  padding: 10px 14px;
  font-size: var(--fs-15);
  line-height: 1.6;
}
.hint-no { display: block; font-size: var(--fs-13); font-weight: 700; color: var(--honey-text); }

.figure { margin: 0 0 20px; text-align: center; }
.figure svg { max-width: 100%; height: auto; }

.btn-choice-selected { border-color: var(--rose-deep); background: var(--sakura); font-weight: 700; }

.self-input {
  display: block;
  width: 100%;
  border: 2px solid var(--edge);
  border-radius: var(--radius-choice);
  padding: 12px 14px;
  font: inherit;
  font-size: var(--fs-17);
  line-height: 1.6;
  background: var(--white);
  color: var(--ink);
  margin-bottom: 16px;
  resize: vertical;
}
.self-area { display: flex; flex-direction: column; gap: 12px; }
.self-label { font-size: var(--fs-15); color: var(--ink-soft); }
.rubric-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rubric-item { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 8px 0; }
.rubric-item label { font-size: var(--fs-17); line-height: 1.5; }
.feedback-score { font-size: var(--fs-17); font-weight: 700; margin-top: 4px; }

.steps-list { margin: 0 0 16px; padding-left: 1.6em; font-size: var(--fs-17); line-height: 1.8; }
.example-answer { font-size: var(--fs-17); font-weight: 700; color: var(--rose-deep); }
.point-list { margin: 0; padding-left: 1.4em; font-size: var(--fs-17); line-height: 1.8; }
.point-list li + li { margin-top: 4px; }

.rest-more { padding: 12px 16px; font-size: var(--fs-13); color: var(--ink-soft); }

.subject-details > summary { list-style: none; cursor: pointer; margin-bottom: 12px; }
.subject-details > summary::-webkit-details-marker { display: none; }
.subject-head { min-height: 44px; }
.planned-fold { background: var(--white); border: 1px solid var(--edge); border-radius: var(--radius-card); }
.planned-summary { min-height: 48px; padding: 12px 16px; font-size: var(--fs-15); color: var(--ink-soft); cursor: pointer; display: flex; align-items: center; }
.planned-list { list-style: none; margin: 0; padding: 0 16px 12px; font-size: var(--fs-13); color: var(--ink-soft); line-height: 1.6; }
.planned-list li { padding: 4px 0; }

.upcoming { display: flex; flex-direction: column; gap: 8px; }
.upcoming-list { list-style: none; margin: 0; padding: 0; background: var(--white); border: 1px solid var(--edge); border-radius: var(--radius-card); }
.upcoming-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; font-size: var(--fs-15); color: var(--ink-soft); }
.upcoming-row + .upcoming-row { border-top: 1px solid var(--edge); }

.subject-checks { margin-top: 8px; }
.point-list { list-style: disc; }
.steps-list { list-style: decimal; }

/* 上線つきの文字（補集合の A・B の上の線）。フォントに頼らず線を引く */
.overline {
  text-decoration: overline;
  text-decoration-thickness: 0.06em;
}
