/* =========================================================
   NIHONGO KAIWA HUB - MOBILE-FIRST STYLESHEET
   Aesthetic: Japanese Modern Tactile / Neo-Tokyo Minimalist
   Optimized for: One-handed smartphone usage, OLED Dark Mode
   ========================================================= */

:root {
  /* Surface & Base */
  --bg-deep: #080C14;
  --bg-surface: #111722;
  --bg-card: #182232;
  --bg-card-hover: #1E2B3E;
  --border-subtle: #233144;
  --border-active: #3D506C;
  
  /* Text & Accents */
  --text-main: #F3F5F7;
  --text-muted: #94A3B8;
  --text-faint: #627288;
  
  /* 4 Specialized Skill Colors (Japanese Traditional Inspired) */
  --kaiwa-red: #E63946;
  --kaiwa-soft: rgba(230, 57, 70, 0.15);
  --kaiwa-border: rgba(230, 57, 70, 0.35);

  --vocab-cyan: #00B4D8;
  --vocab-soft: rgba(0, 180, 216, 0.15);
  --vocab-border: rgba(0, 180, 216, 0.35);

  --grammar-teal: #2EC4B6;
  --grammar-soft: rgba(46, 196, 182, 0.15);
  --grammar-border: rgba(46, 196, 182, 0.35);

  --chokai-gold: #FFB703;
  --chokai-soft: rgba(255, 183, 3, 0.15);
  --chokai-border: rgba(255, 183, 3, 0.35);

  --success-green: #2ECC71;
  --success-soft: rgba(46, 204, 113, 0.18);
  
  /* Layout Constants */
  --bottom-nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 12px);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-jp: 'Zen Kaku Gothic New', sans-serif;
  --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light Theme Variables */
body.light-mode {
  --bg-deep: #F5F3EF;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F0ECE1;
  --border-subtle: #E2DDD5;
  --border-active: #C8C1B5;
  --text-main: #1A1F2C;
  --text-muted: #5A6578;
  --text-faint: #8F9CAE;
  --kaiwa-soft: rgba(230, 57, 70, 0.08);
  --vocab-soft: rgba(0, 180, 216, 0.08);
  --grammar-soft: rgba(46, 196, 182, 0.08);
  --chokai-soft: rgba(255, 183, 3, 0.12);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Container simulating responsive mobile container on large desktop */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-surface);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
}

/* =========================================================
   TOP HEADER
   ========================================================= */
.top-header {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--kaiwa-red);
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.today-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-main);
}

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

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 183, 3, 0.12);
  border: 1px solid rgba(255, 183, 3, 0.3);
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  color: var(--chokai-gold);
}

.streak-label {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.85;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s;
}

.icon-btn:active {
  transform: scale(0.92);
}

/* =========================================================
   WEEK & DAY SELECTOR BANNER
   ========================================================= */
.week-banner {
  padding: 12px 16px 8px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-subtle);
}

.banner-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.week-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--grammar-teal);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-tag {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  font-family: var(--font-jp), var(--font-ui);
}

.day-selector-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.day-selector-scroll::-webkit-scrollbar {
  display: none;
}

.day-chip {
  flex: 0 0 calc((100% - 48px) / 7);
  min-width: 44px;
  padding: 8px 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.day-chip .chip-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.day-chip .chip-date {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.day-chip.active {
  background: var(--kaiwa-red);
  border-color: var(--kaiwa-red);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.35);
}

.day-chip.active .chip-name,
.day-chip.active .chip-date {
  color: #FFFFFF;
}

.day-chip.completed::after {
  content: "•";
  color: var(--success-green);
  font-size: 16px;
  line-height: 0;
  margin-top: 2px;
}

/* =========================================================
   MAIN CONTENT & TABS
   ========================================================= */
.main-content {
  flex: 1;
  padding: 16px;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.view-section.active {
  display: block;
}

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

/* =========================================================
   TODAY TAB: PROGRESS & TASKS
   ========================================================= */
.progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.progress-stats {
  font-size: 12px;
  color: var(--grammar-teal);
  font-weight: 700;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--grammar-teal), var(--vocab-cyan));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.section-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.hint-pill {
  font-size: 11px;
  color: var(--text-faint);
}

/* Task List */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.2s, background 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card:active {
  transform: scale(0.985);
}

.task-card.kaiwa {
  border-left: 4px solid var(--kaiwa-red);
}
.task-card.vocab {
  border-left: 4px solid var(--vocab-cyan);
}
.task-card.grammar {
  border-left: 4px solid var(--grammar-teal);
}
.task-card.chokai {
  border-left: 4px solid var(--chokai-gold);
}

.task-card.done {
  opacity: 0.65;
  background: var(--bg-deep);
}
.task-card.done .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-badge-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.task-card.kaiwa .task-type-badge { background: var(--kaiwa-soft); color: var(--kaiwa-red); }
.task-card.vocab .task-type-badge { background: var(--vocab-soft); color: var(--vocab-cyan); }
.task-card.grammar .task-type-badge { background: var(--grammar-soft); color: var(--grammar-teal); }
.task-card.chokai .task-type-badge { background: var(--chokai-soft); color: var(--chokai-gold); }

.task-target-min {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Custom Checkbox */
.task-check-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border-active);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: transparent;
  font-size: 14px;
  font-weight: 800;
  transition: all 0.2s ease;
}

.task-card.done .task-check-btn {
  background: var(--success-green);
  border-color: var(--success-green);
  color: #FFFFFF;
}

.task-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.task-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.task-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
}

.action-study-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-study-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Weekend Promo Card */
.weekend-promo-card {
  margin-top: 24px;
  background: linear-gradient(135deg, rgba(46, 196, 182, 0.15), rgba(0, 180, 216, 0.08));
  border: 1px dashed var(--grammar-teal);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.promo-icon {
  font-size: 26px;
}

.promo-content h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.promo-content p {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-sm-action {
  background: var(--grammar-teal);
  color: #080C14;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

/* =========================================================
   STUDY STUDIO / SPECIALIZED LEARNING MODES
   ========================================================= */
.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.btn-back-nav {
  background: transparent;
  border: none;
  color: var(--vocab-cyan);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.hub-group-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

/* --- KAIWA STUDIO (YOUTUBE + SHADOWING + RECORDER) --- */
.kaiwa-studio {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.video-player-frame {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000000;
  border: 1px solid var(--border-subtle);
}

.video-player-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.no-video-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  gap: 8px;
  background: #0D131D;
  color: var(--text-muted);
}

.no-video-placeholder .btn-attach-yt {
  background: var(--kaiwa-red);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}

.shadowing-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.btn-ctrl {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.btn-ctrl:active {
  transform: scale(0.95);
}

.key-phrases-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.box-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.phrases-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-jp), var(--font-ui);
}

.phrase-item {
  background: var(--bg-deep);
  border-left: 3px solid var(--kaiwa-red);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.4;
}

/* Audio Recording Bar for Self-Evaluation */
.voice-recorder-bar {
  background: var(--bg-card);
  border: 1px solid var(--kaiwa-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rec-btn {
  background: var(--kaiwa-red);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
}

.rec-btn.recording {
  animation: pulseRec 1s infinite alternate;
}

@keyframes pulseRec {
  from { transform: scale(1); }
  to { transform: scale(1.15); background: #ff1e30; }
}

.rec-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- VOCAB STUDIO (SMART 3D FLASHCARDS) --- */
.vocab-studio {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.flashcard-stage {
  perspective: 1000px;
  width: 100%;
  max-width: 380px;
  height: 240px;
}

.flashcard-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-radius: var(--radius-lg);
}

.flashcard-card.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  border: 1px solid var(--vocab-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.card-front {
  background: linear-gradient(145deg, #162438, #0E1622);
}

.card-back {
  background: linear-gradient(145deg, #0E1B2B, #112236);
  transform: rotateY(180deg);
}

.fc-counter {
  font-size: 11px;
  color: var(--vocab-cyan);
  font-weight: 700;
  text-transform: uppercase;
}

.fc-kanji {
  font-size: 32px;
  font-weight: 700;
  color: #FFFFFF;
  font-family: var(--font-jp);
}

.fc-reading {
  font-size: 16px;
  color: var(--vocab-cyan);
  font-family: var(--font-jp);
  margin-top: 4px;
}

.fc-meaning {
  font-size: 16px;
  font-weight: 600;
  color: #FFFFFF;
}

.fc-example {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-jp);
  line-height: 1.4;
  margin-top: 6px;
}

.fc-flip-hint {
  font-size: 11px;
  color: var(--text-faint);
}

.flashcard-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 380px;
}

.btn-fc-rate {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-fc-rate.again {
  background: rgba(230, 57, 70, 0.15);
  color: var(--kaiwa-red);
  border: 1px solid var(--kaiwa-border);
}

.btn-fc-rate.good {
  background: rgba(46, 204, 113, 0.18);
  color: var(--success-green);
  border: 1px solid rgba(46, 204, 113, 0.4);
}

/* --- GRAMMAR STUDIO (FORMULA & DRILL) --- */
.grammar-studio {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.grammar-rule-card {
  background: var(--bg-card);
  border: 1px solid var(--grammar-border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.grammar-pattern-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--grammar-teal);
  font-family: var(--font-jp);
  margin-bottom: 6px;
}

.grammar-meaning-badge {
  display: inline-block;
  background: var(--grammar-soft);
  color: var(--grammar-teal);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.grammar-formula {
  background: var(--bg-deep);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-jp);
  color: var(--text-main);
  margin-bottom: 12px;
  border-left: 3px solid var(--grammar-teal);
}

.grammar-nuance {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 12px;
}

.grammar-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.example-row {
  background: var(--bg-deep);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}

.drill-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.drill-input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-main);
  font-family: var(--font-jp), var(--font-ui);
  font-size: 14px;
  resize: vertical;
  margin-top: 8px;
  margin-bottom: 10px;
}

/* --- CHOKAI STUDIO (DICTATION & SCRIPT REVEAL) --- */
.chokai-studio {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chokai-audio-card {
  background: var(--bg-card);
  border: 1px solid var(--chokai-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.dictation-input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-main);
  font-family: var(--font-jp);
  font-size: 14px;
  min-height: 100px;
  resize: vertical;
}

.btn-reveal-script {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--chokai-gold);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.script-reveal-content {
  background: var(--bg-deep);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-jp);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 8px;
  display: none;
  border-left: 3px solid var(--chokai-gold);
}

/* =========================================================
   WEEKEND PLANNER TAB (SOẠN BÀI)
   ========================================================= */
.planner-header {
  margin-bottom: 16px;
}

.view-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.view-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.planner-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-icon {
  font-size: 15px;
}

.form-control {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 14px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--vocab-cyan);
}

.form-hint {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.35;
}

.btn-primary-action {
  background: linear-gradient(135deg, var(--grammar-teal), var(--vocab-cyan));
  color: #080C14;
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(46, 196, 182, 0.3);
  transition: transform 0.15s ease;
}

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

/* =========================================================
   SUMMARY TAB
   ========================================================= */
.skills-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-card.kaiwa { border-top: 3px solid var(--kaiwa-red); }
.kpi-card.vocab { border-top: 3px solid var(--vocab-cyan); }
.kpi-card.grammar { border-top: 3px solid var(--grammar-teal); }
.kpi-card.chokai { border-top: 3px solid var(--chokai-gold); }

.kpi-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-icon {
  font-size: 16px;
}

.kpi-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.kpi-value small {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-sub {
  font-size: 10px;
  color: var(--text-faint);
}

.overview-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.overview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.overview-row strong {
  color: var(--text-main);
  font-size: 14px;
}

.subsection-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.weeks-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.week-row-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.week-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.week-row-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--grammar-teal);
}

.week-row-theme {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  font-family: var(--font-jp), var(--font-ui);
}

.week-row-stat {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* =========================================================
   FLOATING FOCUS TIMER
   ========================================================= */
.floating-timer-bar {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 456px;
  background: rgba(17, 23, 34, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--kaiwa-red);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.timer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.timer-dot {
  width: 8px;
  height: 8px;
  background: var(--kaiwa-red);
  border-radius: 50%;
  flex-shrink: 0;
}

.timer-dot.pulse {
  animation: pulseDot 1.2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.timer-task-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.timer-countdown {
  font-size: 15px;
  font-weight: 800;
  color: var(--kaiwa-red);
  font-variant-numeric: tabular-nums;
}

.timer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.timer-btn-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}

.timer-btn-finish {
  background: var(--success-green);
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* =========================================================
   BOTTOM NAVIGATION BAR
   ========================================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.nav-icon {
  font-size: 19px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

.nav-item.active {
  color: var(--kaiwa-red);
}

.nav-item.active .nav-label {
  font-weight: 700;
}

/* =========================================================
   MODAL / BOTTOM SHEET
   ========================================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 20px;
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
}

.btn-close-modal {
  background: var(--bg-card);
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.backup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-modal-action {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.btn-modal-action.danger {
  border-color: rgba(230, 57, 70, 0.4);
  color: var(--kaiwa-red);
}

.theme-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
}

.btn-toggle-theme {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}
