:root {
  --brand-navy: #0d1b2a;
  --brand-blue: #1b4965;
  --brand-cyan: #62b6cb;
  --surface-bg: #eef3f8;
  --panel-bg: #ffffff;
  --panel-border: #dbe4ef;
  --text-soft: #5d7388;
}

body {
  background: radial-gradient(circle at 8% 12%, #dff1ff 0%, #f4f8fc 45%, #ebf1f6 100%);
  min-height: 100vh;
  color: #122235;
}

.topbar {
  background: linear-gradient(120deg, var(--brand-navy), var(--brand-blue));
}

.topbar .btn {
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.topbar .btn:hover {
  transform: translateY(-1px);
}

.subnav-wrap {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

.navbar-brand {
  letter-spacing: 0.02em;
}

.shell {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

.app-hero {
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(125deg, #ffffff 0%, #f4f9ff 50%, #eaf5fb 100%);
  box-shadow: 0 12px 28px rgba(13, 27, 42, 0.08);
}

.panel,
.card {
  border-radius: 16px;
  border: 1px solid var(--panel-border);
}

.card,
.panel {
  box-shadow: 0 10px 24px rgba(13, 27, 42, 0.06);
}

.panel,
.card,
.app-hero {
  animation: fadeUp 0.45s ease both;
}

.stagger-1 { animation-delay: 0.06s; }
.stagger-2 { animation-delay: 0.12s; }
.stagger-3 { animation-delay: 0.18s; }

.fade-in-up {
  animation: fadeUp 0.5s ease both;
}

.pill {
  border-radius: 999px;
}

.muted-note {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.searchbox {
  border-radius: 12px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.25rem;
}

.hero-image {
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: #fff;
  box-shadow: 0 10px 24px rgba(13, 27, 42, 0.08);
}

@media (max-width: 992px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
}

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

/* ---------------------------------------------------------------------------
 * Learn: hub, course outline, lesson reader, quiz
 * ------------------------------------------------------------------------- */
.learn-accent { --accent: var(--brand-blue); }

.progress-thin {
  height: 8px;
  border-radius: 999px;
  background: #e3eaf2;
}
.progress-thin .progress-bar {
  background: var(--accent, var(--brand-blue));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.track-card {
  border-top: 5px solid var(--accent);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.track-card:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(13, 27, 42, 0.1); }
.track-icon {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; font-size: 1.8rem;
  background: color-mix(in srgb, var(--accent) 12%, white);
}
.stat-tile {
  border-radius: 14px; background: #f4f8fc; border: 1px solid var(--panel-border);
  padding: 0.75rem 1rem;
}
.stat-tile .num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-tile .lbl { font-size: 0.8rem; color: var(--text-soft); }

.streak-flame { font-size: 2.2rem; line-height: 1; }
.week-bars { display: flex; align-items: flex-end; gap: 6px; height: 56px; }
.week-bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.week-bars .bar { width: 100%; max-width: 22px; border-radius: 6px 6px 3px 3px; background: var(--brand-cyan); min-height: 4px; }
.week-bars .bar.empty { background: #dbe4ef; }
.week-bars .bar.today { background: var(--brand-blue); }
.week-bars .day { font-size: 0.7rem; color: var(--text-soft); }

.course-head {
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #0d1b2a));
  box-shadow: 0 12px 28px rgba(13, 27, 42, 0.12);
}
.course-head .progress-thin { background: rgba(255,255,255,0.25); }
.course-head .progress-thin .progress-bar { background: #fff; }

.module-card .module-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; font-weight: 700;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, white);
  border-radius: 8px; padding: 0.15rem 0.5rem;
}
.lesson-row {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.7rem 0.75rem; border-radius: 12px;
  color: inherit; text-decoration: none;
  transition: background-color 0.15s ease;
}
.lesson-row:hover { background: #f1f6fb; color: inherit; }
.lesson-row.is-current { background: color-mix(in srgb, var(--accent) 10%, white); }
.check-dot {
  flex: 0 0 28px; height: 28px; border-radius: 50%;
  border: 2px solid #c5d3e1; display: grid; place-items: center;
  font-size: 0.85rem; color: #fff; background: #fff;
}
.check-dot.done { background: #2a9d8f; border-color: #2a9d8f; }
.difficulty-dots { letter-spacing: 1px; color: var(--accent); font-size: 0.7rem; white-space: nowrap; }
.difficulty-dots .off { color: #cdd8e3; }

.lesson-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.5rem; }
.lesson-sidebar { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
@media (max-width: 992px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-sidebar { position: static; max-height: none; }
}
.lesson-body { max-width: 760px; }
.lesson-body .lead { color: var(--text-soft); }
.lesson-content { font-size: 1.05rem; line-height: 1.75; }
.lesson-content h2, .lesson-content h3 { font-size: 1.2rem; font-weight: 700; margin-top: 1.75rem; }
.lesson-content ul, .lesson-content ol { padding-left: 1.3rem; }
.lesson-content li { margin-bottom: 0.3rem; }
.lesson-content blockquote {
  border-left: 4px solid var(--accent); background: #f4f8fc;
  padding: 0.75rem 1rem; border-radius: 0 12px 12px 0; margin: 1.25rem 0;
}
.lesson-content blockquote p:last-child { margin-bottom: 0; }
.lesson-content table { width: 100%; margin: 1rem 0; font-size: 0.95rem; }
.lesson-content th, .lesson-content td { border-bottom: 1px solid var(--panel-border); padding: 0.45rem 0.5rem; }
.lesson-content code { color: inherit; background: #eef3f8; padding: 0.1rem 0.35rem; border-radius: 6px; }

.takeaways {
  border-radius: 16px; padding: 1rem 1.25rem;
  background: color-mix(in srgb, var(--accent) 7%, white);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, white);
}
.takeaways li { margin-bottom: 0.35rem; }
.takeaways li::marker { color: var(--accent); }

.figure-card { border-radius: 16px; border: 1px solid var(--panel-border); background: #fff; overflow: hidden; }
.figure-card img { width: 100%; height: auto; display: block; cursor: zoom-in; background: #fff; }
.figure-card figcaption { padding: 0.6rem 0.9rem; font-size: 0.9rem; color: var(--text-soft); border-top: 1px solid var(--panel-border); }

.def-link {
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px;
  text-decoration-color: var(--accent); cursor: help;
}

.quiz-choice {
  display: block; width: 100%; text-align: left;
  border: 2px solid var(--panel-border); border-radius: 12px;
  background: #fff; padding: 0.7rem 0.9rem; margin-bottom: 0.5rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.quiz-choice:hover:not(:disabled) { border-color: var(--accent); }
.quiz-choice.correct { border-color: #2a9d8f; background: #e8f6f3; }
.quiz-choice.wrong { border-color: #e76f51; background: #fdeee9; }
.quiz-choice:disabled { opacity: 1; cursor: default; }
.quiz-feedback { border-radius: 12px; padding: 0.75rem 1rem; }
.quiz-feedback.ok { background: #e8f6f3; }
.quiz-feedback.ko { background: #fdeee9; }

.pager-card { border-radius: 14px; border: 1px solid var(--panel-border); padding: 0.8rem 1rem; text-decoration: none; color: inherit; display: block; background: #fff; }
.pager-card:hover { border-color: var(--accent); color: inherit; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 2000; }

.kbd-hint kbd { background: #eef3f8; color: #122235; border: 1px solid var(--panel-border); font-size: 0.75rem; }

@media (prefers-reduced-motion: reduce) {
  .panel, .card, .app-hero, .fade-in-up { animation: none; }
  .track-card, .flip-card-inner { transition: none; }
}
.breadcrumb a { color: var(--accent, var(--brand-blue)); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* Install-as-app banner (mobile only, see learn/_install_banner.html) */
.install-banner {
  background: #ffffff;
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 6px 18px rgba(13, 27, 42, 0.08);
  animation: fadeUp 0.35s ease both;
}
.install-icon { border-radius: 11px; flex: 0 0 auto; }

/* Installed app: respect the notch / home indicator */
@media (display-mode: standalone) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar { padding-top: env(safe-area-inset-top); }
}

/* Mobile bottom tab bar for the learning section */
.learn-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--panel-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.learn-tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px 6px; font-size: 0.68rem; font-weight: 600;
  color: var(--text-soft); text-decoration: none;
}
.learn-tabbar a span { font-size: 1.25rem; line-height: 1; filter: grayscale(0.6); opacity: 0.75; }
.learn-tabbar a.active { color: var(--brand-blue); }
.learn-tabbar a.active span { filter: none; opacity: 1; }
@media (max-width: 767.98px) {
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar .navbar-brand { font-size: 1.05rem; }
}
@media (max-width: 991.98px) {
  #phaseFilter { flex-wrap: nowrap !important; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  #phaseFilter .btn { flex: 0 0 auto; }
}

/* ---------------------------------------------------------------------------
 * Courses: briefing walk-through, debrief form, timeline
 * ------------------------------------------------------------------------- */
.dive-accent { --accent: #0f766e; }

.timeline-item {
  display: flex; gap: 0.9rem; align-items: center;
  padding: 0.8rem 0.9rem; border-radius: 14px; border: 1px solid var(--panel-border);
  background: #fff; color: inherit; text-decoration: none; margin-bottom: 0.5rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
a.timeline-item:hover { border-color: var(--accent); color: inherit; transform: translateY(-1px); }
.timeline-item.is-next { border: 2px solid var(--accent); box-shadow: 0 6px 18px rgba(15, 118, 110, 0.12); }
.timeline-icon {
  flex: 0 0 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem;
  background: color-mix(in srgb, var(--accent) 10%, white);
}
.timeline-item.is-done .timeline-icon { background: #2a9d8f; color: #fff; font-size: 1.1rem; }

.status-chip { font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 0.2rem 0.6rem; white-space: nowrap; }
.status-chip.planned { background: #eef3f8; color: var(--text-soft); }
.status-chip.briefed { background: #fff4e0; color: #9a5b00; }
.status-chip.done { background: #e3f5f1; color: #1f7a6d; }

/* Briefing slides */
.briefing { max-width: 760px; margin: 0 auto; }
.briefing-progress { display: flex; gap: 4px; margin-bottom: 1rem; }
.briefing-progress button {
  flex: 1; height: 6px; border-radius: 999px; border: 0; padding: 0;
  background: #dbe4ef; cursor: pointer;
}
.briefing-progress button.seen { background: color-mix(in srgb, var(--accent) 45%, white); }
.briefing-progress button.current { background: var(--accent); }
.briefing-slide {
  min-height: 52vh; border-radius: 20px; background: #fff; border: 1px solid var(--panel-border);
  box-shadow: 0 12px 28px rgba(13, 27, 42, 0.08); padding: 1.6rem 1.4rem;
  animation: fadeUp 0.3s ease both;
}
@media (min-width: 768px) { .briefing-slide { padding: 2.2rem 2.4rem; } }
.briefing-slide .slide-icon { font-size: 2.6rem; line-height: 1; margin-bottom: 0.6rem; }
.briefing-slide h2 { font-weight: 800; }
.briefing-slide .lesson-content { font-size: 1.08rem; }
.briefing-slide .lesson-content table { font-size: 1rem; }
.briefing-nav { display: flex; gap: 0.5rem; margin-top: 1rem; }
.briefing-nav .btn { flex: 1; padding: 0.8rem; font-weight: 600; }
.objective-list { list-style: none; padding: 0; }
.objective-list li { padding: 0.55rem 0 0.55rem 2rem; position: relative; border-bottom: 1px dashed var(--panel-border); }
.objective-list li::before { content: "🎯"; position: absolute; left: 0; }
.skill-card { border: 1px solid var(--panel-border); border-radius: 14px; margin-bottom: 0.5rem; background: #fff; }
.skill-card summary { padding: 0.75rem 0.9rem; cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 0.6rem; align-items: baseline; }
.skill-card summary::-webkit-details-marker { display: none; }
.skill-card summary::after { content: "＋"; margin-left: auto; color: var(--text-soft); }
.skill-card[open] summary::after { content: "－"; }
.skill-card .skill-body { padding: 0 0.9rem 0.8rem; }
.skill-module { font-size: 0.72rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.watch-for { background: #fff7e6; border-radius: 10px; padding: 0.5rem 0.75rem; font-size: 0.92rem; }

/* Debrief: three-way skill result */
.result-toggle { display: flex; gap: 4px; }
.result-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.result-toggle label {
  flex: 1; text-align: center; padding: 0.45rem 0.3rem; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--panel-border); font-size: 0.82rem; font-weight: 600; background: #fff; user-select: none;
}
.result-toggle input:checked + label.r-todo { border-color: #9aa8b6; background: #eef3f8; }
.result-toggle input:checked + label.r-practice { border-color: #e9a23b; background: #fff4e0; }
.result-toggle input:checked + label.r-mastered { border-color: #2a9d8f; background: #e3f5f1; }
.result-toggle input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.result-pill { font-size: 0.75rem; font-weight: 700; border-radius: 999px; padding: 0.15rem 0.55rem; }
.result-pill.todo { background: #eef3f8; color: var(--text-soft); }
.result-pill.practice { background: #fff4e0; color: #9a5b00; }
.result-pill.mastered { background: #e3f5f1; color: #1f7a6d; }

.star-box { border-radius: 14px; padding: 0.9rem 1rem; }
.star-box.stars { background: #e3f5f1; }
.star-box.wish { background: #fff4e0; }
.star-box.next { background: #eaf3fb; }
.feeling-picker { display: flex; gap: 0.4rem; }
.feeling-picker input { position: absolute; opacity: 0; pointer-events: none; }
.feeling-picker label { font-size: 1.9rem; cursor: pointer; filter: grayscale(1); opacity: 0.45; transition: transform 0.15s ease; }
.feeling-picker input:checked + label { filter: none; opacity: 1; transform: scale(1.2); }
.logbook-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; }
.logbook-stat { border-radius: 12px; background: #f4f8fc; padding: 0.6rem 0.8rem; }
.logbook-stat .num { font-weight: 800; font-size: 1.2rem; }
.logbook-stat .lbl { font-size: 0.78rem; color: var(--text-soft); }
.tabs-pill .nav-link { border-radius: 999px; font-weight: 600; color: var(--text-soft); }
.tabs-pill .nav-link.active { background: var(--accent); color: #fff; }
.min-w-0 { min-width: 0; }
.result-pill { white-space: nowrap; flex: 0 0 auto; }
