/* Laptop, short and narrow windows. */
/* Allow long names and tables to shrink within their grid/flex parent. */
.app-main,.card,.card-body,.brand,.summary,.hunt-side{min-width:0}
.brand h1,.bi-name,.bi-meta,.forecast-note{overflow-wrap:anywhere}
.table-scroll{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
.forecast-note{font-size:.75rem;line-height:1.5;color:var(--ink-2);margin:0 0 .65rem}
.incomplete-summary{justify-content:flex-start;gap:.75rem}
.incomplete-summary h2{font-size:1.6rem;line-height:1.2}
.incomplete-summary p,.incomplete-summary li{font-size:.875rem;line-height:1.6}
.incomplete-summary ul{padding-left:1.25rem;margin:0}
/* Laptop-height windows: a denser layout so everything still fits */
@media (max-height:50rem) and (min-width:68.8125rem){
  .top{padding:.625rem 0 .5rem}
  .brand h1{font-size:1.125rem}
  .brand p{margin-top:2px}
  .btn{min-height:2rem;padding-top:.1875rem;padding-bottom:.1875rem}
  .subtabs{margin-bottom:.5rem;padding:.1875rem}
  .subtab{padding:.25rem .75rem}
  .inp,.money{min-height:2rem}
  .inp{padding:.25rem .625rem}
  .money input{padding:.25rem .625rem .25rem .375rem}
  .field label{margin-bottom:.1875rem}
  .estnote{padding:.375rem .75rem;font-size:.7812rem;margin-bottom:.5rem}
  .seg button{font-size:.75rem;padding:.25rem .5rem}
  .card-head{padding:.75rem 1.125rem 0}
  .card-body{padding:.5rem 1.125rem .875rem}
  .mrow{padding:.25rem 0}
  .mrow .lbl{font-size:.8438rem}
  .fields{gap:.625rem .875rem;grid-template-columns:repeat(auto-fit,minmax(min(100%,9.375rem),1fr))}
  .mrow{padding:.1875rem 0}
  th,td{padding:.4375rem .875rem}
  .citem{padding:2px 0}
  .field .hint{margin-top:2px}
  .group + .group{margin-top:.625rem;padding-top:.5rem}
  .bh{margin-bottom:.5rem}
  .editor-pane{gap:.75rem}
  .panel{padding:1rem 1.25rem}
  .hero{padding-bottom:.5rem}
  .hero .big{font-size:2rem;padding:0}
  .pill{font-size:.75rem}
  .stats{padding:.5rem 0;gap:.375rem 1.125rem}
  .stat .v{font-size:1.0625rem}
  .stat .s,.stat .k{font-size:.7188rem}
  .target{margin-top:.625rem;padding:.5rem .75rem}
  .target .v{font-size:1.25rem}
  .panel > .viz{margin-top:.625rem;min-height:9.375rem}
  .target p{font-size:.75rem}
  .viz-body{margin-top:.375rem}
  .cgroups{gap:1rem}
}

/* Short windows: keep the columns but let the page scroll */
@media (max-height:37.4375rem) and (min-width:68.8125rem){
  #app{height:auto;min-height:100vh}
  .card-body,.panel,.viz-body,.editor-pane{overflow:visible}
  .panel > .viz{flex:none;min-height:0}
  .chartwrap{position:relative;inset:auto}
  .budget,.hunt,.cgroups,.budgets-screen{align-items:start}
  .dash{grid-template-rows:none;align-items:start}
  .summary{position:sticky;top:.75rem}
}

/* Narrow screens: one column, normal page scrolling, the summary becomes a sub-tab and the
   icon rail becomes the bottom dock. Keep this width in step with NARROW in views/chrome.js. */
@media (max-width:68.75rem){
  #app{height:auto;min-height:100vh}
  .card-body,.panel,.viz-body,.editor-pane{overflow:visible}
  .panel > .viz{flex:none;min-height:0}
  .chartwrap{position:relative;inset:auto}
  .budget,.hunt,.cgroups,.budgets-screen,.dash{grid-template-columns:minmax(0,1fr)}
  .dash{grid-template-rows:none}
  .card-body.split{grid-template-columns:minmax(0,1fr)}
  .listing-list{border-right:0;border-bottom:1px solid var(--line);max-height:13rem}
  .globe-viewport{width:13rem}
  .subtabs{flex-wrap:wrap}
  .subtab.narrow-only{display:inline-block}
  .budget:not(.show-summary) .summary{display:none}
  .budget.show-summary .editor-pane{display:none}
  /* Room at the bottom for the dock, and none when the page has no rail. */
  #app{padding:0 1.125rem calc(6.25rem + env(safe-area-inset-bottom,0px))}
  #app.no-rail{padding:0 1.125rem 1.5rem}
  .budget-item{flex-wrap:wrap}
  .bi-fig{align-items:flex-start}
  .top{padding:1.25rem 0 .875rem}
  .brand h1{font-size:1.1875rem}
  .brand p{font-size:.6875rem;line-height:1.5}
  .savebar{width:100%}
  .savebar .status{width:100%;margin:0 0 2px}
  .sidebar{top:auto;bottom:calc(.625rem + env(safe-area-inset-bottom,0px));left:.75rem;right:.75rem;width:auto;height:4.625rem;padding:.3125rem;border-radius:1.4375rem;border:1px solid transparent;background:var(--grain) padding-box,var(--pane-strong) padding-box,linear-gradient(160deg,var(--rim-a),var(--rim) 30%,var(--rim) 70%,var(--rim-b)) border-box;backdrop-filter:blur(1.625rem);-webkit-backdrop-filter:blur(1.625rem)}
  .rail-logo{display:none}
  .tabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:2px}
  .tab{padding:.5rem 2px;gap:.3125rem;min-height:3.875rem;flex-direction:column}
  .tab span{position:static;white-space:normal;opacity:1;visibility:visible;background:none;color:inherit;padding:0;font-size:.5625rem;line-height:1.2;text-align:center}
  /* The dock: the glider runs along its bottom edge. */
  .tabs>.glide-track{left:0;right:0;top:auto;bottom:-.25rem;width:auto;height:1px;background:linear-gradient(90deg,transparent 0%,var(--glide-track) 50%,transparent 100%)}
  .tabs>.glide-thumb{left:0;top:auto;bottom:-.25rem;height:1px;width:var(--gw,3rem);transform:translateX(var(--gx,0));background:linear-gradient(90deg,transparent 0%,var(--glide) 50%,transparent 100%)}
  .tabs>.glide-thumb::before{height:300%;width:60%;top:auto;left:50%;bottom:0;transform:translateX(-50%)}
  .tabs>.glide-thumb::after{left:0;bottom:0;width:100%;height:3rem;background:linear-gradient(0deg,color-mix(in srgb,var(--glide) 13%,transparent) 0%,transparent 100%)}
  .card{border-radius:1.25rem}
  .card-head{padding:1rem 1.125rem 0}
  .card-body{padding:.625rem 1.125rem 1.125rem}
  .panel{padding:1.125rem}
  .hero .big{font-size:2.5rem}
  .about{right:1rem;top:4rem}
  .toast{bottom:calc(6rem + env(safe-area-inset-bottom,0px))}
  /* Safe areas, the stacking order of the globe, and controls that need to wrap. */
  #app,#app.no-rail{padding-left:max(1.125rem,env(safe-area-inset-left));padding-right:max(1.125rem,env(safe-area-inset-right))}
  .top{flex-wrap:nowrap;align-items:flex-start;gap:.75rem}
  .savebar{width:auto;flex:none;flex-wrap:nowrap}
  .savebar .status{width:auto;margin:0}
  .brand{flex:1}
  .globe-stage{order:1;min-height:15rem}
  .budgets-panel{order:0}
  .budget,.hunt,.dash,.cgroups{gap:1rem}
  .summary{min-height:20rem}
  .card-body.split{overflow:visible}
  .listing-detail{overflow:visible}
  .listing-detail .lt{flex-wrap:wrap}
  .listing-detail .lt>.inp{flex:1 1 12rem}
  .status-pick{flex:1 1 10rem}
  .listing-detail .lstatus{max-width:none;width:100%}
  /* Budget settings shrinks to a gear on the same row as the sub-tabs. The words stay in
     the button for screen readers, just not on screen. */
  .view-top{align-items:flex-start;gap:.5rem}
  .subtabs{flex:1 1 0;min-width:0;margin:0}
  .subtab{flex:1 0 auto}
  .view-top>.menu-wrap{flex:none}
  #settings-btn{width:2.75rem;height:2.75rem;min-height:2.75rem;padding:0}
  #settings-btn .ui-icon{width:1.25rem;height:1.25rem}
  #settings-btn .settings-label{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  #settings-btn .settings-chevron{display:none}
  .about{max-height:calc(100dvh - 9rem)}
}

/* Touch controls stay comfortable on tablets, including landscape iPads. A 1rem
   input font also avoids Safari zooming into each small field on focus. */
@media (pointer:coarse), (max-width:68.75rem){
  .btn,.btn.small,.opt,.subtab,.combo-option,.menu button{min-height:2.75rem}
  .inp,.money,.money input{min-height:2.75rem;font-size:1rem}
  .mrow .lbl,.ctext{font-size:1rem}
  input[type="range"]{min-height:2rem}
  .icon{width:2.75rem;height:2.75rem}
  .mrow{grid-template-columns:minmax(0,1fr) 6.5rem 2.75rem;gap:.25rem .4rem}
  .mrow input[type="range"]{grid-column:1 / 3;grid-row:2}
  .orow{grid-template-columns:minmax(0,1fr) 6.5rem 2.75rem}
  .orow select{grid-column:1 / 3;grid-row:2;margin-top:.25rem}
  .orow .chk{grid-column:1 / 4;grid-row:3}
  .citem{grid-template-columns:1.5rem minmax(0,1fr) 2.75rem}
  .area{grid-template-columns:minmax(0,1fr) 2.75rem}
  .lrow{min-height:2.75rem}
  .opt{align-items:center}
}
/* Phones: tighter sub-tabs, so the five fit in two rows beside the settings gear. */
@media(max-width:30rem){
  /* Beside the account button there is only room for the link; the red dot says the rest. */
  .status-word{display:none}
  .subtab{padding:.25rem .5rem;font-size:.8125rem}
}
@media(max-width:25rem){
  .card-head,.card-body,.panel{padding-left:.875rem;padding-right:.875rem}
  .mrow{grid-template-columns:minmax(0,1fr) 6rem 2.75rem}
  .mrow:not(.orow) .lblwrap{grid-column:1 / 4}
  .mrow:not(.orow) .money{grid-column:2;grid-row:2}
  .mrow:not(.orow) input[type="range"]{grid-column:1;grid-row:2}
  .mrow:not(.orow)>.icon{grid-column:3;grid-row:2}
  .orow .lblwrap{grid-column:1 / 3}
  .orow .money,.orow.computed .calc-val{grid-column:1 / 3;grid-row:2}
  .orow select{grid-column:1 / 4;grid-row:3}
  .orow .chk{grid-column:1 / 4;grid-row:4}
  .lr-status{max-width:4.5rem}
  .brand h1.wordmark img{height:auto;width:100%;max-width:11.5625rem}
  .stats{column-gap:.75rem}
}

@media (prefers-reduced-motion:no-preference){
  .btn,.subtab,.icon,.inp,.money,.citem,.seg button{transition:background-color .2s ease,border-color .2s ease,color .2s ease,box-shadow .2s ease,transform .2s ease}
  .tab{transition:color .3s ease-in-out}
  .ui-icon{transition:transform .25s cubic-bezier(.2,.8,.2,1)}
  /* One movement for every rail icon. They used to lift and tilt, except Compare which
     only zoomed and Checklist which did something else again, so hovering down the rail
     was three different animations. */
  .tab:hover .ui-icon,.tab:focus-visible .ui-icon{transform:scale(1.12)}
  .btn:not(:disabled):hover{transform:translateY(-1px)}
  .btn.ghost:not(:disabled):hover,.btn.danger-solid:not(:disabled):hover{box-shadow:0 .1875rem .625rem color-mix(in srgb,var(--ink) 8%,transparent)}
  .btn:not(:disabled):active,.tab:active{transform:scale(.98)}
  .progress div,.bar .f{transition:width .35s ease}
  .view-enter{animation:view-enter .32s cubic-bezier(.2,.8,.2,1) both}
  .toast{animation:toast-enter .22s ease-out both}
  .intro .sidebar{animation:glass-slide-left .92s var(--e-out) .05s both}
  .intro .brand{animation:glass-rise .8s var(--e-out) .14s both}
  .intro .savebar{animation:glass-rise .7s var(--e-out) .3s both}
  .intro .editor,.intro .hunt > .card,.intro .compare,.intro .cgroups{animation:glass-rise .9s var(--e-out) .4s both}
  .intro .budgets-panel{animation:glass-rise .9s var(--e-out) .3s both}
  .intro .globe-stage{animation:glass-slide-right .95s var(--e-out) .4s both}
  .intro .summary,.intro .hunt-side{animation:glass-slide-right .95s var(--e-out) .45s both}
  .intro .panel{position:relative}
  .intro .panel::after{content:"";pointer-events:none;position:absolute;inset:0 auto 0 0;width:38%;background:linear-gradient(100deg,transparent,color-mix(in srgb,var(--paper) 70%,transparent),transparent);animation:glass-sheen 1.15s var(--e-soft) 1.6s both}
  .chart-reveal .chart-line{stroke-dasharray:1;animation:balance-draw 1.6s var(--e-pen) .15s both}
  .chart-reveal .chart-area{animation:balance-fill 1.42s var(--e-pen) .37s both}
  @keyframes view-enter{from{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}
  @keyframes toast-enter{from{opacity:0;translate:0 .5rem}to{opacity:1;translate:0 0}}
  @keyframes glass-rise{from{opacity:0;transform:translateY(.875rem)}to{opacity:1;transform:none}}
  @keyframes glass-slide-left{from{opacity:0;transform:translateX(-1.625rem)}to{opacity:1;transform:none}}
  @keyframes glass-slide-right{from{opacity:0;transform:translateX(1.875rem) scale(.985)}to{opacity:1;transform:none}}
  @keyframes glass-sheen{from{transform:translateX(-150%) skewX(-18deg)}to{transform:translateX(360%) skewX(-18deg)}}
  @keyframes balance-draw{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}
  @keyframes balance-fill{from{clip-path:inset(0 100% 0 0)}to{clip-path:inset(0)}}
}
@media print{
  .bg-glows,.bg-icons,.sidebar{display:none!important}
  body{background:white}
  #app{height:auto;display:block;padding:0}
  .card-body,.panel,.editor-pane{overflow:visible}
  .budget,.hunt,.cgroups{display:block}
  .savebar,.toolbar,.subtabs,.addrow,.icon,input[type="range"],.linkbtn,.about,.toast{display:none!important}
  .card{background:white;backdrop-filter:none;break-inside:avoid;margin-bottom:.75rem}
}
