/* 教程索引页（根 index.html）的样式。保留最初的中性白灰 + 品牌绿色。 */
  body.md {
    --fg: #1f2328;
    --fg-muted: #59636e;
    --bg: #ffffff;
    --bg-soft: #f6f8fa;
    --surface: #ffffff;
    --border: #d1d9e0;
    --accent: #1a7f37;
    --accent-dk: #116329;
    --accent-soft: #dafbe1;
    --link: #0969da;
    padding: 0 0 48px;
    background: var(--bg);
  }

  /* 两个列表主页的页脚负责页面收尾，不再在页脚后额外留白。 */
  body.md:not(.howtoDetail) { padding-bottom: 0; }

  .idxHeadInner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    max-width: 60rem;
    margin: 0 auto;
    padding: 28px 20px 18px;
  }
  /* ── 主菜单 ─────────────────────────────────────────────────────────────
     结构参考文档页（fun123.cn/reference/）的导航：站内入口在左，特色功能
     收进右侧下拉。标记 _includes/sitemenu.html。 */
  .idxMenu {
    position: relative;   /* 下拉浮层的定位基准，同时压住下方吸顶的工具条 */
    z-index: 30;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .idxMenuInner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    max-width: 60rem;
    margin: 0 auto;
    padding: 8px 20px;
  }
  .idxMenuLink {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    color: var(--fg-muted);
    background: none;
    border: 0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color .15s ease, background .15s ease;
  }
  .idxMenuLink:hover {
    color: var(--accent-dk);
    background: #eef6f0;
    text-decoration: none;
  }
  .idxMenuLink:focus-visible { outline: 2px solid rgba(26, 127, 55, .35); outline-offset: 1px; }
  .idxMenuLink.is-here { color: var(--accent-dk); background: var(--accent-soft); }
  .idxMenuExt { font-size: 11px; opacity: .55; }
  .idxMenuGroup { position: relative; margin-left: auto; }
  /* 星形图标沿用文档页「特色」的橙色标记 */
  .idxMenuSpark { width: 15px; height: 15px; flex: none; color: #d97706; }
  .idxMenuChevron {
    width: 12px;
    height: 12px;
    flex: none;
    opacity: .6;
    transition: transform .18s ease;
  }
  .idxMenuGroup.open .idxMenuChevron { transform: rotate(180deg); }
  .idxMenuDrop {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    display: grid;
    gap: 1px;
    min-width: 252px;
    max-width: calc(100vw - 24px);
    padding: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(20, 32, 24, .14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s;
  }
  .idxMenuGroup.open .idxMenuDrop { opacity: 1; visibility: visible; transform: none; }
  .idxMenuDrop a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    color: var(--fg);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
  }
  .idxMenuDrop a:hover { color: var(--accent-dk); background: #eef6f0; text-decoration: none; }
  .idxMenuDropSep { height: 1px; margin: 5px 6px; background: var(--border); }
  /* logo 和页面标题排成一行，中间一道细分隔线，让它们读起来是一个整体 */
  .idxBrand {
    display: flex;
    align-items: center;
    gap: 13px;
    margin: 0 0 7px;
  }
  .idxLogoLink { flex: none; line-height: 0; }
  .idxLogo {
    /* 原图 550×175（宽高比 3.14），按高度缩放，44px 时宽约 138px。
       logo 里「APP INVENTOR 2 中文网」那行是小字，再矮就糊了 */
    width: auto;
    height: 44px;
    margin: 0;
    border-radius: 0;
    display: block;
  }
  .idxBrandSep {
    flex: none;
    width: 1px;
    height: 26px;
    background: var(--border);
  }
  .idxHead h1 {
    margin: 0;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: .01em;
  }
  .idxHead p {
    margin: 0;
    color: var(--fg-muted);
    font-size: 15px;
  }

  .idxTools {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .idxToolsInner {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    max-width: 60rem;
    margin: 0 auto;
    padding: 12px 20px;
  }

  .idxSearch {
    flex: 1 1 220px;
    min-width: 0;
    padding: 8px 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--fg);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
  }
  .idxSearch:focus { border-color: var(--link); background: var(--bg); }

  .idxFilters { display: flex; flex-wrap: wrap; gap: 6px; }
  .idxChip {
    padding: 5px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--fg-muted);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s ease;
  }
  .idxChip:hover { color: var(--fg); border-color: #b8c2cc; }
  .idxChip.on {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
  }

  .idxBody { max-width: 60rem; margin: 0 auto; padding: 8px 20px; }

  .idxGroup { margin: 26px 0 0; }
  .idxGroupHead {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 14px;
  }
  .idxGroupHead h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
  }
  .idxStars { color: #f78c34; letter-spacing: .06em; }
  .idxGroupHead span.idxCount { color: var(--fg-muted); font-size: 13px; }

  .idxGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
  }

  .idxCard {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  }
  .idxCard:hover {
    text-decoration: none;
    border-color: #b8c2cc;
    box-shadow: 0 6px 20px rgba(31, 35, 40, .1);
    transform: translateY(-2px);
  }

  .idxThumb {
    aspect-ratio: 16 / 10;
    /* 内嵌一圈浅边框，让图和卡片之间有条界线，浅色截图不至于糊在一起 */
    box-shadow: inset 0 0 0 1px rgba(31, 35, 40, .07);
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
  }
  .idxThumb img {
    width: 100%; height: 100%;
    margin: 0;
    object-fit: cover;
    border-radius: 0;
    display: block;
  }
  /* 没有封面图时用首字占位，避免一片空白 */
  .idxThumbText {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%; height: 100%;
    font-size: 30px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #4b8a5a, #2d6a4f);
  }

  .idxCardBody { flex: 1; padding: 12px 14px 14px; }
  .idxCardTitle {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 6px;
  }
  .idxCardTitle b { font-size: 15px; font-weight: 600; }
  .idxCardTitle .idxStars { font-size: 12px; white-space: nowrap; }
  .idxCardDesc {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--fg-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .idxTags { display: flex; flex-wrap: wrap; gap: 5px; }
  .idxTag {
    padding: 2px 8px;
    font-size: 11px;
    color: var(--fg-muted);
    background: var(--bg-soft);
    border-radius: 999px;
  }

  .idxEmpty {
    display: none;
    padding: 48px 0;
    text-align: center;
    color: var(--fg-muted);
  }
  .idxEmpty.on { display: block; }

  /* 断点跟 howto.css 对齐，避免 640–700px 之间两套规则各生效一半 */
  @media (max-width: 700px) {
    /* 头部改成两行：logo+标题 一行，描述整行落到第二行。 */
    .idxHeadInner {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px 10px;
      padding: 14px 14px 10px;
    }
    .idxHeadMain { display: contents; }
    .idxBrand { grid-column: 1; grid-row: 1; gap: 9px; margin: 0; min-width: 0; }
    .idxHead p { grid-column: 1 / -1; grid-row: 2; font-size: 13.5px; }

    /* 主菜单收紧；下拉改左对齐——窄屏时「特色功能」组常折到第二行靠左，
       右对齐会把面板甩出屏幕外 */
    .idxMenuInner { padding: 6px 12px; }
    .idxMenuLink { padding: 6px 9px; font-size: 12.5px; }
    .idxMenuDrop { right: auto; left: 0; }

    .idxLogo { height: 30px; }
    .idxBrandSep { height: 18px; }
    .idxHead h1 { font-size: 17px; }

    /* 筛选标签不换行堆高，改成横向滑动的一条 */
    .idxToolsInner { display: block; padding: 10px 14px; }
    .idxSearch { width: 100%; }
    .idxFilters {
      margin-top: 9px;
      flex-wrap: nowrap;
      overflow-x: auto;
      padding-bottom: 3px;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .idxFilters::-webkit-scrollbar { display: none; }
    .idxChip { flex: none; }

    .idxBody { padding-left: 14px; padding-right: 14px; }
    .idxGroup { margin-top: 20px; }
    .idxGrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .idxCardBody { padding: 10px 12px 12px; }
    .idxCardDesc { -webkit-line-clamp: 2; font-size: 12.5px; }
  }

  /* 特别窄的机器（iPhone SE 一类）：别把 logo 压变形 */
  @media (max-width: 380px) {
    .idxLogo { height: 26px; }
    .idxHead h1 { font-size: 15px; }
    .idxBrandSep { height: 15px; }
    .idxGrid { gap: 8px; }
  }

  /* ==========================================================================
     App Inventor 侧边栏（300px 固定宽）优先的展示。

     这个宽度里竖版大图卡一张要占近半屏，扫不了几篇；改成「缩略图 + 文字」
     的横版行卡，一屏能看五六篇，更像一个正经的课程列表。
     难度星级同时按等级着色：绿 = 入门/初级，琥珀 = 中级，红 = 进阶。
     ========================================================================== */

  .idxGroup[data-level="☆"] .idxStars,
  .idxCard[data-level="☆"] .idxStars,
  .idxGroup[data-level="★"] .idxStars,
  .idxCard[data-level="★"] .idxStars,
  .idxGroup[data-level="★☆"] .idxStars,
  .idxCard[data-level="★☆"] .idxStars { color: #1f9254; }

  .idxGroup[data-level="★★"] .idxStars,
  .idxCard[data-level="★★"] .idxStars,
  .idxGroup[data-level="★★☆"] .idxStars,
  .idxCard[data-level="★★☆"] .idxStars { color: #e39a1e; }

  .idxGroup[data-level="★★★"] .idxStars,
  .idxCard[data-level="★★★"] .idxStars { color: #dd5d47; }

  @media (max-width: 420px) {
    .idxHeadInner { gap: 6px 8px; padding: 12px 12px 8px; }
    .idxLogo { height: 24px; }
    .idxBrandSep { height: 14px; }
    .idxHead h1 { font-size: 15px; }
    .idxHead p {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      font-size: 12px;
    }
    .idxMenuInner { padding: 5px 10px; }
    .idxMenuLink { padding: 5px 8px; font-size: 12px; }
    .idxToolsInner { padding: 9px 12px; }
    .idxSearch { padding: 7px 10px; font-size: 13.5px; }
    .idxChip { padding: 4px 10px; font-size: 12px; }

    .idxBody { padding: 6px 12px 24px; }
    .idxGroup { margin-top: 16px; }
    .idxGroupHead { margin-bottom: 9px; }
    .idxGroupHead h2 { font-size: 15px; }

    .idxGrid { display: flex; flex-direction: column; gap: 8px; }
    .idxCard {
      display: grid;
      grid-template-columns: 92px minmax(0, 1fr);
    }
    .idxCard:hover { transform: none; }
    .idxThumb {
      width: 92px;
      height: 72px;
      aspect-ratio: auto;
      border-bottom: 0;
      border-right: 1px solid var(--border);
    }
    .idxThumbText { font-size: 22px; }
    .idxCardBody { padding: 8px 10px 9px; }
    .idxCardTitle { margin-bottom: 3px; }
    .idxCardTitle b { font-size: 14px; }
    .idxCardDesc { margin-bottom: 6px; font-size: 12px; -webkit-line-clamp: 2; }
    .idxTag { padding: 1px 7px; font-size: 10.5px; }
  }
