:root {
  --bg-global:       #f4f6f8;
  --bg-dark:         #1e293b;
  --bg-darker:       #0f172a;
  --card-white:      #ffffff;
  --text-primary:    #0f172a;
  --text-secondary:  #64748b;
  --text-light:      #f8fafc;
  --border-light:    #e2e8f0;
  
  --accent-blue:     #3b82f6;
  --accent-green:    #10b981;
  --bg-green-soft:   #ecfdf5;
  --bg-blue-soft:    #eff6ff;
  --state-ok:        #10b981;
  --state-error:     #ef4444;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg-global);
  color: var(--text-primary);
  line-height: 1.5;
}

.container { max-width: 1200px; margin: 2rem auto; padding: 0 1.5rem; }

@media (max-width: 768px) {
  .container { margin: 1rem auto; padding: 0 1rem; }
}

/* Header / Nav */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.main-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-item {
  background: var(--card-white);
  color: var(--text-secondary);
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: all 0.2s ease;
}

.nav-item.active {
  background: var(--bg-darker);
  color: var(--text-light);
}

.nav-item:disabled { opacity: 0.5; cursor: not-allowed; }

.kpi-badge {
  background: var(--card-white);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.kpi-badge .divider { color: var(--border-light); }
.kpi-badge .kpi-pill {
  background: var(--bg-green-soft);
  color: var(--accent-green);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-weight: 800;
}

/* Dashboard Views */
.view-section { display: none; animation: fadeIn 0.3s ease; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.kpi-panel {
  background: linear-gradient(135deg, var(--bg-darker), var(--bg-dark));
  border-radius: 24px;
  padding: 2.5rem;
  margin-bottom: 2rem;
}

.kpi-new-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 0.8fr;
  gap: 1.5rem;
}
@media (max-width: 1024px) {
  .kpi-new-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .kpi-new-grid { grid-template-columns: 1fr; }
}

.kpi-card-dark {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 1.5rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.kpi-col-center {
  justify-content: center;
  gap: 1.25rem;
}

/* Card 1 */
.kpi-active-days {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.icon-fire-blue { font-size: 1.5rem; color: #38bdf8; }
.kpi-active-days .kpi-val { font-size: 2rem; font-weight: 800; line-height: 1; }
.kpi-active-days .kpi-label { font-size: 0.85rem; color: #94a3b8; margin-top: 0.25rem; }

.kpi-progress-row { margin-bottom: 1rem; }
.kpi-progress-row:last-child { margin-bottom: 0; }
.kpi-progress-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.kpi-char { font-size: 1.2rem; font-weight: 800; color: #94a3b8; }
.kpi-fraction { font-size: 1.1rem; font-weight: 800; color: #fff; }
.kpi-domain { font-size: 0.7rem; color: #94a3b8; margin-left: auto; letter-spacing: 1px; }
.kpi-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.kpi-progress-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.hiragana-fill { background: #38bdf8; }
.katakana-fill { background: #818cf8; }

/* Card 2: Streaks */
.kpi-streak-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}
.kpi-icon-medal { font-size: 0.9rem; margin-right: 0.25rem; opacity: 0.8; }
.kpi-streak-label { font-size: 0.7rem; font-weight: 700; color: #38bdf8; letter-spacing: 0.5px; line-height: 1.2; }
.kpi-streak-sub { color: #94a3b8; font-weight: 600; font-size: 0.8rem; }
.kpi-streak-val {
  background: #312e81; /* Indigo oscuro */
  color: #a5b4fc;
  font-size: 1.2rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
}

/* Card 3: Today & Items */
.kpi-today-streak {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.kpi-badge-text {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.25rem;
}
.kpi-today-streak-text .kpi-subtext { display: block; font-size: 0.8rem; color: #94a3b8; }
.kpi-today-streak-val {
  background: #065f46; /* Verde esmeralda oscuro */
  color: #34d399;
  font-size: 1.5rem;
  font-weight: 800;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
}

.kpi-items-of-day {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.kpi-item-card {
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.kpi-item-title { font-size: 0.85rem; font-weight: 800; color: #e2e8f0; }
.kpi-item-sub { font-size: 0.7rem; color: #94a3b8; margin-bottom: 0.75rem; }
.kpi-item-display { font-size: 1.5rem; font-weight: 800; line-height: 1.2; margin: auto 0; }
.kpi-item-display.phrase { font-size: 1.2rem; word-break: break-word; }
.kpi-item-display.kanji { font-size: 2rem; }
.kpi-item-meaning { font-size: 0.75rem; color: #38bdf8; font-weight: 600; margin-top: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Card 4: Accuracy */
.kpi-card-accuracy {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
}
.kpi-accuracy-icon {
  width: 48px; height: 48px;
  background: #0ea5e9;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}
.kpi-accuracy-val { font-size: 3rem; font-weight: 800; line-height: 1; margin-bottom: 0.5rem; }
.kpi-accuracy-label { font-size: 0.7rem; font-weight: 700; color: #94a3b8; letter-spacing: 1px; display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.kpi-accuracy-label span { font-size: 1.2rem; }

.dashboard-lower-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}
@media (max-width: 900px) {
  .dashboard-lower-grid { grid-template-columns: 1fr; }
}

.white-card {
  background: var(--card-white);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02), 0 2px 4px -1px rgba(0,0,0,0.02);
}
@media (max-width: 600px) {
  .white-card { padding: 1.5rem; }
}

.white-card h3 { font-size: 1.25rem; font-weight: 800; margin: 0 0 0.5rem 0; }
.white-card .subtitle { color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.5rem 0; }

/* Practice View */
.module-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
}
@media (max-width: 1024px) {
  .module-layout { grid-template-columns: 1fr; }
}

.module-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.module-title { font-size: 2rem; font-weight: 800; margin: 0 0 0.5rem 0; }
.module-subtitle { color: var(--text-secondary); font-size: 1rem; margin: 0; }

.remaining-badge {
  background: #f1f5f9;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.mode-selector-wrapper {
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}
.mode-selector {
  background: #f1f5f9;
  border-radius: 999px;
  padding: 0.35rem;
  display: inline-flex;
}
.guide-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0;
  align-self: flex-start;
}
@media (max-width: 768px) {
  .guide-controls {
    justify-content: flex-start;
    width: 100%;
    margin-top: 1rem;
  }
  .guide-controls .mode-selector {
    max-width: 100%;
    overflow-x: auto;
  }
}
.mode-pill {
  border: none;
  background: transparent;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.mode-pill.active {
  background: var(--card-white);
  color: var(--accent-blue);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.gray-kana-container {
  background: #f8fafc;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  margin-bottom: 1.5rem;
}
.kana-symbol {
  font-size: 8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.option-btn {
  background: var(--card-white);
  border: 2px solid var(--border-light);
  border-radius: 16px;
  padding: 1.5rem 1rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  cursor: pointer;
  text-transform: uppercase;
  min-height: 64px;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* Sidebar */
.mini-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}
.mini-stat-card {
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
}
.mini-stat-card.green-bg { background: var(--bg-green-soft); color: var(--accent-green); }
.mini-stat-card.blue-bg { background: var(--bg-blue-soft); color: var(--accent-blue); }
.mini-stat-card.orange-bg { background: rgba(251, 146, 60, 0.1); color: #fb923c; }
.mini-stat-card.purple-bg { background: rgba(168, 85, 247, 0.1); color: #a855f7; }

.mini-stat-label { font-size: 0.75rem; font-weight: 800; display: block; margin-bottom: 0.5rem; }
.mini-stat-value { font-size: 2rem; font-weight: 800; display: block; line-height: 1; }

.progression-card { padding: 1.5rem; }
.progression-list { list-style: none; padding: 0; margin: 0; }
.progression-list li {
  display: flex;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-light);
}
.progression-list li:last-child { border-bottom: none; }
.progression-kana { font-size: 1.5rem; font-weight: 800; width: 40px; }
.progression-romaji { font-size: 1rem; font-weight: 700; text-transform: uppercase; color: var(--text-primary); flex: 1; }
.progression-status { color: var(--text-secondary); font-size: 0.875rem; }

/* Flip cards specific */
.flip-wrapper {
  perspective: 1000px;
  width: 100%;
  height: 320px;
  margin-bottom: 1.5rem;
  cursor: pointer;
}
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}
.flip-wrapper.flipped .flip-inner {
  transform: rotateY(180deg);
}
.flip-front, .flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  background: #f8fafc;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flip-back {
  transform: rotateY(180deg);
  background: var(--bg-blue-soft);
}
.flip-back .kana-symbol {
  color: var(--accent-blue);
}

.action-row {
  display: flex;
  gap: 1rem;
}
.primary-btn, .secondary-btn {
  flex: 1;
  border-radius: 16px;
  padding: 1.25rem;
  font-size: 1.125rem;
  font-weight: 800;
  cursor: pointer;
  border: none;
  min-height: 64px;
}
.primary-btn { background: var(--accent-blue); color: #fff; }
.secondary-btn { background: var(--card-white); border: 2px solid var(--border-light); color: var(--text-primary); }
.option-btn:disabled, .primary-btn:disabled, .secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.feedback { text-align: center; font-weight: 800; min-height: 1.5rem; margin-top: 1rem; }
.feedback.ok { color: var(--state-ok); }
.feedback.bad { color: var(--state-error); }

/* Dashboard Additions */
.heatmap-container {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 10px;
  min-height: 120px;
}
.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background-color: var(--border-light);
}
.heatmap-cell[data-level="1"] { background-color: #d1fae5; }
.heatmap-cell[data-level="2"] { background-color: #6ee7b7; }
.heatmap-cell[data-level="3"] { background-color: #34d399; }
.heatmap-cell[data-level="4"] { background-color: #10b981; }

.radar-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 250px;
}
.radar-svg {
  width: 100%;
  max-width: 300px;
  height: auto;
}

.weak-characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.weak-char-card {
  background: var(--bg-global);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.weak-char-card .kana {
  font-size: 1.5rem;
  font-weight: 800;
}
.weak-char-card .stats {
  text-align: right;
  color: var(--state-error);
  font-weight: 700;
  font-size: 0.9rem;
}

/* 3 Life Cards Specific */
.life-cards-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  background: var(--bg-global);
  padding: 1rem;
  border-radius: 16px;
}
.lives-display {
  display: flex;
  gap: 0.5rem;
  font-size: 1.5rem;
}
.life-heart {
  color: var(--state-error);
}
.life-heart.empty {
  color: var(--border-light);
}
.score-display {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-blue);
}

.game-over-panel {
  text-align: center;
  padding: 3rem 1rem;
}
.game-over-panel h2 {
  font-size: 2.5rem;
  color: var(--state-error);
  margin-bottom: 1rem;
}
.game-over-panel p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Filters & Chips */
.filters-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  justify-content: center;
}
.filter-chip {
  background: var(--card-white);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-chip:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}
.filter-chip.active {
  background: var(--bg-blue-soft);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* Kana Guide Grid */
.guide-panel {
  padding: 2rem;
}
.guide-group {
  margin-bottom: 2.5rem;
}
.guide-group-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0.5rem;
  text-transform: capitalize;
}
.kana-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 1rem;
}
.kana-card {
  background: var(--card-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.kana-card .guide-symbol {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.kana-card .guide-romaji {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Kanji Specific adjustments */
.option-btn.kanji-option {
  font-size: 1rem;
  text-transform: none;
}

/* Lectura option button: no uppercase, wraps longer text */
.option-btn.lectura-option {
  font-size: 0.95rem;
  text-transform: none;
  word-break: break-word;
  line-height: 1.4;
  padding: 1rem 0.75rem;
}

/* Pending mode panel (Matching Cards placeholder) */
.pending-mode-panel {
  text-align: center;
  padding: 3rem 1rem;
  background: #f8fafc;
  border-radius: 24px;
  margin-top: 1rem;
}
.pending-mode-panel .pending-mode-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}
.pending-mode-panel h3 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}
.pending-mode-panel p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

/* =========================================
   DASHBOARD CONTENT LOAD PANEL
   ========================================= */
.content-load-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.content-load-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.content-load-btn {
  font-size: 0.9rem !important;
  font-weight: 700 !important;
}
.content-load-panel {
  margin-top: 1.5rem;
  animation: fadeIn 0.25s ease;
}
.content-load-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.content-load-type-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.content-type-btn {
  flex: 1;
  min-width: 140px;
  background: #f8fafc;
  border: 2px solid var(--border-light);
  border-radius: 20px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.content-type-btn:hover {
  border-color: var(--accent-blue);
  background: var(--bg-blue-soft);
  color: var(--accent-blue);
}
.content-type-icon {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

/* Content Forms */
.content-form-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.content-form-header h4 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
}
.back-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
}
.back-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.content-form {
  max-width: 600px;
}
.form-row {
  margin-bottom: 1.25rem;
}
.form-row label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  background: #f8fafc;
  transition: border-color 0.2s;
  outline: none;
  box-sizing: border-box;
}
.form-input:focus {
  border-color: var(--accent-blue);
  background: var(--bg-blue-soft);
}
.form-select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.form-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0.35rem 0 0;
}
.form-actions {
  margin-top: 1.5rem;
}

/* File input */
.file-input {
  cursor: pointer;
}
.file-format-hint {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.code-hint {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Content form feedback states */
.content-form-feedback {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  display: none;
}
.content-form-feedback--success {
  background: var(--bg-green-soft);
  color: var(--accent-green);
  border: 1px solid #6ee7b7;
}
.content-form-feedback--error {
  background: #fef2f2;
  color: var(--state-error);
  border: 1px solid #fca5a5;
}
.content-form-feedback--duplicate {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fcd34d;
}
.content-form-feedback--loading {
  background: var(--bg-blue-soft);
  color: var(--accent-blue);
  border: 1px solid #93c5fd;
}
