/*
 * V2 双角色一级页面 Compact 壳层候选。
 * 能力者覆盖 Agent 工作 / 探索 / 合作 / 我的；委托者覆盖 Agent 工作 / 合作 / 我的。
 * 详情、发布与建档保持沉浸式流程。
 * 当前仍是 HTML-only 可逆增强，不提升为正式 Token 或 Pen 资产。
 */
.mobile-primary-nav { display: none; }

@media (max-width: 599px) {
  :root {
    --v2-mobile-header-height: 60px;
    --v2-mobile-nav-height: 64px;
  }

  .site-header {
    height: calc(var(--v2-mobile-header-height) + env(safe-area-inset-top, 0px));
    min-height: calc(var(--v2-mobile-header-height) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
  .site-header__inner {
    width: calc(100% - 24px);
    height: var(--v2-mobile-header-height);
    min-height: var(--v2-mobile-header-height);
    flex-wrap: nowrap;
    gap: 8px;
  }
  .brand { flex: 0 0 auto; }
  .mobile-nav-toggle { display: none; }
  .main-nav,
  .main-nav.is-open { display: none; }
  .header-actions { min-width: 0; margin-left: auto; gap: 4px; }
  .agent-identity { display: block; }
  .agent-identity__trigger { min-height: 44px; padding: 0 7px; gap: 5px; font-size: 12px; }
  .agent-identity__chevron { display: block; }
  .agent-identity__panel {
    position: fixed;
    z-index: 91;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(82dvh, 620px);
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-radius: 18px 18px 0 0;
    background: var(--surface, #fefeff);
    box-shadow: 0 -12px 40px rgb(23 26 31 / 15%);
    overflow-y: auto;
    animation: agent-sheet-in 180ms cubic-bezier(.22, 1, .36, 1);
  }
  .agent-identity__panel > .agent-identity__divider { display: none; }
  body:has(.agent-identity__trigger[aria-expanded="true"]) { overflow: hidden; }
  body:has(.agent-identity__trigger[aria-expanded="true"]) .site-header { position: static; z-index: auto; }
  body:has(.agent-identity__trigger[aria-expanded="true"])::before {
    position: fixed;
    z-index: 90;
    inset: 0;
    background: rgb(23 26 31 / 34%);
    content: "";
    animation: agent-sheet-backdrop-in 160ms ease-out;
  }
  .account-trigger { display: none; }

  .mobile-primary-nav {
    --v2-mobile-nav-selected: var(--v2-nav-selected, var(--selected, #eef0f2));
    position: fixed;
    z-index: 45;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: calc(var(--v2-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 1px 8px env(safe-area-inset-bottom, 0px);
    border-top: 1px solid color-mix(in oklch, var(--line) 72%, transparent);
    background: #fbfcfd;
    background: color-mix(in oklch, var(--page-bg, #fbfcfd) 96%, transparent);
    backdrop-filter: blur(18px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .mobile-primary-nav--client { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mobile-primary-nav__link {
    position: relative;
    min-width: 0;
    min-height: var(--v2-mobile-nav-height);
    padding: 2px 4px 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-secondary);
    font-size: 10.5px;
    line-height: 1.2;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    transition: color 150ms ease-out;
  }
  .mobile-primary-nav__link::before {
    position: absolute;
    top: 6px;
    left: 50%;
    width: min(76px, calc(100% - 8px));
    height: 52px;
    border-radius: 8px;
    background: transparent;
    transform: translateX(-50%);
    content: "";
    transition: background-color 150ms ease-out, transform 150ms ease-out;
  }
  .mobile-primary-nav__icon {
    position: relative;
    z-index: 1;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    transition: stroke-width 150ms ease-out;
  }
  .mobile-primary-nav__label { position: relative; z-index: 1; white-space: nowrap; }
  .mobile-primary-nav__link.is-current { color: var(--text, #20242a); font-weight: 650; }
  .mobile-primary-nav__link.is-current::before { background: #eef0f2; background: var(--v2-mobile-nav-selected); }
  .mobile-primary-nav__link.is-current .mobile-primary-nav__icon { stroke-width: 1.85; }
  .mobile-primary-nav__link:active::before { background: var(--surface-muted, #e9ebee); transform: translateX(-50%) scale(.97); }
  .mobile-primary-nav__link:focus-visible { outline: 2px solid var(--blue); outline-offset: -4px; }
  .mobile-primary-nav__unread {
    position: absolute;
    z-index: 2;
    top: 6px;
    left: calc(50% + 5px);
    width: 9px;
    height: 9px;
    border: 1.5px solid var(--page-bg, #fbfcfd);
    border-radius: 50%;
    background: #c93632;
    pointer-events: none;
  }
  .mobile-primary-nav__link.is-current .mobile-primary-nav__unread { border-color: #eef0f2; border-color: var(--v2-mobile-nav-selected); }

  .page,
  .client-page,
  .cooperation-page,
  .account-page,
  .client-home-page { padding-bottom: calc(var(--v2-mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 38px); }
  .toast { top: calc(var(--v2-mobile-header-height) + env(safe-area-inset-top, 0px) + 10px); }

  .global-share-panel,
  .global-points-panel {
    right: 12px;
    bottom: calc(var(--v2-mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 10px);
    left: 12px;
    top: auto;
    width: auto;
    max-height: calc(100dvh - var(--v2-mobile-header-height) - var(--v2-mobile-nav-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px);
    overflow-y: auto;
    border-radius: 16px;
  }
  body.is-global-share-open { overflow: hidden; }
  body.is-global-share-open::after {
    position: fixed;
    z-index: 90;
    inset: 0;
    background: rgb(23 26 31 / 34%);
    content: "";
    animation: agent-sheet-backdrop-in 160ms ease-out;
  }
  body.is-global-share-open .global-share-panel {
    z-index: 91;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: calc(100dvh - 24px);
    padding: 18px 22px calc(20px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgb(23 26 31 / 15%);
    animation: agent-sheet-in 180ms cubic-bezier(.22, 1, .36, 1);
  }
}

@keyframes agent-sheet-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes agent-sheet-backdrop-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .agent-identity__panel,
  body:has(.agent-identity__trigger[aria-expanded="true"])::before,
  body.is-global-share-open::after,
  .global-share-panel { animation: none; }
}

@media (max-width: 359px) {
  .brand span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .agent-identity__trigger { padding-inline: 5px; }
}

@media (forced-colors: active) {
  .mobile-primary-nav { border-top-color: CanvasText; background: Canvas; backdrop-filter: none; }
  .mobile-primary-nav__link.is-current::before { border: 1px solid CanvasText; background: Canvas; }
}
