:root{--ink:#173d31;--muted:#6c7c73;--green:#245b45;--lime:#dbef94;--line:#e2e8e1;--paper:#fff;--bg:#f4f6f1}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.6 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif}button,input,select,textarea{font:inherit}button,a,input,select,textarea{-webkit-tap-highlight-color:transparent}button{cursor:pointer;background:#fff;color:var(--ink);border:1px solid var(--line);border-radius:8px;padding:9px 15px;font-weight:600}button:hover{background:#eef3e8}button:disabled{opacity:.45;cursor:not-allowed}button.primary{background:var(--green);border-color:var(--green);color:#fff}button.primary:hover{background:#173d31}a{color:var(--green);text-decoration:none}a:hover{text-decoration:underline}input,select,textarea{border:1px solid #ccd6cd;border-radius:7px;padding:9px 11px;background:#fff;color:var(--ink);min-width:0;width:100%}input:focus,select:focus,textarea:focus,button:focus-visible{outline:2px solid #93b963;outline-offset:2px}textarea{resize:vertical;min-height:76px}h1,h2,h3,p{margin-top:0}h1{font-size:32px;line-height:1.3;letter-spacing:-1px;margin-bottom:8px}h2{font-size:19px;margin-bottom:3px}h3{font-size:16px;margin:0 0 14px}small,.muted{color:var(--muted)}.app-header{height:80px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 5vw;gap:20px}.logo{display:flex;align-items:center;gap:12px;font-size:17px;font-weight:750;line-height:1.4}.logo>span{background:var(--green);color:var(--lime);padding:9px 13px;border-radius:10px;font-size:24px}.logo small{display:block;font-size:9px;letter-spacing:1.5px;font-weight:500}.header-links{display:flex;gap:18px;align-items:center;font-size:12px}.quiet{background:transparent;padding:5px 9px}main{max-width:1320px;margin:auto;padding:38px 36px 24px}.intro{display:flex;justify-content:space-between;align-items:center;gap:24px;margin-bottom:26px}.intro p{color:var(--muted);margin-bottom:0}.intro .eyebrow{font-size:11px;color:var(--green);letter-spacing:2px;margin-bottom:8px}.manual-badge{border:1px solid #d5dfcc;background:#edf3e4;padding:12px 20px;border-radius:10px;font-weight:600}.manual-badge small{display:block;font-weight:400;font-size:11px;margin-top:3px}.dot{width:7px;height:7px;background:#7b9b41;border-radius:50%;display:inline-block;margin-right:8px}.flow{display:flex;align-items:center;justify-content:space-around;padding:18px 10px;border:1px solid var(--line);border-radius:12px;margin-bottom:22px;background:#fff;color:var(--muted);font-size:12px}.flow b{font-size:10px;padding:5px 7px;margin-right:10px;border-radius:5px;background:#eef2e9;color:var(--green)}.flow i{color:#adbaac;font-style:normal}.workspace{border:1px solid var(--line);background:#fff;border-radius:14px;overflow:hidden}.tabs{display:flex;gap:12px;padding:0 24px;border-bottom:1px solid var(--line)}.tabs button{padding:18px 9px;border:0;border-bottom:3px solid transparent;border-radius:0;color:var(--muted)}.tabs button.selected{color:var(--green);border-bottom-color:var(--green);background:transparent}.toolbar{display:flex;align-items:center;justify-content:space-between;padding:24px 26px 10px;gap:20px}.toolbar p{font-size:12px;color:var(--muted);margin-bottom:0}.filters{padding:12px 26px 20px;display:flex;gap:9px}.filters input{max-width:420px}.filters select{max-width:180px}.filters button{flex-shrink:0}.table-wrap{overflow:auto}table{border-collapse:collapse;width:100%;font-size:12px;text-align:left}th{background:#f6f8f3;color:var(--muted);font-size:11px;font-weight:500;white-space:nowrap}td,th{padding:14px 18px;border-bottom:1px solid #edf0e9;vertical-align:top}td{max-width:240px;overflow-wrap:anywhere}td small{display:block;margin-top:3px}td button{font-size:12px;padding:5px 10px;white-space:nowrap}.tag{display:inline-block;border-radius:5px;background:#edf3e7;color:#38583e;padding:3px 8px;font-size:11px;white-space:nowrap}.tag.draft{background:#fff4dd;color:#96721b}.tag.cancelled{background:#f3e7e7;color:#985656}.tag.partial{background:#e7edf4;color:#426686}.empty{text-align:center;padding:65px 20px;color:var(--muted)}.empty b{display:block;font-size:18px;font-weight:500;margin-bottom:7px;color:var(--ink)}.pager{display:flex;align-items:center;justify-content:space-between;padding:15px 24px;color:var(--muted);font-size:12px}.pager>div{display:flex;gap:12px;align-items:center}.pager button{font-size:12px;padding:5px 10px}.footnote{font-size:11px;color:var(--muted);text-align:center;margin:20px 0}.detail{position:fixed;inset:0 0 0 auto;background:#f4f6f1;width:min(900px,100vw);box-shadow:-20px 0 70px #122c3333;z-index:10;overflow:auto;padding:24px}.detail-heading{display:flex;justify-content:space-between;align-items:center;padding-bottom:20px;gap:15px}.detail-heading h2{overflow-wrap:anywhere}.detail-heading small{font-size:11px}.card{background:#fff;border:1px solid var(--line);border-radius:11px;padding:22px;margin-bottom:16px}.card-head{display:flex;align-items:center;justify-content:space-between;gap:15px;margin-bottom:15px}.card-head h3{margin:0}.actions{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:18px}.fields{display:grid;grid-template-columns:repeat(3,1fr);gap:15px}.field small{display:block;font-size:11px}.field div{overflow-wrap:anywhere;white-space:pre-wrap}.note{font-size:12px;background:#f4f7ef;padding:12px;border-radius:6px;color:#667b5e;margin-bottom:12px}.photos{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.photo{border:1px solid var(--line);border-radius:8px;overflow:hidden}.photo img{width:100%;height:120px;object-fit:cover;background:#f0f2ed}.photo figcaption{padding:7px;font-size:11px;overflow-wrap:anywhere}.photo figure{margin:0}.file-list{display:grid;gap:8px;margin-top:12px}.file-list a{border:1px solid var(--line);border-radius:6px;padding:10px;overflow-wrap:anywhere;font-size:12px}.upload-controls{display:flex;align-items:end;gap:10px;flex-wrap:wrap;margin-top:20px;padding-top:16px;border-top:1px solid var(--line)}.upload-controls label{font-size:11px;color:var(--muted)}.upload-controls select{width:140px}.upload-controls input[type=text]{width:130px}.upload-controls input[type=file]{max-width:260px;font-size:12px}.upload-controls .camera input{max-width:170px}.upload-status{margin-top:10px;font-size:12px;color:var(--muted)}.timeline{margin:0;padding-left:20px;color:var(--muted);font-size:12px}.timeline li{padding:6px 0}.timeline b{color:var(--ink);margin-right:10px}dialog{border:0;border-radius:14px;width:min(950px,95vw);max-height:94vh;padding:0;color:var(--ink);box-shadow:0 25px 100px #0004}dialog::backdrop{background:#10281dc0}dialog header,dialog footer{display:flex;justify-content:space-between;align-items:center;padding:18px 24px;border-bottom:1px solid var(--line);gap:15px}dialog footer{border-top:1px solid var(--line);border-bottom:0;justify-content:flex-end}#editBody{padding:20px 24px}#editBody .form-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}#editBody label{display:block;font-size:12px;color:var(--muted)}#editBody label input,#editBody label select,#editBody label textarea{display:block;margin-top:5px;color:var(--ink)}.wide{grid-column:1/-1}.line-editor{margin-top:22px}.line-editor table{min-width:690px}.line-editor input{padding:7px;min-width:65px}.line-editor td{padding:7px 4px}.line-editor th{padding:7px 4px}.line-editor .name-input{min-width:150px}.error{color:#aa3636;font-size:12px;white-space:pre-wrap;padding:0 24px}.danger{color:#ac4040}.inline-links{display:flex;flex-wrap:wrap;gap:8px}.inline-links button{font-size:12px}#notice{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);max-width:90vw;background:#173d31;color:#fff;padding:13px 22px;border-radius:9px;z-index:40;white-space:pre-wrap}#notice.error-notice{background:#8b3434}[hidden]{display:none!important}body.has-detail{overflow:hidden}
@media(max-width:780px){.app-header{height:auto;padding:16px;align-items:flex-start}.header-links{gap:8px;flex-wrap:wrap;justify-content:flex-end;max-width:200px}.header-links a{font-size:11px}.logo{font-size:14px}.logo small{font-size:7px}.logo>span{font-size:20px;padding:8px 10px}main{padding:24px 14px}.intro{display:block;margin-bottom:16px}h1{font-size:28px}.manual-badge{margin-top:18px;font-size:12px;padding:10px 14px}.flow{font-size:10px;padding:12px 5px}.flow b{display:block;width:max-content;margin:0 auto 4px}.flow i{font-size:10px}.tabs{padding:0 12px;gap:3px}.tabs button{padding:14px 9px;font-size:13px}.toolbar{padding:18px 15px 6px;align-items:flex-start}.toolbar p{font-size:11px}.toolbar button{font-size:12px;white-space:nowrap}.filters{padding:12px 15px;flex-wrap:wrap}.filters input{max-width:none;flex:1 0 100%}.filters select{flex:1;max-width:none}.fields{grid-template-columns:repeat(2,1fr)}.detail{padding:17px}.card{padding:15px}.photos{grid-template-columns:repeat(2,1fr)}.photo img{height:130px}#editBody .form-grid{grid-template-columns:repeat(2,1fr)}#editBody{padding:16px}dialog header,dialog footer{padding:14px 16px}.pager{padding:12px}.pager>div{gap:7px}.upload-controls{gap:8px}.flow span{text-align:center}.actions button{flex:1;font-size:12px}.table-wrap td,.table-wrap th{padding:11px}.toolbar h2{font-size:17px}}
@media print{.app-header,.intro,.flow,.workspace,.footnote,.actions,button,.upload-controls,.upload-status{display:none!important}.detail{position:static;width:100%;box-shadow:none;overflow:visible}.card{break-inside:avoid}.detail-heading{padding-bottom:10px}body.has-detail{overflow:visible}}

td button.record-link{border:0;padding:0;background:none;text-align:left;white-space:normal;color:#245b45;font-weight:700;text-decoration:underline;text-underline-offset:3px}
.camera-dialog{width:min(760px,95vw)}.camera-dialog header h2{font-size:18px}.camera-dialog header small{display:block;overflow-wrap:anywhere}.camera-dialog header button{flex-shrink:0}.camera-body{padding:18px 24px}.camera-device,.camera-fields label{display:block;font-size:12px;color:var(--muted)}.camera-device select,.camera-fields input,.camera-fields select{display:block;margin-top:5px}.camera-device{margin-bottom:12px}#cameraVideo{display:block;width:100%;max-height:45vh;aspect-ratio:16/9;object-fit:contain;border-radius:10px;background:#13201a}.camera-fields{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:14px}.camera-status{font-size:13px;white-space:pre-wrap;margin:12px 0;color:var(--green)}.camera-status.camera-error{color:#a13a34}.camera-last{display:flex;align-items:center;gap:12px;font-size:12px}.camera-last img{width:110px;height:74px;object-fit:contain;border-radius:6px;background:#edf0e9}.camera-last a{text-decoration:underline}.camera-dialog footer{flex-wrap:wrap;gap:8px}.camera-launch{padding:10px 15px}
@media(max-width:600px){.camera-body{padding:14px}.camera-dialog header h2{font-size:16px}.camera-dialog header button{font-size:12px;padding:7px}.camera-dialog footer button{font-size:12px;flex:1}.camera-fields{grid-template-columns:1fr 1fr}.camera-dialog{max-height:96vh}}
@media print{.camera-dialog{display:none!important}}


@media screen and (max-width:600px){
}
.camera-dialog[open]{display:flex;flex-direction:column;overflow:hidden}.camera-dialog header,.camera-dialog footer{flex-shrink:0}.camera-body{overflow:auto;min-height:0}#cameraVideo{max-height:32vh}
.volume-editor{margin-top:22px;padding:18px;border:1px solid var(--line);border-radius:10px;background:#f8faf5}.volume-editor>label{max-width:320px}.volume-editor .note{margin-top:12px}.volume-editor table{min-width:590px}.volume-editor td,.volume-editor th{padding:8px 5px}.volume-editor td:first-child{min-width:170px}.volume-editor td input{min-width:75px;padding:8px}.volume-editor #addDimension{margin-top:10px}.volume-total{display:flex;gap:20px;align-items:center;margin-top:15px;flex-wrap:wrap}.volume-total label{max-width:240px}.volume-total input{font-weight:700;font-size:20px;background:#eaf2df}.volume-total span{font-size:12px;color:var(--muted)}.volume-hint{font-size:12px;color:var(--green);margin:12px 0 0}.volume-error{color:#a13a34}
.auth-layer{position:fixed;inset:0;z-index:60;display:grid;place-items:center;padding:24px;background:linear-gradient(135deg,#153d31f2,#244f3ff2)}.auth-card{width:min(430px,100%);padding:34px;border-radius:18px;background:#fff;box-shadow:0 28px 90px #081d174d}.auth-card .auth-mark{display:grid;place-items:center;width:52px;height:52px;margin-bottom:20px;border-radius:14px;background:var(--lime);color:var(--ink);font-size:23px;font-weight:800}.auth-card .eyebrow{margin-bottom:6px;color:var(--green);font-size:10px;letter-spacing:2px}.auth-card h2{margin-bottom:8px;font-size:25px}.auth-card>p:not(.eyebrow){margin-bottom:22px;color:var(--muted);font-size:13px}.auth-card label{display:block;margin:14px 0 0;color:var(--muted);font-size:12px}.auth-card label input{display:block;margin-top:6px;color:var(--ink)}.auth-card>button{width:100%;margin-top:22px;padding:12px}.auth-error{display:block;min-height:20px;margin-top:10px;color:#a13a34;text-align:center}.auth-layer[hidden]{display:none!important}
@media(max-width:600px){.auth-layer{padding:14px}.auth-card{padding:26px 22px}.auth-card h2{font-size:22px}}

/* Phone layout: the same records and forms remain usable without horizontal scrolling. */
html{-webkit-text-size-adjust:100%}
.table-wrap{max-width:100%;-webkit-overflow-scrolling:touch}
body:has(dialog[open]){overflow:hidden}
@media screen and (max-width:600px){
  body{font-size:15px}
  button,input,select{min-height:44px}
  input,select,textarea{font-size:16px}
  button{touch-action:manipulation}
  .app-header{padding:12px max(14px,env(safe-area-inset-right)) 12px max(14px,env(safe-area-inset-left));align-items:center;gap:10px}
  .logo{gap:8px;font-size:15px;min-width:0}
  .logo>span{font-size:20px;padding:7px 11px;flex-shrink:0}
  .logo small{font-size:8px;letter-spacing:.6px}
  .header-links{max-width:110px;gap:4px;font-size:12px}
  #userName{max-width:105px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .quiet{padding:8px 10px}
  main{padding:22px max(12px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
  h1{font-size:26px;letter-spacing:0}
  .intro>div>p:last-child{font-size:14px}
  .manual-badge{margin-top:14px;padding:10px 12px;font-size:13px}
  .manual-badge small{font-size:12px;line-height:1.5}
  .flow{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;padding:12px 6px;margin-bottom:16px;font-size:11px}
  .flow i{display:none}
  .flow b{font-size:11px}
  .tabs{padding:0 8px;gap:0}
  .tabs button{flex:1;min-width:0;padding:15px 4px;font-size:14px;white-space:nowrap}
  .toolbar{display:grid;grid-template-columns:minmax(0,1fr);justify-content:stretch;gap:14px;padding:20px 14px 8px}
  .toolbar h2{font-size:20px}
  .toolbar p{font-size:13px;line-height:1.6}
  .toolbar button{width:100%;font-size:15px;min-height:46px}
  .filters{display:grid;grid-template-columns:minmax(0,1fr) auto auto;padding:12px 14px 16px;gap:8px}
  .filters input{grid-column:1/-1;width:100%}
  .filters select{width:100%;max-width:none}
  .filters button{padding:9px 12px;font-size:14px}
  .pager{flex-direction:column;gap:12px;padding:16px 14px;font-size:13px}
  .pager>div{width:100%;justify-content:space-between}
  .pager button{font-size:14px;padding:9px 14px}
  .empty{padding:38px 18px;font-size:14px}
  .footnote{font-size:12px;line-height:1.7;text-align:left;margin:16px 3px}

  .mobile-table,.line-editor .mobile-table,.volume-editor .mobile-table{display:block;min-width:0;width:100%;font-size:14px}
  .mobile-table thead{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
  .mobile-table tbody{display:grid;gap:12px}
  .mobile-table tbody tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--line);border-radius:10px;background:#fff;overflow:hidden}
  .mobile-table tbody td{display:block;min-width:0;max-width:none;padding:10px 12px;border:0;overflow-wrap:anywhere}
  .mobile-table tbody td::before{content:attr(data-label);display:block;margin-bottom:4px;color:var(--muted);font-size:12px;font-weight:400}
  .mobile-table tbody td:first-child{grid-column:1/-1;background:#f6f8f3;border-bottom:1px solid var(--line)}
  .mobile-table tbody td.cell-actions{grid-column:1/-1;display:flex;justify-content:flex-end;border-top:1px solid var(--line);padding:8px 12px}
  .mobile-table tbody td.cell-actions::before{display:none}
  .mobile-table tbody td.cell-actions button{width:100%;font-size:14px}
  .mobile-table td small{font-size:12px}
  .mobile-table td button.record-link{font-size:15px;min-height:28px}
  #list .table-wrap{padding:0 14px;overflow:visible}
  .tag{font-size:12px;padding:4px 9px}

  .detail{width:100%;height:100%;height:100dvh;padding:0;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
  .detail-heading{position:sticky;top:0;z-index:2;background:var(--bg);border-bottom:1px solid var(--line);padding:max(12px,env(safe-area-inset-top)) 14px 12px}
  .detail-heading h2{font-size:18px;line-height:1.4}
  .detail-heading button{flex-shrink:0;font-size:14px}
  #detailBody{padding:14px 12px max(24px,env(safe-area-inset-bottom))}
  .actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .actions button{font-size:14px;min-height:46px;padding:9px 8px}
  .card{padding:15px 12px;margin-bottom:12px}
  .card h3{font-size:17px}
  .fields{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px 12px}
  .field small{font-size:12px;margin-bottom:4px}
  .field div{font-size:14px}
  .note{font-size:13px;line-height:1.65}
  .timeline{font-size:13px;padding-left:18px;overflow-wrap:anywhere}
  .timeline b{display:block}
  .inline-links button{width:100%;font-size:14px;white-space:normal;overflow-wrap:anywhere;text-align:left}
  .photos{gap:8px}
  .photo img{height:auto;aspect-ratio:1;display:block}
  .photo figcaption{font-size:12px}
  .file-list a{font-size:14px;min-height:44px}
  .upload-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  .upload-controls label{font-size:13px;min-width:0}
  .upload-controls select,.upload-controls input[type=text],.upload-controls input[type=file],.upload-controls .camera input{width:100%;max-width:none}
  .upload-controls input[type=file]{font-size:14px;padding:9px}
  .upload-controls label:has(input[type=file]),.camera-launch{grid-column:1/-1}
  .upload-controls .camera{padding:12px;border:1px solid #b9cfad;border-radius:8px;background:#edf3e4;color:var(--ink);font-weight:600}
  .camera-launch{font-size:15px;min-height:46px}
  .upload-status{font-size:13px;overflow-wrap:anywhere}

  dialog,dialog.camera-dialog{width:100%;max-width:100%;height:100%;height:100dvh;max-height:100%;max-height:100dvh;margin:0;border-radius:0;overscroll-behavior:contain}
  #editor[open]{display:flex;flex-direction:column;overflow:hidden}
  #editForm{display:flex;flex-direction:column;min-height:0;height:100%;overflow:hidden}
  dialog header{flex-shrink:0;gap:10px;padding:max(12px,env(safe-area-inset-top)) 14px 12px;background:#fff}
  dialog header h2{font-size:18px;line-height:1.45}
  dialog header button{flex-shrink:0;min-width:44px}
  #editBody{flex:1;min-height:0;overflow:auto;padding:18px 14px;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
  #editBody .form-grid{grid-template-columns:1fr;gap:16px}
  #editBody label{font-size:14px}
  #editBody input,#editBody select,#editBody textarea{font-size:16px}
  #editBody textarea{min-height:96px}
  dialog footer{flex-shrink:0;padding:12px 14px max(12px,env(safe-area-inset-bottom));background:#fff;gap:10px}
  #editor footer button{flex:1;min-height:48px;font-size:16px}
  #formError{flex-shrink:0;max-height:20vh;overflow:auto;padding:0 14px;margin:0 0 10px;font-size:13px}
  #formError:empty{display:none}
  .line-editor,.volume-editor{margin-top:24px}
  .volume-editor{padding:14px 10px}
  .volume-editor>label{max-width:none}
  .line-editor input,.line-editor .name-input,.volume-editor td input{min-width:0;width:100%;padding:10px}
  .volume-editor td:first-child{min-width:0}
  .mobile-table td[data-label="品名 *"]{grid-column:1/-1}
  #editBody .mobile-table td.cell-actions button{width:auto;min-width:44px;color:#ac4040}
  #addLine,#addDimension{width:100%;min-height:46px;margin-top:12px;font-size:15px}
  .volume-total{gap:10px}
  .volume-total label{max-width:none;width:100%}
  .volume-hint{font-size:13px}
  .camera-body{padding:14px;flex:1}
  .camera-dialog header h2{font-size:17px}
  .camera-dialog header button{font-size:13px}
  .camera-dialog footer button{flex:1 1 40%;font-size:14px;min-height:46px}
  .camera-dialog #cameraCapture{flex-basis:100%;font-size:16px}
  .camera-device,.camera-fields label{font-size:14px}
  #cameraVideo{max-height:35vh;max-height:35dvh}
  .auth-layer{overflow:auto;align-items:start;padding:max(20px,env(safe-area-inset-top)) 14px max(20px,env(safe-area-inset-bottom))}
  .auth-card{margin:auto 0;padding:24px 20px}
  .auth-card label{font-size:14px}
  .auth-card>p:not(.eyebrow){font-size:14px}
  .auth-card>button{font-size:16px;min-height:48px}
  #notice{width:calc(100% - 28px);max-width:440px;bottom:max(16px,env(safe-area-inset-bottom));padding:12px 16px;font-size:14px}
}
@media screen and (max-width:360px){
  .logo{font-size:13px}.logo small{display:none}.fields,.camera-fields{grid-template-columns:1fr}
  .filters{grid-template-columns:1fr 1fr}.filters select{grid-column:1/-1}
  .mobile-table tbody tr{grid-template-columns:1fr}
}

/*
 * Responsive editor dialog.
 * Keep the title and actions fixed while the form body owns vertical scrolling.
 * This also covers tablets and landscape phones whose CSS viewport is wider
 * than the phone-only breakpoint above.
 */
#editor[open]{
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
#editForm{
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto auto;
  width:100%;
  max-height:94vh;
  max-height:94dvh;
  min-height:0;
  overflow:hidden;
}
#editor header,#editor footer,#formError{min-width:0}
#editBody{
  min-height:0;
  overflow-x:hidden;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  touch-action:pan-y;
}
#editBody .form-grid{
  grid-template-columns:repeat(3,minmax(0,1fr));
}
#editBody label,#editBody input,#editBody select,#editBody textarea{
  min-width:0;
  max-width:100%;
}

@media screen and (max-width:1100px){
  #editor{width:min(900px,calc(100vw - 28px));max-height:calc(100dvh - 28px)}
  #editBody .form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media screen and (max-width:700px){
  #editor{width:100%;max-height:100dvh}
  #editBody .form-grid{grid-template-columns:minmax(0,1fr)}
}

/* Keep the tablet camera dialog stable while front and rear streams restart. */
.camera-source-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:end;gap:12px;margin-bottom:12px}
.camera-facing{min-width:0;margin:0;padding:0;border:0}
.camera-facing legend,.camera-device{font-size:12px;color:var(--muted)}
.camera-facing>div{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:5px}
.camera-facing button{min-height:40px;padding:8px 10px}
.camera-facing button.selected{border-color:var(--green);background:var(--green);color:#fff}
.camera-source-row .camera-device{margin:0}
.camera-preview-frame{position:relative;width:100%;height:min(44dvh,520px);min-height:260px;overflow:hidden;border-radius:10px;background:#13201a;contain:layout paint}
.camera-preview-frame #cameraVideo{position:absolute;inset:0;width:100%;height:100%;max-height:none;aspect-ratio:auto;object-fit:contain;border-radius:0;background:transparent}
.camera-preview-frame>span{position:absolute;inset:0;display:none;place-items:center;background:#13201ae6;color:#fff;font-weight:600;pointer-events:none}
.camera-preview-frame #cameraVideo.camera-switching+span{display:grid}

@media screen and (max-width:700px){
  .camera-source-row{grid-template-columns:minmax(0,1fr)}
  .camera-preview-frame{height:min(34dvh,360px);min-height:210px}
}

@media screen and (orientation:landscape) and (max-height:700px){
  .camera-preview-frame{height:min(38dvh,300px);min-height:180px}
}
