/* Meduvita — shared mobile layout (dashboard, index, app pages) */

.mv-mob-nav,
.mv-mob-drawer {
  display: none;
}

/* ── Dashboard mobile shell ── */
@media (max-width: 768px) {
  .mv-mob-nav {
    display: flex;
  }

  .mv-mob-drawer {
    display: block;
  }

  body.mv-has-mob-nav {
    overflow-x: hidden;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .mv-mob-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
  }

  .mv-mob-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.2rem;
    min-height: 52px;
    border: none;
    background: none;
    font-family: 'Sora', sans-serif;
    font-size: 0.58rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
  }

  .mv-mob-nav-item i {
    font-size: 1.05rem;
  }

  .mv-mob-nav-item.mv-mob-on,
  .mv-mob-nav-item:active {
    color: #0d9488;
    background: #f0fdfa;
  }

  .mv-mob-drawer {
    position: fixed;
    inset: 0;
    z-index: 600;
    pointer-events: none;
    visibility: hidden;
    transition: visibility 0.3s;
  }

  .mv-mob-drawer.open {
    pointer-events: auto;
    visibility: visible;
  }

  .mv-mob-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
  }

  .mv-mob-drawer.open .mv-mob-drawer-backdrop {
    opacity: 1;
  }

  .mv-mob-drawer-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: #0f172a;
    border-radius: 18px 18px 0 0;
    padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
  }

  .mv-mob-drawer.open .mv-mob-drawer-panel {
    transform: translateY(0);
  }

  .mv-mob-drawer-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mv-mob-drawer-hd span {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
  }

  .mv-mob-drawer-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
  }

  .mv-mob-drawer-label {
    font-size: 0.56rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.25);
    margin: 0.65rem 0 0.35rem;
  }

  .mv-mob-drawer-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 8px;
  }

  .mv-mob-drawer-link i {
    width: 16px;
    color: #14b8a6;
    font-size: 0.85rem;
  }

  .mv-mob-drawer-link:active {
    background: rgba(255, 255, 255, 0.06);
  }

  .mv-mob-drawer-signout {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.55);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
  }
}

/* ── Index / landing mobile ── */
@media (max-width: 768px) {
  .main .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .main .topbar .tl {
    width: 100%;
    min-width: 0;
  }

  .main .topbar .tl h1 {
    font-size: 0.92rem;
    line-height: 1.3;
    word-break: break-word;
  }

  .main .topbar .tl p {
    font-size: 0.65rem;
    line-height: 1.45;
  }

  .main .topbar .tr {
    display: none;
  }

  .main .content {
    padding: 1rem 0.85rem 1.25rem;
  }

  .stats {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.65rem !important;
  }

  .sc {
    padding: 0.85rem !important;
  }

  .sv {
    font-size: 1.45rem !important;
  }

  .ch {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem !important;
  }

  .ch > div:first-child {
    min-width: 0;
    flex: 1 1 140px;
  }

  .cb {
    padding: 0.85rem 1rem !important;
  }

  .sec-row {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .sec-nm {
    width: 100% !important;
    font-size: 0.68rem !important;
  }

  .sec-row .bar-w {
    flex: 1 1 calc(100% - 80px);
    min-width: 0;
  }

  .sec-btns {
    width: 100%;
    justify-content: flex-start;
    margin-top: 0.15rem;
  }

  .spill {
    flex: 1;
    text-align: center;
    padding: 0.35rem 0.5rem !important;
    font-size: 0.62rem !important;
  }

  .wi-btns {
    flex-direction: column;
  }

  .wb {
    width: 100%;
  }

  .dl-card-head {
    flex-wrap: wrap;
  }

  .sug-grid {
    grid-template-columns: 1fr !important;
  }

  .tutor-info-card {
    position: static !important;
  }

  .loading-state {
    padding: 2rem !important;
  }
}

@media (max-width: 400px) {
  .stats {
    grid-template-columns: 1fr !important;
  }
}

/* ── Index / landing mobile ── */
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-mobile-panel {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  z-index: 999;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.75rem 1rem 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.nav-mobile-panel.open {
  display: block;
}

.nav-mobile-panel a {
  display: block;
  padding: 0.75rem 0.5rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-mobile-panel a:last-child {
  border-bottom: none;
}

.nav-mobile-panel .nav-mobile-cta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-mobile-panel .nav-mobile-cta a {
  flex: 1;
  text-align: center;
  border: none;
  border-radius: 8px;
  padding: 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.nav-mobile-panel .nm-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #fff !important;
}

.nav-mobile-panel .nm-primary {
  background: linear-gradient(135deg, #0d9488, #14b8a6);
  color: #fff !important;
}

@media (max-width: 768px) {
  .nav-inner {
    padding: 0 1rem !important;
    gap: 0.5rem;
  }

  .nav-links {
    display: none !important;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-actions .auth-dropdown {
    display: none;
  }

  .nav-actions .btn-nav-primary {
    padding: 0.48rem 0.85rem !important;
    font-size: 0.78rem !important;
    white-space: nowrap;
  }

  .nav-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  .logo {
    font-size: 1.15rem !important;
    min-width: 0;
    flex: 1;
  }

  .logo-badge {
    display: none;
  }

  .hero {
    min-height: auto;
  }

  .hero-inner {
    padding: 6.5rem 1.15rem 5.5rem !important;
    gap: 2rem !important;
  }

  .hero h1 {
    font-size: 2.15rem !important;
    margin-bottom: 1rem;
  }

  .hero-subtitle {
    font-size: 0.92rem !important;
    margin-bottom: 1.25rem;
  }

  .hero-free-badge {
    font-size: 0.72rem !important;
    padding: 0.4rem 0.85rem !important;
    margin-bottom: 1.25rem;
  }

  .hero-cta-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-hero,
  .btn-hero-outline {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1.25rem !important;
    font-size: 0.92rem !important;
  }

  .hero-micro {
    font-size: 0.7rem !important;
    line-height: 1.55;
    text-align: center;
  }

  .hero-stats {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1rem 1.5rem !important;
    margin-top: 2rem !important;
    padding-top: 1.5rem !important;
  }

  .hero-stat-num {
    font-size: 1.85rem !important;
  }

  .hero-freemium-strip {
    padding: 0.65rem 1rem !important;
    flex-direction: column;
    text-align: center;
    gap: 0.45rem !important;
  }

  .fstrip-text {
    font-size: 0.72rem !important;
    line-height: 1.45;
  }

  .section-wrap,
  .pricing-inner,
  .band-inner,
  .trust-bar-inner {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .highlights-section,
  .comparison-section,
  .features-section,
  .how-section,
  .pricing-section,
  .faq-section {
    padding-top: 60px !important;
    padding-bottom: 60px !important;
  }

  .section-heading {
    font-size: 1.85rem !important;
  }

  .comparison-table-wrap {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    border-radius: 14px;
  }

  .comparison-table {
    min-width: 520px;
    font-size: 0.75rem !important;
  }

  .comparison-table thead th,
  .comparison-table tbody td {
    padding: 0.75rem 0.85rem !important;
  }

  #cookie-banner {
    flex-direction: column;
    align-items: stretch !important;
    padding: 1rem !important;
    gap: 0.75rem !important;
  }

  #cookie-banner > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  #cookie-banner button {
    width: 100%;
  }

  .how-steps {
    gap: 1.25rem !important;
  }

  .pv-trust-row {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .hero-inner {
    padding-top: 5.75rem !important;
  }

  .hero h1 {
    font-size: 1.85rem !important;
  }
}

/* Daily loop modal — full width on phone */
@media (max-width: 480px) {
  .dl-modal-panel {
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 16px 16px 0 0 !important;
    margin-top: auto;
  }

  .dl-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
}

/* ═══ Universal app shell (all sidebar + practice pages) ═══ */
@media (max-width: 768px) {
  html.mv-app-shell,
  body.mv-app-shell {
    overflow-x: hidden;
    max-width: 100vw;
  }

  body.mv-app-shell .sb {
    display: none !important;
  }

  body.mv-app-shell .main {
    margin-left: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw;
  }

  body.mv-app-shell .main .topbar {
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.65rem 1rem !important;
  }

  body.mv-app-shell .main .topbar .tr {
    display: none;
  }

  body.mv-app-shell .main .content {
    padding: 1rem 0.85rem calc(1.25rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.mv-app-shell .tl {
    min-width: 0;
  }

  body.mv-app-shell .tl h1 {
    font-size: 0.88rem !important;
    line-height: 1.3;
    word-break: break-word;
  }

  body.mv-app-shell .tl p {
    font-size: 0.65rem !important;
    line-height: 1.45;
  }

  body.mv-app-shell .tb-back span {
    display: none;
  }

  /* AI tutors */
  body.mv-app-shell .tutor-layout {
    grid-template-columns: 1fr !important;
  }

  body.mv-app-shell .side-panel {
    position: static !important;
    top: auto !important;
    width: 100%;
  }

  body.mv-app-shell .sug-grid {
    grid-template-columns: 1fr !important;
  }

  body.mv-app-shell .vr-hero,
  body.mv-app-shell .qr-hero,
  body.mv-app-shell .dm-hero,
  body.mv-app-shell .sj-hero {
    flex-direction: column !important;
    gap: 1rem !important;
    padding: 1.25rem 1rem !important;
  }

  body.mv-app-shell .hero-right {
    align-items: flex-start !important;
    width: 100%;
  }

  body.mv-app-shell .hero-title {
    font-size: 1.35rem !important;
  }

  body.mv-app-shell .hero-topics {
    justify-content: flex-start !important;
  }

  body.mv-app-shell .chat-msgs {
    min-height: 220px !important;
    max-height: min(42vh, 380px) !important;
  }

  body.mv-app-shell .chips-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.mv-app-shell .chip {
    flex-shrink: 0;
  }

  /* Progress, settings, weak areas */
  body.mv-app-shell .stats-row,
  body.mv-app-shell .prog-grid,
  body.mv-app-shell .settings-grid,
  body.mv-app-shell .set-grid,
  body.mv-app-shell .wa-grid,
  body.mv-app-shell .grid-2 {
    grid-template-columns: 1fr !important;
  }

  body.mv-app-shell .card-row,
  body.mv-app-shell .sec-cards {
    flex-direction: column;
  }

  /* Mock hub */
  body.mv-app-shell .mock-grid,
  body.mv-app-shell .mock-cards {
    grid-template-columns: 1fr !important;
  }
}

/* Practice selection screen */
@media (max-width: 768px) {
  #selectionScreen {
    padding: 1rem 0.75rem 2rem !important;
    align-items: stretch !important;
    min-height: 100dvh;
  }

  .selection-box {
    padding: 1.25rem 1rem !important;
    border-radius: 18px !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .sel-title {
    font-size: 1.45rem !important;
  }

  .sel-sub {
    font-size: 0.78rem !important;
  }

  .section-grid {
    grid-template-columns: 1fr !important;
  }

  .mode-row {
    flex-direction: column;
  }

  .count-row .count-btn {
    min-width: calc(33% - 0.35rem);
  }

  .sen-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .ai-fab {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
    right: 1rem !important;
  }

  .chat-drawer {
    width: calc(100vw - 1.5rem) !important;
    right: 0.75rem !important;
    max-width: 100% !important;
  }
}

/* Exam mode — practice & mock: single-column vertical scroll on phone */
@media (max-width: 768px) {
  body.mv-practice-exam-active {
    overflow: hidden;
    max-width: 100vw;
  }

  #practiceScreen {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    min-height: 0 !important;
  }

  #practiceScreen .exam-topbar,
  #practiceScreen .q-bar,
  #practiceScreen .q-nav,
  .ues-topbar,
  #uesSectionStrip {
    flex-shrink: 0;
    max-width: 100%;
  }

  .exam-topbar,
  .ues-topbar {
    flex-wrap: wrap;
    padding: 0.55rem 0.75rem !important;
    gap: 0.45rem !important;
  }

  .exam-logo {
    font-size: 0.78rem !important;
  }

  .exam-progress-wrap {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }

  .exam-toolbar,
  .ques-nav-row,
  .ues-qnav,
  .ues-toolbar,
  #practiceScreen .q-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    max-width: 100%;
  }

  /* One scrollable column: passage → question → answers */
  #practiceScreen .exam-body,
  #practiceScreen .exam-body.exam-split,
  body.mv-exam-day-mode #practiceScreen .exam-body,
  .exam-body,
  .exam-body.exam-split,
  .ues-body,
  .ues-body.ues-split {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    grid-template-columns: 1fr !important;
    grid-template-rows: none !important;
  }

  #practiceScreen .stimulus-panel,
  body.mv-exam-day-mode #practiceScreen .stimulus-panel,
  .stimulus-panel,
  .ues-stimulus {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    overflow-y: visible !important;
    border-right: none !important;
    border-left: none !important;
    border-bottom: 1px solid var(--border, #dde1e7) !important;
    padding: 1rem 0.85rem !important;
    flex-shrink: 0;
    box-shadow: none !important;
  }

  #practiceScreen .question-panel,
  body.mv-exam-day-mode #practiceScreen .question-panel,
  .question-panel,
  .ues-question {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: auto !important;
    overflow: visible !important;
    overflow-y: visible !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
  }

  #practiceScreen .quiz-container,
  #practiceScreen .q-area {
    min-width: 0;
    width: 100%;
  }

  #practiceScreen .q-area {
    padding: 1rem 0.85rem !important;
  }

  #practiceScreen .q-text,
  #practiceScreen .passage-text,
  #practiceScreen .ans-list {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  #practiceScreen .passage-text .data-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #practiceScreen .ans-opt {
    padding: 0.85rem !important;
    font-size: 0.84rem !important;
    min-height: 48px;
  }

  #practiceScreen .q-nav-bar {
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
    z-index: 20;
    background: #fff;
    padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  }

  #practiceScreen .submit-answer-btn {
    margin: 0 0.85rem 0.75rem;
    width: calc(100% - 1.7rem);
  }

  #practiceScreen .confidence-calibration {
    margin: 0 0.85rem 0.5rem;
  }

  .answer-grid,
  .ues-answers {
    grid-template-columns: 1fr !important;
  }

  .exam-footer,
  .ues-footer,
  .ues-bottom-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  .exam-footer .btn,
  .ues-footer .ues-btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  .opt-btn,
  .ues-opt {
    padding: 0.75rem 0.85rem !important;
    font-size: 0.78rem !important;
  }

  /* Mock exam split view — same vertical stack */
  body.mv-exam-day-mode #examView.exam-split-active {
    height: 100dvh !important;
  }

  body.mv-exam-day-mode #examView .exam-body.exam-split {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  body.mv-exam-day-mode #examView .exam-body.exam-split .stimulus-panel,
  body.mv-exam-day-mode #examView .exam-body.exam-split .question-panel {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }

  .calc-overlay {
    padding: 1rem !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .calc-box {
    width: min(100%, 300px) !important;
  }
}

/* Login */
@media (max-width: 900px) {
  body.mv-app-shell .left-panel,
  .left-panel {
    display: none !important;
  }

  body.mv-app-shell .right-panel,
  .right-panel {
    padding: 1.25rem 1rem;
    width: 100%;
  }

  .auth-box {
    padding: 1.75rem 1.25rem;
    border-radius: 18px;
    max-width: 100%;
  }
}

/* Guides / articles / legal */
@media (max-width: 768px) {
  .top-nav {
    flex-wrap: wrap;
    padding: 0.85rem 1rem !important;
    gap: 0.5rem;
  }

  .top-nav .links {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-left: 0 !important;
  }

  .page-head {
    padding: 2rem 1rem 0.5rem !important;
  }

  .page-head h1 {
    font-size: 1.75rem !important;
  }

  .articles-wrap,
  .article-page-body {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .articles-grid {
    grid-template-columns: 1fr !important;
  }

  .article-page-hero {
    padding: 1.5rem 1rem !important;
  }

  .article-page-hero h1 {
    font-size: 1.5rem !important;
  }

  .legal-wrap,
  .terms-wrap {
    padding: 1.25rem 1rem 3rem !important;
  }

  .legal-toc {
    display: none;
  }
}
