/* ═══════════════════════════════════════════════
   ГеоПро — веб-версия (десктоп, ≥1024px)
   ═══════════════════════════════════════════════ */

@media (min-width: 1024px) {
  /* ── Общие ── */
  body {
    padding-bottom: 0;
    background: radial-gradient(circle at 15% 10%, rgba(76,141,255,.12) 0%, transparent 45%), radial-gradient(circle at 90% 70%, rgba(160,107,255,.10) 0%, transparent 45%), linear-gradient(180deg, #1c2333 0, #0f1620 640px) #0f1620 no-repeat;
    overflow-x: hidden;
  }

  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--muted); }

  /* ── Боковая навигация ── */
  .bottom-nav {
    top: 0; bottom: 0; right: auto; left: 0; width: 240px;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    padding: 32px 16px; gap: 8px;
    background: #0d1117e6; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: none; border-right: 1px solid rgba(76,141,255,.10); box-shadow: 4px 0 32px rgba(0,0,0,.35);
  }
  .bottom-nav::before {
    content: 'ГеоПро'; display: block; font-family: var(--font-heading); font-size: 20px; font-weight: 800;
    letter-spacing: -.02em; color: var(--text); padding: 0 12px 24px; margin-bottom: 12px; border-bottom: 1px solid rgba(76,141,255,.12);
  }
  .bottom-nav .nav-item { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 14px; padding: 14px 16px; border-radius: 14px; font-size: 15px; }
  .bottom-nav .nav-item .nav-icon { width: 22px; height: 22px; }
  .bottom-nav .nav-item .nav-label { font-size: 14px; font-weight: 600; }
  .bottom-nav .nav-item:hover { background: rgba(76,141,255,.08); }
  .bottom-nav .nav-item.active { background: linear-gradient(135deg, rgba(76,141,255,.18), rgba(160,107,255,.10)); box-shadow: inset 0 0 0 1px rgba(76,141,255,.28); }
  .bottom-nav .nav-item.active::before { display: none; }

  .sidebar-subscribe {
    display: block; margin-top: auto; padding: 16px; border-radius: 18px;
    background: linear-gradient(135deg, rgba(245,166,35,.12), rgba(160,107,255,.08)); border: 1px solid rgba(245,166,35,.28);
  }
  .sidebar-subscribe-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .sidebar-subscribe-icon { width: 20px; height: 20px; color: var(--gold); display: inline-flex; }
  .sidebar-subscribe-title { font-family: var(--font-heading); font-weight: 800; font-size: 15px; color: var(--text); }
  .sidebar-subscribe-note { font-size: 12px; color: var(--muted); line-height: 1.4; margin-bottom: 12px; }
  .sidebar-subscribe .btn-primary { min-height: 44px !important; padding: 8px 14px !important; border-radius: 14px !important; font-size: 14px; width: 100%; }

  .screen { margin-left: 240px; width: calc(100% - 240px) !important; min-height: 100vh; max-width: none; box-sizing: border-box; overflow-x: hidden; }

  /* ── Шапка ── */
  .topbar {
    position: relative; display: flex !important; align-items: center; justify-content: center;
    padding: 20px 48px; background: rgba(19, 26, 38, .95) !important; backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,.05) !important; margin-bottom: 24px;
  }
  .topbar .back-link { position: absolute; left: 48px; top: 50%; transform: translateY(-50%); cursor: pointer; color: var(--primary); margin: 0; font-weight: 600; font-size: 15px; }
  .topbar .sec-title { margin: 0; text-align: center; font-size: 20px; display: flex; align-items: center; justify-content: center; gap: 8px; }
  #s-home .topbar { display: flex !important; justify-content: space-between !important; }

  .avatar { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 4px 12px rgba(76,141,255,.15); }
  .avatar svg { width: 22px; height: 22px; }
  .username { font-size: 18px !important; }
  .sublabel { font-size: 13px !important; margin-top: 2px; }
  .streak { font-size: 16px !important; padding: 6px 14px; background: rgba(245,166,35,.1); border-radius: 12px; border: 1px solid rgba(245,166,35,.2); }
  .streak svg { width: 18px; height: 18px; }

  .scroll { padding: 0 48px 48px; max-width: 1200px; width: 100%; margin: 0 auto; box-sizing: border-box; }

  /* ── ГЛАВНАЯ: Дашборд ── */
  .home-hero-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; margin-bottom: 24px; }
  .home-lower-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }

  .home-continue-big { background: linear-gradient(135deg, #4c8dff, #a06bff); border-radius: 24px; padding: 32px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; box-shadow: 0 18px 40px -10px rgba(76,141,255,.4); }
  .home-continue-big::before { content: ''; position: absolute; top: -20px; right: -20px; width: 150px; height: 150px; background: rgba(255,255,255,.15); border-radius: 50%; filter: blur(40px); }
  .hcb-label { font-size: 12px; font-weight: 700; color: rgba(255,255,255,.8); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; z-index: 1; }
  .hcb-title { font-family: var(--font-heading); font-size: 26px; font-weight: 800; color: #fff; line-height: 1.3; margin-bottom: 8px; z-index: 1; }
  .hcb-sub { font-size: 15px; color: rgba(255,255,255,.9); margin-bottom: 24px; z-index: 1; }
  .hcb-action-wrap { margin-top: 24px; z-index: 1; }
  .hcb-action-btn { width: 100%; background: #fff; color: #4c8dff; border: none; border-radius: 14px; padding: 16px; font-family: var(--font-heading); font-size: 16px; font-weight: 800; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.15); display: flex; align-items: center; justify-content: center; gap: 8px; }

  .home-kim-card { background: #1c263a; border: 1px solid rgba(255,255,255,.05); border-radius: 24px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-shadow: 0 18px 40px -10px rgba(0,0,0,.4); }
  .hkc-title { font-family: var(--font-heading); font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 16px; }
  .hkc-ring-wrap { position: relative; width: 130px; height: 130px; margin-bottom: 16px; }
  .hkc-ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .hkc-sub { font-size: 13px; color: var(--muted); }
  .hkc-sub b { color: #fff; font-size: 16px; }

  .home-widget-card { padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .hwc-left { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
  .hwc-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .hwc-icon svg { width: 24px; height: 24px; }
  .hwc-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; white-space: nowrap; }
  .hwc-desc { font-size: 13px; color: var(--muted); white-space: normal; line-height: 1.3; }
  .hwc-btn { border: none; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; flex-shrink: 0; white-space: nowrap; }
  .hwc-score { font-family: var(--font-heading); font-size: 20px; font-weight: 800; color: var(--primary); flex-shrink: 0; }
  .home-widget-card--sub { border: 1px solid rgba(245,166,35,.4) !important; background: linear-gradient(180deg, rgba(245,166,35,.05) 0%, rgba(28,38,58,1) 100%) !important; box-shadow: 0 0 20px rgba(245,166,35,.05) !important; }

  /* ── ПРОФИЛЬ ── */
  #profile-content { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; box-sizing: border-box; }
  #profile-content > * { margin-bottom: 20px !important; min-width: 0; }
  
  #profile-content > .profile-header-card,
  #profile-content > .kim-block,
  #profile-content > .profile-stats-grid,
  #profile-content > .pro-block-card,
  #profile-content > .section-title-with-icon,
  #profile-content > .sub-status-card,
  #profile-content > .sub-offer-card,
  #profile-content > .collection-wrap,
  #profile-content > button { grid-column: 1 / -1; }
  
  #profile-content > button { margin-top: 0 !important; margin-bottom: 24px !important; }
  #profile-content > .section-title-with-icon { margin-top: 0 !important; margin-bottom: 12px !important; }
  #profile-content > .pro-block-card, #profile-content > .sub-status-card { margin-top: 0 !important; margin-bottom: 20px !important; }

  .collection-wrap { display: flex; flex-direction: column; gap: 24px; width: 100%; }
  .collection-wrap > div, .collection-wrap > ul { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 24px; margin: 0 !important; }
  .collection-wrap .info-card { display: flex !important; justify-content: space-between; align-items: center; border: none !important; padding: 0 !important; background: transparent !important; }
  
  .collection-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
  .collection-item { display: flex; align-items: center; gap: 16px; background: var(--card2); border: 1px solid var(--border); border-radius: 16px; padding: 16px; transition: 0.2s; }
  .collection-item:hover { background: rgba(255,255,255,0.05); }
  .collection-item.locked { opacity: 0.6; background: var(--card); }
  .ci-icon { font-size: 24px; flex-shrink: 0; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.05); border-radius: 12px; }
  .collection-item.unlocked .ci-icon { background: rgba(245,166,35,0.15); }
  .ci-body { flex: 1; min-width: 0; }
  .ci-title { font-family: var(--font-heading); font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 2px; }
  .ci-sub { font-size: 12px; color: var(--muted); }

  .profile-header-card { padding: 12px 24px !important; display: flex; align-items: center; gap: 16px; }
  .profile-avatar-big { width: 88px; height: 88px; border-radius: 26px; background: var(--card) !important; border: 2px solid rgba(76,141,255,0.3); display: flex; align-items: center; justify-content: center; overflow: hidden; }
  .profile-avatar-big img { width: 100%; height: 100%; object-fit: cover; }
  .profile-avatar-big svg { width: 40px; height: 40px; color: var(--primary); margin-left: 4px; margin-top: 2px; }
  
  .profile-name-big { font-size: 28px; }
  .profile-level-big { font-size: 16px; }
  .profile-tabs { padding: 0 48px; }

  .sub-status-card { display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: space-between !important; gap: 20px; padding: 24px !important; width: 100%; box-sizing: border-box; }
  .sub-status-card > div:first-child { flex-shrink: 0; }
  .sub-status-card > div:nth-child(2) { flex: 1; }
  .sub-status-card > div:last-child { margin-top: 0 !important; flex-shrink: 0; width: auto !important; }
  .sub-status-card .btn-primary { width: auto !important; min-width: 200px; padding: 14px 24px !important; margin: 0 !important; }

  /* ── КИМ-БЛОК ── */
  .kim-block { display: flex; flex-direction: column; gap: 20px; width: 100%; padding: 24px; }
  .kim-top { display: flex; align-items: center; gap: 24px; flex-wrap: nowrap; }
  .kim-ring { width: 104px; height: 104px; }
  .kim-ring svg { min-width: 104px; }
  .kim-ring-num { font-size: 24px; }
  .kim-ring-denom { font-size: 11px; }
  .kim-info-title { font-size: 16px; margin-bottom: 8px; }
  .kim-info-forecast { font-size: 14px; line-height: 1.4; margin-bottom: 8px; }
  .kim-info-forecast-chip { font-size: 11px; padding: 2px 8px; }
  .kim-info-forecast-dyn { font-size: 12px; }
  .kim-info-next { font-size: 13px; }
  .kim-map { grid-template-columns: repeat(10, 1fr); gap: 6px; }
  .kim-cell { font-size: 13px; border-radius: 8px; }
  .kim-cell--selected { transform: scale(1.05); }
  .kim-task-card { padding: 20px; }
  .kim-task-title { font-size: 15px; }
  .kim-task-sub { font-size: 12px; margin-bottom: 16px; }
  .kim-lesson-row { padding: 12px 16px; margin-bottom: 8px; border-radius: 12px; }
  .kim-lesson-check { width: 18px; height: 18px; }
  .kim-lesson-title { font-size: 14px; }
  .kim-lesson-points { font-size: 12px; }

  /* ── РЕЙТИНГ ── */
  #leaderboard-block { display: flex !important; flex-direction: column !important; background: var(--card) !important; border: 1px solid var(--border) !important; border-radius: 24px !important; padding: 24px !important; width: 100% !important; box-sizing: border-box !important; box-shadow: 0 10px 30px rgba(0,0,0,.2) !important; }
  #s-rating .info-card:first-child { background: linear-gradient(135deg, #1a2c5c, #0f1638) !important; border: 1px solid rgba(76,141,255,.3) !important; border-radius: 20px !important; margin-bottom: 24px !important; padding: 24px !important; }
  #leaderboard-block .btn-ghost { display: flex !important; align-items: center; justify-content: center; background: rgba(76,141,255,.1) !important; color: var(--primary) !important; font-family: var(--font-body) !important; font-size: 14px !important; font-weight: 600 !important; padding: 14px !important; border-radius: 14px !important; border: 1px solid rgba(76,141,255,.2) !important; margin-top: 24px !important; transition: background .2s; width: 100% !important; box-sizing: border-box !important; cursor: pointer; }
  #leaderboard-block .btn-ghost:hover { background: rgba(76,141,255,.2) !important; }
  #leaderboard-block > div { width: 100% !important; }

  /* ── СПИСОК УРОКОВ (s-topic) ── */
  #topic-content { max-width: 900px; margin: 0 auto; box-sizing: border-box; width: 100%; }

  .section-layout { 
    display: grid !important; 
    grid-template-columns: minmax(0, 1fr) 320px !important; 
    gap: 32px !important; 
    align-items: start !important; 
    width: 100% !important; 
  }
  
  .section-main-col { min-width: 0 !important; display: block !important; }
  .section-side-col { display: flex !important; flex-direction: column !important; gap: 20px !important; width: 320px !important; min-width: 0 !important; }
  
  .lesson-card-rich { 
    display: flex !important; 
    align-items: center !important; 
    justify-content: space-between !important; 
    padding: 20px !important; 
    margin-bottom: 16px !important; 
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .lc-body { flex: 1 !important; min-width: 0 !important; margin-right: 16px !important; }
  .lc-title { font-size: 16px !important; white-space: normal !important; overflow: visible !important; text-overflow: clip !important; margin-bottom: 4px !important; }
  .lc-meta { font-size: 13px !important; color: var(--muted) !important; white-space: nowrap !important; }
  .lc-action-btn { padding: 10px 24px !important; border-radius: 12px !important; font-weight: 700 !important; font-size: 14px !important; white-space: nowrap !important; flex-shrink: 0 !important; margin-left: 16px !important; }

  .side-info-card { padding: 24px; width: 100%; box-sizing: border-box; }
  .side-info-title { font-size: 15px; margin-bottom: 16px; word-break: break-word; }
  .side-info-list li { font-size: 14px; margin-bottom: 10px; padding-left: 20px; word-break: break-word; }
  .side-info-desc { font-size: 13px; }

  /* ── AI ЧАТ (s-ai) ── */
  #s-ai { height: 100vh; overflow: hidden; }
  #s-ai.active { display: flex; flex-direction: column; }
  
  #s-ai .scroll {
    display: flex;
    justify-content: center;
    padding: 32px 48px !important;
    background: var(--bg);
    box-sizing: border-box;
    overflow: hidden;
  }

  /* FIX: #ai-content одновременно является .scroll.
     Этот селектор точечно переопределяет отступы родительского .scroll
     только на экране Профессора и не затрагивает остальные экраны. */
  #s-ai .scroll#ai-content {
    padding: 0 !important;
    justify-content: flex-start;
    align-items: stretch;
  }

  #ai-content {
    width: 100%;
    max-width: 900px;
    height: 100%;
    padding: 0 !important; 
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    overflow: hidden;
  }
  
  .ai-fullscreen-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 0 !important;
  }

  .ai-chat-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 20px 24px; 
    background: var(--card);
    border-bottom: 1px solid var(--border); 
    margin: 0; 
    border-radius: 0;
    flex-shrink: 0;
  }
  .ai-chat-header-left { display: flex; gap: 12px; align-items: center; }
  
  .ai-chat-avatar { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; background: url('/images/professor_avatar.png') center/cover no-repeat, var(--grad); border: 2px solid rgba(76,141,255,0.4); }
  .ai-chat-msg-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; background: url('/images/professor_avatar.png') center/cover no-repeat, var(--grad); border: 2px solid rgba(76,141,255,0.4); }

  .ai-chat-name { font-family: var(--font-heading); font-weight: 700; font-size: 18px; }
  .ai-chat-status { font-size: 12px; color: var(--primary2); }
  .ai-chat-close { background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; display: none; }
  
  .ai-chat-messages { 
    flex: 1; 
    min-height: 0;
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    padding: 24px;
    background: var(--bg);
  }
  
  /* Красивый скроллбар для чата */
  .ai-chat-messages::-webkit-scrollbar { width: 6px; }
  .ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
  .ai-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
  .ai-chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

  .ai-chat-msg-row { display: flex; gap: 12px; width: 100%; }
  .ai-chat-msg-row--user { justify-content: flex-end; }
  .ai-chat-msg-row--assistant { justify-content: flex-start; }
  
  .ai-chat-msg { max-width: 75%; padding: 16px 20px; border-radius: 16px; font-size: 15px; line-height: 1.5; }
  .ai-chat-msg--assistant { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
  .ai-chat-msg--user { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
  
  .ai-chat-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
  .ai-chat-quick-btn { background: var(--card2); border: 1px solid var(--border); border-radius: 20px; padding: 8px 14px; font-size: 13px; color: var(--text); cursor: pointer; transition: background 0.2s; }
  .ai-chat-quick-btn:hover { background: var(--card); }
  
  .ai-chat-input-row { 
    display: flex; 
    gap: 12px; 
    padding: 20px 24px; 
    background: var(--card);
    border-top: 1px solid var(--border); 
    border-radius: 0;
    flex-shrink: 0; 
    margin: 0 !important;
  }
  
  .ai-chat-input { 
    flex: 1; 
    background: var(--bg); 
    border: 1px solid var(--border); 
    border-radius: 16px; 
    padding: 16px 20px; 
    color: var(--text); 
    font-family: var(--font-body); 
    font-size: 15px; 
    resize: none; 
    outline: none; 
    /* ★ ФИКС: защита от сжатия */
    min-height: 54px !important;
    box-sizing: border-box !important;
  }
  
  .ai-chat-send { 
    width: 52px; 
    height: 52px; 
    border-radius: 16px; 
    background: var(--grad); 
    border: none; 
    color: #fff; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    flex-shrink: 0; 
  }
  
  .ai-chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .ai-chat-action-btn { background: rgba(76,141,255,.1); color: var(--primary); border: 1px solid rgba(76,141,255,.3); border-radius: 12px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
  .ai-chat-image-wrap { margin-top: 12px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); max-width: 400px; }
  .ai-chat-image { width: 100%; height: auto; display: block; }
  .ai-chat-image-caption { padding: 8px 12px; font-size: 12px; color: var(--muted); background: var(--card2); }
  
  .ai-chat-typing { display: flex; gap: 4px; align-items: center; padding: 16px; }
  .ai-chat-typing span { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
  .ai-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
  .ai-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
  @keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

  /* ── КВИЗ ── */
  .quiz-wrap { max-width: 720px; width: 100%; margin: 0 auto; box-sizing: border-box; padding: 24px 0 48px; }
  .result-wrap { max-width: 720px; width: 100%; margin: 0 auto; box-sizing: border-box; }

  /* ── УРОК ЗАВЕРШЁН (kim-screens.js) ── */
  .lc-wrap { max-width: 720px; margin: 0 auto; padding: 32px 32px 48px; display: flex; flex-direction: column; gap: 24px; }
  .lc-wrap .lc-title { font-size: 28px; }
  .lc-hero { padding: 32px; }
  .lc-points-num { font-size: 64px; }
  .lc-pills { justify-content: flex-start; }
  .lc-btns { flex-direction: row; }
  .lc-btns > button { flex: 1; }

  /* ── ПЕЙВОЛЛ (screens.js) ── */
  .paywall-card { max-width: 620px; }
  .paywall-title { font-size: 24px; }
  .paywall-col-feats { font-size: 12px; }
  .paywall-price-btn { padding: 12px; }

  /* ── АПГРЕЙД (screens.js) ── */
  .upgrade-hero { text-align: center; margin-bottom: 32px; }
  .upgrade-hero-title { font-size: 32px; }
  .upgrade-features { grid-template-columns: 1fr 1fr; gap: 16px; }
  .upgrade-plans { grid-template-columns: 1fr 1fr; gap: 16px; }
  .upgrade-plan-price { font-size: 24px; }

  /* ── Прячем Профессора на десктопе (плавающего) ── */
  #professor-container, .professor-floating-btn, .professor-widget,
  [id*="professor"], [class*="professor"], #floating-professor {
    display: none !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important;
  }
}

/* ── Широкие экраны (≥1440px) ── */
@media (min-width: 1440px) {
  .scroll { max-width: 1320px; }
  #profile-content { grid-template-columns: 1fr 1fr 1fr; }
  #profile-content > .kim-block { grid-column: 1 / -1; }
}
