/* KOK.mn Mobile Experience v2.0 — KL-010 staging
 * Based on kok-mobile-v1.css (2026-08-30) with header/search/overflow fixes.
 * Desktop rules outside these media queries are untouched.
 * Load after legacy CSS; uses !important to override topform inline mobile bugs
 * (e.g. .kok-compact-search { min-width:430px } at max-width:900px).
 */

@media screen and (max-width: 900px) {
  html, body {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
  }
  body *, body *::before, body *::after { box-sizing: border-box; }
  img, video, iframe, object, embed { max-width: 100% !important; }
  input, select, textarea, button { max-width: 100%; font-size: 16px; }
  a, button, input[type="submit"], input[type="button"] { touch-action: manipulation; }

  #container,
  #main.kok-modern-main,
  .kok-info-hub,
  .kok-compact-hub,
  .kok-business-network {
    width: calc(100% - 20px) !important;
    min-width: 0 !important;
    max-width: none !important;
    margin-right: auto !important;
    margin-left: auto !important;
  }
  .side-tools, .kok-site-notice { display: none !important; }

  /* Header and account panel */
  #toppanel,
  #toppanel > .headerMenu,
  #toppanel .headerMenu,
  html body #toppanel > .kok-v2-header {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  html body #toppanel > .kok-v2-header {
    display: grid !important;
    height: auto !important;
    min-height: 96px !important;
    grid-template-areas: "brand account" "nav nav" !important;
    grid-template-columns: minmax(120px,1fr) minmax(148px,190px) !important;
    grid-template-rows: 48px 46px !important;
    gap: 0 8px !important;
    padding: 4px 10px 0 !important;
    overflow: visible !important;
  }
  html body #toppanel .kok-v2-brand {
    grid-area: brand !important;
    width: auto !important;
    min-width: 0 !important;
    height: 42px !important;
    align-items: flex-start !important;
    padding-left: 2px !important;
  }
  html body #toppanel .kok-v2-brand-title,
  html body #toppanel .kok-v2-brand-note {
    width: 100% !important;
    max-width: 100% !important;
    text-align: left !important;
  }
  html body #toppanel .kok-v2-brand-title { font-size: 18px !important; }
  html body #toppanel .kok-v2-account.tab {
    grid-area: account !important;
    justify-self: end !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 190px !important;
  }
  html body #toppanel .kok-v2-account.tab > ul.login,
  html body #toppanel .kok-v2-account.tab > ul.login > li#toggle,
  html body #toppanel .kok-v2-account-open,
  html body #toppanel .kok-v2-account-close {
    width: 100% !important;
    min-width: 0 !important;
  }
  html body #toppanel .kok-v2-nav {
    grid-area: nav !important;
    width: calc(100% + 20px) !important;
    min-width: 0 !important;
    height: 46px !important;
    margin-left: -10px !important;
    padding: 5px 10px 7px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 6px !important;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  html body #toppanel .kok-v2-nav::-webkit-scrollbar { display: none; }
  html body #toppanel .kok-v2-nav > a.kok-v2-nav-link {
    min-width: max-content !important;
    height: 34px !important;
    padding: 0 11px !important;
    font-size: 10px !important;
    scroll-snap-align: start;
  }
  #panel .content.clearfix {
    width: calc(100% - 20px) !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    padding: 12px 0 15px !important;
  }
  #panel .kok-auth-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  #panel .kok-publisher-metrics { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  #panel .kok-publisher-actions { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
  .kok-welcome-dialog { width: 100% !important; max-width: 520px !important; }
  .kok-theme-switch {
    position: absolute !important;
    top: 101px !important;
    right: 12px !important;
    width: 78px !important;
    height: 30px !important;
    font-size: 9px !important;
  }

  /* Search and discovery */
  .kok-header-clearance { height: 7px !important; }
  body.kok-inner-page .kok-compact-hub {
    display: grid !important;
    grid-template-columns: 40px minmax(0,1fr) auto !important;
    gap: 7px !important;
    padding: 8px !important;
  }
  .kok-compact-search {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    min-width: 0 !important;
    width: 100% !important;
    order: 5;
  }
  .kok-compact-action-primary { grid-column: 2 !important; }
  .kok-compact-action:not(.kok-compact-action-primary) { display: none !important; }
  .kok-compact-toggle { grid-column: 3 !important; padding: 0 10px !important; font-size: 9px !important; }

  .kok-info-hub { width: calc(100% - 20px) !important; }
  .kok-feature-row {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .kok-feature-row::-webkit-scrollbar { display: none; }
  .kok-feature-row .kok-feature-card {
    width: 88% !important;
    min-width: 88% !important;
    height: 158px !important;
    min-height: 158px !important;
    padding: 14px 15px !important;
    border-right: 1px solid rgba(255,255,255,.18) !important;
    border-bottom: 0 !important;
    scroll-snap-align: start;
  }
  .kok-feature-row .kok-feature-card:last-child { border-right: 0 !important; }
  .kok-feature-row .kok-feature-card h2 { font-size: 15px !important; }
  .kok-feature-row .kok-feature-card p { min-height: 28px !important; font-size: 10px !important; }
  .kok-feature-visual { width: 44px !important; height: 44px !important; flex-basis: 44px !important; }

  .kok-utility-bar {
    display: flex !important;
    overflow-x: auto !important;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
  }
  .kok-utility-bar::-webkit-scrollbar { display: none; }
  .kok-utility-item { min-width: 205px !important; height: 56px !important; scroll-snap-align: start; }
  .kok-search-actions { grid-template-columns: 1fr !important; gap: 9px !important; }
  .kok-action-links { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  .kok-search-form { min-width: 0 !important; }
  .kok-search-input { min-width: 0 !important; font-size: 16px !important; }
  .kok-search-button { min-width: 72px !important; padding: 0 12px !important; }

  /* Main layout */
  #main.kok-modern-main { width: calc(100% - 20px) !important; }
  .kok-content-layout { grid-template-columns: minmax(0,1fr) !important; gap: 10px !important; }
  .kok-content-primary { border-radius: 11px !important; overflow: hidden !important; }
  .kok-content-sidebar { order: 2 !important; }
  .kok-home-category-zone { margin-top: 10px !important; padding: 9px !important; }
  .kok-home-category-zone .kok-category-showcase { grid-template-columns: 1fr !important; gap: 9px !important; }

  /* File list and search results */
  .kok-latest-list {
    min-height: 92px !important;
    grid-template-columns: 58px minmax(0,1fr) !important;
    gap: 10px !important;
    padding: 10px !important;
  }
  .kok-latest-media { width: 56px !important; height: 56px !important; }
  .kok-latest-action {
    grid-column: 2 !important;
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-direction: row !important;
    gap: 8px !important;
    padding-top: 7px !important;
    border-top: 1px solid #e8eef2 !important;
  }
  .kok-latest-download { min-width: 74px !important; height: 30px !important; }
  .kok-latest-list > .kok-latest-body > .kok-latest-title {
    height: auto !important;
    max-height: 34px !important;
    font-size: 12px !important;
    line-height: 17px !important;
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .kok-latest-links { flex-wrap: wrap !important; }

  .kok-search-page { padding: 8px !important; }
  .kok-search-hero { align-items: flex-start !important; padding: 13px !important; }
  .kok-search-card { grid-template-columns: 58px minmax(0,1fr) !important; gap: 9px !important; padding: 9px !important; }
  .kok-search-media { width: 58px !important; height: 58px !important; }
  .kok-search-action {
    grid-column: 1 / -1 !important;
    display: grid !important;
    grid-template-columns: 1fr minmax(112px,150px) !important;
    padding: 8px 0 0 !important;
    border-top: 1px solid #e4ecef !important;
    border-left: 0 !important;
  }

  /* Category and sidebar */
  .kok-featured-service { grid-template-columns: 1fr !important; min-height: 0 !important; }
  .kok-featured-service-copy { padding: 16px !important; }
  .kok-featured-service-title { font-size: 18px !important; line-height: 23px !important; }
  .kok-featured-service-media { min-height: 128px !important; padding: 8px !important; }
  .kok-featured-service-media img { height: auto !important; max-height: 190px !important; }
  .kok-category-showcase { width: 100% !important; float: none !important; }
  .kok-category-group { min-height: 0 !important; }
  .kok-category-card { height: 70px !important; grid-template-columns: 48px minmax(0,1fr) !important; }
  .kok-category-thumb { width: 48px !important; height: 48px !important; }
  .kok-sidebar-section summary { min-height: 48px !important; font-size: 12px !important; }
  .kok-sidebar-link { min-height: 46px !important; font-size: 11px !important; }
  .kok-sidebar-count { min-width: 32px !important; height: 22px !important; }

  /* Detail, QPay and file content */
  .kok-help-bar { padding: 10px 12px !important; font-size: 10px !important; }
  .kok-file-card { border-radius: 12px !important; }
  .kok-file-head { padding: 14px !important; }
  .kok-file-title { font-size: 18px !important; line-height: 24px !important; }
  .kok-file-main { grid-template-columns: 1fr !important; gap: 14px !important; padding: 12px !important; }
  .kok-file-preview { min-height: 210px !important; }
  .kok-file-preview img { max-height: 280px !important; }
  .kok-meta-grid { grid-template-columns: 1fr !important; }
  .kok-qpay-entry { align-items: stretch !important; flex-direction: column !important; padding: 12px !important; }
  .kok-qpay-open { width: 100% !important; min-height: 44px !important; }
  .kok-qpay-modal { padding: max(8px,env(safe-area-inset-top)) 8px max(8px,env(safe-area-inset-bottom)) !important; }
  .kok-qpay-dialog { max-height: calc(100dvh - 16px); overflow-y: auto !important; }
  .kok-qpay-banks-grid { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
  .kok-qpay-bank { min-height: 58px !important; }
  .kok-download-btn { width: 100% !important; min-width: 0 !important; }

  #examples, #images, #zurag, #aguulga, #aguulga_zurag, #tulbur_hiih {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
  }
  #images #zurag { display: grid !important; grid-template-columns: repeat(2,minmax(0,1fr)) !important; gap: 8px !important; }
  #images #zurag > a { display: block !important; width: 100% !important; }
  #images #zurag > a img { width: 100% !important; height: 120px !important; object-fit: cover !important; border-radius: 9px !important; }
  #zurag pre { width: 100% !important; max-width: 100% !important; padding: 10px !important; overflow-wrap: anywhere; white-space: pre-wrap !important; }
  #zurag .container, #zurag .row, #zurag .col-sm { width: 100% !important; max-width: 100% !important; margin: 0 !important; }
  #zurag .row { display: grid !important; grid-template-columns: 1fr !important; gap: 10px !important; }
  #zurag .col-sm { padding: 12px !important; border-radius: 10px !important; }
  #zurag .card-body, #zurag .card-text { height: auto !important; min-height: 0 !important; }
  #zurag input[type="button"] { width: 100% !important; min-height: 44px !important; }
  #zurag table { width: 100% !important; max-width: 100% !important; }

  /* Publisher and account pages */
  #kok-publisher-dashboard .kpd-shell,
  #kok-wallet-dashboard .kwd-shell,
  #kok-publisher-public .kpv-shell,
  #kok-profile-edit .kpe-shell,
  #kok-register-page .kr-shell,
  #kok-file-add .kfa-shell { padding: 8px 8px 18px !important; }

  #kok-publisher-dashboard .kpd-hero,
  #kok-wallet-dashboard .kwd-hero,
  #kok-publisher-public .kpv-profile {
    display: block !important;
    min-height: 0 !important;
    padding: 17px !important;
  }
  #kok-publisher-dashboard .kpd-hero-copy,
  #kok-publisher-dashboard .kpd-hero-actions,
  #kok-wallet-dashboard .kwd-hero-copy,
  #kok-wallet-dashboard .kwd-hero-balance,
  #kok-publisher-public .kpv-person,
  #kok-publisher-public .kpv-stats {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    text-align: left !important;
  }
  #kok-publisher-dashboard .kpd-hero-actions { margin-top: 13px !important; white-space: normal !important; }
  #kok-publisher-dashboard .kpd-hero-actions .kpd-btn { margin: 0 6px 6px 0 !important; }
  #kok-wallet-dashboard .kwd-hero-balance { margin-top: 14px !important; padding-top: 13px !important; border-top: 1px solid rgba(255,255,255,.18) !important; border-left: 0 !important; }

  #kok-publisher-dashboard .kpd-metrics,
  #kok-wallet-dashboard .kwd-metrics {
    display: grid !important;
    width: 100% !important;
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 8px !important;
    margin: 10px 0 0 !important;
    border-spacing: 0 !important;
  }
  #kok-publisher-dashboard .kpd-metric,
  #kok-wallet-dashboard .kwd-metric { display: block !important; width: 100% !important; height: auto !important; min-height: 76px !important; }

  #kok-publisher-dashboard .kpd-income-grid,
  #kok-wallet-dashboard .kwd-grid,
  #kok-profile-edit .kpe-layout {
    display: grid !important;
    width: 100% !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin: 10px 0 0 !important;
    border-spacing: 0 !important;
  }
  #kok-publisher-dashboard .kpd-income-main,
  #kok-publisher-dashboard .kpd-income-side,
  #kok-wallet-dashboard .kwd-card,
  #kok-profile-edit .kpe-photo-column,
  #kok-profile-edit .kpe-form-column {
    display: block !important;
    width: 100% !important;
    border-right: 0 !important;
    border-left: 0 !important;
  }
  #kok-publisher-dashboard .kpd-income-main { border-bottom: 1px solid #e8eef4 !important; }
  #kok-wallet-dashboard .kwd-card + .kwd-card { border-top: 1px solid #e5edf2 !important; }

  #kok-publisher-dashboard .kpd-table-wrap,
  #kok-wallet-dashboard .kwd-panel { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  #kok-publisher-dashboard .kpd-table,
  #kok-wallet-dashboard .kwd-table { min-width: 680px !important; }
  #kok-publisher-dashboard .kpd-share-row,
  #kok-publisher-dashboard .kpd-share-input,
  #kok-publisher-dashboard .kpd-share-action { display: block !important; width: 100% !important; }
  #kok-publisher-dashboard .kpd-share-action { padding: 8px 0 0 !important; }

  #kok-profile-edit .kpe-hero,
  #kok-register-page .kr-hero { min-height: 0 !important; padding: 18px !important; }
  #kok-profile-edit .kpe-back,
  #kok-register-page .kr-login { position: static !important; display: block !important; width: 100% !important; margin-top: 13px !important; }
  #kok-profile-edit .kpe-form-grid { display: block !important; width: 100% !important; margin: 0 !important; border-spacing: 0 !important; }
  #kok-profile-edit .kpe-field { display: block !important; width: 100% !important; }
  #kok-profile-edit .kpe-actions { display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; }
  #kok-profile-edit .kpe-btn { width: 100% !important; margin: 0 !important; }
  #kok-register-page .kr-grid { display: block !important; width: 100% !important; }
  #kok-register-page .kr-form-side,
  #kok-register-page .kr-terms-side { display: block !important; width: 100% !important; padding: 16px !important; border-left: 0 !important; }
  #kok-register-page .kr-terms-side { border-top: 1px solid #e4edf2 !important; }
  #kok-register-page .kr-field-row { display: block !important; width: 100% !important; margin: 0 !important; }
  #kok-register-page .kr-field-col { display: block !important; width: 100% !important; padding: 0 !important; }
  #kok-register-page .kr-benefits { display: grid !important; grid-template-columns: repeat(3,minmax(0,1fr)) !important; gap: 7px !important; border-spacing: 0 !important; }
  #kok-register-page .kr-benefit { display: block !important; padding: 10px 6px !important; }
  #kok-register-page .kr-terms-box { height: 240px !important; }
  #kok-register-page .kr-btn { width: 100% !important; margin-right: 0 !important; }

  #kok-file-add .kfa-shell { padding: 10px 8px 20px !important; }
  #kok-file-add .kfa-hero { padding: 18px 15px !important; }
  #kok-file-add .kfa-hero h1 { font-size: 21px !important; }
  #kok-file-add .kfa-steps { display: grid !important; grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
  #kok-file-add .kfa-step { display: block !important; min-width: 0 !important; padding: 42px 8px 10px !important; border-right: 1px solid #e5edf5 !important; text-align: center !important; }
  #kok-file-add .kfa-step:last-child { border-right: 0 !important; }
  #kok-file-add .kfa-step-no { top: 9px !important; left: 50% !important; margin: 0 0 0 -14px !important; }
  #kok-file-add .kfa-step span { display: none !important; }
  #kok-file-add .kfa-layout { display: block !important; width: 100% !important; margin: 0 !important; border-spacing: 0 !important; }
  #kok-file-add .kfa-main,
  #kok-file-add .kfa-side { display: block !important; width: 100% !important; }
  #kok-file-add .kfa-side { margin-top: 10px !important; }
  #kok-file-add .kfa-card-head,
  #kok-file-add .kfa-card-body { padding-right: 14px !important; padding-left: 14px !important; }
  #kok-file-add .kfa-upload-box { padding: 18px 10px !important; }
  #kok-file-add .kfa-form-grid { display: block !important; width: 100% !important; margin: 0 !important; border-spacing: 0 !important; }
  #kok-file-add .kfa-field { display: block !important; width: 100% !important; }
  #kok-file-add .kfa-actions { display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; text-align: left !important; }
  #kok-file-add .kfa-primary,
  #kok-file-add .kfa-secondary { width: 100% !important; min-width: 0 !important; margin: 0 !important; }
  #kok-file-add #load { width: calc(100% - 28px) !important; max-width: 360px !important; }

  #kok-publisher-public .kpv-profile { display: block !important; padding: 18px 15px !important; }
  #kok-publisher-public .kpv-person,
  #kok-publisher-public .kpv-stats { display: block !important; width: 100% !important; text-align: left !important; }
  #kok-publisher-public .kpv-stats { display: grid !important; grid-template-columns: repeat(3,minmax(0,1fr)) !important; gap: 6px !important; margin-top: 15px !important; }
  #kok-publisher-public .kpv-stat { width: 100% !important; min-width: 0 !important; margin: 0 !important; }
  #kok-publisher-public .kpv-file-card { display: grid !important; grid-template-columns: 78px minmax(0,1fr) !important; min-height: 0 !important; }
  #kok-publisher-public .kpv-file-media,
  #kok-publisher-public .kpv-file-content,
  #kok-publisher-public .kpv-file-action { display: block !important; width: auto !important; }
  #kok-publisher-public .kpv-file-media { padding: 10px 0 8px 10px !important; }
  #kok-publisher-public .kpv-file-media img,
  #kok-publisher-public .kpv-file-placeholder { width: 66px !important; height: 66px !important; line-height: 66px !important; }
  #kok-publisher-public .kpv-file-content { min-width: 0 !important; padding: 10px !important; }
  #kok-publisher-public .kpv-file-action { grid-column: 1 / -1 !important; display: grid !important; grid-template-columns: 1fr 1fr 124px !important; align-items: center !important; gap: 6px !important; padding: 9px 10px !important; border-top: 1px solid #edf1f5 !important; border-left: 0 !important; text-align: left !important; }
  #kok-publisher-public .kpv-price { margin: 0 !important; font-size: 16px !important; }
  #kok-publisher-public .kpv-publish-cta { padding: 16px !important; }
  #kok-publisher-public .kpv-publish-cta .kpv-btn { position: static !important; width: 100% !important; margin-top: 12px !important; }

  input[type="text"],input[type="email"],input[type="password"],input[type="tel"],input[type="number"],input[type="search"],select,textarea { font-size: 16px !important; }

  /* Footer */
  #footer.kok-site-footer { margin-bottom: 16px !important; }
  .kok-footer-main { grid-template-columns: repeat(2,minmax(0,1fr)) !important; padding: 26px 22px !important; }
  .kok-footer-bottom { padding: 13px 22px !important; }
}

@media screen and (max-width: 620px) {
  #container,
  #main.kok-modern-main,
  .kok-info-hub,
  .kok-compact-hub,
  .kok-business-network { width: calc(100% - 12px) !important; }
  html body #toppanel > .kok-v2-header {
    grid-template-columns: minmax(108px,1fr) minmax(138px,170px) !important;
    padding-right: 7px !important;
    padding-left: 7px !important;
  }
  html body #toppanel .kok-v2-nav { width: calc(100% + 14px) !important; margin-left: -7px !important; padding-right: 7px !important; padding-left: 7px !important; }
  html body #toppanel .kok-v2-account-copy { padding: 0 4px !important; }
  html body #toppanel .kok-v2-account-label { display: none !important; }
  html body #toppanel .kok-v2-account-name { font-size: 9px !important; }
  .kok-theme-switch { display: none !important; }

  .kok-business-network { padding: 9px !important; }
  .kok-business-links { gap: 8px !important; }
  .kok-business-link { min-width: 166px !important; }
  .kok-feature-row .kok-feature-card { width: 92% !important; min-width: 92% !important; }
  .kok-feature-visual { display: none !important; }
  .kok-action-links { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }

  .kok-search-total { min-width: 60px !important; padding: 7px !important; }
  .kok-search-hero-icon { display: none !important; }
  .kok-search-title { font-size: 15px !important; line-height: 21px !important; }
  .kok-search-subtitle { display: none !important; }

  .kok-qpay-head { padding: 15px 46px 13px 12px !important; }
  .kok-qpay-steps { overflow-x: auto !important; }
  .kok-qpay-banks-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  .kok-qpay-qr-frame img { width: min(205px,68vw) !important; }

  #images #zurag { grid-template-columns: 1fr !important; }
  #images #zurag > a img { height: auto !important; max-height: 220px !important; }

  #kok-publisher-dashboard .kpd-metrics,
  #kok-wallet-dashboard .kwd-metrics { grid-template-columns: 1fr 1fr !important; }
  #kok-publisher-dashboard .kpd-table,
  #kok-wallet-dashboard .kwd-table { min-width: 620px !important; }

  .kok-footer-main { grid-template-columns: 1fr !important; gap: 0 !important; padding: 23px 18px !important; }
  .kok-footer-brand,.kok-footer-column { min-height: 0 !important; padding-right: 0 !important; padding-left: 0 !important; border-left: 0 !important; }
  .kok-footer-column { margin-top: 19px !important; padding-top: 19px !important; border-top: 1px solid rgba(255,255,255,.16) !important; }
  .kok-footer-bottom { grid-template-columns: 1fr !important; gap: 9px !important; padding: 14px 18px !important; }
  .kok-footer-legal { justify-content: flex-start !important; flex-wrap: wrap !important; }
}

@media screen and (max-width: 380px) {
  html body #toppanel > .kok-v2-header { grid-template-columns: minmax(98px,1fr) 138px !important; }
  html body #toppanel .kok-v2-brand-title { font-size: 16px !important; }
  html body #toppanel .kok-v2-brand-note { display: none !important; }
  html body #toppanel .kok-v2-account-avatar { flex-basis: 27px !important; width: 27px !important; height: 27px !important; }
  html body #toppanel .kok-v2-account-arrow { display: none !important; }

  body.kok-inner-page .kok-compact-hub { grid-template-columns: 38px minmax(0,1fr) !important; }
  .kok-compact-toggle { display: none !important; }
  .kok-compact-action-primary { grid-column: 2 !important; padding: 0 8px !important; font-size: 9px !important; }
  .kok-compact-search button { padding: 0 11px !important; }

  .kok-latest-list { grid-template-columns: 50px minmax(0,1fr) !important; gap: 8px !important; padding: 8px !important; }
  .kok-latest-media { width: 48px !important; height: 48px !important; }
  .kok-latest-note { display: none !important; }
  .kok-search-card { grid-template-columns: 50px minmax(0,1fr) !important; }
  .kok-search-media { width: 50px !important; height: 50px !important; }
  .kok-search-action { grid-template-columns: 1fr 108px !important; }

  #kok-publisher-dashboard .kpd-metrics,
  #kok-wallet-dashboard .kwd-metrics { grid-template-columns: 1fr !important; }
  #kok-register-page .kr-benefits { grid-template-columns: 1fr !important; }
  #kok-publisher-public .kpv-person-info { display: block !important; max-width: none !important; margin-top: 10px !important; }
  #kok-publisher-public .kpv-stats { grid-template-columns: 1fr !important; }
  #kok-publisher-public .kpv-file-action { grid-template-columns: 1fr 1fr !important; }
  #kok-publisher-public .kpv-file-action .kpv-btn { grid-column: 1 / -1 !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ===== KL-010 additive mobile header / search / overflow hardening ===== */
@media screen and (max-width: 900px) {
  /* Explicitly kill known topform overflow source */
  .kok-compact-hub {
    overflow-x: hidden !important;
    width: calc(100% - 20px) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .kok-compact-search {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    align-items: center !important;
  }
  .kok-compact-search input[type="text"] {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    font-size: 16px !important; /* iOS zoom prevention */
  }
  .kok-compact-search button {
    flex: 0 0 auto !important;
    min-height: 44px !important;
    min-width: 72px !important;
    padding: 0 14px !important;
  }
  .kok-compact-home {
    min-width: 40px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .kok-compact-action-primary {
    min-height: 44px !important;
    align-items: center !important;
  }

  /* Compact header: brand + auth; nav scroll without page overflow */
  html body #toppanel > .kok-v2-header {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  html body #toppanel .kok-v2-brand-title {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
  }
  html body #toppanel .kok-v2-brand-note {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
  }
  html body #toppanel .kok-v2-account-open,
  html body #toppanel .kok-v2-account-close {
    min-height: 44px !important;
    box-sizing: border-box !important;
  }
  html body #toppanel .kok-v2-nav > a.kok-v2-nav-link {
    min-height: 40px !important;
    max-width: 85vw !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  html body #toppanel .kok-v2-nav > a.kok-v2-nav-link > span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Containers: prevent horizontal page scroll */
  #toppanel,
  #panel,
  .kok-content-layout,
  .kok-content-primary,
  .kok-content-sidebar,
  .kok-sidebar-categories {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .kok-sidebar-name {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }
}

@media screen and (max-width: 600px) {
  .kok-compact-hub {
    width: calc(100% - 12px) !important;
    overflow-x: hidden !important;
  }
  /* Search first: full-width row, then actions */
  body.kok-inner-page .kok-compact-hub,
  .kok-compact-hub {
    display: grid !important;
    grid-template-columns: 44px minmax(0,1fr) auto !important;
    grid-template-areas:
      "home primary more"
      "search search search" !important;
    gap: 8px !important;
    padding: 8px !important;
  }
  .kok-compact-home { grid-area: home !important; }
  .kok-compact-action-primary { grid-area: primary !important; }
  .kok-compact-toggle { grid-area: more !important; }
  .kok-compact-search {
    grid-area: search !important;
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    order: 0 !important;
  }
}

@media screen and (max-width: 380px) {
  .kok-compact-hub {
    grid-template-columns: 40px minmax(0,1fr) !important;
    grid-template-areas:
      "home primary"
      "search search" !important;
  }
  .kok-compact-toggle { display: none !important; }
}

/* ===== KL-010D RECOVERY — must load AFTER topform.php inline CSS =====
 * Root cause: topform sets html body #toppanel > .kok-v2-header {
 *   min-width: 1100px !important; } outside any media query, AFTER the
 * head-linked mobile sheet. That expands the mobile layout viewport so
 * max-width:900px queries never match → scaled desktop UI.
 * Fix: equal/higher specificity + late load; kill 1100px; force stack.
 */

@media screen and (max-width: 900px) {
  /* Kill layout-viewport expansion */
  html body #toppanel > header.kok-v2-header,
  html body #toppanel > .kok-v2-header {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    white-space: normal !important;
    overflow: visible !important;
    display: grid !important;
    grid-template-columns: minmax(0,1fr) minmax(140px,170px) !important;
    grid-template-areas:
      "brand account"
      "nav nav" !important;
    grid-template-rows: auto auto !important;
    gap: 6px 8px !important;
    padding: 8px 10px !important;
  }
  html body #toppanel > .headerMenu,
  html body #toppanel .headerMenu {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    padding: 6px 10px !important;
    white-space: normal !important;
    flex-wrap: wrap !important;
  }
  #panel .content.clearfix {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 12px 10px !important;
  }
  #panel .kok-auth-grid {
    grid-template-columns: 1fr !important;
  }

  html, body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  #container,
  #main,
  #main.kok-modern-main {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    box-sizing: border-box !important;
  }

  /* Single column: categories near top of content */
  .kok-content-layout {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .kok-content-sidebar {
    order: -1 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .kok-content-primary,
  #mainleft.kok-content-primary,
  #mainleft {
    order: 1 !important;
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .kok-content-sidebar > #mainright,
  #mainright {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Header readability / touch */
  html body #toppanel .kok-v2-brand {
    grid-area: brand !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    align-items: flex-start !important;
  }
  html body #toppanel .kok-v2-brand-title {
    font-size: 22px !important;
    line-height: 26px !important;
    white-space: nowrap !important;
  }
  html body #toppanel .kok-v2-brand-note {
    font-size: 11px !important;
    line-height: 14px !important;
  }
  html body #toppanel .kok-v2-account.tab {
    grid-area: account !important;
    max-width: 170px !important;
  }
  html body #toppanel .kok-v2-account-open,
  html body #toppanel .kok-v2-account-close {
    min-height: 44px !important;
    font-size: 12px !important;
  }
  html body #toppanel .kok-v2-nav {
    grid-area: nav !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    height: auto !important;
    min-height: 44px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
  }
  html body #toppanel .kok-v2-nav > a.kok-v2-nav-link {
    min-height: 40px !important;
    font-size: 12px !important;
    padding: 0 12px !important;
  }

  /* Search full width + readable */
  .kok-compact-hub,
  body.kok-inner-page .kok-compact-hub {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    display: grid !important;
    grid-template-columns: 44px minmax(0,1fr) auto !important;
    grid-template-areas:
      "home primary more"
      "search search search" !important;
    gap: 8px !important;
    padding: 10px !important;
    box-sizing: border-box !important;
  }
  .kok-compact-search {
    grid-area: search !important;
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
  }
  .kok-compact-search input[type="text"] {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }
  .kok-compact-search button {
    min-height: 44px !important;
    min-width: 72px !important;
    font-size: 14px !important;
  }
  .kok-compact-home,
  .kok-compact-action-primary {
    min-height: 44px !important;
  }

  /* Banners: single column responsive */
  .kok-home-banner-grid {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 8px !important;
  }
  .kok-banner-slider,
  .kok-banner-stage,
  .kok-home-product-banner {
    height: auto !important;
    min-height: 140px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .kok-banner-slide img,
  .kok-banner-slider img {
    width: 100% !important;
    height: auto !important;
    max-height: 200px !important;
    object-fit: cover !important;
  }
  .kok-home-product-banner {
    grid-template-columns: minmax(0,1fr) !important;
  }

  /* Product list readability */
  .kok-latest-list {
    grid-template-columns: 64px minmax(0,1fr) !important;
    min-height: 0 !important;
    padding: 12px !important;
    gap: 12px !important;
  }
  .kok-latest-list > .kok-latest-body > .kok-latest-title {
    font-size: 15px !important;
    line-height: 20px !important;
    max-height: none !important;
    height: auto !important;
    -webkit-line-clamp: 3;
  }
  .kok-latest-download {
    min-height: 40px !important;
    font-size: 13px !important;
  }
  .kok-search-card {
    grid-template-columns: 64px minmax(0,1fr) !important;
  }
  .kok-search-title,
  .kok-file-title {
    font-size: 17px !important;
    line-height: 22px !important;
  }

  /* Sidebar accordion touch */
  .kok-sidebar-section summary {
    min-height: 48px !important;
    font-size: 14px !important;
  }
  .kok-sidebar-link {
    min-height: 44px !important;
    font-size: 13px !important;
  }
}

@media screen and (max-width: 768px) {
  .kok-feature-row {
    display: flex !important;
    overflow-x: auto !important;
  }
  .kok-home-category-zone .kok-category-showcase {
    grid-template-columns: 1fr !important;
  }
}

@media screen and (max-width: 430px) {
  html body #toppanel > header.kok-v2-header,
  html body #toppanel > .kok-v2-header {
    grid-template-columns: minmax(0,1fr) minmax(120px,150px) !important;
  }
  .kok-compact-hub,
  body.kok-inner-page .kok-compact-hub {
    grid-template-columns: 44px minmax(0,1fr) !important;
    grid-template-areas:
      "home primary"
      "search search" !important;
  }
  .kok-compact-toggle { display: none !important; }
}

@media screen and (max-width: 360px) {
  html body #toppanel .kok-v2-brand-title { font-size: 18px !important; }
  html body #toppanel .kok-v2-brand-note { display: none !important; }
}
