/* Responsive portal shell. Keep every field, table column and permission intact. */
.portal-menu-toggle,.portal-menu-close{display:none}
.portal-nav-backdrop[hidden],.portal-table-hint[hidden]{display:none}
.grid>* , .form-grid>*, .card-head>*, .section-head>*{min-width:0}
.card,.stat,.table-wrap,.wiki-content,.wiki-toc{min-width:0;max-width:100%}
.cards{grid-template-columns:repeat(auto-fit,minmax(min(310px,100%),1fr))}
.wiki-grid{grid-template-columns:repeat(auto-fit,minmax(min(290px,100%),1fr))}
.wiki-related{grid-template-columns:repeat(auto-fit,minmax(min(230px,100%),1fr))}
.wiki-category-admin{grid-template-columns:repeat(auto-fit,minmax(min(360px,100%),1fr))}
.content,.auth-card{overflow-wrap:anywhere}
.content pre{max-width:100%;overflow-x:auto}
.content pre[style*="pre-wrap"]{overflow-wrap:anywhere}
.hero a{color:var(--cyan-2);text-decoration:underline;text-underline-offset:3px}
.content img,.auth-card img,.content svg,.auth-card svg{max-width:100%;height:auto}
.sidebar{display:flex;flex-direction:column;overflow-y:auto;overscroll-behavior:contain}
.sidebar>.nav{flex-shrink:0}
.sidebar-foot{position:static;margin-top:auto;padding-top:28px;flex-shrink:0}
.portal-nav-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-shrink:0}
.topbar{gap:16px;min-height:72px;height:auto;padding-top:12px;padding-bottom:12px}
.topbar>div:first-of-type{min-width:0;overflow-wrap:anywhere}
.topbar>.inline{justify-content:flex-end}
.table-wrap{overscroll-behavior-inline:contain;-webkit-overflow-scrolling:touch}
.table-wrap:focus-visible,.wiki-content table:focus-visible{outline:3px solid #087fa0;outline-offset:3px}
.portal-table-hint{position:sticky;left:0;margin:0;padding:9px 12px;background:#edf8fb;color:#126b80;border-bottom:1px solid var(--line);font-size:12px;line-height:1.5}
.content :is(section,h2,h3)[id]{scroll-margin-top:calc(var(--portal-topbar-height,84px) + 16px)}

@media(max-width:1050px){
  .wiki-search{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media(max-width:960px){
  .content{padding:22px}
  .sidebar{height:auto;overflow:visible;padding:18px 20px}
  /* Full navigation remains available when JavaScript is absent. */
  .sidebar .nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:16px;overflow:visible}
  .sidebar .nav a{min-height:44px;display:flex;align-items:center;overflow-wrap:anywhere}
  .portal-nav-ready .sidebar{position:fixed;inset:0 auto 0 0;width:min(86vw,340px);height:100vh;height:100dvh;padding:0 16px 20px;overflow-y:auto;z-index:40;visibility:hidden;transform:translateX(-105%);transition:transform .18s ease;box-shadow:16px 0 48px rgba(0,0,0,.22)}
  .portal-nav-ready .sidebar .nav{grid-template-columns:minmax(0,1fr);margin-top:10px}
  .portal-nav-ready .portal-nav-heading{position:sticky;top:0;z-index:1;padding:16px 0;background:var(--navy)}
  .portal-nav-ready .portal-menu-toggle,.portal-nav-ready .portal-menu-close{display:inline-flex;align-items:center;gap:8px;min-height:44px;flex-shrink:0}
  .portal-menu-close{width:44px;padding:10px;font-size:25px;background:rgba(255,255,255,.1);color:#fff}
  .portal-menu-toggle{padding:10px 12px}
  .portal-menu-icon{font-size:21px;line-height:1}
  .portal-nav-ready .topbar{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;padding:12px 20px}
  .portal-nav-backdrop{position:fixed;inset:0;z-index:30;background:rgba(2,10,20,.55);touch-action:none}
  html.portal-nav-open,body.portal-nav-open{overflow:hidden}
  .portal-nav-open .sidebar{visibility:visible;transform:translateX(0)}
  .sidebar a:focus-visible,.sidebar button:focus-visible{outline:3px solid var(--cyan);outline-offset:2px}
  .grid.stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .section-head,.card-head{flex-wrap:wrap;gap:12px}
}

@media(max-width:760px){
  .wiki-search,.wiki-category-admin{grid-template-columns:minmax(0,1fr)}
  .wiki-search-query{grid-column:auto}
  .wiki-editor-language>div:first-child,.wiki-editor-actions{flex-wrap:wrap}
}

@media(max-width:620px){
  .content{padding:16px 12px 28px}
  .hero{padding:22px 18px}
  .hero h1{font-size:25px;line-height:1.2}
  .hero p{line-height:1.55}
  .card{padding:16px}
  .grid,.form-grid{gap:14px}
  .grid.stats,.form-grid,.cards,.wiki-grid{grid-template-columns:minmax(0,1fr)}
  .stat{padding:17px}
  .section{margin-top:24px}
  .section-head{align-items:flex-start;flex-direction:column;gap:8px}
  .section h2{line-height:1.35}
  .card-head{align-items:flex-start}
  .metric{gap:12px;align-items:flex-start}
  .metric>*{min-width:0}
  .metric>:last-child{text-align:right}
  .badge{max-width:100%;white-space:normal;overflow-wrap:anywhere;line-height:1.4}
  .topbar{padding:12px;align-items:flex-start;flex-wrap:wrap}
  .portal-nav-ready .topbar{padding:12px;gap:8px;grid-template-columns:44px minmax(0,1fr) auto;align-items:center}
  .portal-menu-toggle{width:44px;padding:10px}
  .portal-menu-label{display:none}
  .topbar .inline{gap:6px}
  .portal-nav-ready .topbar:has(>.inline>.button:nth-child(2))>.inline{grid-column:1/-1;justify-content:flex-start}
  .topbar .button{padding:10px;font-size:12px}
  .topbar small{font-size:12px;line-height:1.4;margin-top:3px}
  label{font-size:13px;line-height:1.45}
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea{font-size:16px;min-height:44px;min-width:0;max-width:100%}
  textarea{line-height:1.5}
  .module-picker .choices__inner,.module-picker .choices__list--dropdown .choices__item{font-size:16px}
  .module-picker .choices__button{min-width:44px;min-height:44px}
  input[type=checkbox],input[type=radio]{flex-shrink:0}
  .button,button{min-height:44px;max-width:100%;white-space:normal;line-height:1.4;text-align:center;overflow-wrap:anywhere}
  .inline,.actions{min-width:0;align-items:stretch}
  .inline>form,.actions>form{min-width:0;max-width:100%}
  form.inline>input:not([type=hidden]):not([type=checkbox]):not([type=radio]),form.inline>select{flex:1 1 160px}
  form.inline>button{flex:1 1 auto}
  .toggle-row label,.checkbox{min-height:44px}
  .backup-row{align-items:stretch;flex-direction:column}
  .backup-row .actions{justify-content:flex-start}
  .table-wrap th,.table-wrap td{min-width:7.5rem;padding:12px;line-height:1.5}
  .table-wrap input,.table-wrap select{width:100%}
  .table-wrap .inline{min-width:150px}
  .table-wrap .button,.table-wrap button{font-size:13px}
  .alert{padding:12px;line-height:1.5}
  .auth-shell{min-height:100vh;min-height:100svh;padding:20px 14px}
  .auth-card{padding:24px 22px}
  .auth-card h1{font-size:25px;line-height:1.25}
  .auth-card p{line-height:1.55}
  .auth-card .inline{flex-wrap:wrap}
  .wiki-content{padding:18px;font-size:15px}
  .wiki-content h2{font-size:21px}
  .wiki-article-head h1{font-size:28px}
  .wiki-toc{padding:16px}
  .wiki-language{flex-wrap:wrap}
  .wiki-language a,.wiki-categories a,.wiki-toc a,.wiki-read-more{min-height:44px;display:flex;align-items:center}
  .hero p a{min-height:44px;display:inline-flex;align-items:center}
}

@media(prefers-reduced-motion:reduce){.portal-nav-ready .sidebar{transition:none}}
