/* ───────── Sheet handle (mobile bottom sheet) ───────── */
.sheet-handle {
  display: none;
}

/* ───────── Legend toggle button (mobile) ───────── */
.legend-toggle {
  display: none;
}

/* ═══════════════════════════════════════════════════
   MOBILE — max-width: 767px
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* ── Side panel -> floating glass card ──
     Inset from every screen corner and floating ABOVE the nav bar ("штора")
     and everything else, rather than a full-width slab glued to the bottom. */
  .sidepanel {
    position: fixed;
    left: var(--nav-inset); right: var(--nav-inset); top: auto;
    /* Sit ABOVE the floating nav pill, with the SAME gap as the side insets. */
    bottom: calc(var(--nav-h) + var(--nav-inset));
    transform: none;
    width: auto;
    border-radius: 24px;
    padding: 8px 20px 18px;
    z-index: 90; /* over the nav bar (80) and the rest of the UI */
    background: rgba(10, 10, 10, 0.72);
    backdrop-filter: blur(34px) saturate(1.4);
    -webkit-backdrop-filter: blur(34px) saturate(1.4);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.06) inset,
      0 20px 60px rgba(0, 0, 0, 0.6);
    transition: height 0.3s cubic-bezier(.4, 0, .2, 1);
    overflow: hidden;
  }
  /* Three positions: fully down (collapsed) / partial (peek) / fully up (expanded). */
  .sidepanel.sheet-collapsed {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    box-shadow: none;
    pointer-events: none;
  }
  .sidepanel.sheet-peek {
    height: 42dvh;
    overflow-y: auto;
  }
  .sidepanel.sheet-expanded {
    height: 82dvh;
    overflow-y: auto;
  }
  /* Full-width grab zone across the top of the sheet — the whole strip is
     draggable, not just a 4px bar (which was near-impossible to hit and got
     clipped by the panel's overflow). The visible pill is drawn inside it. */
  .sheet-handle {
    display: block;
    width: 100%;
    height: 30px;
    flex: none;
    margin: 0 0 2px;
    cursor: grab;
    position: relative;
    touch-action: none; /* let us own the vertical drag instead of the browser */
  }
  .sheet-handle::before {
    content: '';
    position: absolute;
    top: 9px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }
  .sheet-handle:active { cursor: grabbing; }
  .sheet-handle:active::before { background: rgba(255, 255, 255, 0.5); }
  .sp-title { font-size: 22px; }
  .sp-time-num { font-size: 32px; }
  .sp-hint { font-size: 13px; }
  .sp-foot { display: none; }
  .sp-cta { padding: 16px 18px; min-height: 48px; font-size: 13px; }
  .sp-resources { padding: 14px 16px; min-height: 44px; }

  /* ── Top bar — full-width experience strip ── */
  .topbar {
    top: 0; left: 0; right: 0;
    justify-content: stretch;
    padding-top: env(safe-area-inset-top, 0px);
    border-bottom: 1px solid var(--border);
  }
  .progress-card.exp.glass {
    width: 100%;
    border-radius: 0;
    border: none;
    padding: 10px 16px 10px;
    gap: 12px;
  }
  .progress-meta { flex-shrink: 0; width: auto; }
  .progress-bar { flex: 1; min-width: 40px; width: auto !important; height: 8px; }
  .progress-count { font-size: 18px; }
  .progress-count span { font-size: 11px; }
  .exp-next { font-size: 9.5px; }

  /* ── Legend & toggle — hidden on mobile ── */
  .legend { display: none; }
  .legend-toggle { display: none; }

  /* ── Touch-friendly nodes ── */
  .node.tier-topic .shape { width: 34px; height: 34px; }
  .node.tier-topic { min-width: 100px; }

  /* ── Quiz -> fullscreen ── */
  .quiz-card {
    max-width: none;
    width: 100%; height: 100%;
    border-radius: 0;
    padding: 24px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
    overflow-y: auto;
  }
  .quiz-overlay { align-items: stretch; }
  .quiz-question { font-size: 15px; }
  .quiz-match-cols { grid-template-columns: 1fr; gap: 12px; }
  .quiz-option { padding: 14px 16px; min-height: 48px; }
  .quiz-next { padding: 14px 28px; min-height: 48px; }
  .quiz-cta { padding: 16px 18px; min-height: 48px; }
  .quiz-score { font-size: 52px; }

  /* ── Victory overlay ── */
  .victory-card {
    padding: 40px 24px;
    margin: 16px;
    max-width: none;
  }
  .victory-card h1 { font-size: 38px; }
  .victory-card p { font-size: 14px; }

  /* ── Build animation overlay ── */
  .anim-overlay { padding: 0 20px; }
  .anim-overlay h2 { font-size: 16px; }
}
