/* Mobile Study Studio Styles (CETs 2026 Vault) */
:root {
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Work Sans", sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Outfit", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Dark Theme */
  --bg-app: #0b0f17;
  --bg-card: #151c2c;
  --bg-elevated: #1c2538;
  --bg-card-hover: #222d44;
  --border: #1e293b;
  --border-strong: #2e3d55;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #0d9488;
  --accent-light: #2dd4bf;
  --accent-math: #6366f1;
  --accent-science: #10b981;
  --accent-lang: #f59e0b;
  --accent-dost: #0ea5e9;
  --accent-coaching: #ec4899;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
}

[data-theme="light"] {
  --bg-app: #f4f6f9;
  --bg-card: #ffffff;
  --bg-elevated: #f1f4f8;
  --bg-card-hover: #e8ecf2;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(75px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Sticky Top App Header */
header.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 23, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
  color: #0b0f17;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

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

.sync-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 9999px;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: var(--accent-light);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.sync-status-badge.offline {
  background: rgba(148, 163, 184, 0.12);
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.sync-status-badge.saving {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning);
}

.btn-header-tool {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
}

/* Tab Screens */
.tab-screen {
  display: none;
  flex-direction: column;
  padding: 16px 14px 20px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  gap: 16px;
}
.tab-screen.active {
  display: flex;
}

/* Progress Hero Card */
.progress-hero-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.hero-text-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-title {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.2;
}

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

.progress-circle-wrap {
  position: relative;
  width: 66px;
  height: 66px;
  flex-shrink: 0;
}
.progress-circle-wrap svg {
  width: 66px;
  height: 66px;
  transform: rotate(-90deg);
}
.progress-circle-wrap circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}
.circle-bg { stroke: var(--bg-card-hover); }
.circle-val {
  stroke: var(--accent-light);
  stroke-dasharray: 188;
  stroke-dashoffset: 188;
  transition: stroke-dashoffset 0.4s ease;
}
.circle-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
}

/* Subject Chips Carousel */
.subject-chips-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.subject-chips-carousel::-webkit-scrollbar { display: none; }

.subject-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.subject-chip.active {
  background: var(--accent-primary);
  border-color: var(--accent-light);
  color: #ffffff;
}

/* Search Bar */
.search-box-row {
  position: relative;
  width: 100%;
}
.search-box-row input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px 11px 40px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.search-box-row input:focus {
  border-color: var(--accent-light);
}
.search-icon-svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

/* Module Cards Feed */
.modules-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.module-card-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background: var(--bg-card);
}

.mod-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mod-num-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mod-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.mod-count {
  font-size: 11px;
  color: var(--text-dim);
}

.mod-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.module-card.expanded .mod-arrow {
  transform: rotate(180deg);
}

.module-units-tray {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg-app);
}
.module-card.expanded .module-units-tray {
  display: block;
}

/* Unit Item Row */
.unit-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.unit-row:last-child { border-bottom: none; }

.unit-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.unit-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border-strong);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.unit-checkbox.checked {
  background: var(--accent-light);
  border-color: var(--accent-light);
  color: #0b0f17;
}

.unit-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.unit-top-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.badge-tag-pdf { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-tag-wistia { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.badge-tag-youtube { background: rgba(248, 113, 113, 0.15); color: #ef4444; }
.badge-tag-canva { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.badge-tag-drive { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-tag-exam { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.unit-title-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}
.unit-row.checked .unit-title-text {
  text-decoration: line-through;
  color: var(--text-dim);
}

.unit-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.unit-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.unit-action-btn.primary {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-light);
}

/* Offline Downloads Tab */
.download-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.storage-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.storage-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 9999px;
  overflow: hidden;
}
.storage-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-light);
  transition: width 0.3s ease;
}

.btn-big-download {
  background: var(--accent-primary);
  color: #ffffff;
  border: 1px solid var(--accent-light);
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Settings Tab */
.settings-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-row {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-row-title { font-size: 14px; font-weight: 700; }
.settings-row-desc { font-size: 12px; color: var(--text-muted); }

/* Switch Toggle */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}
.switch-toggle input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  transition: .3s;
  border-radius: 34px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .switch-slider {
  background-color: var(--accent-light);
  border-color: var(--accent-light);
}
input:checked + .switch-slider:before {
  transform: translateX(20px);
  background-color: #0b0f17;
}

/* Bottom Navigation Bar (iPhone Standard 4-Tabs) */
nav.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(11, 15, 23, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
}

.bottom-tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 8px;
  min-width: 60px;
}
.bottom-tab-btn.active {
  color: var(--accent-light);
}
.bottom-tab-btn .tab-icon {
  font-size: 20px;
}

/* Slide-up Focus Station Sheet (Modal) */
.focus-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: none;
  align-items: flex-end;
}
.focus-sheet-backdrop.open { display: flex; }

.focus-sheet {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 80vh;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* Video Theatre Modal */
.video-theatre-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 210;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.video-theatre-backdrop.open { display: flex; }

.theatre-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.theatre-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.theatre-title { font-size: 14px; font-weight: 700; }
.theatre-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.theatre-iframe-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
}
.theatre-iframe-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}
