/* Keep tablet content readable in both orientations. */
@media(min-width:581px) and (max-width:1100px),(min-width:581px) and (hover:none) and (pointer:coarse){
  html{height:auto;overflow-x:hidden;overflow-y:auto}
  body[data-theme]{--hero-space:clamp(104px,16dvh,176px);--layout-gap:14px;--page-gap:16px;--tablet-overview-height:clamp(250px,26vw,280px);--tablet-daily-height:clamp(280px,24dvh,310px);--tablet-links-height:56px;--footer-height:calc(32px + env(safe-area-inset-bottom));--footer-bottom-space:12px;--text-small:12px;--text-note:12px;--text-detail:13px;height:auto;min-height:100dvh;overflow:visible}
  body[data-theme=tide]{--banner-height:calc(var(--hero-space) + 16px)}
  body[data-theme] .dashboard{height:auto;min-height:100dvh;grid-template-rows:var(--tablet-overview-height) max-content minmax(var(--footer-height),1fr);align-content:stretch}
  body[data-theme] .page-footer{align-self:end;height:var(--footer-height);font-size:12px;line-height:1.4}
  body[data-theme] .dashboard .overview-cards{grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
  body[data-theme] .overview-cards [data-integration]{display:flex;grid-column:auto;min-width:0;padding:12px}
  body[data-theme] .overview-provider{gap:7px}
  body[data-theme] .overview-provider h2{font-size:14px}
  body[data-theme] .overview-provider p{font-size:8px;letter-spacing:.6px}
  body[data-theme] .pending-badge{font-size:10px}
  body[data-theme] .dashboard .daily-cards{grid-template-columns:minmax(0,1fr) minmax(0,1.3fr);grid-template-rows:var(--tablet-daily-height) var(--tablet-links-height);grid-template-areas:"work holdings" "links links";gap:var(--layout-gap)}
  body[data-theme] .dashboard .daily-cards .work-card,
  body[data-theme] .dashboard .daily-cards .holdings-card{height:100%;padding:16px}
  body[data-theme] .dashboard .daily-cards .work-card{grid-area:work}
  body[data-theme] .dashboard .daily-cards .holdings-card{grid-area:holdings}
  body[data-theme] .daily-cards .links-card.website-panel{grid-area:links;padding:0}
  body[data-theme] .website-grid{grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:minmax(0,1fr)}
  body[data-theme] .work-card .card-header{margin-bottom:8px}
  body[data-theme] .work-card .work-main{flex:1 1 0;align-content:safe center}
  body[data-theme] .work-card.has-sticker .work-main{--sticker-size:clamp(72px,12vw,160px);position:relative;column-gap:10px}
  body[data-theme] .work-card.has-sticker .work-animation,
  body[data-theme] .work-card.has-sticker .lunch-sticker{position:absolute;grid-column:auto;grid-row:auto;right:0;top:50%;transform:translateY(-50%);width:var(--sticker-size);max-height:100%}
  body[data-theme] .work-card.has-sticker #countdown{font-size:clamp(24px,calc((100cqw - var(--sticker-size) - 10px)/5.1),40px)}
  body[data-theme] .work-card[data-mode=evening] #countdown{font-size:clamp(20px,5cqw,26px);line-height:1.4}
  body[data-theme] .work-card #countdown-label{font-size:13px;line-height:1.4}
  body[data-theme] .work-card #work-caption{font-size:12px;line-height:1.4;margin-top:5px}
  body[data-theme] .work-card .work-progress{margin-top:8px}
  body[data-theme] .work-card .progress-label{font-size:13px;margin-bottom:6px}
  body[data-theme] .work-card .timeline{font-size:12px;margin-top:6px}
  body[data-theme] .work-card .work-footer{font-size:12px;line-height:1.4;margin-top:10px;padding-top:8px}
  body[data-theme] .work-card #vacation-countdown{font-size:12px}
  body[data-theme] .daily-cards .holdings-header{margin-bottom:10px}
  body[data-theme] .daily-cards .holdings-date{font-size:12px;line-height:1.3}
  body[data-theme] .daily-cards .holding-tile{padding:6px 8px}
  body[data-theme] .daily-cards .holding-price-line{margin:10px 0 6px}
  body[data-theme] .daily-cards .holding-chart-wrap{margin-top:8px}
  body[data-theme] .daily-cards .holding-stats{font-size:12px;gap:4px 8px;margin-top:8px}
  body[data-theme] .overview-cards [data-integration=deepseek] .deepseek-summary{gap:7px}
  body[data-theme] .deepseek-spend figcaption{flex-wrap:wrap;row-gap:2px;font-size:12px}
  body[data-theme] .deepseek-spend figcaption a{margin-left:auto;font-size:12px}
  body[data-theme] .overview-cards [data-integration=deepseek] .quota-detail{font-size:12px}
  body[data-theme] .electricity-power{font-size:11px}
  body[data-theme] .electricity-power strong{font-size:14px}
  body[data-theme] .electricity-footnote{font-size:11px}
  body[data-theme] .overview-cards .electricity-chart{max-height:128px;margin-block:auto}
  body[data-theme] .overview-cards .deepseek-spend{justify-content:center}
  body[data-theme] .overview-cards .deepseek-spend-chart{max-height:118px}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .empty-ring{width:min(112px,calc(100cqw / var(--quota-count,2) - 10px),max(24px,calc(100cqh - 56px)))}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .empty-ring>span{font-size:clamp(9px,28cqw,32px)}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .reset-ring>span{font-size:clamp(6px,17cqw,20px)}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .remaining-ring::before{inset:clamp(4px,7.5cqw,9px)}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .quota-item{gap:5px;font-size:clamp(10px,1.3vw,13px)}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .quota-item small{font-size:clamp(8px,1.05vw,11px)}
  body[data-theme] .daily-cards .holding-chart-wrap{flex:1 1 0;max-height:112px;min-height:20px}
  body[data-theme] .daily-cards .holdings-card:has(.holdings-message:not([hidden])) .holding-chart-wrap{min-height:12px}
  body[data-theme] .daily-cards .holding-stats{margin-top:auto;padding-top:4px}
  body[data-theme] .codex-account{max-width:none;padding:3px 5px}
  body[data-theme] .codex-account-copy{gap:3px}
  body[data-theme] .codex-account-copy strong,
  body[data-theme] .codex-account-copy small{font-size:10px}
}

/* Keep the two main cards compact and equally tall in portrait as well. */
@media(min-width:768px) and (max-width:1100px) and (orientation:portrait),(min-width:768px) and (hover:none) and (pointer:coarse) and (orientation:portrait){
  body[data-theme]{--hero-space:clamp(140px,18dvh,240px);--page-gap:clamp(16px,2.5vw,28px);--tablet-overview-height:clamp(230px,24dvh,300px)}
  body[data-theme] .work-card .card-header h1{font-size:16px}
  body[data-theme] .work-card.has-sticker .work-main{--sticker-size:clamp(72px,10vw,112px)}
  body[data-theme] .work-card.has-sticker #countdown{font-size:clamp(22px,calc((100cqw - var(--sticker-size) - 10px)/5.1),36px)}
  body[data-theme] .work-card[data-mode=evening] #countdown{font-size:clamp(20px,5cqw,26px)}
  body[data-theme] .daily-cards .holding-title{gap:4px;min-height:0;align-content:start}
  body[data-theme] .daily-cards .holding-title strong{font-size:clamp(18px,4.8cqw,24px)}
  body[data-theme] .daily-cards .holding-price{font-size:clamp(27px,7.8cqw,42px)}
  body[data-theme] .daily-cards .holding-currency{font-size:clamp(20px,4.5cqw,27px)}
  body[data-theme] .daily-cards .holding-chart-wrap{margin-block:auto;max-height:128px}
  body[data-theme] .daily-cards .holding-stats{margin-top:8px}
}

@media(min-width:768px) and (max-width:1100px) and (orientation:portrait) and (max-height:1000px),(min-width:768px) and (hover:none) and (pointer:coarse) and (orientation:portrait) and (max-height:1000px){
  body[data-theme]{--hero-space:clamp(104px,14dvh,140px);--tablet-overview-height:clamp(210px,25dvh,240px)}
}

/* Larger portrait tablets use larger type and touch targets, not taller plots. */
@media(min-width:960px) and (max-width:1100px) and (min-height:1200px) and (orientation:portrait),(min-width:960px) and (min-height:1200px) and (hover:none) and (pointer:coarse) and (orientation:portrait){
  body[data-theme]{--hero-space:clamp(260px,26dvh,420px);--tablet-overview-height:300px;--text-small:14px;--text-detail:15px}
  body[data-theme] .overview-provider h2{font-size:16px}
  body[data-theme] .overview-cards .overview-value{font-size:42px}
  body[data-theme] .overview-cards .deepseek-spend figcaption,
  body[data-theme] .overview-cards [data-integration=deepseek] .quota-detail{font-size:13px}
  body[data-theme] .overview-cards .electricity-chart{max-height:136px}
  body[data-theme] .overview-cards .deepseek-spend-chart{max-height:136px}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .empty-ring{width:min(128px,calc(100cqw / var(--quota-count,2) - 10px),max(24px,calc(100cqh - 56px)))}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .quota-item{font-size:14px}
  body[data-theme] .dashboard [data-integration=codex] #codex-windows .quota-item small{font-size:12px}
  body[data-theme] .work-card.has-sticker #countdown{font-size:clamp(24px,calc((100cqw - var(--sticker-size) - 10px)/5.1),38px)}
  body[data-theme] .work-card[data-mode=evening] #countdown{font-size:clamp(22px,5cqw,28px)}
  body[data-theme] .work-card #countdown-label{font-size:15px}
  body[data-theme] .daily-cards .holding-price{font-size:clamp(32px,7.8cqw,44px)}
  body[data-theme] .daily-cards .holding-chart-wrap{max-height:128px}
  body[data-theme] .daily-cards .holding-stats{font-size:14px}
  body[data-theme] .website-grid{gap:14px}
  body[data-theme] .website-grid .website-tile>strong{font-size:20px}
}

/* Put spare portrait height into the wallpaper, rather than stretching cards. */
@media(min-width:768px) and (max-width:1100px) and (orientation:portrait),(min-width:768px) and (hover:none) and (pointer:coarse) and (orientation:portrait){
  html{height:100%;overflow:hidden}
  body[data-theme]{--hero-space:calc(100dvh - var(--tablet-overview-height) - var(--tablet-daily-height) - var(--tablet-links-height) - var(--layout-gap)*3 - var(--footer-height) - var(--footer-bottom-space) - env(safe-area-inset-top));height:100dvh;min-height:0;overflow:hidden}
  body[data-theme] .dashboard{height:100dvh;min-height:0;grid-template-rows:var(--tablet-overview-height) max-content var(--footer-height)}
  body[data-theme] .page-footer{align-self:stretch}
}

/* Use spare landscape height for the banner and keep the footer beside the content. */
@media(min-width:768px) and (max-width:1100px) and (orientation:landscape),(min-width:768px) and (hover:none) and (pointer:coarse) and (orientation:landscape){
  body[data-theme]{
    --layout-gap:clamp(10px,1.4dvh,14px);
    --tablet-overview-height:clamp(210px,28dvh,280px);
    --tablet-links-height:clamp(48px,6dvh,56px);
    --hero-space:max(88px,calc(100dvh - var(--tablet-overview-height) - var(--tablet-daily-height) - var(--tablet-links-height) - var(--layout-gap)*3 - var(--footer-height) - var(--footer-bottom-space) - env(safe-area-inset-top)));
  }
  body[data-theme] .dashboard{grid-template-rows:var(--tablet-overview-height) max-content var(--footer-height);align-content:start}
  body[data-theme] .page-footer{align-self:stretch}
  body[data-theme=tide] .scene-header{background-position:center 20%}
}
