:root{color-scheme:dark;--bg:#14191f;--panel:#202831;--line:#38434f;--accent:#eec642;--text:#e9edf2}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:16px/1.5 system-ui,sans-serif}main{max-width:920px;margin:auto;padding:28px 20px 50px}header{padding:12px 0 22px}.eyebrow{color:var(--accent);font-size:12px;letter-spacing:.18em;font-weight:700}h1{font-size:clamp(30px,5vw,48px);margin:6px 0}h2{font-size:19px;margin:0 0 12px}p{color:#c1cbd5;margin:8px 0}section,.notice{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:20px;margin:14px 0}.notice{border-left:4px solid var(--accent);font-size:14px}.actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin:12px 0}button,select,input{font:inherit;border:1px solid var(--line);border-radius:6px;padding:9px 12px;max-width:100%;background:#10161c;color:var(--text)}button{background:var(--accent);color:#171a1d;font-weight:650;cursor:pointer}button.danger{background:#efac9f}button:disabled{opacity:.4;cursor:not-allowed}pre{white-space:pre-wrap;overflow-wrap:anywhere;background:#10161c;padding:12px;border-radius:6px;font-size:13px;max-height:300px;overflow:auto}progress{width:100%;accent-color:var(--accent)}footer{font-size:12px;color:#aab7c2}.fileRow{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px solid var(--line)}.fileRow span{flex:1;overflow-wrap:anywhere}.fileRow button{font-size:12px;padding:5px 8px}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid white;outline-offset:2px}

/* Shared navigation and operation status. */
a{color:var(--accent)}
.dashboard-header{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.header-nav{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.header-nav form{margin:0}
.nav-link{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--line);border-radius:8px;padding:8px 12px;text-decoration:none;font-weight:650}
.nav-link:hover{border-color:var(--accent)}
.nav-link:focus-visible,summary:focus-visible{outline:2px solid white;outline-offset:3px}
.operation-status{padding:10px 14px;margin:0}
.status-line{display:flex;align-items:center;gap:12px}
.status-line p{flex:1;min-width:0;overflow-wrap:anywhere;margin:0 0 4px}
.status-line progress{width:40%}
summary{cursor:pointer;color:#c1cbd5;font-size:14px}
.help-page section{margin:14px 0}
.help-page li{margin:6px 0}
.help-page h2{color:var(--accent)}

/* Desktop: reserve the actual header, status and footer heights before sizing
   the two equal grid rows. No viewport-width floor or content-driven row growth.
   Cap the grid height so every tile is at least 30% wider than it is tall. */
main:has(.dashboard){
  --gap:clamp(8px,1.3vh,14px);
  --log-extra:188px;
  width:100%;
  max-width:1600px;
  height:100dvh;
  margin:auto;
  padding:clamp(8px,1.5vh,18px) clamp(12px,2vw,28px);
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto auto;
  gap:var(--gap);
  container-type:inline-size;
}
main:has(.dashboard)>.dashboard-header{padding:0}
main:has(.dashboard) h1{font-size:clamp(24px,4vh,42px);line-height:1.15;margin:3px 0}
main:has(.dashboard)>footer{line-height:1.3}
.dashboard{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  grid-template-rows:repeat(2,minmax(0,1fr));
  gap:var(--gap);
  min-height:0;
  max-height:calc((100cqw - var(--gap)) * 10 / 13 + var(--gap));
  align-self:stretch;
}
.tile{
  margin:0;min-width:0;min-height:0;
  display:flex;flex-direction:column;
  padding:clamp(8px,1.6vh,20px);
  overflow:auto;overflow-wrap:anywhere;
}
.tile-heading{
  display:flex;flex-direction:column;align-items:center;text-align:center;
  gap:clamp(4px,0.9vh,10px);margin:0 0 6px;flex:none;
}
.tile-heading .tile-icon{
  display:block;flex:none;color:var(--accent);
  width:clamp(36px,8vh,76px);height:clamp(36px,8vh,76px);
}
.tile h2{font-size:clamp(16px,2.4vh,22px);line-height:1.2;margin:0}
.tile .actions{justify-content:center;gap:6px;margin:5px 0;flex:none}
.tile button,.tile input,.tile select{min-width:0;max-width:100%;font-size:clamp(13px,1.85vh,16px);padding:6px 9px}
.tile button{white-space:normal;overflow-wrap:anywhere}
.tile #device{
  flex:1 1 90px;min-height:44px;max-height:135px;
  margin:4px 0 0;padding:8px;overflow:auto;
}
.tile #fsList{max-height:150px;overflow:auto}
.tile #releaseInfo,.tile #fsInfo{font-size:13px;text-align:center;margin:4px 0}
.admin-access{align-self:center;margin:auto 0;max-width:100%;text-align:center}
#adminPanel{min-height:0;overflow:auto}
/* Opening the log adds space below the original viewport, rather than
   shrinking the dashboard. The log retains its own bounded scroll area. */
main:has(.dashboard):has(.operation-status details[open]){height:calc(100dvh + var(--log-extra))}
.operation-status #log{height:180px;max-height:180px;margin:8px 0 0}

/* Short desktop windows use horizontal headings to preserve space for controls. */
@media(max-height:800px) and (min-width:651px){
  .tile-heading{flex-direction:row;justify-content:center;gap:10px}
  .tile-heading .tile-icon{width:clamp(32px,6.5vh,52px);height:clamp(32px,6.5vh,52px)}
  .tile .actions{margin:4px 0}
}
/* Phones and extremely short windows use natural document flow for accessibility. */
@media(max-width:650px),(max-height:420px){
  main:has(.dashboard),main:has(.dashboard):has(.operation-status details[open]){
    height:auto;min-height:100dvh;display:flex;flex-direction:column;
  }
  .dashboard{max-height:none;grid-template-rows:auto}
  .tile{min-height:180px;overflow:visible}
  .tile #device{flex:none;min-height:90px}
  #adminPanel{overflow:visible}
}
@media(max-width:650px){
  .dashboard{grid-template-columns:minmax(0,1fr)}
  .tile{min-height:max(180px,calc(100cqw * 7 / 13))}
  .status-line{flex-direction:column;align-items:stretch;gap:4px}
  .status-line progress{width:100%}
}

/* Source switching must hide flex action rows as well as their controls. */
.tile .actions[hidden]{display:none}
#serverSource select,#localImage{width:min(100%,380px)}

/* Highlight the maintenance-mode prerequisite without changing dashboard layout. */
.maintenance-warning{display:flex;align-items:flex-start;gap:12px;border-color:var(--accent);color:var(--accent);background:#29251c;padding:14px;margin:12px 0;font-size:16px}
.maintenance-warning>span{font-size:24px;line-height:1.2;flex:none}
.maintenance-warning p{color:inherit;margin:5px 0 0}

#cloudBackupSource[hidden]{display:none}
#cloudRestore{width:min(100%,380px)}
#cloudInfo{font-size:13px;text-align:center;margin:4px 0}

/* Shared responsive source tabs: equal columns, no fixed width or height. */
.source-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;min-width:0;flex:none;margin:5px 0;border-bottom:1px solid var(--line)}
.tile .source-tabs button{width:100%;min-width:0;min-height:32px;border:0;border-bottom:2px solid transparent;border-radius:6px 6px 0 0;background:#171e25;color:#aab7c2;text-align:center;font-weight:600;line-height:1.2;padding:6px 8px}
.tile .source-tabs button[aria-pressed="true"]{background:#30363d;color:var(--accent);border-bottom-color:var(--accent)}
.tile .source-tabs button:hover:not(:disabled){color:var(--accent)}
.tile .source-tabs button:focus-visible{outline-offset:-3px}

/* Help illustrations keep their intrinsic proportions and shrink on narrow screens. */
.maintenance-warning>div{flex:1;min-width:0}
.maintenance-warning .warning-image{display:block;max-width:100%;height:auto;margin:12px auto 0;border-radius:4px}

/* Center the installation title and its shared option as one responsive group. */
.install-heading{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:6px 16px;min-width:0}
.backup-first{display:inline-flex;align-items:center;gap:6px;font-size:clamp(12px,1.7vh,15px);white-space:nowrap;cursor:pointer}
.tile .backup-first input{appearance:auto;accent-color:var(--accent);width:16px;height:16px;padding:0;margin:0;flex:none;cursor:pointer}
.backup-first:has(input:disabled){opacity:.5;cursor:not-allowed}

/* A connected button is a status indicator, not an available action. */
#connect.connected:disabled{background:#45c77b;color:#10271a;border-color:#65df94;box-shadow:0 0 9px rgba(69,199,123,.48);opacity:1;cursor:default}

/* Black at rest; color/glow only during an operation or pending error acknowledgement. */
#progress{--progress-color:#10161c;--progress-glow:transparent;appearance:none;-webkit-appearance:none;height:10px;border:0;border-radius:6px;background:#10161c;accent-color:var(--progress-color)}
#progress.active{--progress-color:#45c77b;--progress-glow:rgba(69,199,123,.48)}
#progress.warning{--progress-color:var(--accent);--progress-glow:rgba(238,198,66,.48)}
#progress::-webkit-progress-bar{background:#10161c;border-radius:6px}
#progress::-webkit-progress-value{background:var(--progress-color);border-radius:6px;box-shadow:0 0 8px var(--progress-glow)}
#progress::-moz-progress-bar{background:var(--progress-color);border-radius:6px;box-shadow:0 0 8px var(--progress-glow)}
/* At zero progress, show the warning on the track itself. */
#progress.warning{box-shadow:0 0 4px var(--progress-glow)}

/* Global connection controls do not consume a management tile. */
main:has(.dashboard){grid-template-rows:auto auto minmax(0,1fr) auto auto}
.connection-banner{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:0;padding:8px 16px}
.connection-label{display:flex;align-items:center;gap:12px}
.connection-label svg{width:36px;height:36px;flex:none}
.connection-label h2,.connection-label p{margin:0}
.connection-label p{font-size:12px}
.connection-banner .actions{margin:0}
.tile h3{font-size:14px;margin:6px 0;text-align:center}
.tile .server-actions{border-bottom:1px solid var(--line);padding-bottom:8px}
.profile-tile{opacity:.65;text-align:center}
.profile-tile p{margin:5px 0}
.coming-soon{margin-top:auto!important;font-size:13px}
dialog{color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:12px;width:min(680px,calc(100% - 24px));max-height:85dvh;overflow:auto;padding:18px}
dialog::backdrop{background:#000a}
.dialog-heading{display:flex;justify-content:space-between;align-items:center;gap:12px}
.dialog-heading h2{margin:0}
.release-group{padding:10px;margin:10px 0}
.release-group h3{margin:0;color:var(--accent)}
#publishFiles{display:block;width:100%;margin:8px 0}
#publishSelection,#publishStatus,#releaseBrowseStatus{overflow-wrap:anywhere}
@media(max-width:650px),(max-height:420px){.connection-banner{align-items:flex-start}.connection-banner .actions{width:100%}.tile #device{flex:none}}
