/* Shared upload control; the native camera chooser is shown on touch layouts. */
.mobile-camera { display: none; }
.camera-label {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 50px; margin: 0; padding: 14px 12px;
  border: 1px solid #d1e5ea; border-radius: 9px; background: #f0f8fa;
  color: var(--teal-dark); font-size: .9rem; font-weight: 500;
  text-align: center; cursor: pointer;
}
.camera-label input { display: none; }
.camera-label > span { color: inherit; }
.camera-label svg { flex: 0 0 21px; width: 21px; height: 21px; }

/* Tablets keep the navigation rail, while the editing form gets the full column. */
@media (min-width: 801px) and (max-width: 1100px) {
  .topbar { gap: 19px; padding-right: 22px; }
  .breadcrumb { padding-left: 17px; }
  .account { gap: 9px; }
  .account > span { max-width: 100px; }
  .editor-grid { grid-template-columns: minmax(0,1fr); gap: 0; }
  .editor-grid > aside { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
  .editor-grid > aside > .panel { margin-bottom: 20px; }
  .editor-grid > aside > .panel:last-child { grid-column: 1 / -1; }
  .settings-grid { grid-template-columns: minmax(0,1fr); }
  .page-heading { flex-wrap: wrap; gap: 18px; }
  .save-footer .small { max-width: 48%; }
  .product-collection-tabs { column-gap: 3px; }
  .collection-tab { padding-left: 10px; padding-right: 10px; }
}

@media (max-width: 800px) {
  :root { background: white; }
  body { background: white; }
  .workspace-shell {
    display: block; width: 100%; max-width: none; min-height: 100vh;
    margin: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible;
  }
  .topbar {
    position: sticky; top: 0; z-index: 40; display: flex; flex-wrap: nowrap;
    align-items: center; justify-content: space-between; gap: 12px;
    height: 65px; min-height: 65px; padding: 0 18px;
    border-bottom: 1px solid var(--line); background: #fffffffa;
  }
  .masthead-brand { flex: 0 0 auto; }
  .masthead-brand img { width: 130px; max-width: 100%; height: auto; }
  .breadcrumb { display: none; }
  .account { gap: 9px; min-width: 0; margin-left: auto; }
  .account > span { display: none; }
  .avatar { flex: 0 0 28px; width: 28px; height: 28px; font-size: .72rem; }
  .logout { min-height: 36px; padding-left: 11px; font-size: .8125rem; }
  .sidebar {
    position: static; inset: auto; display: block; width: 100%; height: auto;
    min-height: 0; padding: 10px 18px 12px; border-right: 0;
    border-bottom: 1px solid var(--line); background: white;
  }
  .nav-label, .sidebar-foot { display: none; }
  .sidebar nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px 10px; }
  .nav-link {
    display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0;
    min-height: 44px; margin: 0; padding: 10px 12px; border-radius: 8px;
    font-size: .875rem; line-height: 1.4; white-space: normal;
  }
  .nav-link svg { flex: 0 0 18px; width: 18px; height: 18px; }
  .nav-link span { min-width: 0; }
  .nav-count { margin-left: auto; padding: 2px 5px; font-size: .6875rem; }
  .main { width: 100%; min-width: 0; margin: 0; padding: 0; }
  .content { width: 100%; max-width: none; margin: 0; padding: 25px 18px 110px; }
  .page-heading { flex-wrap: wrap; align-items: flex-start; gap: 17px; margin-bottom: 25px; }
  .page-heading > div { min-width: 0; }
  .page-heading h1 { margin-bottom: 9px; font-size: 1.65rem; line-height: 1.3; letter-spacing: -.04em; }
  .page-heading p { font-size: .875rem; line-height: 1.8; }
  .heading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; width: 100%; }
  .heading-actions .primary { flex: 1 1 auto; }
  .primary, .secondary { min-height: 44px; padding: 11px 16px; font-size: .875rem; }
  .primary svg, .secondary svg { width: 18px; height: 18px; flex: 0 0 18px; }
  .compact-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px 20px; width: 100%; margin: 0; padding: 15px 17px; border: 1px solid #eef2f5; border-radius: 10px; background: #fafcfd; }
  .summary-item, .summary-item:first-child, .summary-item:last-child { min-width: 0; padding: 0; border: 0; font-size: .8125rem; }
  .summary-item strong { font-size: 1.12rem; }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin: 20px 0 23px; }
  .stat-card { min-width: 0; padding: 17px; border-radius: 10px; }
  .stat-value { margin: 14px 0 7px; font-size: 1.8rem; }
  .stat-symbol { width: 28px; height: 28px; }
  .stat-note { line-height: 1.7; }
  .two-panels, .settings-grid { grid-template-columns: minmax(0,1fr); gap: 0; }
  .panel { min-width: 0; max-width: 100%; margin-bottom: 21px; border-radius: 10px; box-shadow: none; }
  .panel-heading { gap: 14px; padding: 18px; }
  .panel-heading h2 { font-size: .98rem; }
  .panel-body { padding: 18px; }
  .setup-notice { flex-wrap: wrap; align-items: flex-start; gap: 12px; padding: 17px; font-size: .8125rem; }
  .setup-notice > div { flex: 1 1 calc(100% - 42px); min-width: 0; }
  .setup-notice .quiet { margin: 0 0 0 31px; padding: 2px 0; }

  /* Categories stay readable; wide data tables scroll within their own panel. */
  .catalog-panel { border: 0; border-radius: 0; }
  .toolbar { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 17px; }
  .toolbar-products { padding: 0 0 18px; }
  .toolbar-products > .primary, .toolbar-products > .secondary { width: 100%; min-width: 0; }
  .search-control { grid-column: 1 / -1; width: 100%; min-width: 0; margin: 0; }
  .search-control .search-input { width: 100%; max-width: none; min-width: 0; padding-left: 42px; font-size: 16px; }
  .toolbar .search-input { min-width: 0; max-width: none; }
  .toolbar select { width: 100%; min-width: 0; max-width: none; padding-right: 32px; font-size: 16px; }
  .toolbar-products select { grid-column: 1 / -1; }
  .result-count { grid-column: 1 / -1; margin: 0; font-size: .8125rem; }
  .product-collection-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: stretch; gap: 2px 0; margin: 0 0 18px; padding: 0 0 5px; }
  .collection-tab, .collection-tab:first-child { min-width: 0; min-height: 44px; padding: 12px 5px; font-size: .875rem; line-height: 1.5; text-align: center; white-space: normal; }
  .collection-tab.active::after, .collection-tab:first-child.active::after { bottom: 1px; left: 20%; right: 20%; }
  .table-wrap { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .table-wrap > table { min-width: 790px; }
  th, td { padding-left: 15px; padding-right: 15px; }
  .catalog-footer { flex-wrap: wrap; gap: 8px; padding-top: 15px; line-height: 1.7; }

  /* Photo controls lead the form; product and inspiration uploads remain separate. */
  .editor-grid { display: flex; flex-direction: column; gap: 0; width: 100%; min-width: 0; }
  .editor-grid > div, .editor-grid > aside { width: 100%; min-width: 0; }
  .editor-grid > aside { order: -1; }
  .editor-grid > aside > .panel:last-child { display: none; }
  .editor-grid .panel { margin-bottom: 22px; }
  .editor-grid > aside .panel-body { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: stretch; gap: 12px; }
  .editor-grid > aside .section-description { grid-column: 1 / -1; margin: 0; font-size: .8125rem; line-height: 1.7; }
  .mobile-camera { display: block; min-width: 0; }
  .camera-label { flex-direction: column; min-height: 112px; height: 100%; padding: 15px 10px; gap: 12px; border-radius: 8px; font-size: .875rem; }
  .camera-label svg { width: 24px; height: 24px; flex-basis: 24px; }
  .editor-grid > aside .upload-label { min-width: 0; min-height: 112px; margin: 0; padding: 15px 10px; gap: 10px; border-radius: 8px; font-size: .875rem; }
  .editor-grid > aside .upload-label .hint { font-size: .6875rem; line-height: 1.5; }
  .editor-grid > aside .image-grid { grid-column: 1 / -1; gap: 10px; margin-top: 1px; }
  .image-item { min-width: 0; border-radius: 8px; }
  .image-remove { width: 26px; height: 26px; font-size: 18px; }
  .editor-grid > aside .cover-note { grid-column: 1 / -1; margin: 0; line-height: 1.6; }
  .field-grid { grid-template-columns: minmax(0,1fr); gap: 20px; margin-bottom: 23px; }
  .field-grid .field { min-width: 0; margin-bottom: 0; }
  .field-row { flex-direction: column; gap: 0; }
  .editor-grid input, .editor-grid textarea, .editor-grid select, .login-card input, #password-form input { min-width: 0; font-size: 16px; }
  .editor-grid input[type=checkbox], .editor-grid input[type=radio] { flex-basis: 17px; width: 17px; height: 17px; min-height: 0; }
  .editor-grid .panel-heading .hint { max-width: 130px; text-align: right; font-size: .75rem; line-height: 1.6; }
  .switches { flex-direction: column; gap: 10px; }
  .switches label { min-height: 47px; margin: 0; padding: 12px 14px; font-size: .875rem; }
  .spec-table-wrap { max-width: 100%; overflow: visible; }
  .spec-table { width: 100%; max-width: 100%; }
  .spec-table thead { display: none; }
  .spec-table tbody { display: block; }
  .spec-table .spec-row { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px 12px; margin: 0 17px 17px; padding: 17px 13px; border: 1px solid #e6ecf1; border-radius: 9px; background: #fcfdfe; }
  .spec-table .spec-row td, .spec-table .spec-row td:first-child, .spec-table .spec-row td:last-child { min-width: 0; padding: 0; border: 0; background: transparent; }
  .spec-table input { width: 100%; min-width: 0; min-height: 44px; padding: 10px 8px; border-radius: 7px; font-size: 16px; }
  .spec-area { margin-top: 7px; font-size: .8125rem; line-height: 1.5; }
  .spec-table .remove-spec { width: 100%; height: 44px; padding: 0; font-size: 24px; }
  .spec-table .remove-spec::after { content: "移除"; padding-left: 4px; font-size: .8125rem; }
  .spec-actions { padding: 4px 18px 19px; }
  .spec-actions > .quiet { min-height: 44px; padding-left: 0; }
  .calc-preview { padding: 15px; font-size: .8125rem; line-height: 1.9; }
  .save-footer { position: fixed; inset: auto 0 0; z-index: 45; width: auto; margin: 0; padding: 13px 18px calc(13px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid #e3ebf0; border-radius: 0; background: #fffffffa; box-shadow: 0 -4px 22px #23404d05; }
  .save-footer > .small { display: none; }
  .save-footer .heading-actions { display: flex; flex-wrap: nowrap; width: 100%; gap: 12px; }
  .save-footer .secondary { flex: 0 0 87px; min-height: 46px; }
  .save-footer .primary { flex: 1 1 auto; min-height: 46px; }

  .setting-line { flex-wrap: wrap; align-items: flex-start; gap: 8px 15px; font-size: .875rem; }
  .setting-line > span { min-width: 0; overflow-wrap: anywhere; }
  .code { max-width: 100%; padding: 12px; font-size: .75rem; }
  .enquiry-card { padding: 18px; }
  .enquiry-top { align-items: flex-start; gap: 14px; }
  .enquiry-top > div { min-width: 0; overflow-wrap: anywhere; }
  .enquiry-top select { flex: 0 0 110px; width: 110px; padding-left: 10px; font-size: .875rem; }
  .enquiry-lines { padding: 13px; overflow-wrap: anywhere; }
  .enquiry-detail { overflow-wrap: anywhere; }
  .login-wrap { min-height: 100dvh; padding: 22px 17px; }
  .login-card { width: 100%; max-width: 430px; padding: 29px 25px; border-radius: 14px; }
  .login-card img { width: 145px; margin-bottom: 27px; }
  .login-card h1 { font-size: 1.5rem; }
  .dialog-overlay { padding: 18px; }
  .dialog { padding: 24px; border-radius: 12px; }
  .dialog-actions .primary, .dialog-actions .secondary { min-height: 44px; }
  .lightbox { padding: 16px; }
  .lightbox img { max-width: 100%; max-height: 90dvh; }
  #toast { bottom: calc(92px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); font-size: .875rem; text-align: center; }
}

@media (max-width: 359px) {
  .topbar { padding-left: 14px; padding-right: 14px; }
  .masthead-brand img { width: 117px; }
  .sidebar { padding-left: 14px; padding-right: 14px; }
  .content { padding-left: 14px; padding-right: 14px; }
  .nav-link { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .collection-tab, .collection-tab:first-child { font-size: .8125rem; }
  .panel-body { padding: 15px; }
  .spec-table .spec-row { margin-left: 13px; margin-right: 13px; padding-left: 10px; padding-right: 10px; gap: 13px 9px; }
  .save-footer { padding-left: 14px; padding-right: 14px; }
}
