/* --- RESET & BASIC STYLES --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root {
  --bg-dark: #05100c;
  --panel-dark: #081c15;
  --card-dark: #0c241b;
  --accent-green: #10b981;
  --accent-light: #34d399;
  --text-main: #ecfdf5;
  --text-muted: #6ee7b7;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.main-wrapper {
  width: 100%;
  max-width: 480px;
  height: 100%;
  height: 100dvh;
  background-color: var(--panel-dark);
  display: flex;
  flex-direction: column;
  position: relative;
  border-left: 1px solid #10b98122;
  border-right: 1px solid #10b98122;
}

@media (min-width: 481px) {
  .main-wrapper {
    height: 92vh;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  }
}

/* --- NAVBAR --- */
.navbar {
  height: 55px;
  min-height: 55px;
  background-color: var(--card-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid #10b98122;
  z-index: 10;
  flex-shrink: 0;
}

.brand-selector-box {
  display: flex;
  align-items: center;
}

.brand-select-badge {
  background-color: var(--accent-green);
  color: #064e3b;
  font-weight: 800;
  font-size: 0.7rem;
  padding: 5px 6px;
  border-radius: 6px;
  border: none;
  outline: none;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 2px 5px rgba(16, 185, 129, 0.3);
}

.nav-selectors {
  display: flex;
  gap: 5px;
}

.nav-selectors select {
  background-color: #05100c;
  color: var(--accent-light);
  border: 1px solid #10b98144;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.nav-actions {
  display: flex;
  gap: 5px;
}

.btn-head {
  background-color: #05100c;
  color: var(--accent-light);
  border: 1px solid #10b98144;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-head:hover, .btn-head.active {
  background-color: var(--accent-green);
  color: #064e3b;
}

/* --- STORY STAGE --- */
.story-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-dark);
  min-height: 0;
}

.view-image {
  height: 32vh;
  min-height: 160px;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #10b98122;
  position: relative;
  flex-shrink: 0;
}

.view-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* --- THU GỌN KHOẢNG CÁCH NỘI DUNG BÀI HỌC --- */
.view-text {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  min-height: 0;
}

.story-heading {
  color: var(--accent-light);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
  text-align: center;
  border-bottom: 1px dashed #10b98133;
  padding-bottom: 4px;
}

.sentence-block {
  margin-bottom: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background-color: var(--card-dark);
  border: 1px solid #10b98115;
  transition: all 0.2s;
}

.sentence-block.in-practice {
  border-color: var(--accent-green);
  background-color: #064e3b33;
}

.sentence-block.ai-speaking {
  border-color: #f59e0b;
  background-color: #78350f33;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.sentence-en {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.3;
  font-weight: 500;
}

.word-unit {
  cursor: pointer;
  transition: color 0.1s;
}

.word-unit:hover {
  color: var(--accent-light);
  background-color: #10b98122;
  border-radius: 3px;
}

.sentence-ipa {
  font-size: 0.75rem;
  color: #a7f3d0;
  margin-top: 2px;
  font-style: italic;
}

.sentence-vi {
  font-size: 0.8rem;
  color: #6ee7b7;
  margin-top: 2px;
}

/* --- AI TOOLBAR --- */
.ai-toolbar {
  height: 40px;
  background-color: #06281f;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid #10b98133;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.ai-toolbar.hidden {
  display: none;
}

.lbl-practice {
  color: #a7f3d0;
}

.btn-practice {
  background-color: var(--accent-green);
  color: #064e3b;
  border: none;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

.highlight-num {
  font-weight: 800;
}

.hint-click {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-style: italic;
}

/* --- PLAYER BAR CỐ ĐỊNH ĐÁY --- */
.player-bar {
  height: 60px;
  min-height: 60px;
  background-color: var(--card-dark);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  border-top: 1px solid #10b98122;
  position: relative;
  flex-shrink: 0;
  z-index: 10;
}

.btn-ctrl {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
}

.btn-mode {
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  gap: 3px;
  border: 1px solid currentColor;
}

.btn-mode.mp3 { color: #34d399; }
.btn-mode.ai { color: #f59e0b; }

.btn-icon-step svg {
  width: 22px;
  height: 22px;
  fill: var(--text-main);
}

.btn-main-play {
  width: 42px;
  height: 42px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

.btn-main-play svg {
  width: 20px;
  height: 20px;
  fill: #064e3b;
}

.hidden {
  display: none !important;
}

/* Dropup Menus */
.dropup-box {
  position: relative;
}

.btn-badge {
  background-color: #05100c;
  border: 1px solid #10b98133;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 36px;
}

.badge-lbl {
  font-size: 0.55rem;
  color: var(--text-muted);
}

.badge-val {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-light);
}

.dropup-menu {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--panel-dark);
  border: 1px solid #10b98144;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
  overflow: hidden;
  z-index: 100;
  min-width: 110px;
}

.dropup-item {
  padding: 7px 10px;
  font-size: 0.8rem;
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
  border-bottom: 1px solid #10b98111;
}

.dropup-item:hover, .dropup-item.active {
  background-color: var(--accent-green);
  color: #064e3b;
  font-weight: 600;
}

/* --- MODAL MỤC LỤC TOÀN CẢNH --- */
.modal-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-box {
  background-color: #081c15;
  border: 1px solid #10b98155;
  border-radius: 16px;
  width: 92%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid #10b98122;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  color: #34d399;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
}

.index-month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.month-tab-btn {
  background-color: #0c241b;
  border: 1px solid #10b98133;
  color: #a7f3d0;
  padding: 8px 6px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.month-tab-btn:hover {
  background-color: #10b98122;
  border-color: #34d399;
}

.month-tab-btn.active {
  background-color: #10b981;
  color: #064e3b;
  border-color: #34d399;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.index-days-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid #10b98122;
  padding-top: 10px;
}

.index-item {
  background-color: #0c241b;
  border: 1px solid #10b98115;
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
}

.index-item:hover {
  background-color: #10b98115;
  border-color: #10b98144;
  transform: translateX(3px);
}

.index-item.current {
  background-color: #10b98125;
  border-color: #34d399;
}

.index-day-badge {
  background-color: #10b981;
  color: #064e3b;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 8px;
}

.index-item-title {
  color: #ecfdf5;
  font-size: 0.85rem;
}