/* One responsive layout system: content, controls and navigation never share space. */
.app {
  --layout-gutter: clamp(16px, 3.5vw, 64px);
  --layout-gap: clamp(10px, 2dvh, 22px);
  --layout-bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "header" "content" "tools" "footer";
  padding: max(14px, min(3dvh, 30px), env(safe-area-inset-top))
    max(var(--layout-gutter), env(safe-area-inset-right)) var(--layout-bottom)
    max(var(--layout-gutter), env(safe-area-inset-left));
  gap: var(--layout-gap);
}
.masthead {
  grid-area: header;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}
.site-brand { min-width: 0; width: fit-content; font-size: 20px; }
.site-brand small { font-size: 10px; letter-spacing: .8px; overflow-wrap: anywhere; }
.masthead-right { min-width: 0; justify-self: end; }
.live-weather { min-width: 0; max-width: 100%; flex-wrap: wrap; justify-content: flex-end; text-align: right; }
.live-weather > span { min-width: 0; overflow-wrap: anywhere; }
.page-nav {
  position: relative;
  inset: auto;
  transform: none;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  padding: 5px;
  gap: 3px;
  justify-self: center;
}
.nav-link { min-width: 0; padding: 10px 13px; font-size: 13px; }
.stage {
  grid-area: content;
  width: clamp(360px, 31vw, 430px);
  max-width: 100%;
  height: min(510px, 100%);
  min-height: 0;
  max-height: 100%;
  align-self: center;
  justify-self: end;
  margin: 0;
}
.main-column { grid-template-rows: minmax(0, 1fr) auto; }
.panels { min-width: 0; }
.panel {
  padding: 24px clamp(20px, 2.1vw, 32px) 20px;
  overflow-x: hidden;
  overflow-y: auto;
  justify-content: safe center;
  scrollbar-gutter: stable;
  scroll-padding-block: 20px;
  -webkit-overflow-scrolling: touch;
}
.panel > * { min-width: 0; max-width: 100%; }
.panel h1 { font-size: clamp(32px, 3vw, 52px); line-height: 1.4; letter-spacing: 1.2px; margin-bottom: 16px; }
.panel h2 { font-size: 28px; line-height: 1.4; overflow-wrap: anywhere; margin-bottom: 20px; }
.hello-copy { line-height: 1.8; margin-bottom: 16px; }
.welcome-line { flex-shrink: 0; }
.home-description { font-size: 13px; line-height: 1.9; overflow-wrap: anywhere; margin-bottom: 20px; }
.home-actions { flex-wrap: wrap; gap: 10px 20px; }
.button, .text-link { max-width: 100%; white-space: normal; min-height: 40px; }
.destination-grid { min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.destination { min-width: 0; padding: 12px; gap: 11px; }
.destination > div { flex: 1; min-width: 0; }
.destination h3 { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.destination-icon { flex: 0 0 32px; width: 32px; height: 32px; }
.destination .outbound { flex-shrink: 0; margin-left: auto; }
.about-profile-card { gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.about-profile-card img { flex-shrink: 0; width: 58px; height: 58px; }
.about-profile-card > div { min-width: 0; }
.about-profile-card strong { overflow-wrap: anywhere; }
.about-motto { font-size: 18px; overflow-wrap: anywhere; margin-bottom: 20px; }
.about-since { padding-top: 16px; line-height: 1.7; }
.contact-item { padding: 14px 12px; gap: 9px; }
.contact-item > div { min-width: 0; flex: 1; }
.contact-item a { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.copy-button { margin-left: 0; }
.stage-footer {
  min-height: 50px;
  margin-inline: clamp(18px, 2.1vw, 32px);
  padding-block: 8px;
  gap: 8px 12px;
  flex-wrap: wrap;
}
.moment { min-width: 0; white-space: normal; flex-wrap: wrap; line-height: 1.6; gap: 5px; font-size: 11px; }
.pager { margin-left: auto; font-size: 12px; flex-shrink: 0; }
.pager-button { width: 30px; height: 32px; }
.scene-caption { grid-area: tools; position: relative; inset: auto; align-self: center; justify-self: start; min-width: 0; }
.view-toggle { grid-area: tools; position: relative; inset: auto; justify-self: end; align-self: center; width: fit-content; min-height: 38px; margin: 0; font-size: 12px; }
.view-toggle span { display: inline; }
.site-footer { grid-area: footer; flex-wrap: wrap; min-height: 18px; font-size: 10px; line-height: 1.5; }
.art-credit { font-size: 10px; letter-spacing: 1.2px; }
.scene-settings { max-height: calc(100dvh - 24px); padding: 24px; }
.settings-actions { flex-wrap: wrap; }
.room-controls > div { flex-wrap: wrap; }
.room-control-button { flex: 1 1 90px; }
.toast { bottom: max(18px, env(safe-area-inset-bottom)); }

/* Compact desktops and tablets: reserve a real dock row below the content/tools. */
@media (max-width: 1000px) {
  .app {
    --layout-gap: 10px;
    --dock-height: 52px;
    --footer-height: 30px;
    grid-template-rows: auto minmax(0, 1fr) auto var(--dock-height) var(--footer-height);
    grid-template-areas: "header" "content" "tools" "dock" "footer";
  }
  .masthead { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-height: 46px; }
  .masthead-right { grid-column: 2; }
  .page-nav {
    position: fixed;
    inset: auto max(var(--layout-gutter), env(safe-area-inset-right))
      calc(var(--layout-bottom) + var(--footer-height) + var(--layout-gap))
      max(var(--layout-gutter), env(safe-area-inset-left));
    width: min(420px, calc(100% - 2 * var(--layout-gutter)));
    max-width: none;
    height: var(--dock-height);
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 28px;
    gap: 2px;
    padding: 5px;
  }
  .nav-link { flex: 1; padding: 9px 7px; gap: 5px; font-size: 12px; }
  .nav-link .icon { width: 15px; height: 15px; }
  .stage { width: min(390px, 100%); height: min(460px, 100%); justify-self: center; }
  .panel { padding: 20px 24px 16px; }
  .panel h1 { font-size: 38px; }
  .stage-footer { margin-inline: 22px; }
  .view-toggle { min-height: 36px; }
  .scene-caption { display: none; }
  .site-footer { justify-content: center; align-content: center; text-align: center; height: var(--footer-height); }
  .art-credit { display: none; }
  .toast { bottom: calc(var(--layout-bottom) + var(--footer-height) + var(--dock-height) + 2 * var(--layout-gap)); }
}

/* Medium landscape windows leave the central windowsill clock unobstructed. */
@media (min-width: 800px) and (max-width: 1000px) and (min-aspect-ratio: 4/5) and (min-height: 461px) {
  .stage { width: min(360px, 34vw); justify-self: end; }
  .panel { padding-inline: 20px; }
}

@media (max-width: 620px) {
  .app { --layout-gutter: 18px; padding-top: max(12px, env(safe-area-inset-top)); }
  .site-brand { font-size: 18px; }
  .site-brand small { font-size: 9px; letter-spacing: .45px; }
  .masthead-right { gap: 8px; }
  .live-weather { flex-direction: column; align-items: flex-end; gap: 3px; padding: 0; border: 0; background: none; backdrop-filter: none; color: var(--header-ink); font-size: 11px; }
  .weather-divider { display: none; }
  .stage { width: min(370px, 100%); border-radius: 20px; }
  .panel { padding: 20px; }
  .panel h1 { font-size: clamp(29px, 9vw, 36px); }
  .panel h2 { font-size: 26px; }
  .hello-copy { font-size: 12px; margin-bottom: 12px; }
  .home-actions { gap: 8px 16px; }
  .stage-footer { margin-inline: 18px; }
  .site-footer { font-size: 9px; letter-spacing: .1px; }
  .view-toggle { padding: 8px 12px; }
}

/* Keep the original open view of the windowsill in roomy portrait windows. */
@media (max-width: 1000px) and (max-aspect-ratio: 4/5) and (min-height: 760px) {
  .stage { align-self: start; margin-top: 8px; height: min(420px, calc(54dvh - 84px), 100%); }
}

@media (max-height: 650px) {
  .app { --layout-gap: 8px; padding-block: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-bottom)); }
  .panel { padding-block: 16px; }
  .panel h1 { font-size: clamp(29px, 3.2vw, 38px); margin-bottom: 12px; }
  .panel h2 { font-size: 24px; margin-bottom: 14px; }
  .hello-copy { margin-bottom: 10px; }
  .home-description { margin-bottom: 14px; }
  .stage-footer { min-height: 44px; padding-block: 6px; }
  .view-toggle { min-height: 34px; padding-block: 8px; }
}

/* An extremely short window must scroll, not shrink content into an unreadable sliver. */
@media (max-height: 460px) {
  html, body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  .app { height: auto; min-height: 100dvh; grid-template-rows: auto minmax(230px, 1fr) auto auto; grid-template-areas: "header" "content" "tools" "footer"; }
  .stage { height: 230px; min-height: 230px; align-self: start; }
  .panel { justify-content: flex-start; }
  .site-footer { height: auto; min-height: 24px; }
  .scene-caption { display: none; }
  .toast { bottom: 12px; }
}
@media (max-width: 1000px) and (max-height: 460px) {
  .masthead { grid-template-rows: auto auto; row-gap: 8px; }
  .page-nav { position: relative; inset: auto; transform: none; grid-column: 1 / -1; grid-row: 2; width: min(420px, 100%); height: 46px; margin: 0; justify-self: center; }
}
@media (max-width: 359px) {
  .app { --layout-gutter: 12px; }
  .nav-link { font-size: 11px; padding-inline: 4px; gap: 4px; }
  .nav-link .icon { width: 13px; height: 13px; }
  .panel { padding-inline: 16px; }
  .stage-footer { margin-inline: 14px; gap: 5px; }
  .destination { padding: 10px 8px; gap: 8px; }
  .contact-item { flex-wrap: wrap; }
}
