/* H5 mobile shell — first pass */
.mobile-nav-actions{display:none}

@media(max-width:860px){
  .header-inner{height:64px;gap:8px}
  .brand{min-width:0;flex:0 1 auto}
  .brand .brand-logo{width:132px;max-height:40px;height:auto}
  .header-actions{gap:4px;margin-left:auto}
  .publish-link,.btn-register,.login-link,.member-link,.admin-menu{display:none!important}
  .menu-toggle{width:36px;height:36px;font-size:16px}
  .lang-switch summary{height:34px;padding:0 6px}
  .main-nav{top:64px;left:8px;right:8px;max-height:calc(100vh - 76px);overflow:auto;padding:10px}
  .main-nav a{padding:11px 10px;font-size:13px;border-radius:4px}
  .nav-en{font-size:8px}
  .mobile-nav-actions{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:8px;padding-top:9px;border-top:1px solid #e5edf1}
  .mobile-nav-actions a{display:flex;align-items:center;justify-content:center;padding:10px 8px;border-radius:4px;background:#f4f9fb;color:#0b6ea8;font-size:10px;font-weight:800;text-align:center}
  .mobile-nav-actions a.primary{background:#0b6ea8;color:#fff}
  .mobile-nav-actions a:last-child:nth-child(odd){grid-column:1/-1}
  .account-person .btn{width:auto!important;margin:8px 0 0;padding:8px 14px;align-self:flex-start;font-size:9px}
  .account-page .account-card{min-height:0!important}
  .account-page .account-card p{margin-bottom:5px}
  .account-page .account-grid{gap:7px}
  .account-kpis b{font-size:18px}
}
@media(max-width:560px){
  .header-inner{height:60px}
  .brand .brand-logo{width:122px;max-height:37px}
  .main-nav{top:60px}
  .lang-switch summary{height:32px;padding:0 5px;font-size:8px}
  .lang-switch summary svg{width:13px;height:13px}
  .account-portal-inner{padding:18px 0 14px}
  .account-person h1{font-size:23px}
  .account-person p{font-size:9px}
  .account-kpis a{padding:8px 7px}
  .account-kpis b{font-size:20px}
  .account-kpis span{font-size:9px}
  .account-page .account-card{padding:14px}
}


/* H5 second pass: pages, tables, bottom navigation */
.h5-bottom-nav{display:none}
@media(max-width:860px){
  body{padding-bottom:calc(58px + env(safe-area-inset-bottom))}
  .h5-bottom-nav{position:fixed;left:0;right:0;bottom:0;z-index:70;display:grid;grid-template-columns:repeat(6,1fr);background:rgba(255,255,255,.98);border-top:1px solid #e1e9ee;box-shadow:0 -8px 24px rgba(10,45,70,.06);padding-bottom:env(safe-area-inset-bottom)}
  .h5-bottom-nav a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:56px;color:#7b8f9c;font-size:8px}
  .h5-bottom-nav a span{font-size:17px;line-height:1}
  .h5-bottom-nav a small{font-size:8px}
  .h5-bottom-nav a.active{color:#0b6ea8;font-weight:800}
  .h5-bottom-nav a.active span{color:#c58a2a}

  /* trade */
  .trade-hero-inner{padding:24px 0 16px;gap:14px}
  .trade-hero h1{font-size:31px}
  .trade-hero-copy p{font-size:11px;line-height:1.7}
  .trade-hero-search{gap:3px;padding:5px}
  .trade-hero-metrics{gap:7px 12px;font-size:7px;padding:10px 0 11px}
  .trade-hero-links{font-size:8px;gap:12px}
  .directory-layout{padding-top:10px;gap:9px}
  .directory-sidebar{padding:8px;border-radius:5px}
  .sidebar-title{padding:6px 6px 8px;font-size:11px}
  .sidebar-nav{display:flex;gap:5px;overflow:auto;padding-bottom:2px;scrollbar-width:none}
  .sidebar-nav a{flex:0 0 auto;white-space:nowrap;padding:7px 9px;border:1px solid #e2ebf0;border-radius:18px;font-size:9px;background:#fff}
  .sidebar-nav a.active{background:#eaf4fa;border-color:#bfdce9;color:#0b6ea8}
  .sidebar-nav .count{display:none}
  .commodity-strip{flex-wrap:nowrap;overflow:auto;padding-bottom:4px;margin-top:10px;scrollbar-width:none}
  .commodity-strip span{flex:0 0 auto}
  .trade-filter-row{flex-wrap:nowrap;overflow:auto;scrollbar-width:none}
  .trade-filter-row a,.trade-filter-row button{flex:0 0 auto}
  .trade-filter-row span{display:none}
  .directory-toolbar h2{font-size:17px}
  .listing-grid{gap:10px}
  .listing-body h3{font-size:15px}
  .listing-body p{font-size:10px;line-height:1.65}
  .listing-meta{font-size:8px}
  .listing-foot .btn-outline{height:29px;font-size:8px}
  .pagination{margin:14px 0 4px}

  /* escrow */
  .escrow-landing-inner{padding:25px 0 22px;gap:16px}
  .escrow-landing-hero h1{font-size:32px}
  .escrow-landing-hero p{font-size:11px;line-height:1.7}
  .escrow-landing-stats{margin-top:10px}
  .escrow-landing-stats b{font-size:18px}
  .escrow-plan-list .plan-line{padding:13px 0;gap:4px 8px}
  .escrow-plan-list .plan-line h3{font-size:16px}
  .escrow-plan-list .plan-line .plan-rate{font-size:17px}
  .process-rail{grid-template-columns:1fr 1fr;gap:0}
  .rail-step{padding:9px 5px}
  .bank-trust{padding:16px;gap:16px}
  .bank-trust-copy h2{font-size:22px}
  .bank-points div{font-size:9px}
  .escrow-cover,.escrow-cover img{min-height:260px}
  .escrow-cover-copy h2{font-size:22px}
  .escrow-cases.portal-cases .escrow-case-grid{grid-template-columns:1fr}
  .escrow-apply form{padding:12px}
  .escrow-apply label{font-size:9px}

  /* trace */
  .trace-portal-inner{padding:24px 0 20px;gap:14px}
  .trace-portal-copy h1{font-size:32px}
  .trace-portal-copy p{font-size:11px;line-height:1.7}
  .trace-portal-search{padding:15px}
  .trace-portal-metrics{gap:7px 11px;font-size:7px;padding:9px 0 10px}
 .trace-journey{gap:14px}
  .trace-journey-intro h2{font-size:25px}
  .trace-journey-intro p{font-size:10px}
  .journey-step{grid-template-columns:34px 1fr;gap:9px;padding-bottom:17px}
  .journey-no{width:32px;height:32px;font-size:8px}
  .journey-step:not(:last-child):before{left:16px;top:27px}
  .journey-step h4{font-size:12px}
  .journey-step p{font-size:9px}
  .trace-audience-grid article{padding:12px 0}
  .trace-audience-grid h3{font-size:14px}

  /* talk */
  .chat-portal-inner{padding:24px 0 20px;gap:14px}
  .chat-portal-inner h1{font-size:29px}
  .chat-portal-inner p{font-size:11px}
  .chat-portal-stats b{font-size:17px}
  .chat-channel-banner{padding:16px;margin-top:10px}
  .chat-channel-banner h2{font-size:21px}
  .chat-channel-banner p{font-size:9px}
  .chat-layout{gap:8px}
  .chat-sidebar{max-height:205px}
  .chat-rooms{max-height:150px}
  .chat-main{min-height:0}
  .chat-main-head{padding:10px 11px}
  .chat-thread{max-height:360px;padding:11px}
  .chat-bubble{max-width:92%;font-size:9px}
  .chat-composer{position:sticky;bottom:58px;z-index:3;background:#fff}
  .chat-composer textarea{min-height:42px}
  .chat-context-body{padding:10px 11px}
  .chat-context-links a{padding:8px 0;font-size:8px}

  /* forms / detail / tables */
  .portal-page .table-wrap,.account-page .table-wrap,.detail .table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .portal-page table,.account-page table,.admin-main table{min-width:600px}
  .detail{width:calc(100% - 16px);margin:12px auto 78px;padding:14px}
  .detail h1{font-size:23px}
  .listing-gallery{grid-template-columns:1fr;gap:8px}
  .form-shell,.form-shell.wide{width:calc(100% - 16px);margin:12px auto 76px;padding:16px}
  .form-shell h1{font-size:24px}
  .form-shell label{font-size:9px}
  .form-shell input,.form-shell select,.form-shell textarea{font-size:10px;padding:9px}
  .auth-shell,.form-shell .btn.primary,.form-shell .btn.full{font-size:10px}
  .site-footer{margin-bottom:0}

  /* admin: keep readable on phones */
  main.admin-main.wrap{width:calc(100% - 16px)}
  .admin-sidebar{overflow:auto}
  .admin-list-stats{grid-template-columns:1fr 1fr}
  .recommend-grid{grid-template-columns:1fr}
}
@media(max-width:560px){
  .trade-hero h1{font-size:28px}
  .escrow-landing-hero h1,.trace-portal-copy h1,.chat-portal-inner h1{font-size:29px}
  .account-page .account-grid{grid-template-columns:1fr}
  .h5-bottom-nav a{min-height:54px}
}


.chat-back{display:none}
@media(max-width:860px){
  .portal-chat .chat-portal-hero,.portal-chat .chat-channel-banner{display:none}
  .portal-chat .chat-layout{display:block;width:calc(100% - 16px);margin:0 auto;padding-top:8px}
  .portal-chat .chat-layout:not(.chat-has-thread) .chat-main,
  .portal-chat .chat-layout:not(.chat-has-thread) .chat-context{display:none}
  .portal-chat .chat-layout.chat-has-thread .chat-sidebar{display:none}
  .portal-chat .chat-layout.chat-has-thread .chat-main{display:flex;min-height:0;height:calc(100dvh - 64px - env(safe-area-inset-bottom));border-radius:0;border-left:0;border-right:0;margin:0}
  .portal-chat .chat-sidebar{max-height:calc(100dvh - 64px - env(safe-area-inset-bottom));border-radius:0}
  .portal-chat .chat-rooms{max-height:none}
  .portal-chat .chat-thread{flex:1;min-height:0;max-height:none;padding:11px 11px 14px}
  .portal-chat .chat-composer{position:sticky;bottom:0;z-index:4;padding:8px;background:#fff;box-shadow:0 -6px 14px rgba(10,45,70,.06)}
  .portal-chat .chat-composer textarea{min-height:40px}
  .portal-chat .chat-context{display:none}
  .portal-chat .chat-main-head{padding:8px 10px}
  .portal-chat .chat-main-head .chat-peer{flex:1}
  .chat-back{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;border:1px solid #dfe8ed;border-radius:50%;color:#0b6ea8;font-size:16px;flex:0 0 auto}
  .commodity-strip b{width:auto!important;white-space:nowrap;font-size:7px;flex:0 0 auto}
}
@media(max-width:560px){
  .portal-chat .chat-layout.chat-has-thread .chat-main{height:calc(100dvh - 60px - env(safe-area-inset-bottom))}
}


/* H5 final sweep: forms, detail, tables, admin */
@media(max-width:860px){
  .portal-page .section-head{align-items:flex-start;gap:8px}
  .portal-page .section-head h2{font-size:20px}
  .portal-page .section-head p{font-size:9px;line-height:1.7}
  .portal-page .form-shell .btn.primary,
  .portal-page .form-shell .btn.full,
  .detail .btn.primary,
  .escrow-apply .btn.primary{min-height:42px;font-size:10px}
  .trace-form-grid,.escrow-form-grid{grid-template-columns:1fr!important}
  .trace-form-grid label,.escrow-form-grid label{grid-column:auto!important}
  .trace-form-wide,.escrow-apply form{width:100%}
  .account-page .section-head,.admin-main .section-head{margin-top:16px}
  .account-page .table-wrap,.portal-page .table-wrap,.admin-main .table-wrap{position:relative;margin-bottom:14px}
  .account-page .table-wrap:before,.portal-page .table-wrap:before,.admin-main .table-wrap:before{content:"左右滑动查看";display:block;padding:5px 9px;background:#f7fafc;border-bottom:1px solid #e8eff3;color:#8a9ba6;font-size:7px;text-align:right}
  .admin-main .page-title h1{font-size:23px}
  .admin-main .page-title p{font-size:9px}
  .admin-main .admin-sidebar{padding:6px}
  .admin-main .admin-nav-item{padding:6px 8px;font-size:8px}
  .admin-main .admin-panel{padding:12px}
  .admin-main .form-shell{padding:0}
  .admin-main .form-shell label{font-size:9px}
  .admin-main .form-shell input,.admin-main .form-shell select,.admin-main .form-shell textarea{font-size:10px;padding:8px}
  .admin-listing-status-row{grid-template-columns:1fr!important}
  .admin-listing-status-row .inline-check{padding-bottom:0}
  .recommend-actions{flex-wrap:wrap}
  .recommend-actions .btn{flex:1 1 auto;justify-content:center}
  .pagination{gap:4px}
  .pagination a{min-width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center}
  .site-footer{padding-bottom:8px}
}
@media(max-width:560px){
  .portal-page .form-shell .btn.primary,.portal-page .form-shell .btn.full{width:100%}
  .detail .listing-gallery{grid-template-columns:1fr}
  .detail .contact-reveal{padding:12px}
  .detail .contact-reveal p{font-size:10px;word-break:break-all}
  .admin-list-stats a{padding:8px}
  .admin-list-stats b{font-size:17px}
}


/* English H5 adjustments */
@media(max-width:860px){
  html[lang="en"] .h5-bottom-nav small{font-size:7px;letter-spacing:-.02em}
  html[lang="en"] .h5-bottom-nav a span{font-size:16px}
  html[lang="en"] .account-kpis span{font-size:6.5px;line-height:1.3}
  html[lang="en"] .account-kpis b{font-size:16px}
  html[lang="en"] .portal-copy h1,
  html[lang="en"] .trade-hero h1,
  html[lang="en"] .escrow-landing-hero h1,
  html[lang="en"] .trace-portal-copy h1,
  html[lang="en"] .chat-portal-inner h1{overflow-wrap:anywhere;line-height:1.06}
  html[lang="en"] .chat-main-head .chat-peer b{font-size:10px}
  html[lang="en"] .chat-secure{font-size:7px;white-space:nowrap}
  html[lang="en"] .footer-col a{font-size:9px}
  html[lang="en"] .mobile-nav-actions a{font-size:9px}
  html[lang="en"] .lang-switch summary{font-size:8px;padding:0 5px}
}
@media(max-width:560px){
  html[lang="en"] .brand .brand-logo{width:118px;max-height:35px}
  html[lang="en"] .lang-current{max-width:46px;overflow:hidden;text-overflow:ellipsis}
  html[lang="en"] .account-kpis span{font-size:6px}
  html[lang="en"] .h5-bottom-nav small{font-size:6.5px}
}


/* Fix trade directory horizontal overflow on phones */
@media(max-width:860px){
  html,body{overflow-x:hidden}
  .directory-layout{grid-template-columns:minmax(0,1fr)!important;gap:8px;padding-top:8px}
  .directory-sidebar{position:static;top:auto;min-width:0;max-width:100%;overflow:hidden}
  .directory-main{width:100%;min-width:0;max-width:100%}
  .sidebar-nav{max-width:100%;overflow-x:auto;overflow-y:hidden}
  .sidebar-nav a{flex:0 0 auto}
  .trade-filter-row{max-width:100%;overflow-x:auto;overflow-y:hidden}
  .commodity-strip{max-width:100%;overflow-x:auto}
  .listing-grid,.listing-card{width:100%;min-width:0;max-width:100%}
  .directory-toolbar{min-width:0}
  .directory-toolbar > div{min-width:0}
  .directory-toolbar h2{overflow-wrap:anywhere}
  .directory-toolbar .text-link{white-space:nowrap;flex:0 0 auto}
}
@media(max-width:560px){
  html[lang="en"] .directory-toolbar{display:block}
  html[lang="en"] .directory-toolbar .text-link{display:inline-block;margin-top:6px}
}


.h5-bottom-nav a.h5-publish span{display:grid;place-items:center;width:25px;height:25px;border-radius:50%;background:#f3e5c8;color:#8a6420;font-size:17px;font-weight:800;line-height:1}
.h5-bottom-nav a.h5-publish small{color:#8a6420;font-weight:800}
.h5-bottom-nav a.h5-publish.active span{background:#c9a35d;color:#fff}

@media(max-width:860px){
  body.portal-chat{padding-bottom:0!important}
  .portal-chat .h5-bottom-nav{display:none!important}
  .portal-chat .site-footer{display:none!important}
  .portal-chat .chat-composer{bottom:0!important}
  .portal-chat .chat-layout.chat-has-thread{height:calc(100dvh - 64px)!important;min-height:0!important}
  .portal-chat .chat-layout.chat-has-thread .chat-main{height:100%!important;min-height:0!important}
}

@media(max-width:860px){
  /* Mobile chat list: fill the viewport instead of leaving a white page below. */
  .portal-chat .chat-layout:not(.chat-has-thread){
    display:flex!important;
    width:100%!important;
    height:calc(100dvh - 64px)!important;
    min-height:0!important;
    margin:0!important;
    padding:0!important;
    gap:0!important;
  }
  .portal-chat .chat-layout:not(.chat-has-thread) .chat-sidebar{
    display:flex!important;
    flex-direction:column!important;
    width:100%!important;
    height:100%!important;
    max-height:none!important;
    border-radius:0!important;
    overflow:hidden!important;
  }
  .portal-chat .chat-layout:not(.chat-has-thread) .chat-rooms{
    flex:1!important;
    max-height:none!important;
    overflow:auto!important;
    align-content:start!important;
  }
  .portal-chat .chat-layout:not(.chat-has-thread) .chat-main,
  .portal-chat .chat-layout:not(.chat-has-thread) .chat-context{display:none!important}
}

.chat-side-foot{display:none}
@media(max-width:860px){
  .portal-chat .chat-layout:not(.chat-has-thread) .chat-side-foot{
    display:flex;
    flex:0 0 auto;
    align-items:center;
    gap:10px;
    padding:13px 15px calc(13px + env(safe-area-inset-bottom));
    border-top:1px solid rgba(226,202,151,.28);
    background:
      radial-gradient(120px 80px at 10% 0%,rgba(226,202,151,.12),transparent 70%),
      linear-gradient(180deg,rgba(8,35,56,.20),rgba(5,25,42,.82));
    color:#dbe8ef;
  }
  .chat-side-mark{
    display:grid;place-items:center;
    width:32px;height:32px;border-radius:50%;
    flex:0 0 32px;overflow:hidden;
    background:#071e33;
    box-shadow:0 0 0 3px rgba(226,202,151,.10);
  }
  .chat-side-mark img{display:block;width:100%;height:100%;object-fit:contain}
  .chat-side-foot b{display:block;font-size:12px;letter-spacing:.02em}
  .chat-side-foot small{display:block;margin-top:2px;color:#9fb9c9;font-size:9px;letter-spacing:.03em}
  .chat-side-talk{
    display:inline-flex;align-items:center;gap:5px;
    margin-left:auto;padding:5px 9px;border-radius:20px;
    border:1px solid rgba(226,202,151,.45);
    background:rgba(226,202,151,.10);
    color:#e2ca97;text-decoration:none;
    font-size:8px;font-weight:800;letter-spacing:.12em;
  }
  .chat-side-talk span{font-size:12px;line-height:1;letter-spacing:0}
  .chat-side-talk:hover{background:rgba(226,202,151,.20);color:#fff}
}
