/* ==========================================================================
   Scientia — 高校理科 白チャート式自習ソフト
   White Base + Gold Accent (Obsidian + Gold Dark Mode)
   ========================================================================== */

:root {
  --bg: #FAF8F3;
  --surface: rgba(255, 255, 255, 0.90);
  --surface-2: rgba(248, 243, 231, 0.92);
  --surface-elevated: #FFFFFF;
  --ink: #1A1814;
  --ink-soft: #464034;
  --muted: #766C59;

  --gold: #B8860B;
  --gold-mid: #C99A2E;
  --gold-bright: #D4AF37;
  --gold-deep: #8C6508;
  --gold-soft: rgba(212, 175, 55, 0.13);
  --gold-soft-2: rgba(212, 175, 55, 0.24);

  --line: rgba(184, 134, 11, 0.22);
  --line-strong: rgba(184, 134, 11, 0.48);
  --line-neutral: rgba(28, 27, 24, 0.12);
  --specular: rgba(255, 255, 255, 0.96);

  --ps-btn-bg: #FFFDF7;
  --ps-btn-border: rgba(184, 134, 11, 0.58);
  --ps-btn-fg: #7D5A06;
  --ps-cross: #2458A6;
  --ps-circle: #B83B3B;
  --ps-square: #8642A8;
  --ps-triangle: #1E7A56;

  --ok: #256D4B;
  --ok-soft: #EAF5EF;
  --ng: #A83832;
  --ng-soft: #FCEEEA;
  --warn: #9E7318;
  --warn-soft: #FDF5E2;

  /* Subject Accents (harmonized with Pearl + Gold) */
  --subj-physics: #2B5B84;
  --subj-physics-soft: #EDF4FA;
  --subj-chemistry: #8A4F2B;
  --subj-chemistry-soft: #FAF0EA;
  --subj-biology: #2F6F4E;
  --subj-biology-soft: #ECF6F0;
  --subj-earth: #6B4C8C;
  --subj-earth-soft: #F3EFF9;

  --grad-champagne: linear-gradient(135deg, rgba(255,255,255,0.92) 0%, rgba(250,246,236,0.88) 58%, rgba(243,233,210,0.88) 100%);
  --grad-gold: linear-gradient(135deg, #C89B3C 0%, #B8860B 50%, #9E7318 100%);
  --grad-gold-subtle: linear-gradient(180deg, rgba(212, 175, 55, 0.08) 0%, rgba(255, 255, 255, 0) 100%);

  --shadow-sm: 0 2px 8px rgba(28, 27, 24, 0.07), 0 4px 16px rgba(158, 115, 24, 0.06);
  --shadow-md: 0 8px 24px rgba(28, 27, 24, 0.10), 0 14px 36px rgba(158, 115, 24, 0.09);
  --shadow-lg: 0 14px 36px rgba(28, 27, 24, 0.16), 0 24px 60px rgba(158, 115, 24, 0.16);

  --serif: "Noto Serif JP", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "MS PMincho", Georgia, serif;
  --sans: "Noto Sans JP", "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --maxw: 1220px;
  --topbar-h: 50px;
  --hudbar-h: 34px;
}

:root[data-theme="dark"] {
  --bg: #080A12;
  --surface: rgba(16, 20, 32, 0.72);
  --surface-2: rgba(22, 27, 44, 0.80);
  --surface-elevated: rgba(24, 30, 48, 0.88);
  --ink: #F4F6FB;
  --ink-soft: #C7CEE0;
  --muted: #8E97B0;

  --gold: #E5C158;
  --gold-mid: #F0D278;
  --gold-bright: #F5D77F;
  --gold-deep: #B8860B;
  --gold-soft: rgba(229, 193, 88, 0.14);
  --gold-soft-2: rgba(229, 193, 88, 0.24);

  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(229, 193, 88, 0.36);
  --line-neutral: rgba(255, 255, 255, 0.10);
  --specular: rgba(255, 255, 255, 0.12);

  --ps-btn-bg: rgba(22, 27, 44, 0.88);
  --ps-btn-border: rgba(229, 193, 88, 0.46);
  --ps-btn-fg: #F5D77F;
  --ps-cross: #6FA8FF;
  --ps-circle: #FF7B7B;
  --ps-square: #C98BFF;
  --ps-triangle: #5CD6A0;

  --ok: #59B98A;
  --ok-soft: rgba(89, 185, 138, 0.16);
  --ng: #E87B74;
  --ng-soft: rgba(232, 123, 116, 0.16);
  --warn: #F0D278;
  --warn-soft: rgba(240, 210, 120, 0.16);

  --subj-physics: #76B3E8;
  --subj-physics-soft: rgba(118, 179, 232, 0.16);
  --subj-chemistry: #E5A073;
  --subj-chemistry-soft: rgba(229, 160, 115, 0.16);
  --subj-biology: #6FC798;
  --subj-biology-soft: rgba(111, 199, 152, 0.16);
  --subj-earth: #B599E0;
  --subj-earth-soft: rgba(181, 153, 224, 0.16);

  --grad-champagne: linear-gradient(135deg, rgba(22, 28, 46, 0.88) 0%, rgba(16, 20, 32, 0.82) 58%, rgba(30, 26, 22, 0.86) 100%);
  --grad-gold: linear-gradient(135deg, #F0D278 0%, #E5C158 50%, #B8860B 100%);
  --grad-gold-subtle: linear-gradient(180deg, rgba(229, 193, 88, 0.10) 0%, rgba(16, 20, 32, 0) 100%);

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.40);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.52);
  --shadow-lg: 0 20px 52px rgba(0, 0, 0, 0.70);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100dvh;
  overflow: hidden;
  margin: 0;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  background-image:
    linear-gradient(180deg, rgba(250, 248, 244, 0.52), rgba(244, 239, 230, 0.76)),
    url('./assets/ui/bg-ps5-light.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  height: 100dvh;
  overflow: hidden;
}

:root[data-theme="dark"] body {
  background-image:
    linear-gradient(180deg, rgba(6, 8, 14, 0.45), rgba(6, 8, 14, 0.72)),
    url('./assets/ui/bg-ps5-dark.png');
  background-size: cover;
  background-position: center;
}

#app {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--hudbar-h);
  overflow: hidden;
}

#main-view,
.screen-viewport {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

a {
  color: var(--gold-deep);
  text-decoration: none;
  transition: color 0.16s ease;
}
:root[data-theme="dark"] a { color: var(--gold-mid); }
a:hover { color: var(--gold); }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

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

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.32;
  margin: 0;
  color: var(--ink);
}

/* Boot */
.boot {
  grid-row: 1 / -1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink-soft);
  font-weight: 600;
}
.boot-emblem {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFFFF, #F5E9C9);
  border: 1.5px solid rgba(184, 134, 11, 0.55);
  color: var(--gold-deep);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(184, 134, 11, 0.22);
}
:root[data-theme="dark"] .boot-emblem {
  background: radial-gradient(circle at 35% 30%, #1c2238, #080a12);
  border: 1.5px solid rgba(229, 193, 88, 0.50);
  color: var(--gold-bright);
  box-shadow: var(--shadow-md);
}

/* ── Topbar ── */
.topbar {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  padding: 0 14px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: inset 0 -1px 0 var(--specular), 0 2px 12px rgba(158, 115, 24, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 9px;
  padding: 2px 6px 2px 2px;
}
.brand-emblem-medallion {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFFFF, #F5E9C9);
  border: 1.5px solid rgba(184, 134, 11, 0.55);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.18);
  flex-shrink: 0;
}
:root[data-theme="dark"] .brand-emblem-medallion {
  background: radial-gradient(circle at 35% 30%, #1c2238, #080a12);
  border: 1px solid rgba(229, 193, 88, 0.45);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--grad-gold);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.28);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  padding: 2px 0;
}
.topnav-bumper {
  display: inline-flex;
  align-items: center;
  opacity: 0.85;
  flex-shrink: 0;
}

.topnav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.16s ease;
  border: 1px solid transparent;
}
.topnav a:hover {
  background: var(--gold-soft);
  color: var(--gold-deep);
  border-color: var(--line);
}
:root[data-theme="dark"] .topnav a:hover {
  color: var(--gold-bright);
}
.topnav a.active {
  background: var(--grad-gold);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.25);
}

.topbar-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.quick-search-wrap {
  position: relative;
}
.quick-search {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.quick-search:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
.quick-search-icon {
  font-size: 13px;
  color: var(--gold);
}
.quick-search input {
  border: 0;
  background: transparent;
  outline: none;
  width: 155px;
  font-size: 13px;
}
.quick-search input::placeholder { color: var(--muted); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, 88vw);
  max-height: 420px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 80;
}
.search-dropdown[hidden] { display: none; }
.search-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.14s ease;
}
.search-item:hover {
  background: var(--gold-soft);
}
.search-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
}
.search-item-meta {
  font-size: 11.5px;
  color: var(--muted);
}
.search-empty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  touch-action: manipulation;
  transition: all 0.16s ease;
}
.icon-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold-deep);
}
:root[data-theme="dark"] .icon-btn:hover { color: var(--gold-bright); }
.icon-btn.active {
  background: var(--grad-gold);
  border-color: transparent;
  color: #FFFFFF;
}

/* ── Layout ── */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(14px, 3.5vw, 36px);
}

main {
  display: block;
  min-height: calc(100vh - var(--topbar-h) - 80px);
}

.page {
  padding-top: 28px;
  padding-bottom: 72px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  text-decoration: none;
}
.btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold-deep);
}
:root[data-theme="dark"] .btn:hover { color: var(--gold-bright); }

.btn-gold {
  background: var(--grad-gold);
  border-color: transparent;
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(184, 134, 11, 0.25);
}
.btn-gold:hover {
  background: linear-gradient(135deg, #D4AF37 0%, #B8860B 100%);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(184, 134, 11, 0.34);
}
.btn-sm {
  padding: 5px 12px;
  font-size: 12.5px;
}

/* ── Badges & Pills ── */
.subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.subject-pill[data-subject="physics"] {
  background: var(--subj-physics-soft);
  color: var(--subj-physics);
}
.subject-pill[data-subject="chemistry"] {
  background: var(--subj-chemistry-soft);
  color: var(--subj-chemistry);
}
.subject-pill[data-subject="biology"] {
  background: var(--subj-biology-soft);
  color: var(--subj-biology);
}
.subject-pill[data-subject="earth"] {
  background: var(--subj-earth-soft);
  color: var(--subj-earth);
}

.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.level-badge.lv-1 {
  background: #F4EFE6;
  color: #6B5B3E;
  border-color: rgba(184, 134, 11, 0.25);
}
.level-badge.lv-2 {
  background: #FBF5E6;
  color: #9E7318;
  border-color: rgba(184, 134, 11, 0.40);
}
.level-badge.lv-3 {
  background: linear-gradient(135deg, #FBF2D8, #F4E2B2);
  color: #7D5608;
  border-color: rgba(184, 134, 11, 0.60);
}
.level-badge.lv-4 {
  background: var(--grad-gold);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(184, 134, 11, 0.25);
}
:root[data-theme="dark"] .level-badge.lv-1 {
  background: rgba(255, 255, 255, 0.07);
  color: #CFC7B6;
}
:root[data-theme="dark"] .level-badge.lv-2 {
  background: rgba(212, 175, 55, 0.14);
  color: #E3C15A;
}
:root[data-theme="dark"] .level-badge.lv-3 {
  background: rgba(212, 175, 55, 0.25);
  color: #F6DF96;
}

/* ── Cards & Panels ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.card-hover:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 {
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-head h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--grad-gold);
}
.section-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ── Progress Bar ── */
.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad-gold);
  transition: width 0.35s ease;
}

/* ── Home View ── */
.hero {
  background: var(--grad-champagne);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 42px);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  margin-bottom: 28px;
}
.hero::after {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.18) 0%, transparent 70%);
  pointer-events: none;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold-deep);
  text-transform: uppercase;
  margin-bottom: 10px;
}
:root[data-theme="dark"] .hero-kicker { color: var(--gold-mid); }
.hero h1 {
  font-size: clamp(26px, 3.6vw, 38px);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.hero p {
  max-width: 68ch;
  color: var(--ink-soft);
  margin: 0 0 22px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.stat-value {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--gold-deep);
}
:root[data-theme="dark"] .stat-value { color: var(--gold-bright); }
.stat-foot {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 34px;
}
.subject-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  position: relative;
}
.subject-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.subject-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.subject-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--gold-soft);
  border: 1px solid var(--line);
}
.subject-card h3 {
  font-size: 19px;
}
.subject-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.subject-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}

.level-guide-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 34px;
}
.level-guide-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.level-guide-card p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.quick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.quick-example-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

/* ── Filter Bar & Chips ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold-deep);
}
.chip.active {
  background: var(--grad-gold);
  border-color: transparent;
  color: #FFFFFF;
  font-weight: 600;
}

/* ── Unit List (Subject View) ── */
.unit-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}
.unit-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.unit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.unit-order {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold-deep);
  text-transform: uppercase;
}
:root[data-theme="dark"] .unit-order { color: var(--gold-mid); }
.unit-card h3 { font-size: 18px; }
.unit-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* ── Unit View (White Chart Core) ── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--gold); }

.unit-header {
  background: var(--grad-champagne);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.unit-header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.unit-header h1 {
  font-size: clamp(22px, 3vw, 30px);
  margin-bottom: 8px;
}
.unit-header p {
  margin: 0;
  color: var(--ink-soft);
}

.unit-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

/* Foundations / Formula Boxes */
.foundations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}
.formula-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.formula-box h3 {
  font-size: 16.5px;
  margin-bottom: 10px;
  color: var(--ink);
}
.formula-math {
  background: var(--gold-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
  overflow: hidden;
}
.formula-points {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.formula-points li + li { margin-top: 4px; }

/* Example Card (White Chart Example-First) */
.examples-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.example-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.example-card.is-done {
  border-color: rgba(37, 109, 75, 0.45);
}

.example-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  background: var(--grad-champagne);
  border-bottom: 1px solid var(--line);
}
.example-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.example-num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 13px;
  color: var(--gold-deep);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  padding: 2px 10px;
  border-radius: 999px;
}
:root[data-theme="dark"] .example-num { color: var(--gold-bright); }
.example-header h3 {
  font-size: 18.5px;
}

.example-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.done-toggle.checked {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
}
.bookmark-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
}
.bookmark-btn.active {
  background: var(--gold-soft-2);
  border-color: var(--gold);
  color: var(--gold-deep);
}

.example-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.problem-box {
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.problem-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold-deep);
  text-transform: uppercase;
  margin-bottom: 6px;
}
:root[data-theme="dark"] .problem-label { color: var(--gold-mid); }

.diagram-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.diagram-box svg {
  max-width: 100%;
  height: auto;
}
.diagram-caption {
  font-size: 12.5px;
  color: var(--muted);
}

/* 白チャート指針 (Chart Pointer) */
.chart-pointer {
  background: linear-gradient(135deg, var(--gold-soft) 0%, var(--surface) 100%);
  border: 1px solid var(--line-strong);
  border-left: 5px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.chart-pointer-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14.5px;
  color: var(--gold-deep);
  margin-bottom: 6px;
}
:root[data-theme="dark"] .chart-pointer-head { color: var(--gold-bright); }
.chart-pointer-body {
  font-size: 14.5px;
  color: var(--ink);
}

/* Collapsible Solution & Explanation */
.solution-toggle-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.solution-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.solution-panel[hidden] { display: none; }

.solution-steps {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.solution-steps li {
  padding-left: 4px;
  line-height: 1.75;
}

.final-answer-box {
  background: var(--gold-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}
.final-answer-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-deep);
  letter-spacing: 0.08em;
}
:root[data-theme="dark"] .final-answer-label { color: var(--gold-bright); }
.final-answer-val {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.explanation-box {
  font-size: 14.5px;
  color: var(--ink-soft);
  border-top: 1px dashed var(--line-strong);
  padding-top: 12px;
}
.pitfall-box {
  background: var(--ng-soft);
  border: 1px solid rgba(168, 56, 50, 0.25);
  border-left: 4px solid var(--ng);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  font-size: 13.5px;
}
.pitfall-title {
  font-weight: 700;
  color: var(--ng);
  margin-bottom: 4px;
}

/* Personal Memo */
.memo-box {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.memo-box label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.memo-box textarea {
  width: 100%;
  min-height: 62px;
  resize: vertical;
  border: 1px solid var(--line-neutral);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 8px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}
.memo-box textarea:focus {
  border-color: var(--gold);
}

/* Similar Practice Section */
.practice-section {
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  padding: 18px 22px;
}
.practice-section-title {
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.practice-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.practice-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

/* Unit Terms Footer */
.unit-terms-footer {
  margin-top: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.terms-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.term-chip:hover {
  border-color: var(--gold);
  background: var(--gold-soft-2);
}

/* ── Interactive Practice Widgets (for interactive.js) ── */
.practice-prompt {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--ink);
}
.practice-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.practice-feedback {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.6;
}
.practice-feedback.is-ok {
  background: var(--ok-soft);
  border: 1px solid rgba(37, 109, 75, 0.35);
  color: var(--ok);
}
.practice-feedback.is-ng {
  background: var(--ng-soft);
  border: 1px solid rgba(168, 56, 50, 0.35);
  color: var(--ng);
}

/* Choice Grid */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
}
.choice-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.choice-btn.selected {
  border-color: var(--gold);
  background: var(--gold-soft-2);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}
.choice-btn.correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.choice-btn.wrong {
  border-color: var(--ng);
  background: var(--ng-soft);
}

/* Formula Tap */
.formula-tap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.formula-slots {
  min-height: 48px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line-strong);
  background: var(--bg);
}
.formula-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.formula-token {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.formula-token:hover:not(:disabled) {
  border-color: var(--gold);
  background: var(--gold-soft);
  transform: translateY(-1px);
}
.formula-token:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Graph Builder */
.graph-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.graph-canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  justify-content: center;
}
.graph-svg {
  width: 100%;
  max-width: 460px;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}
.graph-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.graph-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Vector Builder */
.vector-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.vector-canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  justify-content: center;
}
.vector-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Numeric / Calculator input row */
.calc-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.calc-answer-input {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14.5px;
  outline: none;
}
.calc-answer-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

/* ── Scientific Calculator Drawer (.calc-drawer) ── */
.calc-drawer {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(370px, calc(100vw - 24px));
  max-height: calc(100vh - 90px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.calc-drawer[hidden],
.calc-drawer.is-closed {
  display: none;
}
.calc-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: var(--grad-champagne);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 14px;
}
.calc-drawer-body {
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.calc-display {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: right;
  font-family: var(--mono);
}
.calc-expr {
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
  word-break: break-all;
}
.calc-result {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  min-height: 30px;
  word-break: break-all;
}
.calc-keypad {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.calc-key {
  padding: 9px 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.calc-key:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.calc-key.is-op {
  background: var(--gold-soft);
  color: var(--gold-deep);
}
:root[data-theme="dark"] .calc-key.is-op { color: var(--gold-bright); }
.calc-key.is-eq {
  background: var(--grad-gold);
  color: #FFFFFF;
  border-color: transparent;
}
.calc-history {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  max-height: 110px;
  overflow: hidden;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
}

/* ── Glossary View ── */
.glossary-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.glossary-search {
  flex: 1;
  min-width: 240px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 14.5px;
  outline: none;
}
.glossary-search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.term-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.term-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.term-card h3 {
  font-size: 17px;
  color: var(--ink);
}
.term-reading {
  font-size: 12px;
  color: var(--muted);
}
.term-formula {
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
}

/* ── Modal Backdrop (Term Popup) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 16, 13, 0.56);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 120;
}
.modal-backdrop[hidden] { display: none; }
.modal-dialog {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow: hidden;
  background: var(--surface);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--specular);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.modal-close {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.modal-close:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hudbar-h) + 12px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 140;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Empty State ── */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}

/* ==========================================================================
   One-Screen Puzzle-Game Console Layout & Controller Focus
   ========================================================================== */

/* ── Signature PS5 Focus Reticle ── */
[data-nav-item]:focus-visible,
[data-nav-item].is-gp-focused {
  outline: 2.5px solid #C59216 !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(212, 175, 55, 0.25), 0 8px 22px rgba(158, 115, 24, 0.16) !important;
  transform: translateY(-1px);
  transition: outline-color 0.16s ease, box-shadow 0.18s ease, transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  z-index: 2;
}
:root[data-theme="dark"] [data-nav-item]:focus-visible,
:root[data-theme="dark"] [data-nav-item].is-gp-focused {
  outline: 2px solid #F5D77F !important;
  box-shadow: 0 0 0 4px rgba(245, 215, 127, 0.22), 0 10px 28px rgba(0, 0, 0, 0.42) !important;
}

[data-nav-item].is-nav-captured,
[data-nav-item].is-nav-editing {
  outline: 2.5px solid var(--ok) !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 109, 75, 0.26), inset 0 0 0 1px var(--gold-bright) !important;
}

/* ── Bottom HUD Guide Bar ── */
.hud-bottombar {
  height: var(--hudbar-h);
  min-height: var(--hudbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 var(--specular);
  font-size: 11.5px;
  color: var(--ink-soft);
  overflow: hidden;
  z-index: 40;
}

.hud-input-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

.hud-input-status.is-gamepad {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-deep);
}
:root[data-theme="dark"] .hud-input-status.is-gamepad {
  color: var(--gold-bright);
}

.hud-guides {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
}

.hud-guide-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-neutral);
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ── Screen Stages & Split Panels ── */
.screen-stage {
  height: 100%;
  min-height: 0;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 14px;
  display: grid;
  gap: 12px;
  overflow: hidden;
}

.home-stage {
  grid-template-columns: 1.25fr 1fr;
}

.subject-stage {
  grid-template-columns: 1.55fr 1fr;
}

.unit-stage {
  grid-template-rows: auto 1fr;
}

.arena-stage {
  grid-template-rows: auto 1fr;
}

.glossary-stage {
  grid-template-rows: auto 1fr;
}

.unit-split {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 12px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.puzzle-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--specular);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.puzzle-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.puzzle-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.puzzle-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ── Single-Focus Stage Architecture ── */
.stage-single {
  max-width: 1080px;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.unit-stage.stage-single {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.stage-card-focused {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-elevated);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.stage-card-focused .puzzle-panel-body {
  padding: 18px 26px;
  font-size: 15.5px;
  line-height: 1.75;
}

.phase-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
}

.phase-stepper > button,
.phase-stepper .phase-step {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.phase-stepper > button:hover,
.phase-stepper .phase-step:hover {
  color: var(--ink);
  background: var(--gold-soft);
  border-color: var(--line);
}

.phase-stepper > button.is-done,
.phase-stepper .phase-step.is-done {
  color: var(--ink-soft);
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface-elevated) 75%, transparent);
}

.phase-stepper > button.is-active,
.phase-stepper .phase-step.is-active,
.phase-stepper > button[aria-current="step"],
.phase-stepper .phase-step[aria-current="step"] {
  background: linear-gradient(135deg, #D4AF37 0%, #B8860B 100%);
  border-color: var(--gold-deep);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.25);
}

/* ── Grids & Puzzle Tiles ── */
.world-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.stage-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.stage-tile:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.stage-tile.is-selected {
  border-color: var(--gold-bright);
  background: var(--gold-soft);
  box-shadow: inset 0 0 0 1px var(--gold-bright);
}

.stage-tile.is-cleared {
  border-color: rgba(37, 109, 75, 0.5);
  background: linear-gradient(180deg, var(--ok-soft) 0%, var(--surface) 100%);
}

.stage-row-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.stage-row:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.stage-row-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stage-row-main {
  min-width: 0;
  flex: 1 1 auto;
}

.stage-row-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-row-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-row-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--ok);
  flex-shrink: 0;
}

.pip-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  display: inline-block;
}

.pip.is-done {
  background: var(--gold-bright);
  border-color: var(--gold);
  box-shadow: 0 0 4px rgba(212, 175, 55, 0.45);
}

.pip-practice {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

/* ── Toolbars & Stage Bars ── */
.unit-stage-bar,
.arena-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.unit-stage-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.unit-stage-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.unit-mode-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.lv-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  margin-right: 4px;
}

/* ── Home, Subject, Unit, Arena, Glossary Sub-Elements ── */
.home-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.home-quick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.home-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.tab-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.pager-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pager-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 44px;
  text-align: center;
}

.subject-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.subject-switcher,
.level-filter-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.stage-clear-mark {
  font-size: 13px;
  font-weight: 700;
  color: var(--ok);
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inspector-body {
  gap: 10px;
}

.inspector-title {
  font-size: 18px;
  font-family: var(--serif);
}

.inspector-desc {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0;
}

.inspector-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inspector-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 4px;
}

.ex-code {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold-deep);
}
:root[data-theme="dark"] .ex-code {
  color: var(--gold-mid);
}

.step-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.foundation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.foundation-title {
  font-size: 17px;
  font-family: var(--serif);
  margin-bottom: 6px;
}

.foundation-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
}

.foundation-points-box {
  background: var(--gold-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

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

.formula-note {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.solution-step-item {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 8px;
}

.solution-step-head {
  font-weight: 700;
  font-size: 13px;
  color: var(--gold-deep);
  margin-bottom: 4px;
}
:root[data-theme="dark"] .solution-step-head {
  color: var(--gold-bright);
}

.solution-step-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink);
}

.practice-panel-head {
  gap: 8px;
}

.stage-jump-btn {
  padding: 4px 8px;
  min-width: 32px;
  text-align: center;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}

.term-stage-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
}

.term-formula-mini {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--gold-deep);
}
:root[data-theme="dark"] .term-formula-mini {
  color: var(--gold-mid);
}

.glossary-search {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  min-width: 170px;
}

/* ── Search & Controls Modals ── */
.modal-dialog-wide {
  width: min(760px, 100%);
}

.search-modal-input-wrap {
  margin-bottom: 10px;
}

.search-modal-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
}

.search-results,
.search-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: hidden;
  min-height: 0;
}

.search-modal-foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: hidden;
  min-height: 0;
}

.help-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.help-card-action {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--gold-deep);
  white-space: nowrap;
}
:root[data-theme="dark"] .help-card-action {
  color: var(--gold-bright);
}

.help-card-binds {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.help-card-pad {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.help-card-key {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
}

.term-modal-fit-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.term-modal-def {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
}

.term-modal-foot {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ==========================================================================
   PS5 Console Activity Cards, Artwork, Trophy Emblems & Glyphs
   ========================================================================== */

[data-fit-box] {
  overflow: hidden;
  min-height: 0;
}

.ps5-art-card {
  position: relative;
  overflow: hidden;
  border: 1.5px solid var(--line-strong);
  background: #FFFFFF;
  box-shadow: 0 4px 16px rgba(158, 115, 24, 0.08);
}
:root[data-theme="dark"] .ps5-art-card {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.ps5-art-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--card-art);
  background-size: cover;
  background-position: center;
  opacity: 0.55;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
  z-index: 0;
  pointer-events: none;
}
.ps5-art-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 253, 248, 0.84) 68%, rgba(251, 245, 230, 0.95) 100%);
  z-index: 0;
  pointer-events: none;
}
:root[data-theme="dark"] .ps5-art-card::after {
  background: linear-gradient(180deg, rgba(8, 10, 18, 0.35) 0%, rgba(8, 10, 18, 0.86) 100%);
}
.ps5-art-card > * {
  position: relative;
  z-index: 1;
}
.ps5-art-card:hover::before,
.ps5-art-card.is-gp-focused::before {
  transform: scale(1.06);
  opacity: 0.65;
}

.ps5-inspector-hero {
  position: relative;
  height: 98px;
  min-height: 92px;
  max-height: 108px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: #FFFFFF;
  background-image: var(--card-art);
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px 12px;
  border: 1.5px solid var(--line-strong);
  box-shadow: 0 4px 16px rgba(158, 115, 24, 0.08);
  flex-shrink: 0;
}
:root[data-theme="dark"] .ps5-inspector-hero {
  background-color: var(--surface-2);
  box-shadow: none;
}
.ps5-inspector-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 253, 248, 0.86) 72%, rgba(251, 245, 230, 0.95) 100%);
  z-index: 0;
  pointer-events: none;
}
:root[data-theme="dark"] .ps5-inspector-hero::after {
  background: linear-gradient(180deg, rgba(8, 10, 18, 0.18) 0%, rgba(8, 10, 18, 0.86) 100%);
}
.ps5-inspector-hero > * {
  position: relative;
  z-index: 1;
}

.ps5-banner-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background-color: var(--surface-2);
}

.ps5-trophy-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}
.ps5-trophy-mini {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
}

.ps-glyph-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}
.ps-glyph {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ps-key-hint {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  padding: 0 3px;
}

/* ── Responsive (One-Screen Safe) ── */
@media (max-width: 960px) {
  .home-stage,
  .subject-stage,
  .unit-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
  .stage-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .stats-grid,
  .level-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-height: 760px) {
  :root {
    --topbar-h: 44px;
    --hudbar-h: 30px;
  }
  .screen-stage {
    padding: 6px 10px;
    gap: 8px;
  }
  .puzzle-panel-head {
    padding: 6px 10px;
  }
  .puzzle-panel-body {
    padding: 8px 10px;
    gap: 8px;
  }
  .stage-tile {
    padding: 7px 9px;
    gap: 4px;
  }
  .unit-stage-bar,
  .arena-toolbar {
    padding: 5px 10px;
  }
}

@media (max-width: 768px) {
  .topbar {
    gap: 8px;
    padding: 0 10px;
    overflow: hidden;
  }
  .topbar-tools {
    gap: 6px;
  }
  #btn-pad-toggle,
  #btn-calc-toggle {
    min-height: 34px;
    padding: 5px 10px;
    touch-action: manipulation;
  }
}

@media (max-width: 640px) {
  .topbar {
    gap: 6px;
    padding: 0 8px;
  }
  .topnav a {
    padding: 4px 8px;
    font-size: 12px;
  }
  .icon-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  .stage-grid,
  .world-grid,
  .codex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hud-guides {
    display: none;
  }
}

/* ── Print ── */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  .topbar,
  .topbar-tools,
  .calc-drawer,
  .toast-container,
  .modal-backdrop,
  .filter-bar,
  .solution-toggle-bar,
  .memo-box,
  .app-footer {
    display: none !important;
  }
  .solution-panel[hidden] {
    display: flex !important;
  }
  .card,
  .example-card,
  .formula-box {
    box-shadow: none !important;
    border-color: #CCCCCC !important;
    break-inside: avoid;
  }
}


/* ==========================================================================
   yukkuri_science — ゆっくり対話＆演習 UI スタイル
   ========================================================================== */

#app-root {
  min-height: 100dvh;
}

.boot {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--ink-soft);
}

/* 共通ボタン・バッジ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-primary {
  background: var(--grad-gold);
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  filter: brightness(1.06);
  background: var(--grad-gold);
}

.btn-danger {
  border-color: var(--ng);
  color: var(--ng);
}

.btn-danger:hover {
  background: var(--ng-soft);
}

/* ホーム画面 */
.home-shell {
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: block;
  height: auto;
  min-height: 0;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  border: 1px solid var(--line-strong);
}

[data-theme="dark"] .brand-badge {
  color: var(--gold-bright);
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.search-wrap {
  position: relative;
  flex: 1 1 240px;
  max-width: 380px;
}

.search-input {
  width: 100%;
  padding: 8px 30px 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 13px;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}

.progress-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.filter-bar {
  max-width: 1240px;
  margin: 10px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-elevated);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip.is-active {
  background: var(--grad-gold);
  color: #fff;
  border-color: transparent;
}

.home-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.resume-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface-elevated);
  border: 1.5px solid var(--gold);
  box-shadow: var(--shadow-sm);
}

.resume-kicker {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-deep);
}

[data-theme="dark"] .resume-kicker {
  color: var(--gold-bright);
}

.resume-title {
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}

.resume-sub {
  font-size: 12px;
  color: var(--muted);
}

.subject-shelf {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shelf-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  padding-left: 10px;
  border-left: 4px solid var(--gold);
}

.shelf-title.subject-dot-physics { border-left-color: var(--subj-physics); }
.shelf-title.subject-dot-chemistry { border-left-color: var(--subj-chemistry); }
.shelf-title.subject-dot-biology { border-left-color: var(--subj-biology); }
.shelf-title.subject-dot-earth { border-left-color: var(--subj-earth); }

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.unit-card {
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-elevated);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.unit-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
}

.unit-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tier-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.tier-jhs {
  background: var(--subj-biology-soft);
  color: var(--subj-biology);
}

.tier-hs {
  background: var(--subj-physics-soft);
  color: var(--subj-physics);
}

.tier-maniac {
  background: var(--subj-earth-soft);
  color: var(--subj-earth);
}

[data-theme="dark"] .tier-jhs { background: rgba(47,111,78,0.28); color: #86efac; }
[data-theme="dark"] .tier-hs { background: rgba(43,91,132,0.28); color: #93c5fd; }
[data-theme="dark"] .tier-maniac { background: rgba(107,76,140,0.28); color: #d8b4fe; }

.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.status-badge.is-started {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-badge.is-done {
  background: var(--ok-soft);
  color: var(--ok);
}

.unit-card-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.unit-card-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.unit-card-meta {
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ==========================================================================
   ゆっくりステージ画面
   ========================================================================== */

.stage-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  position: relative;
}

.stage-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 15;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.hud-pill:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.hud-pill-accent {
  background: var(--grad-gold);
  color: #fff;
  border-color: transparent;
}

.hud-unit-title {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-popover {
  position: absolute;
  top: 54px;
  z-index: 30;
  width: min(380px, calc(100vw - 24px));
  max-height: 62dvh;
  overflow-y: auto;
  background: var(--surface-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
}

.popover-left { left: 14px; }
.popover-right { right: 14px; }

.popover-header {
  font-size: 13px;
  font-weight: 800;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-list-btn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.step-list-btn:hover { background: var(--gold-soft); }
.step-list-btn.is-active {
  background: var(--gold-soft-2);
  border-color: var(--gold);
  font-weight: 700;
}

.step-list-num {
  width: 22px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.step-list-sec {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-soft);
  flex-shrink: 0;
}

.step-list-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.note-item strong {
  display: block;
  font-size: 13px;
  color: var(--gold-deep);
}

[data-theme="dark"] .note-item strong {
  color: var(--gold-bright);
}

.note-item p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* 中央ボード */
.board-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
}

.board-container {
  max-width: 900px;
  margin: 0 auto;
}

.board-card {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.board-card-kicker {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-deep);
}

[data-theme="dark"] .board-card-kicker {
  color: var(--gold-bright);
}

.board-card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.board-card-desc,
.board-card-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
}

.board-subhead {
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
}

.board-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.55;
}

.board-diagram-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.board-svg {
  width: 100%;
  max-width: 560px;
  height: auto;
  max-height: 190px;
  color: var(--ink);
}

.board-diagram-caption {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.formula-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.formula-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.formula-expr {
  font-size: 14px;
  font-weight: 800;
  margin: 4px 0;
  color: var(--ink);
}

.formula-note {
  font-size: 12px;
  color: var(--ink-soft);
}

.problem-box,
.pointer-box,
.final-answer-box,
.pitfall-box {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.6;
}

.problem-box {
  background: var(--surface-2);
  border-left: 4px solid var(--subj-physics);
}

.pointer-box {
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
}

.final-answer-box {
  background: var(--ok-soft);
  border-left: 4px solid var(--ok);
}

.pitfall-box {
  background: var(--ng-soft);
  border-left: 4px solid var(--ng);
}

.sol-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sol-step {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.sol-step-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.sol-step-math {
  font-size: 14px;
  font-weight: 700;
  margin: 4px 0;
}

.sol-step-text {
  font-size: 13px;
  color: var(--ink-soft);
}

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

.summary-term-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* 下部：ゆっくり対話＆プレイヤーバー */
.caption-pane {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialogue-row {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 112px 1fr 112px;
  align-items: end;
  gap: 12px;
}

.yukkuri-slot {
  position: relative;
  width: 112px;
  height: 98px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.72;
}

.yukkuri-slot[data-speaking="true"] {
  opacity: 1;
  transform: translateY(-4px) scale(1.04);
}

.yukkuri-left .y-part {
  transform: scaleX(-1);
}

.y-part {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.caption-card {
  background: var(--surface-elevated);
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.caption-card[data-speaker="reimu"] {
  border-color: #dc2626;
}

.caption-card[data-speaker="marisa"] {
  border-color: #ca8a04;
}

.caption-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.speaker-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
}

.speaker-tag[data-speaker="reimu"] { background: #dc2626; }
.speaker-tag[data-speaker="marisa"] { background: #b45309; }

.section-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.step-title-el {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.subtitle-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  font-weight: 600;
  color: var(--ink);
}

.caption-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 10px;
}

.caption-footer .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.practice-gate-hint {
  font-size: 11px;
  color: var(--gold-deep);
  font-weight: 700;
  margin-right: auto;
  flex: 1 1 140px;
}

[data-theme="dark"] .practice-gate-hint {
  color: var(--gold-bright);
}

.player-bar {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.ctrl-play.is-playing {
  background: var(--grad-gold);
  color: #fff;
  border-color: transparent;
}

.timeline {
  flex: 1 1 auto;
  display: flex;
  gap: 3px;
  align-items: center;
}

.timeline-seg {
  flex: 1 1 0;
  height: 7px;
  border-radius: 999px;
  border: none;
  background: var(--line);
  cursor: pointer;
  padding: 0;
}

.timeline-seg.is-done { background: var(--ok); }
.timeline-seg.is-active { background: var(--gold); height: 10px; }

.tts-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn-text {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.ctrl-btn-text.is-active {
  border-color: var(--ok);
  color: var(--ok);
}

/* モーダル */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: 84dvh;
  background: var(--surface-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-panel-sm {
  width: min(460px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
}

.modal-search-bar {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  padding: 14px 18px;
  overflow-y: auto;
}

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

.glossary-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.glossary-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.glossary-item-meta {
  font-size: 11px;
  color: var(--muted);
}

.glossary-item p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-label {
  font-size: 12px;
  font-weight: 700;
}

.settings-textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  padding: 8px;
  font-size: 12px;
}

.settings-msg {
  font-size: 12px;
  font-weight: 700;
  color: var(--ok);
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 720px) {
  .topbar {
    padding: 8px 12px;
  }
  .topbar-inner {
    gap: 8px;
  }
  .brand {
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
  }
  .brand-title {
    font-size: 14px;
    word-break: break-word;
  }
  .search-wrap {
    flex: 1 1 100%;
    max-width: none;
  }
  .search-input {
    padding: 6px 28px 6px 10px;
    font-size: 12.5px;
  }
  .filter-bar {
    margin-top: 8px;
    gap: 6px;
  }
  .chip-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .chip-group::-webkit-scrollbar {
    display: none;
  }
  .filter-chip {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 11.5px;
  }
  .home-main {
    padding: 12px 12px 32px;
    gap: 16px;
  }

  .stage-hud {
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .hud-left, .hud-right {
    gap: 5px;
  }
  .hud-pill {
    padding: 4px 9px;
    font-size: 11px;
    gap: 4px;
    white-space: nowrap;
  }
  .hud-unit-title {
    max-width: 118px;
  }
  .board-area {
    padding: 10px 10px;
  }
  .board-card {
    padding: 12px 14px;
    gap: 9px;
    border-radius: 12px;
  }
  .board-card-title {
    font-size: 15.5px;
  }
  .board-card-desc,
  .board-card-body {
    font-size: 13px;
  }

  .caption-pane {
    padding: 8px 10px 10px;
    gap: 6px;
  }
  .dialogue-row {
    grid-template-columns: 62px 1fr 62px;
    gap: 6px;
  }
  .yukkuri-slot {
    width: 62px;
    height: 56px;
  }
  .caption-card {
    padding: 8px 10px;
    gap: 4px;
    border-radius: 11px;
  }
  .step-title-el {
    font-size: 11.5px;
  }
  .subtitle-text {
    font-size: 12.5px;
    line-height: 1.45;
  }
  .ctrl-btn {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  .ctrl-btn-text {
    padding: 4px 7px;
    font-size: 10.5px;
  }
}
