:root {
  --teal-900: #0f3d3e;
  --teal-800: #0d5c54;
  --teal-700: #0f766e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-300: #5eead4;
  --teal-100: #ccfbf1;
  --teal-50:  #f0fdfa;

  --red-600: #dc2626;
  --red-50:  #fef2f2;
  --green-600: #16a34a;
  --green-50: #f0fdf4;

  --ink: #0f2726;
  --ink-soft: #4b6564;
  --border: #d8f0ed;
  --card-bg: #ffffff;
  --page-bg: var(--teal-50);

  --radius: 14px;
  --shadow: 0 2px 10px rgba(13, 148, 136, 0.12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  /* 固定表示の下部ナビ(高さ約50px+セーフエリア)の分だけ、要素を画面内に
     スクロールする際の目標位置を上に余裕を持たせる。これが無いと、
     ブラウザ側のスクロール処理(フォーカス移動・自動テスト等)が要素を
     下部ナビの真下(=クリック不能な位置)まで寄せてしまうことがある。 */
  scroll-padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, var(--teal-50) 0%, #ffffff 60%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic",
    "Noto Sans JP", Meiryo, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(240, 253, 250, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--teal-900);
  box-shadow: 0 1px 0 rgba(13, 148, 136, 0.1);
}

.app-header h1 {
  flex: 1;
  font-size: 0.88rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--teal-900);
  text-align: center;
}

.icon-btn {
  background: var(--teal-100);
  border: none;
  color: var(--teal-700);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active { background: var(--teal-500); color: white; }

/* ---------- Layout ---------- */
#app {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn .18s ease; }

/* ホームは要素数が少ないため、余白を下に溜め込まず画面全体で
   縦方向にバランスさせる。 */
/* ホームはヒーロー(画面上端に張り付くバナー)を主役にした
   トップアンカー型のレイアウトのため、他の画面と同じ通常のブロック
   フローで良い(縦方向の中央寄せは行わない)。 */
#screen-home.active {
  display: block;
}

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

h2 {
  color: var(--teal-900);
  margin: 4px 0 16px;
}

/* ---------- Year chips ---------- */
.year-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.year-chips::-webkit-scrollbar { display: none; }

.year-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--teal-500);
  background: white;
  color: var(--teal-700);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.year-chip.active {
  background: var(--teal-600);
  border-color: var(--teal-600);
  color: white;
}

/* ---------- Subject grid ---------- */
.subject-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.subject-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.subject-card:active { transform: scale(0.98); }

.subject-card .name {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.3;
}

.subject-card .meta {
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin-top: 4px;
}

.subject-card .rate {
  flex-shrink: 0;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--teal-600);
  min-width: 52px;
  text-align: right;
}

.subject-card .rate.no-data {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
  text-align: center;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--teal-600);
  color: white;
  box-shadow: var(--shadow);
}

.btn-outline {
  background: white;
  color: var(--teal-700);
  border: 1.5px solid var(--teal-500);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  text-decoration: underline;
}

.btn-danger-outline {
  background: white;
  color: var(--red-600);
  border: 1.5px solid var(--red-600);
}

.home-actions { margin-top: 18px; }

/* ---------- ホーム: ヒーロー帯 ---------- */
.home-hero {
  position: relative;
  overflow: hidden;
  margin: -16px -16px 0;
  /* ホームでは常設ヘッダーを非表示にしているため、ヒーロー自身が
     ステータスバー(セーフエリア)の分を確保する。背景色はステータスバーの
     裏まで届かせつつ、中身(アプリ名)はステータスバーと重ならない位置まで
     押し下げる。1画面に収めるため上下のpaddingは必要最小限に絞る。 */
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 64px;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
  border-radius: 0 0 28px 28px;
}

.home-hero-pattern {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.5;
  background-image: radial-gradient(rgba(255, 255, 255, 0.35) 1.5px, transparent 1.5px);
  background-size: 20px 20px;
}

.home-hero-pattern::before,
.home-hero-pattern::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
}

.home-hero-pattern::before {
  width: 220px;
  height: 220px;
  top: -120px;
  right: -70px;
}

.home-hero-pattern::after {
  width: 150px;
  height: 150px;
  bottom: -90px;
  left: -50px;
}

.home-hero-appname {
  position: relative;
  z-index: 1;
  margin: 6px 0 0;
  color: white;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
}

/* ---------- ホーム: 浮遊カード(今日の目標リング) ---------- */
.home-hero-card {
  position: relative;
  z-index: 2;
  margin: -50px 0 16px;
  background: var(--card-bg);
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: 0 16px 32px rgba(15, 61, 62, 0.16);
}

.home-hero-ring-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.home-hero-ring-wrap {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 100px;
}

.home-hero-ring { transform: rotate(-90deg); }

.home-hero-ring-track {
  fill: none;
  stroke: var(--teal-100);
  stroke-width: 10;
}

.home-hero-ring-fill {
  fill: none;
  stroke: var(--teal-500);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

.home-hero-ring-fill.complete { stroke: var(--teal-700); }

.home-hero-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.home-hero-ring-count {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--teal-800);
  line-height: 1;
}

.home-hero-ring-slash {
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 1px;
}

.home-hero-ring-label {
  font-size: 0.62rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.home-hero-ring-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.home-hero-substat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.home-hero-substat-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--teal-700);
  line-height: 1;
}

.home-hero-substat-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.home-hero-goal-message {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.home-hero-goal-message.complete { color: var(--teal-700); }

/* ---------- ホーム: メインCTA ---------- */
.home-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--teal-600);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 15px 18px;
  margin: 0 0 14px;
  box-shadow: 0 10px 22px rgba(13, 148, 136, 0.25);
  cursor: pointer;
  text-align: left;
}

.home-cta:active { transform: scale(0.98); }

.home-cta-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 12px;
}

.home-cta-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.home-cta-label { font-size: 1.03rem; font-weight: 800; }

.home-cta-sub { font-size: 0.72rem; opacity: 0.85; }

.home-cta-arrow {
  flex-shrink: 0;
  opacity: 0.85;
  display: flex;
}

/* ---------- ホーム: 機能グリッド ---------- */
.home-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.home-feature-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
  aspect-ratio: 2.2 / 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 8px;
  cursor: pointer;
  color: var(--teal-700);
  box-shadow: 0 2px 10px rgba(13, 148, 136, 0.07);
}

.home-feature-card:active { background: var(--teal-50); }

.home-feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--teal-50);
}

.home-feature-label { font-size: 0.78rem; font-weight: 700; color: var(--ink); }

.home-feature-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--teal-600);
  color: white;
  font-size: 0.64rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Quiz ---------- */
.quiz-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: var(--teal-100);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--teal-500);
  border-radius: 999px;
  transition: width .25s ease;
}

.progress-text {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 700;
  white-space: nowrap;
}

.question-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.subject-tag {
  display: inline-block;
  background: var(--teal-100);
  color: var(--teal-700);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin: 0 0 10px;
}

.question-text {
  font-size: 0.98rem;
  line-height: 1.65;
  margin: 0;
  white-space: pre-wrap;
}

.sub-items {
  margin: 12px 0 0;
  padding-left: 1.3em;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--ink);
}

.sub-items li {
  margin-bottom: 8px;
}

.sub-items li::marker {
  color: var(--teal-600);
  font-weight: 700;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  cursor: pointer;
}

.choice-btn:active { background: var(--teal-50); }

.choice-letter {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal-100);
  color: var(--teal-700);
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choice-btn.correct {
  border-color: var(--green-600);
  background: var(--green-50);
}
.choice-btn.correct .choice-letter {
  background: var(--green-600);
  color: white;
}

.choice-btn.incorrect {
  border-color: var(--red-600);
  background: var(--red-50);
}
.choice-btn.incorrect .choice-letter {
  background: var(--red-600);
  color: white;
}

.choice-btn.disabled {
  cursor: default;
}

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--teal-900);
  color: white;
}

.feedback-text {
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.5;
}

.feedback .btn-primary {
  margin-bottom: 0;
  background: var(--teal-300);
  color: var(--teal-900);
}

/* ---------- Post-answer actions ---------- */
.post-answer-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.post-answer-actions .btn {
  flex: 1;
  margin-bottom: 0;
  font-size: 0.88rem;
  padding: 13px 8px;
}

/* ---------- Session result ---------- */
.score-big {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--teal-600);
  margin: 0 0 4px;
  text-align: center;
}

.score-sub {
  text-align: center;
  color: var(--ink-soft);
  margin: 0 0 20px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.session-item .mark {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: white;
}

.session-item.ok .mark { background: var(--green-600); }
.session-item.ng .mark { background: var(--red-600); }

.session-item .qtext {
  flex: 1;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Stats ---------- */
.stats-overall {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-around;
  text-align: center;
}

.stats-overall .stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--teal-600);
}

.stats-overall .stat-label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.stats-subject-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.stats-row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.stats-row .row-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.stats-row .row-top .pct { color: var(--teal-600); }

.stats-row .row-bar {
  height: 7px;
  background: var(--teal-100);
  border-radius: 999px;
  overflow: hidden;
}

.stats-row .row-bar-fill {
  height: 100%;
  background: var(--teal-500);
}

.stats-row .row-meta {
  margin-top: 5px;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.empty-note {
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 0;
}

@media (min-width: 480px) {
  .subject-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Search bar ---------- */
.search-bar {
  position: relative;
  margin-bottom: 14px;
}

.search-input {
  width: 100%;
  padding: 12px 40px 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  font-size: 0.92rem;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.search-input::-webkit-search-cancel-button { display: none; }

.search-input:focus {
  outline: none;
  border-color: var(--teal-500);
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--teal-100);
  color: var(--teal-700);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-results-count {
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin: 0 0 12px;
}

.search-results-section { margin-bottom: 18px; }

.search-results-heading {
  color: var(--teal-700);
  font-size: 0.85rem;
  margin: 0 0 8px;
}

.search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 8px;
  cursor: pointer;
}

.search-result-item:active { background: var(--teal-50); }

.search-result-meta {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal-600);
  margin-bottom: 4px;
}

.search-result-snippet {
  display: block;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink);
}

.search-result-snippet mark {
  background: #fde68a;
  color: var(--ink);
  border-radius: 3px;
  padding: 0 2px;
}

/* ---------- Feature nav (home quick links) ---------- */
.feature-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.feature-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--teal-900);
  font-size: 0.85rem;
  font-weight: 700;
}

.feature-nav-btn:active { transform: scale(0.97); }

.feature-nav-icon { font-size: 1.4rem; }

/* ---------- Notes ---------- */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.note-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.note-card:active { transform: scale(0.98); }

.note-card-title {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.note-card-snippet {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.note-card-date {
  font-size: 0.7rem;
  color: var(--ink-soft);
}

/* ---------- Tag chips (subject / free tags) ---------- */
.tag-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--teal-500);
  background: white;
  color: var(--teal-700);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.tag-chip.active {
  background: var(--teal-600);
  border-color: var(--teal-600);
  color: white;
}

.tag-chip.small {
  padding: 3px 9px;
  font-size: 0.68rem;
  border-width: 1px;
  cursor: default;
}

.tag-chip.removable {
  background: var(--teal-100);
  border-color: var(--teal-100);
  color: var(--teal-700);
  cursor: default;
}

.tag-chip.removable button {
  background: none;
  border: none;
  color: var(--teal-700);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* ---------- Note editor form ---------- */
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal-700);
  margin: 14px 0 6px;
}

.form-input,
.form-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--card-bg);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--teal-500);
}

.form-textarea {
  resize: vertical;
  line-height: 1.6;
  white-space: pre-wrap;
}

.note-linked-question { margin-bottom: 4px; }

.note-linked-question-btn {
  width: 100%;
  text-align: left;
  background: var(--teal-50);
  border: 1.5px solid var(--teal-300);
  color: var(--teal-700);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.note-edit-actions {
  margin-top: 20px;
}

/* ---------- Analysis ---------- */
.analysis-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.analysis-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--teal-700);
  margin: 0 0 12px;
}

.analysis-cumulative-percent {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--teal-800);
  letter-spacing: -0.02em;
  text-align: center;
}

.analysis-cumulative-percent-sign {
  font-size: 1.2rem;
  font-weight: 700;
  margin-left: 2px;
  color: var(--teal-600);
}

.analysis-cumulative-fraction {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 600;
  text-align: center;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

.chart-wrap-radar { height: 280px; }
.chart-wrap-small { height: 160px; }

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

.weak-rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #f7f7f8;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
}

.weak-rank-item:active { background: var(--teal-50); }

.weak-rank-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal-600);
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.weak-rank-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.weak-rank-meta {
  font-size: 0.7rem;
  color: var(--teal-600);
  font-weight: 700;
}

.weak-rank-text {
  font-size: 0.82rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weak-rank-count {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--red-600);
  background: var(--red-50);
  border-radius: 999px;
  padding: 3px 9px;
}

/* ---------- Settings ---------- */
.settings-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.settings-desc {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 0 0 16px;
}

.file-btn {
  display: block;
  box-sizing: border-box;
  text-align: center;
  cursor: pointer;
}

/* ---------- Update toast ---------- */
.update-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 300;
  max-width: 528px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--teal-900);
  color: white;
  border-radius: 14px;
  padding: 12px 12px 12px 16px;
  box-shadow: 0 8px 24px rgba(15, 61, 62, 0.35);
  transform: translateY(140%);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

.update-toast.show {
  transform: translateY(0);
}

.update-toast-text {
  font-size: 0.85rem;
  font-weight: 700;
  flex: 1;
}

.update-toast-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.update-toast-btn {
  background: var(--teal-300);
  color: var(--teal-900);
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.update-toast-btn:active { transform: scale(0.97); }

.update-toast-dismiss {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Mode tabs (択一トレ / 条文トレ) ---------- */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-tab {
  padding: 16px 10px;
  border-radius: var(--radius);
  border: 1.5px solid var(--teal-500);
  background: white;
  color: var(--teal-700);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.mode-tab:active { transform: scale(0.98); }

.mode-tab.active {
  background: linear-gradient(135deg, var(--teal-700), var(--teal-600));
  border-color: var(--teal-600);
  color: white;
}

.mode-tabs-small {
  margin-bottom: 16px;
}

.mode-tabs-small .mode-tab {
  padding: 10px 8px;
  font-size: 0.85rem;
  box-shadow: none;
}

/* ---------- Bottom navigation (共通) ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(13, 148, 136, 0.08);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 9px 4px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
}

.bottom-nav-btn.active { color: var(--teal-600); }

.bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ---------- フッター(免責表示) ---------- */
.app-footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 20px calc(80px + env(safe-area-inset-bottom));
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.6;
  text-align: center;
}

.app-footer p { margin: 2px 0; }

/* ---------- 条文トレ: カード / 穴埋め ---------- */
.jobun-card { padding: 20px 16px; }

.jobun-article-text {
  font-size: 1rem;
  line-height: 2.2;
  margin: 0;
  white-space: pre-wrap;
  color: var(--ink);
}

.jobun-blank {
  display: inline-block;
  min-width: 3.6em;
  padding: 1px 8px;
  margin: 0 2px;
  border-radius: 6px;
  font-weight: 800;
  text-align: center;
  vertical-align: baseline;
}

.jobun-blank.pending {
  background: #e5e7eb;
  border-bottom: 2px solid #9ca3af;
}

.jobun-blank.active {
  background: var(--teal-100);
  border-bottom: 2px solid var(--teal-500);
}

.jobun-blank.resolved.correct {
  background: var(--green-50);
  color: var(--green-600);
  border-bottom: 2px solid var(--green-600);
}

.jobun-blank.resolved.incorrect {
  background: var(--red-50);
  color: var(--red-600);
  border-bottom: 2px solid var(--red-600);
}

.jobun-dontknow-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-decoration: underline;
  padding: 4px 0 14px;
  cursor: pointer;
}

/* ---------- 条文トレ: 4択グリッド ---------- */
.jobun-choice-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 54px;
  margin-bottom: 6px;
}

.jobun-choice-btn {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 10px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.jobun-choice-btn:active { background: var(--teal-50); }

.jobun-choice-btn.correct {
  border-color: var(--green-600);
  background: var(--green-50);
  color: var(--green-600);
}

.jobun-choice-btn.incorrect {
  border-color: var(--red-600);
  background: var(--red-50);
  color: var(--red-600);
}

.jobun-choice-btn.disabled { cursor: default; }

.jobun-session-counter {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--teal-900);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(15, 61, 62, 0.35);
  z-index: 5;
  pointer-events: none;
}

/* ---------- 条文トレ: フィードバック / アクション ---------- */
.jobun-feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--teal-900);
  color: white;
  text-align: center;
}

.jobun-feedback .feedback-text { margin: 0; }

.jobun-post-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.jobun-post-actions-secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.jobun-post-actions-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.jobun-post-actions .btn {
  margin-bottom: 0;
  font-size: 0.85rem;
  padding: 13px 6px;
}

.jobun-post-actions-primary .btn {
  font-size: 0.95rem;
  padding: 15px 6px;
  font-weight: 800;
}

.jobun-post-actions #btnJobunBookmark.active {
  background: var(--teal-100);
  border-color: var(--teal-600);
  color: var(--teal-700);
}

/* ---------- 条文一覧(アコーディオン) ---------- */
.jobun-law-group { margin-bottom: 10px; }

.jobun-law-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.jobun-law-heading:active { background: var(--teal-50); }

.jobun-law-heading.expanded {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: none;
}

.jobun-law-heading-name {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jobun-law-heading-stats {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal-700);
  background: var(--teal-50);
  border-radius: 999px;
  padding: 3px 10px;
}

.jobun-law-heading-chevron {
  flex-shrink: 0;
  color: var(--teal-500);
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}

.jobun-law-heading.expanded .jobun-law-heading-chevron {
  transform: rotate(180deg);
}

.jobun-law-rows {
  background: var(--teal-50);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  padding: 10px;
}

.jobun-article-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 8px;
  cursor: pointer;
}

.jobun-law-rows .jobun-article-row:last-child { margin-bottom: 0; }

.jobun-article-row:active { background: var(--teal-50); }

.jobun-mastery-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.jobun-mastery-dot.gray { background: #cbd5e1; }
.jobun-mastery-dot.teal { background: var(--teal-500); }
.jobun-mastery-dot.red { background: var(--red-600); }

.jobun-article-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.jobun-article-row-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.jobun-article-row-preview {
  font-size: 0.75rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
