#hiveView{width:100%;max-width:680px;margin-inline:auto}
body.app-mode.hive-mode #portalBackBtn{width:min(100%,680px);margin-inline:auto}
body.app-mode #hiveView .app-header h2{font-size:34px;white-space:normal;overflow-wrap:anywhere;line-height:1.12}
#hiveView>.tabs{margin:12px 0 20px;gap:0;overflow:hidden;border:1px solid #eee8da;border-radius:24px;background:#fff;box-shadow:0 10px 28px #1c232d0e}
#hiveView .tab-btn{min-width:0;height:60px;min-height:60px;border:0;border-radius:0;padding:10px 8px;background:transparent;font-size:16px;gap:8px}
#hiveView .tab-btn + .tab-btn{border-left:1px solid #eceef2}
#hiveView .tab-btn svg{width:21px;height:21px;flex-basis:21px}
#hiveView .tab-btn.active{background:#fff7dc;color:#9a7000}
#hiveView .tab-btn:focus-visible{outline:3px solid #b7881c;outline-offset:-4px}
#hiveInfoTab{display:block}
#hiveInfoTab[data-fill-space] .hive-weight-tile,
#hiveInfoTab[data-fill-space] .hive-overview-tile,
#hiveInfoTab[data-fill-space] .hive-sync-card{min-height:var(--hive-info-card-height)}
.hive-weight-tile{position:relative;display:grid;grid-template-columns:48px minmax(0,1fr) 16px;align-items:center;gap:12px;width:100%;min-height:116px;padding:20px 18px;text-align:left;background:linear-gradient(135deg,#fffefb,#fff9e9);border:1px solid #e6d5a3;border-radius:24px;box-shadow:0 6px 24px #5e480608;color:#191e27;cursor:pointer;font:inherit}
.hive-weight-tile:focus-visible{outline:3px solid #ce9c21;outline-offset:3px}
.hive-weight-icon{display:grid;place-items:center;width:48px;height:54px;border-radius:17px;background:#fff1c5;color:#bc8b19;transform:scale(1.2);transform-origin:center}
.hive-weight-icon svg{width:30px;height:30px}
.hive-weight-copy{display:block;min-width:0}.hive-weight-label{padding-right:22px;font-size:14px;color:#727985}
.hive-weight-value-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px}
#hiveView #metricTotalWeight{font-size:clamp(28px,9vw,38px);font-weight:800;line-height:1.15;letter-spacing:-1px;white-space:nowrap;text-align:center}
#hiveView #metricTotalWeight.no-data{font-size:23px;white-space:normal;color:#8a919a}
.hive-weight-change{display:grid;justify-items:center;justify-self:end;align-self:center;max-width:118px;overflow-wrap:anywhere;text-align:center;gap:2px;padding:8px 10px;border-radius:12px;background:#f0f0ea;color:#6f6b59;font-size:12px;line-height:1.25}
.hive-weight-change.positive{color:#347247;background:#edf6e5}.hive-weight-change.negative{color:#ad5551;background:#fff0e8}
.hive-weight-change small{font-size:10px}.hive-weight-time,.hive-weight-hint{font-size:12px;color:#7d838d;line-height:1.4}
.hive-weight-arrow{color:#9a792f;font-size:27px}
.hive-reading-status{position:absolute;top:12px;right:14px;display:flex;align-items:center;color:#858b94;line-height:1}
.hive-reading-status svg{display:block;width:19px;height:19px}.hive-reading-status .online{color:#3b8a5b}
.hive-reading-status .connection-slash{display:none}.hive-reading-status .offline .connection-slash{display:block}
.hive-reading-notice{font-size:12px;color:#8c7b53;margin:7px 4px 2px;line-height:1.4}
.hive-weather-footer{margin:12px 4px 0;font-size:11px;overflow-wrap:anywhere}
.hive-overview-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:14px}
.hive-overview-tile{display:flex;align-items:center;gap:10px;min-width:0;min-height:116px;padding:17px 14px;background:#fff;border:1px solid #e8e8e4;border-radius:22px;box-shadow:0 5px 18px #1b243207}
.hive-overview-tile .metric-icon,.hive-sync-card .metric-icon{display:grid;place-items:center;flex:0 0 36px;width:36px;height:44px;border-radius:15px;background:#fff6d8;color:#c59a25}
.hive-overview-tile svg,.hive-sync-card svg{width:24px;height:24px}
.hive-overview-tile>div{min-width:0}.hive-overview-label{color:#7c838d;font-size:13px;line-height:1.4}
.hive-overview-value{font-size:24px;font-weight:780;line-height:1.3;overflow-wrap:anywhere;margin-top:5px}
#metricSignal{font-size:21px}.hive-overview-value.no-data{font-size:17px;color:#959ba4}
.hive-sync-card{display:grid;grid-template-columns:36px minmax(0,1fr);align-items:center;gap:10px;margin-top:12px;padding:17px 16px;background:#fff;border:1px solid #e8e8e4;border-radius:22px;box-shadow:0 5px 18px #1b243207}
#metricLastSync{display:block;font-size:18px;line-height:1.4;overflow-wrap:anywhere;margin-top:4px}
.hive-humidity{grid-column:1/-1;display:flex;align-items:center;gap:8px;border-top:1px solid #f0f0ec;padding-top:11px;margin-top:3px;color:#7c838d;font-size:13px}
.hive-humidity svg{width:18px;height:18px;color:#c59a25}.hive-humidity strong{color:#262c36;font-size:16px;margin-left:auto}
#hiveScaleTab{display:grid;gap:16px;min-width:0}
.hive-chart-card{min-width:0;margin-top:0}.hive-chart-card .chart-head{display:none}
.hive-chart-card .chart-summary{margin-top:4px}.hive-chart-card .chart-summary-label{font-size:12px}.hive-chart-card .chart-summary-value{font-size:24px;overflow-wrap:anywhere}
#chartPeriodPercent{display:block;font-size:12px;color:#7e858e;margin-top:5px}
.hive-chart-card .chart-summary-value.no-data{font-size:15px;line-height:1.4;overflow-wrap:normal}
.hive-chart-card .chart-control input[type="date"]{font-size:16px}
.hive-chart-surface{position:relative;margin-top:16px;min-width:0;border-radius:16px;overflow:hidden;background:#fffdf8}
#hiveWeightCanvas{display:block;width:100%;height:clamp(180px,26vh,260px);touch-action:pan-y pinch-zoom;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
#hiveWeightCanvas:focus-visible{outline:2px solid #b7881c;outline-offset:-2px}
.hive-chart-tooltip{position:absolute;z-index:2;max-width:calc(100% - 8px);padding:9px 11px;border-radius:11px;background:#2c2b27ed;color:#fff;font-size:12px;line-height:1.5;white-space:pre-line;pointer-events:none;box-shadow:0 4px 14px #0002}
.hive-chart-tools{display:none}
.hive-chart-tools button{min-width:42px;min-height:40px;padding:5px 11px;border:1px solid #e5dfd0;border-radius:12px;background:#fffcf4;color:#85651c;font:inherit;cursor:pointer}
.hive-chart-tools button:disabled{opacity:.38;cursor:default}
/* Keep the selected point available to screen readers without a visual footer. */
#hiveChartReadout{position:absolute;width:1px;height:1px;min-height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0}
.hive-chart-count{font-size:11px;color:#969ba3;margin-right:auto}
.hive-chart-empty{text-align:center;padding:32px 12px 28px;color:#7b828d;font-size:14px;line-height:1.5}
.hive-chart-empty p{margin:0 0 17px}.hive-chart-empty .btn{font-size:14px;min-height:44px;background:#fff7dd;border:1px solid #dfc172;color:#775616;box-shadow:none}
.hive-manage-scale{display:flex;align-items:center;gap:13px;width:100%;text-align:left;border:1px solid #e7e5dc;border-radius:20px;background:#fff;padding:18px 20px;color:#2b3038;font:inherit;cursor:pointer}
.hive-manage-scale>span{display:grid;gap:5px;flex:1}.hive-manage-scale small{color:#8a8f97;font-size:12px}.hive-manage-scale svg{width:24px;height:24px;color:#bb9023}.hive-manage-scale b{color:#bb9023;font-size:23px}
.hive-device-back{justify-self:start;border:0;background:none;color:#91712c;padding:7px 0;margin-bottom:12px;font:inherit;font-size:14px;cursor:pointer}
@media(max-width:430px){.hive-chart-card .chart-controls{grid-template-columns:minmax(0,1fr) 16px minmax(0,1fr)}.hive-chart-card .chart-apply{grid-column:1/-1;width:100%;font-size:15px}.hive-chart-card .chart-summary-item{padding:13px 7px}.hive-chart-card .chart-summary-value{font-size:20px}.hive-chart-card .chart-summary-label{font-size:11px}.hive-chart-card .chart-control{padding-inline:7px;grid-template-columns:15px minmax(0,1fr)}.hive-chart-card .chart-control input[type="date"]{font-size:16px}}
@media(max-width:374px){.hive-chart-card .chart-controls{grid-template-columns:minmax(0,1fr)}.hive-chart-card .chart-date-arrow{display:none}.hive-chart-card .chart-control{grid-template-columns:74px 15px minmax(0,1fr)}.hive-chart-card .chart-control .sr-only{position:static;width:auto;height:auto;margin:0;padding:0;overflow:visible;clip:auto;clip-path:none;white-space:normal;font-size:11px;color:#7c838d}}

/* Size the overview against the space left by mobile browser chrome.
   svh stays stable when Safari's bars expand; vh is the fallback. */
@media(max-width:640px){
  #hiveView{--hive-tile-min:clamp(72px,11vh,94px);--hive-value-size:clamp(20px,3.1vh,23px);--hive-weight-size:clamp(28px,4.6vh,32px)}
  body.app-mode.hive-mode #portalBackBtn{padding-top:env(safe-area-inset-top,0px);min-height:calc(36px + env(safe-area-inset-top,0px))}
  body.app-mode #hiveView>.app-header{min-height:0;padding:6px 2px 6px}
  body.app-mode #hiveView .app-header h2{font-size:28px}
  body.app-mode #hiveView .app-header p{font-size:13px;margin-top:3px}
  #hiveView>.tabs{margin:8px 0 12px;gap:0;border-radius:22px}
  #hiveView .tab-btn{height:56px;min-height:56px;font-size:15px}
  .hive-weight-tile{grid-template-columns:38px minmax(0,1fr) 12px;min-height:104px;padding:18px 14px;gap:10px;border-radius:20px}
  .hive-weight-icon{width:38px;height:42px;border-radius:14px}
  .hive-weight-icon svg{width:25px;height:25px}
  .hive-weight-value-row{gap:10px}
  #hiveView #metricTotalWeight{font-size:var(--hive-weight-size);line-height:1.1}
  #hiveView #metricTotalWeight.no-data{font-size:21px}
  .hive-weight-change{max-width:100px;padding:7px 8px;font-size:11px}
  .hive-weight-change small{font-size:10px}
  .hive-weight-arrow{font-size:24px}
  .hive-reading-status{top:10px;right:12px}
  .hive-reading-status svg{width:17px;height:17px}
  .hive-reading-notice{margin:4px 3px 0;line-height:1.3}
  .hive-weather-footer{margin-top:10px;font-size:11px}
  .hive-overview-grid{gap:8px;margin-top:8px}
  .hive-overview-tile{min-height:var(--hive-tile-min);padding:10px 12px;gap:8px;border-radius:18px}
  .hive-overview-tile .metric-icon,.hive-sync-card .metric-icon{flex-basis:32px;width:32px;height:36px;border-radius:12px}
  .hive-overview-tile svg,.hive-sync-card svg{width:21px;height:21px}
  .hive-overview-label{font-size:12px;line-height:1.3}
  .hive-overview-value{font-size:var(--hive-value-size);margin-top:3px;line-height:1.2}
  #metricSignal{font-size:clamp(18px,2.9vh,21px)}
  .hive-overview-value.no-data{font-size:15px}
  .hive-sync-card{grid-template-columns:32px minmax(0,1fr) auto;gap:8px;margin-top:8px;padding:10px 12px;border-radius:18px}
  #metricLastSync{font-size:15px;line-height:1.3;margin-top:2px}
  .hive-humidity{grid-column:auto;display:grid;grid-template-columns:16px auto;gap:3px 4px;border-top:0;border-left:1px solid #f0f0ec;padding:0 0 0 10px;margin:0;font-size:12px;line-height:1.3}
  .hive-humidity svg{width:16px;height:16px}
  .hive-humidity strong{grid-column:1/-1;justify-self:end;margin-left:0;font-size:14px;line-height:1.2}
}
@supports(height:1svh){
  @media(max-width:640px){
    #hiveView{--hive-tile-min:clamp(72px,11svh,94px);--hive-value-size:clamp(20px,3.1svh,23px);--hive-weight-size:clamp(28px,4.6svh,32px)}
    #metricSignal{font-size:clamp(18px,2.9svh,21px)}
  }
}
@media(max-width:359px){
  .hive-weight-tile{grid-template-columns:32px minmax(0,1fr) 12px;padding-inline:12px;gap:8px}
  .hive-weight-icon{width:32px;height:38px}
  #hiveView #metricTotalWeight{font-size:24px}
  .hive-weight-value-row{gap:7px}
  .hive-weight-change{max-width:86px;padding:6px;font-size:10px}
  .hive-weight-change small{font-size:9px}
  .hive-overview-tile{padding-inline:10px;gap:7px}
  .hive-overview-tile .metric-icon{flex-basis:28px;width:28px}
  #metricLastSync{font-size:14px}
}

/* Compact chart: date range, summary, and plot. */
@media(max-width:640px){
  #hiveScaleTab{gap:10px}
  .hive-chart-card{display:grid;grid-template-columns:minmax(0,1fr);gap:5px;padding:10px;border-radius:20px;
    grid-template-areas:"dates" "stats" "plot" "updated"}
  .hive-chart-card .chart-controls{grid-area:dates;margin:0}
  .hive-chart-card .chart-summary{grid-area:stats;margin:0}
  .hive-chart-card .chart-summary-item{padding:4px 6px}
  .hive-chart-card .chart-summary-label{font-size:11px;line-height:1.2}
  .hive-chart-card .chart-summary-value{font-size:20px;margin-top:3px}
  .hive-chart-card .chart-summary-value.no-data{font-size:15px}
  #chartPeriodPercent{margin-top:1px;line-height:1.2}
  .hive-chart-surface{grid-area:plot;margin:0;border-radius:12px}
  #hiveWeightCanvas{height:clamp(150px,22vh,205px)}
  .hive-chart-tools button{min-width:0;min-height:44px;padding:4px 5px;font-size:20px;line-height:1.15;border-radius:11px}
  #hiveZoomIn{grid-area:zoom-in}#hiveZoomOut{grid-area:zoom-out}
  #hiveZoomReset{grid-area:reset;font-size:12px}
  .hive-chart-empty{padding:22px 8px}
  .hive-manage-scale{padding:13px 14px;border-radius:18px}
}
@media(min-width:375px) and (max-width:640px){
  .hive-chart-card .chart-controls{grid-template-columns:minmax(0,1fr) 10px minmax(0,1fr) 68px;gap:4px}
  .hive-chart-card .chart-control{grid-template-columns:minmax(0,1fr);padding-inline:5px}
  .hive-chart-card .chart-control>svg{display:none}
  .hive-chart-card .chart-date-arrow{font-size:14px}
  .hive-chart-card .chart-apply{grid-column:auto;width:68px;padding-inline:4px;font-size:12px}
}
@supports(height:1svh){@media(max-width:640px){#hiveWeightCanvas{height:clamp(150px,22svh,205px)}}}

.hive-chart-updated{grid-area:updated;display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px 12px;color:#7c838d;font-size:11px;line-height:1.4;padding:8px 3px 3px}
.hive-chart-updated time{font-variant-numeric:tabular-nums}

/* Enlarge the reading while preserving room for longer numeric values. */
#hiveView #metricTotalWeight:not(.wide-weight):not(.no-data){font-size:clamp(32px,10vw,44px)}
@media(max-width:640px){#hiveView #metricTotalWeight:not(.wide-weight):not(.no-data){font-size:clamp(30px,9vw,36px)}}
@media(max-width:359px){#hiveView #metricTotalWeight:not(.wide-weight):not(.no-data){font-size:24px}}
