/* Newly added separately so clients that cached the prior V3.6 stylesheet
   still receive this iPad-only home control treatment immediately. */
.ipad-upcoming-courses {
  display: none;
}

/* 手机将近期两节课程放到“上一段 / 下一段”上方，减少浏览长课表时的遗漏。 */
@media (max-width: 800px) {
  .ui-v3 .view-status-bar > .ipad-upcoming-courses {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin: 0;
  }

  .ui-v3 .view-status-bar > .ipad-upcoming-courses .ipad-upcoming-card {
    display: grid;
    min-width: 0;
    min-height: 96px;
    align-content: center;
    gap: 5px;
    border: 1px solid rgba(37, 84, 199, 0.15);
    border-left: 5px solid #2554c7;
    border-radius: 14px;
    padding: 14px 15px;
    background: linear-gradient(135deg, rgba(236, 241, 255, 0.9), rgba(255, 255, 255, 0.98));
    box-shadow: 0 8px 18px rgba(37, 84, 199, 0.08);
  }

  .ui-v3 .view-status-bar > .ipad-upcoming-courses .ipad-upcoming-card:nth-child(2) {
    border-left-color: #a04792;
    background: linear-gradient(135deg, rgba(253, 239, 249, 0.9), rgba(255, 255, 255, 0.98));
  }

  .ui-v3 .ipad-upcoming-title,
  .ui-v3 .ipad-upcoming-card small {
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-v3 .ipad-upcoming-card strong {
    overflow: hidden;
    color: var(--ink);
    font-size: clamp(20px, 7vw, 26px);
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-v3 .ipad-upcoming-card .ipad-upcoming-course-label {
    font-size: 16px;
    font-weight: 850;
  }

  .ui-v3 .view-status-bar > .ipad-upcoming-courses.needs-child-selection {
    grid-template-columns: minmax(0, 1fr);
  }

  .ui-v3 .ipad-upcoming-notice {
    margin: 0;
    border: 1px dashed rgba(37, 84, 199, 0.28);
    border-radius: 14px;
    padding: 16px;
    color: #2554c7;
    background: rgba(236, 241, 255, 0.58);
    font-weight: 850;
    text-align: center;
  }
}

@media (min-width: 801px) and (max-width: 1200px) and (pointer: coarse),
  (min-width: 801px) and (max-width: 1024px) and (hover: none) {
  /* 日历/课程清单是首页主阅读入口：沿用 iPhone 的高辨识双色切换器，
     并在 iPad 上始终以左右各半的一行呈现。 */
  .ui-v3 .schedule-board .simple-view-switcher {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    max-width: none;
    border: 1px solid rgba(124, 58, 237, 0.28);
    border-radius: 16px;
    padding: 10px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.14), rgba(236, 72, 153, 0.1));
    box-shadow: 0 10px 22px rgba(91, 33, 182, 0.13);
  }

  .ui-v3 .schedule-board .simple-view-switcher .view-toggle {
    min-width: 0;
    min-height: 60px;
    border-color: rgba(124, 58, 237, 0.12);
    color: #624c83;
    background: rgba(255, 255, 255, 0.92);
    font-size: 18px;
    font-weight: 950;
  }

  .ui-v3 .schedule-board .simple-view-switcher .view-toggle.active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #be3b82);
    box-shadow: 0 8px 18px rgba(124, 58, 237, 0.27);
  }

  .ui-v3 .schedule-board .simple-view-switcher .view-toggle.active.has-badge::after {
    color: #fff;
    background: rgba(255, 255, 255, 0.27);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.34);
  }

  /* 日历/清单切换后先展示近期两节课程，再进入具体日历或清单内容。 */
  .ui-v3 #homePage .schedule-board .ipad-upcoming-courses {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 18px 18px;
  }

  .ui-v3 #homePage .schedule-board .ipad-upcoming-card {
    display: grid;
    min-width: 0;
    min-height: 108px;
    align-content: center;
    gap: 6px;
    border: 1px solid rgba(37, 84, 199, 0.15);
    border-left: 5px solid #2554c7;
    border-radius: 14px;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(236, 241, 255, 0.9), rgba(255, 255, 255, 0.98));
    box-shadow: 0 8px 18px rgba(37, 84, 199, 0.08);
  }

  .ui-v3 #homePage .schedule-board .ipad-upcoming-card:nth-child(2) {
    border-left-color: #a04792;
    background: linear-gradient(135deg, rgba(253, 239, 249, 0.9), rgba(255, 255, 255, 0.98));
  }

  .ui-v3 .ipad-upcoming-title,
  .ui-v3 .ipad-upcoming-card small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }

  .ui-v3 .ipad-upcoming-card strong {
    overflow: hidden;
    color: var(--ink);
    font-size: clamp(20px, 2.5vw, 28px);
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-v3 .ipad-upcoming-card small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-v3 .ipad-upcoming-card .ipad-upcoming-course-label {
    font-size: 15px;
    font-weight: 850;
  }

  .ui-v3 #homePage .schedule-board .ipad-upcoming-courses.needs-child-selection {
    grid-template-columns: 1fr;
  }

  .ui-v3 .ipad-upcoming-notice {
    margin: 0;
    border: 1px dashed rgba(37, 84, 199, 0.28);
    border-radius: 14px;
    padding: 20px;
    color: #2554c7;
    background: rgba(236, 241, 255, 0.58);
    font-weight: 850;
    text-align: center;
  }

  /* iPad 统计区只保留三项，三列始终一行展示。 */
  .ui-v3 #homePage .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ui-v3 #homePage :is(#nextCourseInsight, #secondNextCourseInsight) {
    display: none;
  }

  /* 首页的时间翻页和快捷筛选都应对齐筛选卡片的左右边缘，
     不让控件只停留在左侧。默认采用较窄 iPad 适合的五列两行。 */
  .ui-v3 .content-shell > .view-status-bar .view-status-actions {
    grid-auto-flow: row !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
    min-width: 0 !important;
  }

  .ui-v3 .content-shell > .view-status-bar .view-status-actions .ghost-button {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    justify-content: center;
  }

  .ui-v3 .content-shell > .quick-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .ui-v3 .content-shell > .quick-actions button {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 0 6px;
    justify-content: center;
    font-size: 14px;
    line-height: 1.2;
  }
}

/* 10/11 英寸 iPad 横屏及更宽的触控平板：九个快捷筛选一行均分并贴齐右侧。 */
@media (min-width: 981px) and (max-width: 1200px) and (pointer: coarse),
  (min-width: 981px) and (max-width: 1024px) and (hover: none) {
  .ui-v3 .content-shell > .quick-actions {
    grid-template-columns: repeat(9, minmax(0, 1fr));
  }
}
