/* This stylesheet is linked only at the existing phone breakpoint. */
@media (max-width: 720px) {
  body {
    --mh-bg: var(--mn-bg);
    --mh-bar: var(--mn-bar);
    --mh-text: var(--mn-ink);
    --mh-muted: var(--mn-muted);
    --mh-accent: var(--mn-ink);
    --mh-strip: var(--mn-soft);
    --mh-line: var(--mn-line);
    --mh-popup: var(--mn-bar);
    --mh-pad: clamp(16px, 5.1%, 28px);
    --mh-head: calc(64px + env(safe-area-inset-top));
    --mh-foot: calc(62px + env(safe-area-inset-bottom));
  }
  html body:has(#home-panel.active) {
    & .app-shell > .workspace {
      display: block !important;
      height: 100dvh !important;
      min-height: 0 !important;
      padding: var(--mh-head) 0 var(--mh-foot) !important;
      box-sizing: border-box;
      overflow: hidden !important;
    }
    & #panel-grid, & #panel-grid > .creator-surface, & #home-panel {
      display: block !important;
      width: 100% !important;
      max-width: none !important;
      height: 100% !important;
      min-height: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      border: 0 !important;
      border-radius: 0 !important;
    }
    & #home-panel { overflow: auto !important; overscroll-behavior-y: contain; }
    & #home-panel > :not(.mh-page),
    & .app-shell::before, & .app-shell::after { display: none !important; }
  }
  @layer mobile-shell {
  html body:has(.app-shell) {
    & .app-shell > .workspace > .topbar {
      position: fixed !important;
      inset: 0 0 auto !important;
      height: var(--mh-head) !important;
      min-height: 0 !important;
      padding: env(safe-area-inset-top) var(--mh-pad) 0 !important;
      border: 0 !important;
      border-bottom: 1px solid var(--mh-line) !important;
      background: var(--mh-bar) !important;
      overflow: visible !important;
    }
    & .workspace > .topbar > .topbar-actions {
      display: flex !important;
      width: 100% !important;
      align-items: center !important;
      justify-content: flex-end !important;
      gap: 6px !important;
    }
    & .mh-brand {
      display: flex !important;
      order: -1; margin-right: auto; align-items: center; gap: 7px;
      white-space: nowrap; font-size: 15px; color: var(--mh-text);
    }
    & .mh-brand > span { width: 32px; height: 32px; background: url("/luminglogo.webp?v=20261109-1") center / contain no-repeat; }
    & #topbar-recharge-button, & #mh-more summary {
      display: inline-flex !important; align-items: center; justify-content: center;
      width: auto !important; min-width: 44px !important; height: 44px !important;
      flex: none !important; padding: 0 4px !important; list-style: none;
      cursor: pointer; border: 0 !important; background: transparent !important;
      color: var(--mh-text) !important; box-shadow: none !important;
    }
    & #topbar-recharge-button span, & #mh-more summary span { font-weight: 500; font-size: 14px !important; line-height: 1.2; }
    & #mh-more summary svg { width: 12px; height: 12px; margin-left: 2px; }
    & #mh-more summary::-webkit-details-marker { display: none; }
    & #mh-more { position: relative; }
    & #mh-more[open] summary svg { transform: rotate(180deg); }
    & .topbar-actions :is(#mobile-login-entry, #mobile-profile-entry):not([hidden]) {
      display: grid !important; grid-template: 1fr / 1fr !important; place-items: stretch !important;
      width: 36px !important; min-width: 36px !important; height: 36px !important; flex: none !important;
      padding: 0 !important; overflow: hidden; border: 1px solid var(--mh-line) !important;
      border-radius: 50% !important; background: var(--mh-strip) !important;
    }
    & #mobile-login-entry span { display: none !important; }
    & #mobile-login-entry svg { display: block !important; place-self: center; width: 18px !important; height: 18px !important; }
    & #mobile-profile-entry .avatar { width: 100% !important; height: 100% !important; max-width: none !important; overflow: hidden; }
    & #mobile-profile-entry .avatar img { width: 100%; height: 100%; object-fit: cover; }
    & .app-shell > .sidebar {
      position: fixed !important; inset: auto 0 0 !important; height: var(--mh-foot) !important;
      padding: 0 0 env(safe-area-inset-bottom) !important; border-top: 1px solid var(--mh-line) !important;
    }
    & .app-shell > .sidebar .module-nav {
      width: 100% !important; height: 61px !important; margin: 0 !important; padding: 0 4px !important;
    }
    & .sidebar .module-nav .nav-item:not([hidden]) {
      min-height: 0 !important; height: 100% !important; gap: 4px !important; padding: 4px 0 !important;
      background: transparent !important; color: var(--mh-muted) !important; border: 0 !important;
    }
    & .sidebar .module-nav .nav-item.active { color: var(--mh-accent) !important; }
    & .sidebar .module-nav .nav-item { position: relative; }
    & .sidebar .module-nav .nav-item.active::before {
      content: ""; position: absolute; inset: 0 auto auto 50%; transform: translateX(-50%);
      width: 22px; height: 2px; border-radius: 1px; background: var(--mh-text);
    }
    & .sidebar .module-nav .nav-item span { max-width: 100%; color: inherit; font-size: 11px; }
  }

  #mh-more .mh-menu {
    position: absolute; top: 100%; right: -38px; z-index: 2;
    width: min(222px, 84vw); max-height: calc(100dvh - 140px); overflow-y: auto;
    padding: 6px; background: var(--mh-popup); border: 1px solid var(--mh-line);
    border-radius: 8px; box-shadow: 0 8px 28px #0002;
  }
  #mh-more .mh-menu :is(#wechat-contact-button, #reward-tasks-entry, #referral-entry-button, #theme-toggle-button, #language-menu-button) {
    display: flex !important; justify-content: flex-start !important; align-items: center !important;
    width: 100% !important; height: 44px !important; gap: 10px !important;
    padding: 0 12px !important; background: transparent !important; color: var(--mh-text) !important;
    border: 0 !important; border-radius: 6px !important;
  }
  #mh-more .mh-menu :is(#wechat-contact-button, #reward-tasks-entry, #referral-entry-button, #theme-toggle-button, #language-menu-button) :is(span, svg) {
    display: block !important; font-size: 14px !important; color: inherit !important;
  }
  #mh-more .mh-menu :is(#language-menu, #wechat-contact-popover):not([hidden]) {
    position: relative !important; inset: auto !important; width: 100% !important; max-width: none !important;
    transform: none !important; box-sizing: border-box; box-shadow: none !important;
  }
  }
  #home-panel .mh-page {
    display: block !important; max-width: 620px; margin: auto; padding: 28px var(--mh-pad) 32px;
    color: var(--mh-text); text-align: left; letter-spacing: 0;
  }
  #home-panel .mh-page :is(h1,h2,p) { margin: 0; }
  #home-panel .mh-page .mh-label { font-size: 12px; font-weight: 600; line-height: 1.5; color: var(--mh-muted); }
  #home-panel .mh-intro p { display: flex; align-items: center; gap: 10px; }
  #home-panel .mh-intro p::before { content: ""; width: 22px; height: 2px; background: var(--mh-accent); }
  #home-panel .mh-intro h1 { margin: 7px 0 22px; color: var(--mh-text); font-size: 28px; font-weight: 700; line-height: 1.4; letter-spacing: 0; }
  #home-panel .mh-page :where(button) {
    appearance: none; padding: 0; margin: 0; border: 0; background: none;
    color: var(--mh-text); font: inherit; text-align: left; cursor: pointer; box-shadow: none;
  }
  #home-panel .mh-page strong { display: block; color: var(--mh-text); font-size: 16px; line-height: 1.4; }
  #home-panel .mh-page small { display: block; margin-top: 3px; color: var(--mh-muted); font-size: 12px; line-height: 1.5; }
  #home-panel .mh-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 10px 0 24px; }
  #home-panel .mh-pair button { min-width: 0; align-self: start; }
  #home-panel .mh-pair strong { font-size: 18px; }
  #home-panel .mh-cover {
    position: relative; display: block; width: 100%; aspect-ratio: 10 / 9; max-height: 210px;
    margin-bottom: 9px; border-radius: 8px; background: var(--mh-strip) center / cover no-repeat;
  }
  #home-panel .mh-cover-image { background-image: url("/assets/home-image-generation.webp"); }
  #home-panel .mh-cover-video { background-image: url("/assets/home-video-generation.webp"); background-position: center; }
  #home-panel .mh-cover-video svg {
    position: absolute; bottom: 9px; left: 9px; width: 28px; height: 28px; padding: 7px;
    color: white; fill: currentColor; background: #111a; border: 1px solid #fffb; border-radius: 50%;
  }
  #home-panel button:is(.mh-inspiration, .mh-tool) {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%;
    padding: 15px 12px; background: var(--mh-strip); border-radius: 8px;
  }
  #home-panel button.mh-inspiration { margin-bottom: 16px; }
  #home-panel .mh-entry-icon { display: grid; place-items: center; width: 36px; height: 36px; background: var(--mh-bg); border: 1px solid var(--mh-line); border-radius: 7px; }
  #home-panel .mh-entry-icon svg { width: 20px; height: 20px; stroke-width: 1.6; }
  #home-panel .mh-browse { display: flex; align-items: center; gap: 3px; padding: 6px 8px; background: var(--mh-bg); border-radius: 20px; font-size: 12px; white-space: nowrap; }
  #home-panel .mh-browse svg { width: 13px; height: 13px; }
  #home-panel #mh-tools-label { margin-bottom: 7px; }
  #home-panel .mh-tool + .mh-tool { margin-top: 8px; }
  #home-panel .mh-tool > svg:last-child { width: 16px; height: 16px; color: var(--mh-muted); }
  #home-panel .mh-page button:focus-visible, #mh-more :focus-visible { outline: 2px solid var(--mh-accent); outline-offset: 2px; }
}
