/* iPhone/PWA 专用覆盖层；电脑端原始 styles.css 保持为独立快照。 */

.mobile-app-bar {
  display: none;
}

.mobile-workflow-toggle,
.mobile-workflow-backdrop {
  display: none;
}

.mobile-sync-state {
  color: #6e6e73;
  font-size: 11px;
  white-space: nowrap;
}

/* 手机端无论竖屏或横屏，外围全景都只属于“今日决策”首页。 */
body:not([data-mode="decision"]) #externalCoreAlert {
  display: none !important;
}

@media (max-width: 820px), (max-width: 1024px) and (pointer: coarse) {
  :root {
    --mobile-drawer-width: min(88vw, 340px);
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body {
    padding-top: calc(48px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: #f3f6f8;
    font-size: 14px;
  }

  body.mobile-workflow-open {
    overflow: hidden;
  }

  button,
  input,
  select,
  textarea,
  .nav-item {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .mobile-app-bar {
    position: fixed;
    z-index: 1200;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: calc(48px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    color: #1c1c1e;
    background: rgba(249, 249, 251, 0.96);
    border-bottom: 1px solid #d1d1d6;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  .mobile-app-bar strong {
    font-size: 15px;
    white-space: nowrap;
  }

  .mobile-app-identity {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .mobile-app-identity strong {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-workflow-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    padding: 0 9px;
    border: 1px solid #cfe4ff;
    border-radius: 9px;
    color: #007aff;
    background: #eaf3ff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-workflow-toggle[aria-expanded="true"] {
    border-color: #007aff;
    background: #007aff;
    color: #ffffff;
  }

  .mobile-workflow-toggle-icon {
    font-size: 15px;
    line-height: 1;
  }

  .mobile-app-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 9px;
    min-width: 0;
  }

  .mobile-logout {
    min-height: 32px;
    padding: 0 9px;
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    color: #6e6e73;
    background: #ffffff;
    font-size: 12px;
  }

  .app-shell {
    display: block !important;
    min-height: 0;
  }

  .workspace-topbar {
    display: none !important;
  }

  .sidebar {
    position: fixed !important;
    z-index: 1100;
    top: calc(48px + env(safe-area-inset-top)) !important;
    right: auto;
    bottom: 0;
    left: 0;
    display: flex;
    width: var(--mobile-drawer-width);
    height: auto !important;
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom)) !important;
    overflow: hidden;
    background: rgba(242, 242, 247, 0.992);
    border-top: 0;
    border-right: 1px solid #d1d1d6;
    box-shadow: 12px 0 28px rgba(28, 28, 30, 0.12);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    transform: translateX(calc(-100% - 18px));
    visibility: hidden;
    pointer-events: none;
    transition: transform 200ms ease, visibility 0s linear 200ms;
  }

  body.mobile-workflow-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .mobile-workflow-backdrop {
    position: fixed;
    z-index: 1050;
    inset: calc(48px + env(safe-area-inset-top)) 0 0;
    display: block;
    width: 100%;
    min-height: 0 !important;
    padding: 0;
    border: 0;
    background: rgba(28, 28, 30, 0.24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, visibility 0s linear 180ms;
    -webkit-tap-highlight-color: transparent;
  }

  body.mobile-workflow-open .mobile-workflow-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .brand,
  .sidebar-note {
    display: none !important;
  }

  .workflow-nav {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
  }

  .nav-stack.workflow-stage-list {
    display: grid !important;
    flex: 1 1 auto;
    align-content: start;
    gap: 0;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 0 3px 10px 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .nav-item {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 44px !important;
    margin: 0;
    padding: 0 11px !important;
    border-radius: 9px !important;
    color: #3a3a3c !important;
    font-size: 12px;
    line-height: 1.25;
    text-align: left;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }

  .nav-item::before {
    display: none !important;
    content: none !important;
  }

  .nav-item .nav-index {
    display: none !important;
  }

  .workflow-home-item {
    min-height: 46px !important;
    padding-left: 12px !important;
    border-radius: 12px !important;
    font-size: 13px;
  }

  .workflow-stage-toggle {
    min-height: 52px;
    padding: 7px 10px;
  }

  .workflow-stage-copy strong {
    font-size: 13px;
  }

  .workflow-stage-copy small {
    font-size: 9.5px;
  }

  .workflow-stage-items {
    padding: 0 7px 8px 42px;
  }

  .workflow-stage-items .nav-item {
    grid-template-columns: minmax(0, 1fr);
    min-height: 44px !important;
    padding: 0 10px !important;
    border-radius: 0 !important;
  }

  .nav-item.active {
    color: #007aff !important;
    background: #eaf3ff !important;
    box-shadow: none;
  }

  .nav-item.active::before {
    color: #007aff;
  }

  .main {
    width: 100%;
    min-width: 0 !important;
    padding: 12px !important;
  }

  .section {
    min-width: 0;
  }

  .section-heading {
    margin-bottom: 14px;
  }

  .section-heading h1,
  .section-heading h2,
  h1,
  h2 {
    font-size: clamp(22px, 7vw, 30px) !important;
    line-height: 1.18;
  }

  h3 {
    font-size: 16px;
  }

  .panel,
  .decision-block,
  .market-review-panel,
  .review-conclusion-card,
  .review-conclusion-hero {
    width: 100%;
    min-width: 0;
    border-radius: 12px !important;
  }

  .panel,
  .decision-block,
  .market-review-panel {
    padding: 14px !important;
  }

  .decision-toolbar,
  .market-emotion-toolbar,
  .event-inference-heading,
  .event-inference-toolbar,
  .review-conclusion-heading,
  .panel-title-row {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .decision-toolbar button,
  .market-emotion-toolbar button,
  .event-inference-toolbar button,
  #reviewConclusionRefreshBtn {
    width: 100% !important;
    min-height: 46px;
  }

  .decision-grid,
  .review-conclusion-grid,
  .review-execution-grid,
  .review-candidate-grid,
  .market-emotion-grid,
  .sell-advisor-grid,
  .sell-advisor-report-grid,
  .cycle-frame-main,
  .cycle-frame-metrics,
  .metrics-grid,
  .external-indexes,
  .journal-form-grid,
  .preplan-layout,
  .judge-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .review-conclusion-hero {
    padding: 16px !important;
  }

  .review-conclusion-hero-main {
    grid-template-columns: 54px minmax(0, 1fr) !important;
    align-items: start;
  }

  .review-conclusion-light {
    width: 52px !important;
    height: 52px !important;
    font-size: 14px !important;
  }

  .review-conclusion-hero h3 {
    font-size: 18px !important;
  }

  .review-timeline {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .review-candidate-card {
    min-width: 0;
  }

  .external-core-alert {
    margin-bottom: 12px;
    padding: 12px !important;
    border-radius: 10px;
    overflow-wrap: anywhere;
  }

  .hero-section,
  .hero-section-us {
    min-height: 0 !important;
    padding: 22px 16px !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  table {
    min-width: 680px;
  }

  .journal-exit-table,
  .table-wrap,
  .responsive-table,
  .result-table,
  .archive-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  img,
  svg,
  canvas {
    max-width: 100%;
  }

  pre,
  code,
  .decision-body,
  .review-conclusion-card,
  .market-review-panel {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .anime-assistant,
  .assistant-character,
  .floating-character {
    max-width: 105px !important;
    max-height: 150px !important;
    pointer-events: none;
  }
}

@media (max-width: 390px) {
  .main {
    padding: 9px !important;
  }

  .mobile-app-bar strong {
    font-size: 14px;
  }

  .mobile-sync-state {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .mobile-workflow-backdrop {
    transition: none !important;
  }
}

/* ===== Premium frosted glass mobile shell ===== */

@media (max-width: 820px), (max-width: 1024px) and (pointer: coarse) {
  .mobile-app-bar {
    border-bottom-color: rgba(207, 217, 221, 0.82);
    background: rgba(247, 250, 250, 0.82);
    -webkit-backdrop-filter: blur(22px) saturate(118%);
    backdrop-filter: blur(22px) saturate(118%);
    box-shadow: 0 6px 18px rgba(22, 36, 44, 0.065);
  }

  .mobile-workflow-toggle,
  .mobile-logout {
    border-color: rgba(207, 217, 221, 0.82);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(244, 248, 248, 0.58));
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.88), 0 5px 14px rgba(22, 36, 44, 0.06);
  }

  .mobile-workflow-toggle {
    color: #05645d;
  }

  .mobile-logout {
    min-height: 44px;
  }

  .mobile-workflow-toggle[aria-expanded="true"] {
    border-color: rgba(255, 255, 255, 0.82);
    background: linear-gradient(135deg, #15968a, #08776e 68%, #05645d);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.34), 0 7px 18px rgba(8, 119, 110, 0.2);
  }

  .mobile-workflow-toggle:focus-visible,
  .mobile-logout:focus-visible {
    outline: 3px solid #05645d;
    outline-offset: 2px;
  }

  .sidebar {
    isolation: isolate;
    border-right-color: rgba(207, 217, 221, 0.86);
    background:
      radial-gradient(circle at 4% 5%, rgba(37, 160, 146, 0.1), transparent 34%),
      linear-gradient(155deg, rgba(247, 250, 250, 0.93), rgba(238, 244, 244, 0.85));
    -webkit-backdrop-filter: blur(26px) saturate(118%);
    backdrop-filter: blur(26px) saturate(118%);
    box-shadow: inset -1px 0 rgba(255, 255, 255, 0.68), 14px 0 34px rgba(22, 36, 44, 0.14);
  }

  .sidebar::before,
  .sidebar::after {
    display: none;
  }

  .sidebar > .workflow-nav {
    position: relative;
    z-index: 1;
  }

  .workflow-home-item,
  .workflow-stage {
    border-color: rgba(207, 217, 221, 0.84) !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.76), rgba(245, 249, 248, 0.52)) !important;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .workflow-home-item {
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.92), 0 10px 24px rgba(22, 36, 44, 0.075) !important;
  }

  .workflow-stage-list .workflow-home-item.active,
  .workflow-stage-list .nav-item.active {
    background: linear-gradient(100deg, rgba(8, 119, 110, 0.14), rgba(255, 255, 255, 0.3)) !important;
    color: #05645d !important;
  }

  .workflow-stage-list .workflow-home-item.active::before {
    display: block !important;
    content: "" !important;
  }

  .mobile-workflow-backdrop {
    background: rgba(22, 36, 44, 0.2);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  @media (max-width: 820px), (max-width: 1024px) and (pointer: coarse) {
    .mobile-app-bar,
    .sidebar,
    .workflow-home-item,
    .workflow-stage,
    .mobile-workflow-toggle,
    .mobile-logout {
      background: #f4f8f7 !important;
    }

    .mobile-workflow-toggle[aria-expanded="true"] {
      background: #05645d !important;
      color: #ffffff !important;
    }
  }
}

@media (prefers-reduced-transparency: reduce) {
  .mobile-app-bar,
  .sidebar,
  .workflow-home-item,
  .workflow-stage,
  .mobile-workflow-toggle,
  .mobile-logout,
  .mobile-workflow-backdrop {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  .mobile-app-bar,
  .sidebar,
  .workflow-home-item,
  .workflow-stage,
  .mobile-workflow-toggle,
  .mobile-logout {
    background: #f4f8f7 !important;
  }

  .mobile-workflow-backdrop {
    background: rgba(22, 36, 44, 0.26) !important;
  }

  .mobile-workflow-toggle[aria-expanded="true"] {
    background: #05645d !important;
    color: #ffffff !important;
  }
}

/* ===== Post-close opportunity: mobile reading order ===== */

@media (max-width: 820px), (max-width: 1024px) and (pointer: coarse) {
  #auto-picker {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
  }

  .post-close-opportunity-empty,
  .post-close-opportunity-hero {
    padding: 18px 16px;
  }

  .post-close-opportunity-empty > strong,
  .post-close-opportunity [data-role="opportunity-headline"] {
    font-size: clamp(24px, 7vw, 28px);
  }

  .post-close-opportunity-empty > p,
  .post-close-opportunity [data-role="opportunity-reason"] {
    font-size: 15px;
    line-height: 1.65;
  }

  .post-close-opportunity-section > header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .post-close-opportunity-theme-grid,
  .post-close-opportunity-core-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-close-opportunity-theme-card,
  .post-close-opportunity-core-card {
    padding: 15px;
  }

  .post-close-opportunity-core-card [data-field] {
    grid-template-columns: 64px minmax(0, 1fr);
    font-size: 14px;
  }

  .auto-picker-full-analysis-summary {
    min-height: 56px;
    padding: 10px 14px;
  }

  .auto-picker-full-analysis-body {
    width: 100%;
    min-width: 0;
    padding: 12px;
    overflow-x: hidden;
  }
}
