/* Mobile-First App Design System */
:root {
  --bg-app: #0b1120;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #273549;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-blue: #3b82f6;
  --accent-blue-light: #60a5fa;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;
  --font-base: 15px;
  --bottom-nav-height: 64px;
  --header-height: 56px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: var(--font-base);
  line-height: 1.5;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 16px));
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}

/* Header Bar */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(11, 17, 32, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 999;
}

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

.app-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-blue));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-icon:active {
  background: var(--bg-surface-elevated);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
}

.nav-tab .tab-icon {
  font-size: 20px;
  transition: transform 0.2s;
}

.nav-tab.active {
  color: var(--accent-emerald-light);
  font-weight: 700;
}

.nav-tab.active .tab-icon {
  transform: scale(1.15);
}

/* Screen Containers */
.screen {
  display: none;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  animation: mobileSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen.active {
  display: block;
}

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

/* Mobile Hero Banner */
.hero-card {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.25), transparent 70%);
  border-radius: 50%;
}

.hero-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #fff;
}

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

/* Progress Tracker */
.progress-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-bar-container {
  height: 8px;
  background-color: #0b1120;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-blue));
  width: 0%;
  transition: width 0.4s ease;
}

/* Quick Action Chips */
.chips-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: none;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.chip:active {
  background-color: var(--accent-emerald);
  color: #fff;
  border-color: var(--accent-emerald);
}

/* Module Accordion List */
.module-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.module-header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.module-number {
  width: 28px;
  height: 28px;
  background-color: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-emerald-light);
  flex-shrink: 0;
}

.module-title-box {
  flex: 1;
}

.module-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

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

.module-arrow {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.module-item.open .module-arrow {
  transform: rotate(180deg);
}

.module-body {
  display: none;
  padding: 0 16px 16px 16px;
  border-top: 1px solid rgba(51, 65, 85, 0.4);
  background-color: rgba(11, 17, 32, 0.4);
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.6;
}

.module-item.open .module-body {
  display: block;
}

.module-body p {
  margin-top: 12px;
}

.module-body ul {
  margin-left: 20px;
  margin-top: 8px;
}

.module-body li {
  margin-bottom: 6px;
}

.module-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn-sm {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-sm.primary {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #0b1120;
  font-weight: 700;
}

/* Mobile Calculator Keypad & Cards */
.calc-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.form-field {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.mobile-input {
  width: 100%;
  background-color: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  outline: none;
}

.mobile-input:focus {
  border-color: var(--accent-emerald);
}

.calc-display {
  background: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.display-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(51, 65, 85, 0.5);
  font-size: 13.5px;
}

.display-row:last-child {
  border-bottom: none;
}

.display-val {
  font-weight: 700;
  color: #fff;
}

.display-total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 2px solid var(--accent-emerald);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-emerald-light);
}

/* Timeline Feed */
.timeline-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  border-left: 4px solid var(--accent-blue);
}

.timeline-card.highlight {
  border-left-color: var(--accent-emerald);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08), var(--bg-surface));
}

.timeline-year-tag {
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  background-color: #0b1120;
  color: var(--accent-emerald-light);
  margin-bottom: 8px;
}

.timeline-card h4 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 6px;
}

.timeline-card p {
  font-size: 13.5px;
  color: #cbd5e1;
  line-height: 1.5;
}

/* Flashcards Screen */
.flashcard-container {
  perspective: 1000px;
  margin: 20px 0;
  min-height: 240px;
}

.flashcard {
  width: 100%;
  height: 240px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

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

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 1px solid var(--border-color);
}

.flashcard-front {
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

.flashcard-back {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  transform: rotateY(180deg);
  border-color: var(--accent-emerald);
}

.flashcard-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-emerald-light);
  font-weight: 700;
  margin-bottom: 12px;
}

.flashcard-text {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  line-height: 1.5;
}

.flashcard-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 16px;
}

.flashcard-controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.btn-card {
  flex: 1;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-card:active {
  background: var(--bg-surface-elevated);
}

/* Search Results Screen */
.search-box {
  position: sticky;
  top: var(--header-height);
  padding: 12px 0;
  background: var(--bg-app);
  z-index: 100;
}

.search-input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  outline: none;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}

.search-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.search-result-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
}

.search-result-item h5 {
  font-size: 15px;
  color: var(--accent-emerald-light);
  margin-bottom: 4px;
}

.search-result-item p {
  font-size: 13px;
  color: #cbd5e1;
}

/* Audio Player Floating Pill */
.audio-player-bar {
  display: none;
  position: fixed;
  top: calc(var(--header-height) + 8px);
  left: 16px;
  right: 16px;
  background: rgba(16, 185, 129, 0.95);
  backdrop-filter: blur(12px);
  color: #0b1120;
  padding: 10px 16px;
  border-radius: 30px;
  z-index: 1001;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.audio-player-bar.playing {
  display: flex;
}
