/* Mobile presentation only. Electrical models and stored projects are unchanged. */
@media screen and (max-width: 1024px) {
  html { -webkit-text-size-adjust:100%; }
  body { min-width:0; }
  aside, .shell, header, main, footer { width:100%; max-width:100%; min-width:0; }
  aside {
    position:sticky; top:0; z-index:3; height:auto;
    padding:10px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    overflow:visible; box-shadow:0 2px 8px #123c3b22;
  }
  .brand { display:inline-block; font-size:21px; line-height:1.2; }
  .brand small { font-size:7px; letter-spacing:1.5px; margin-top:2px; }
  aside .workspace, aside .aside-bottom { display:none; }
  nav {
    display:flex; flex-wrap:nowrap; align-items:stretch; gap:8px;
    max-width:100%; overflow-x:auto; overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch; margin-top:8px; padding:2px 2px 6px;
    scrollbar-width:thin;
  }
  .nav-group { display:flex; flex:none; gap:5px; }
  .nav-label { display:none; }
  nav button {
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    flex:none; gap:5px; min-width:76px; min-height:58px; max-width:130px;
    margin:0; padding:8px 10px; white-space:normal; text-align:center;
    font-size:12px; line-height:1.25;
  }
  nav button span { display:inline; margin:0; color:inherit; }
  nav button .nav-icon { display:block; width:24px; height:24px; font-size:22px; line-height:24px; }
  nav button .nav-icon svg { display:block; width:24px; height:24px; }
  nav button .nav-text { display:block; }
  .shell { margin-left:0; }
  header { gap:12px; min-height:0; padding:14px 16px; }
  .project-context { flex:1 1 100%; min-width:0; max-width:100%; }
  header>.actions { width:100%; }
  header>.actions button { flex:1 1 120px; }
  main { padding:20px 12px; min-height:50vh; }
  footer { padding:16px 12px calc(16px + env(safe-area-inset-bottom)); }
  h1 { font-size:26px; overflow-wrap:anywhere; }
  h2 { font-size:20px; overflow-wrap:anywhere; }
  h3 { font-size:17px; overflow-wrap:anywhere; }
  p, li, .reference, .subtle, .muted, .notice, .context-scope { overflow-wrap:anywhere; }
  .field { font-size:14px; }
  button, .button, select, input:not([type="checkbox"]):not([type="radio"]), summary {
    min-height:44px;
  }
  button, .button { touch-action:manipulation; }
  input, select, textarea { min-width:0; max-width:100%; font-size:16px; }
  input[type="checkbox"], input[type="radio"] {
    display:inline-block; width:24px; height:24px; min-width:24px;
    vertical-align:middle; margin:8px 8px 8px 0; padding:0; flex:none;
  }
  label:has(>input[type="checkbox"]), label:has(>input[type="radio"]) {
    display:flex; align-items:center; min-height:44px; gap:4px; line-height:1.4;
  }
  textarea { min-height:96px; resize:vertical; }
  .actions { gap:10px; }
  .actions button, .actions .button { max-width:100%; white-space:normal; }
  .grid2, .split, .tree-layout { grid-template-columns:minmax(0,1fr); }
  .stats { grid-template-columns:minmax(0,1fr); }
  .card, .stat, .recovery { min-width:0; padding:16px; }
  .topline, .section-head, .project, .load { min-width:0; flex-wrap:wrap; }
  .notice { padding:12px; margin:16px 0; font-size:13px; }
  .status-line { gap:7px; }
  .pill { max-width:100%; overflow-wrap:anywhere; }
  details { min-width:0; max-width:100%; }
  summary { padding:10px 0; cursor:pointer; line-height:1.5; }
  details[open]>summary { margin-bottom:8px; }
  .table-scroll, .mobile-scroll {
    width:100%; max-width:100%; min-width:0; overflow-x:auto;
    overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch;
  }
  .table-scroll table { min-width:520px; }
  .table-scroll .reference-grid { min-width:1050px; }
  .table-scroll .compact-bands { min-width:300px; }
  .card>table, .reference-group>table { display:block; max-width:100%; overflow-x:auto; }
  table { font-size:14px; }
  th { font-size:12px; }
  th, td { padding:10px; }
  .tree-canvas { max-width:100%; min-width:0; max-height:60vh; max-height:60dvh; padding:12px; }
  .tree-canvas .node-wrap { width:max-content; }
  .tree-node { min-width:185px; width:210px; max-width:240px; font-size:14px; }
  .tree-node small, .tree-edge, .center-label, .child-count { font-size:12px; }
  .tree-edge { min-height:44px; max-width:240px; padding:8px 10px; }
  .tree-canvas .toggle { min-height:44px; min-width:44px; }
  .branch { margin-left:8px; padding-left:10px; }
  .inspector { position:static; min-width:0; }
  .load-row .actions { justify-content:flex-start; }
  dialog {
    width:calc(100vw - 24px); max-width:640px; min-width:0;
    max-height:calc(100vh - 24px); max-height:calc(100dvh - 24px);
    padding:18px; margin:auto; overflow:auto; overscroll-behavior:contain;
    scroll-padding-bottom:80px;
  }
  dialog form, dialog fieldset { min-width:0; max-width:100%; }
  dialog .actions { padding-top:12px; }
  dialog .actions button { flex:1 1 110px; }
  #toast { left:12px; right:12px; bottom:calc(12px + env(safe-area-inset-bottom)); max-width:none; font-size:14px; }
  #toast:not(:empty) { padding:12px 16px; }
}
@media screen and (max-width:1024px) and (orientation:landscape) {
  aside { position:static; }
  .brand { display:none; }
  nav { margin-top:0; }
  nav button { min-height:48px; flex-direction:row; max-width:170px; }
  dialog { max-height:calc(100dvh - 12px); padding:14px; }
}
@media screen and (max-width:360px) {
  main { padding:16px 8px; }
  .card { padding:12px; }
  header { padding:12px; }
  h1 { font-size:24px; }
  nav button { min-width:72px; padding:8px; }
}
/* Safari native select can ignore min-height while using its compact appearance. */
@media screen and (max-width:1024px){
 select{-webkit-appearance:none;appearance:none;height:auto;min-height:44px;padding:12px 34px 12px 10px;background-image:linear-gradient(45deg,transparent 50%,#254f46 50%),linear-gradient(135deg,#254f46 50%,transparent 50%);background-position:calc(100% - 16px) 50%,calc(100% - 11px) 50%;background-size:5px 5px;background-repeat:no-repeat;}
 button{min-width:44px;}
}
/* Safari can paint a long project option beyond a narrow select's box. */
@media screen and (max-width:1024px){
 .project-context select { overflow:hidden; text-overflow:ellipsis; }
}
/* Prevent inherited desktop width:100% from overlapping mobile nav groups. */
@media screen and (max-width:1024px){nav button{width:auto;flex:0 0 auto}.nav-group{flex-shrink:0}}

@media print{.memory-print tr{break-inside:avoid;page-break-inside:avoid}.memory-print thead{display:table-header-group}.memory-print h3{break-after:avoid;page-break-after:avoid}.memory-print .table-scroll{overflow:visible}.memory-print table{width:100%;table-layout:auto}.memory-print td,.memory-print th{overflow-wrap:anywhere}}

@media print{.memory-print .distribution-table{table-layout:fixed;font-size:9pt}.memory-print .distribution-table td,.memory-print .distribution-table th{overflow-wrap:normal;word-break:normal;white-space:normal;padding:6px}.memory-print .distribution-table td:nth-child(2),.memory-print .distribution-table td:nth-child(3),.memory-print .distribution-table td:nth-child(4){white-space:nowrap}.memory-print .table-scroll{display:block;max-height:none;overflow:visible!important}.memory-print table{min-width:0!important}.memory-print h3{margin-top:18px}}

@media print{.memory-print .loads-print-table{table-layout:fixed;font-size:9pt}.memory-print .loads-print-table td,.memory-print .loads-print-table th{overflow-wrap:normal;word-break:normal;padding:6px}.memory-print .loads-print-table td:nth-child(2),.memory-print .loads-print-table td:nth-child(3),.memory-print .loads-print-table td:nth-child(4){white-space:nowrap}}
