/* =========================================================
   KiraKira Nihongo — Multi-User Auth, Profile, Membership & Leaderboard
   Self-contained styles designed to harmonize with style.css variables
   ========================================================= */

/* =========================================================
   Strict Auth Gate — Block Anonymous Users Until Logged In
   ========================================================= */
body.auth-gate-locked .app-tab-nav,
body.auth-gate-locked .app-main,
body.auth-gate-locked .header-status-group,
body.auth-gate-locked .header-actions > :not(#authHeaderSlot):not(#themeToggleBtn) {
  display: none !important;
}

body.auth-gate-locked #authModalBackdrop {
  background: rgba(11, 16, 27, 0.9);
}

body.light-theme.auth-gate-locked #authModalBackdrop {
  background: rgba(244, 247, 251, 0.94);
}

/* Top-Left Home Button */
.header-left-group {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.home-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.28));
  background: var(--bg-secondary, #1e293b);
  color: var(--text-main, #f8fafc);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.home-nav-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-indigo, #2563eb);
  background: rgba(37, 99, 235, 0.16);
}

.home-icon {
  font-size: 1rem;
  line-height: 1;
}

/* Header User Status Bar */
.auth-header-slot {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.auth-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.78rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.25));
  background: var(--bg-secondary, #1e293b);
  color: var(--text-main, #f8fafc);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.auth-header-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-indigo, #2563eb);
}

.auth-header-btn.primary {
  background: linear-gradient(135deg, var(--accent-indigo, #1d4ed8), var(--accent-red, #991b1b));
  border-color: transparent;
  color: #ffffff;
}

.auth-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.75rem 0.3rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-secondary, #1e293b);
  border: 1px solid rgba(37, 99, 235, 0.45);
  color: var(--text-main, #f8fafc);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.auth-user-pill:hover {
  transform: translateY(-1px);
  border-color: #60a5fa;
}

.auth-avatar-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 99, 235, 0.2);
  font-size: 0.9rem;
}

.auth-tier-badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.auth-tier-badge.free {
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-muted, #94a3b8);
}

.auth-tier-badge.pro {
  background: linear-gradient(135deg, #f59e0b, #991b1b);
  color: #ffffff;
}

.auth-role-badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
}

/* Modal Backdrop & Card */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.auth-modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-secondary, #1e293b);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 18px;
  padding: 1.65rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.auth-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle, #334155);
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-size: 1.1rem;
  cursor: pointer;
}

.auth-modal-close:hover {
  color: var(--text-main, #f8fafc);
  border-color: var(--accent-indigo, #2563eb);
}

.auth-modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.75rem 0 1.25rem;
  background: var(--bg-primary, #0f172a);
  padding: 0.3rem;
  border-radius: 12px;
}

.auth-tab-btn {
  padding: 0.6rem;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.auth-tab-btn.active {
  background: var(--accent-indigo, #2563eb);
  color: #ffffff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted, #cbd5e1);
}

.auth-field input,
.auth-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.72rem 0.9rem;
  border-radius: 10px;
  border: 1.5px solid var(--border-subtle, #334155);
  background: var(--bg-primary, #0f172a);
  color: var(--text-main, #f8fafc);
  font-size: 0.95rem;
  font-family: inherit;
}

.auth-field input:focus,
.auth-field textarea:focus {
  outline: none;
  border-color: var(--accent-indigo, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.auth-feedback {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.auth-feedback.error {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.38);
  color: #fda4af;
}

.auth-feedback.success {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.38);
  color: #6ee7b7;
}

.auth-feedback a {
  color: #93c5fd;
  word-break: break-all;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.auth-forgot-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.45rem;
}

.auth-link-btn {
  background: none;
  border: none;
  padding: 0.15rem 0;
  color: #60a5fa;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-link-btn:hover {
  color: #93c5fd;
}

/* Profile & Membership Modal */
.profile-header-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #2c070d 0%, #161a26 60%, #0b0f17 100%);
  border: 1px solid rgba(153, 27, 27, 0.45);
  margin-bottom: 1.15rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(220, 38, 38, 0.3);
}

body.light-theme .profile-header-banner {
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 50%, #f4f7fb 100%);
  border: 1px solid rgba(153, 27, 27, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.profile-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  flex-shrink: 0;
}

.profile-meta-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
}

.avatar-pick-btn {
  padding: 0.45rem;
  font-size: 1.25rem;
  border-radius: 10px;
  border: 1.5px solid var(--border-subtle, #334155);
  background: var(--bg-primary, #0f172a);
  cursor: pointer;
}

.avatar-pick-btn.selected {
  border-color: var(--accent-indigo, #2563eb);
  background: rgba(37, 99, 235, 0.22);
}

.membership-tier-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.tier-option-card {
  padding: 0.75rem;
  border-radius: 12px;
  border: 1.5px solid var(--border-subtle, #334155);
  background: var(--bg-primary, #0f172a);
  cursor: pointer;
  text-align: left;
  color: var(--text-main, #f8fafc);
}

.tier-option-card.selected {
  border-color: var(--accent-indigo, #2563eb);
  background: rgba(37, 99, 235, 0.14);
}

.tier-option-card strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.tier-option-card small {
  color: var(--text-muted, #94a3b8);
  font-size: 0.76rem;
  line-height: 1.35;
}

.profile-actions-row {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.4rem;
}

/* Guest Merge Banner */
.guest-merge-banner {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(37, 99, 235, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

.guest-merge-actions {
  display: flex;
  gap: 0.45rem;
}

/* Leaderboard Section */
.leaderboard-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.leaderboard-filter-pills {
  display: inline-flex;
  gap: 0.4rem;
  background: var(--bg-secondary, #1e293b);
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, #334155);
}

.lb-filter-btn {
  padding: 0.48rem 0.95rem;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.lb-filter-btn.active {
  background: var(--accent-indigo, #2563eb);
  color: #ffffff;
}

.leaderboard-privacy-note {
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.leaderboard-table-wrap {
  background: var(--bg-card, #121722);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: var(--shadow-sm);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leaderboard-table thead tr {
  background: linear-gradient(90deg, #4a0c15 0%, #340810 60%, #191322 100%);
}

body.light-theme .leaderboard-table thead tr {
  background: linear-gradient(90deg, #7f1d1d 0%, #8b1523 58%, #5c0f18 100%);
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.88rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.14));
}

.leaderboard-table th {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #f8fafc;
  border-bottom: 1px solid rgba(220, 38, 38, 0.35);
}

body.light-theme .leaderboard-table th {
  color: #ffffff;
  border-bottom: 1px solid #6b101b;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

.leaderboard-table tbody tr.is-me {
  background: rgba(37, 99, 235, 0.14);
}

body.light-theme .leaderboard-table tbody tr.is-me {
  background: #eff6ff;
}

.lb-rank-cell {
  font-weight: 800;
  font-size: 1rem;
  width: 64px;
}

.lb-user-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
}

.lb-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted, #94a3b8);
}

/* Verify.html Standalone Layout */
.verify-page-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  margin: 0;
}

.verify-shell {
  width: 100%;
  max-width: 460px;
}

.verify-card {
  background: var(--bg-secondary, #1e293b);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.verify-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.verify-logo {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 0.3rem;
}

.verify-brand h1 {
  margin: 0;
  font-size: 1.45rem;
}

.verify-brand p {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
}

.verify-welcome {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.35);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.verify-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.verify-state {
  text-align: center;
  padding: 1rem 0;
}

.verify-error-box h2 {
  color: #fb7185;
  margin-bottom: 0.5rem;
}

.verify-success-box h2 {
  color: #34d399;
  margin-bottom: 0.5rem;
}

/* =========================================================
   Gradual 5-Lesson Block Lock, Star Animation & Leaderboard Badges
   ========================================================= */
.lesson-tile.locked {
  opacity: 0.52;
  cursor: not-allowed;
}

.lesson-tile.locked:hover {
  border-color: rgba(244, 63, 94, 0.45);
}

.lesson-lock-badge {
  margin-left: auto;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.locked-popup-card {
  text-align: center;
}

.locked-popup-icon {
  font-size: 2.5rem;
  margin-bottom: 0.35rem;
}

.locked-popup-body {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-muted, #cbd5e1);
}

.locked-remaining-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.locked-chip-label {
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
}

.locked-bab-chip {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

/* Lesson Clear Starburst Animation */
.star-celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.star-celebration-overlay.fade-out {
  opacity: 0;
}

.star-burst-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-star-particle {
  position: absolute;
  font-size: 1.75rem;
  opacity: 0;
  animation: starPopFloat 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes starPopFloat {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3) rotate(0deg);
  }
  25% {
    opacity: 1;
    transform: translate(calc(var(--tx) * 0.55), calc(var(--ty) * 0.55)) scale(1.25) rotate(120deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), calc(var(--ty) - 24px)) scale(0.7) rotate(300deg);
  }
}

.star-toast-banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.95rem 1.35rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.96), rgba(153, 27, 27, 0.96));
  color: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  animation: starBannerPop 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.star-toast-icon {
  font-size: 2rem;
}

.star-toast-banner strong {
  display: block;
  font-size: 1rem;
}

.star-toast-banner small {
  display: block;
  font-size: 0.8rem;
  opacity: 0.92;
}

@keyframes starBannerPop {
  0% { opacity: 0; transform: scale(0.82) translateY(14px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* 5-Lesson Block Unlock Celebration Modal */
.block-celebration-card {
  text-align: center;
  border-color: rgba(16, 185, 129, 0.45);
}

.block-confetti-row {
  font-size: 1.5rem;
  letter-spacing: 0.35rem;
  margin-bottom: 0.35rem;
}

.block-badge-hero {
  font-size: 3.1rem;
  line-height: 1.1;
  margin: 0.25rem 0;
}

.block-unlock-next {
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.38);
  color: #6ee7b7;
  font-size: 0.9rem;
  margin: 0.5rem 0 0.85rem;
}

.block-badge-pill-earned {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.16);
  border: 1px solid rgba(37, 99, 235, 0.35);
  font-size: 0.82rem;
}

/* Leaderboard Badges Strip */
.lb-badges-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.lb-badge-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(37, 99, 235, 0.3);
  font-size: 0.78rem;
  cursor: help;
}

.lb-badge-more {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted, #94a3b8);
  padding: 0 0.25rem;
  align-self: center;
}

.lb-no-badges {
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
}

/* =========================================================
   Scorecard: Total Score Achievement Path & Fixed Bottom Table Layout
   ========================================================= */
.path-achievement-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.path-total-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.path-score-highlight {
  color: #34d399;
  font-weight: 800;
}

.path-score-pct {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
}

.path-active-pill {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(37, 99, 235, 0.35);
  color: var(--text-main, #f8fafc);
}

.path-total-bar-wrap {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-primary, #0f172a);
  overflow: hidden;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.2));
}

.path-total-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #10b981);
  transition: width 0.35s ease;
}

.path-clue-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.05rem;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.32);
}

.path-clue-box.path-clue-master {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.path-clue-text {
  flex: 1;
  min-width: 240px;
}

.path-clue-text strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.path-clue-text p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-muted, #cbd5e1);
}

.path-blocks-roadmap {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.path-block-mini {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.2));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.path-block-mini.is-active {
  border-color: rgba(37, 99, 235, 0.5);
}

.path-block-mini.is-done {
  border-color: rgba(16, 185, 129, 0.5);
}

.path-block-mini.is-locked {
  opacity: 0.65;
}

.path-block-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.path-block-name {
  font-size: 0.8rem;
  font-weight: 700;
}

.path-status-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.path-status-pill.done {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
}

.path-status-pill.active {
  background: rgba(37, 99, 235, 0.18);
  color: #60a5fa;
}

.path-status-pill.locked {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
}

.path-block-score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted, #94a3b8);
}

.path-mini-bar-wrap {
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.path-mini-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #10b981);
}

/* Compact Slim 2-Column Non-Overflowing Bottom Lesson Table */
.scorecard-lessons-grid.sc-lessons-grid-fixed {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.4rem 0.6rem !important;
  width: 100%;
  margin-top: 0.75rem;
}

.scorecard-lesson-row.sc-lesson-card-fixed {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0.26rem !important;
  padding: 0.46rem 0.7rem !important;
  border-radius: 9px;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.scorecard-lesson-row.sc-lesson-card-fixed.lesson-locked {
  opacity: 0.62;
}

.sc-card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  line-height: 1.2;
}

.sc-card-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.sc-lesson-card-fixed .sc-lesson-badge {
  font-size: 0.84rem;
  font-weight: 800;
}

.sc-lesson-card-fixed .sc-lesson-count {
  font-size: 0.7rem;
}

.sc-lesson-card-fixed .sc-lesson-percent {
  font-size: 0.82rem;
  min-width: 46px;
}

.sc-lesson-card-fixed .sc-lesson-bar-wrap,
.sc-lesson-card-fixed .progress-bar-bg {
  height: 4px !important;
  margin: 0.05rem 0;
}

.sc-card-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

.sc-lesson-cov-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
  min-width: 0;
}

.sc-lesson-card-fixed .rumpang-pill {
  font-size: 0.64rem;
  padding: 0.06rem 0.38rem;
}

.sc-lesson-card-fixed .sc-lesson-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.sc-lesson-card-fixed .btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.25;
  border-radius: 6px;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .path-blocks-roadmap {
    grid-template-columns: 1fr;
  }
  .scorecard-lessons-grid.sc-lessons-grid-fixed {
    grid-template-columns: 1fr !important;
    gap: 0.45rem !important;
  }
  .scorecard-lesson-row.sc-lesson-card-fixed {
    padding: 0.58rem 0.75rem !important;
    gap: 0.35rem !important;
  }
  .sc-card-bottom-row {
    flex-wrap: wrap;
  }
  .sc-lesson-card-fixed .btn-xs {
    min-height: 34px;
    padding: 0.3rem 0.65rem;
    font-size: 0.76rem;
  }
}

/* =========================================================
   Japanese Kana On-Screen Keyboard (Hiragana / Katakana)
   ========================================================= */
.kana-only-notice {
  margin-top: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.38);
  color: #fbbf24;
  text-align: left;
}

.kana-only-notice[hidden] {
  display: none !important;
}

.kana-osk {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 14px;
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.22));
  user-select: none;
}

.kana-osk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.kana-osk-script-tabs {
  display: inline-flex;
  gap: 0.3rem;
  background: var(--bg-secondary, #1e293b);
  padding: 0.22rem;
  border-radius: 9px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.2));
}

.kana-osk-tab {
  padding: 0.34rem 0.7rem;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.kana-osk-tab.active {
  background: var(--accent-indigo, #2563eb);
  color: #ffffff;
}

.kana-osk-mod-actions {
  display: inline-flex;
  gap: 0.32rem;
  flex-wrap: wrap;
}

.kana-osk-mod-btn {
  min-width: 36px;
  height: 34px;
  padding: 0 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.4);
  background: rgba(37, 99, 235, 0.14);
  color: var(--text-main, #f8fafc);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

.kana-osk-mod-btn:hover {
  background: rgba(37, 99, 235, 0.28);
  border-color: #60a5fa;
  transform: translateY(-1px);
}

.kana-osk-mod-btn:active {
  transform: scale(0.95);
}

.kana-osk-bksp {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.kana-osk-clear {
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.14);
  color: #fda4af;
}

.kana-osk-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.32rem;
}

.kana-osk-key {
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.22));
  background: var(--bg-secondary, #1e293b);
  color: var(--text-main, #f8fafc);
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.kana-osk-key:hover {
  background: rgba(37, 99, 235, 0.22);
  border-color: var(--accent-indigo, #2563eb);
}

.kana-osk-key:active {
  transform: scale(0.93);
  background: var(--accent-indigo, #2563eb);
  color: #ffffff;
}

.kana-osk-spacer {
  display: block;
}

@media (max-width: 560px) {
  .kana-osk-grid {
    gap: 0.2rem;
  }
  .kana-osk-key {
    height: 36px;
    font-size: 0.94rem;
  }
}

/* =========================================================
   Original Book Mapping Badges (Transcript Explorer)
   ========================================================= */
.book-mapping-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.book-map-chip {
  font-size: 0.74rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.24));
  color: var(--text-muted, #cbd5e1);
}

.book-cat-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.book-cat-conv {
  background: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(37, 99, 235, 0.45);
}

.book-cat-ex1 {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.book-cat-ex {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}





/* =========================================================
   Admin / Sensei Management Dashboard Styles
   ========================================================= */

.admin-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-stat-card {
  background: var(--bg-secondary, #1e293b);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #94a3b8);
}

.admin-stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main, #f8fafc);
  font-family: var(--font-heading, inherit);
}

.admin-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.admin-search-input {
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 10px;
  color: var(--text-main, #f8fafc);
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  width: 100%;
  max-width: 340px;
}

.admin-search-input:focus {
  outline: none;
  border-color: var(--accent-indigo, #2563eb);
}

.admin-role-badge.admin {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(217, 119, 6, 0.3));
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-role-badge.student {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.admin-status-pill.verified {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
}

.admin-status-pill.unverified {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.admin-btn-group {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.admin-action-btn {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid var(--border-subtle, #334155);
  color: var(--text-main, #f8fafc);
  padding: 0.32rem 0.65rem;
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-action-btn:hover {
  background: var(--accent-indigo, #2563eb);
  border-color: var(--accent-indigo, #2563eb);
  color: #ffffff;
}

.admin-action-btn.promote {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.admin-action-btn.promote:hover {
  background: #d97706;
  color: #ffffff;
}

/* Student Detail Inspection Drawer / Card */
.student-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.student-detail-box {
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.student-detail-box strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 0.25rem;
}

.stage-breakdown-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.stage-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.14);
}

.stage-badge.mastered {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.stage-badge.learning {
  background: rgba(37, 99, 235, 0.18);
  color: #93c5fd;
}

.stage-badge.weak {
  background: rgba(185, 28, 28, 0.16);
  color: var(--accent-red, #dc2626);
}

/* =========================================================
   Light Theme Crispness Overrides (Dark Red Banner + White Cards + Sumi Black + Grey + Deep Blue)
   ========================================================= */
body.light-theme .app-header {
  background: linear-gradient(90deg, #5c0f18 0%, #3b0a12 34%, #181c28 72%, #111520 100%);
}

body.light-theme .app-tab-nav {
  background: #ffffff;
  border-bottom: 1px solid #dde3ec;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

body.light-theme .nav-tab-btn {
  color: #475569;
}

body.light-theme .nav-tab-btn:hover {
  color: #111827;
  background: #f8fafc;
}

body.light-theme .nav-tab-btn.active {
  color: #8b1523;
  background: rgba(139, 21, 35, 0.06);
  border-bottom-color: #8b1523;
}

/* Unified frosted-glass buttons inside the Dark Red Header Banner (Light & Dark) */
.app-header .auth-user-pill,
.app-header .home-nav-btn,
.app-header .auth-header-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.22);
}

.app-header .auth-user-pill:hover,
.app-header .home-nav-btn:hover,
.app-header .auth-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.42);
  color: #ffffff;
}

.app-header .auth-header-btn.primary {
  background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
  border-color: rgba(147, 197, 253, 0.4);
  color: #ffffff;
}

/* High-contrast WCAG AAA semantic text & badges on white surfaces in Light Theme */
body.light-theme .auth-role-badge,
body.light-theme .auth-link-btn,
body.light-theme .path-status-pill.active,
body.light-theme .stage-badge.learning,
body.light-theme .lb-badge-chip,
body.light-theme .block-badge-pill-earned {
  color: #1e40af;
}

body.light-theme .auth-feedback.success,
body.light-theme .verify-success-box h2,
body.light-theme .block-unlock-next,
body.light-theme .path-score-highlight,
body.light-theme .path-status-pill.done,
body.light-theme .admin-status-pill.verified,
body.light-theme .stage-badge.mastered {
  color: #166534;
}

body.light-theme .kana-only-notice,
body.light-theme .kana-osk-bksp,
body.light-theme .admin-role-badge.admin,
body.light-theme .admin-status-pill.unverified,
body.light-theme .admin-action-btn.promote {
  color: #92400e;
}

body.light-theme .admin-role-badge.student {
  color: #334155;
  background: #f1f5f9;
}

body.light-theme .format-pill-btn.active .pill-title,
body.light-theme .lesson-tile .tile-num,
body.light-theme .lesson-tag-remove,
body.light-theme .badge-info,
body.light-theme .hud-lessons-badge,
body.light-theme .lesson-nav-btn.active .lesson-num,
body.light-theme .sc-score-mid,
body.light-theme .modal-cov-bab {
  color: #1e40af !important;
}

body.light-theme .option-btn.correct,
body.light-theme .filled-cloze-target.correct,
body.light-theme .cloze-opt-btn.correct,
body.light-theme .badge-coverage-summary,
body.light-theme .sc-score-full,
body.light-theme .badge-romaji-mode {
  color: #166534 !important;
}

body.light-theme .badge-hardest-cloze,
body.light-theme .filled-cloze-target.wrong,
body.light-theme .cloze-opt-btn.wrong {
  color: #991b1b !important;
}

body.light-theme .scoring-weight-note,
body.light-theme .sc-target-hint,
body.light-theme .badge-timer-type {
  color: #92400e !important;
}

body.light-theme .cloze-opt-btn .opt-num-badge {
  background: #eef1f6;
  color: #334155;
}

body.light-theme .btn-weak-audio:hover {
  background: #eef1f6;
}

body.light-theme .kana-osk {
  background: #f4f7fb;
  border-color: #cbd5e1;
}

body.light-theme .kana-osk-key {
  background: #ffffff;
  color: #11141c;
  border-color: #cbd5e1;
}

body.light-theme .kana-osk-key:hover {
  background: #eef4fc;
  border-color: #1d4ed8;
}

body.light-theme .kana-osk-mod-btn {
  background: rgba(29, 78, 216, 0.1);
  border-color: rgba(29, 78, 216, 0.35);
  color: #1e3a8a;
}

body.light-theme .kana-osk-clear {
  background: rgba(153, 27, 27, 0.1);
  border-color: rgba(153, 27, 27, 0.38);
  color: #991b1b;
}

body.light-theme .book-cat-conv {
  background: rgba(29, 78, 216, 0.1);
  color: #1d4ed8;
  border-color: rgba(29, 78, 216, 0.32);
}

body.light-theme .book-cat-ex {
  background: rgba(153, 27, 27, 0.1);
  color: #991b1b;
  border-color: rgba(153, 27, 27, 0.32);
}

body.light-theme .book-cat-ex1 {
  background: rgba(21, 128, 61, 0.1);
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.32);
}

/* Explorer Voice Settings Panel */
.voice-settings-panel {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.voice-settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.voice-settings-select {
  flex: 1 1 210px;
  padding: 0.42rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.84rem;
}

.voice-notice-box {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: rgba(153, 27, 27, 0.1);
  border: 1px solid rgba(153, 27, 27, 0.34);
  color: var(--text-main);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* =========================================================
   WP3, WP5, WP6: Mobile Kana OSK, Tables & 100dvh Modals
   ========================================================= */
.kana-osk-native-toggle.active {
  background: var(--accent-indigo, #2563eb);
  border-color: #60a5fa;
  color: #ffffff;
}

@media (max-width: 600px) {
  /* WP3: Fit all 10 Kana columns cleanly on 360px phones with comfortable 42px key height */
  .kana-osk {
    padding: 0.45rem 0.35rem;
    border-radius: 12px;
  }
  .kana-osk-toolbar {
    gap: 0.35rem;
    margin-bottom: 0.45rem;
  }
  .kana-osk-mod-btn {
    min-width: 34px;
    height: 38px;
    padding: 0 0.42rem;
    font-size: 0.88rem;
  }
  .kana-osk-grid {
    gap: 0.18rem;
  }
  .kana-osk-key {
    height: 42px;
    min-height: 42px;
    font-size: 1rem;
    border-radius: 7px;
  }

  /* WP5: Smooth touch-scrolling Leaderboard & Admin tables */
  .leaderboard-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }
  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.55rem 0.55rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* WP6: 100dvh mobile-safe modals (prevent soft keyboard clipping) */
  .auth-modal-backdrop {
    padding: 0.6rem;
    align-items: center;
  }
  .auth-modal-card,
  .app-modal .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 1.25rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1.15rem 1rem;
  }
}

