/* App layout only: grid, flex, sizes, gaps and overflow. Every colour, border and font
   comes from components.css or XP.css. Breakpoints are container queries on .window-body. */

.explorer, .merch, .viewer, .crew, .chat, .compose, .wizard, .cart, .wmp, .oe, .ie { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s1); }
.ex-tiles, .m-grid, .v-strip { list-style: none; margin: 0; padding: 0; }

/* Radio */
.wmp-vol input { flex: 1; min-width: 0; }
.wmp-vol .tbtn { min-height: 0; padding: 2px; }
.wmp-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; padding: var(--s2); overflow: auto; }
.wmp-panel .playlist { flex: 1; }

/* Inbox: message list over the preview pane, one line per message */
.oe .tbtn { flex-direction: column; gap: 2px; }
.oe-side section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.oe-side section:first-child { flex: none; } /* the whole folder tree, Contacts gets the rest */
.oe-side .tp-link { display: inline-flex; width: auto; } /* XP highlights the label only */
.oe-main:has(> .oe-side[hidden]) { grid-template-columns: 1fr; }
.oe-right { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.oe-list { flex: 0 0 40%; min-height: 0; margin-bottom: var(--s1); }
.oe-list table { table-layout: fixed; }
.oe-list th:first-child { width: 32%; }
.oe-list th:last-child { width: 84px; }
.oe-list td { padding-block: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* ~17px rows, as XP */
.oe-list td .ico { margin-right: var(--s1); vertical-align: top; }
.oe-preview { flex: 1; min-height: 0; }
.oe-body { padding: var(--s2) var(--s3); }
.oe-body p { margin: 0 0 var(--s2); }

/* Explorer (Events, Recycle Bin) */
.ex-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px 1fr; }
.ex-main > .taskpane.bar { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.bar-body { flex: 1; min-height: 0; overflow: auto; }
.ex-pane { display: grid; grid-template-columns: minmax(210px, 250px) 1fr; min-height: 0; overflow: hidden; }
.ex-files { min-height: 0; overflow: auto; padding: var(--s2); }
.ex-tiles { display: grid; gap: var(--s1); }
.ev-head { display: grid; grid-template-columns: 170px 1fr; gap: var(--s3); align-items: start; margin-bottom: var(--s2); }
.bin .pane { overflow: auto; }
.bin-tiles { padding: var(--s2); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@container (max-width: 820px) {
  .ex-pane { grid-template-columns: 1fr; overflow: auto; }
  .ex-files, .ex-pane .preview { overflow: visible; }
  .ex-tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
@container (max-width: 600px) {
  .ex-main { display: flex; flex-direction: column; overflow: auto; }
  .ex-main > .taskpane { order: 2; flex: none; overflow: visible; }
  .ex-main > .taskpane.bar { order: 0; }
  .ex-main > .pane { flex: none; overflow: visible; }
  .ev-head { grid-template-columns: 120px 1fr; }
  .ab-label { display: none; }
  .oe-main > .taskpane.oe-side { display: none; }
}

.ie > iframe { flex: 1; min-height: 0; width: 100%; border: 0; background: var(--pane); }
/* 1zoku TV resizes from its bottom-right corner (desktop only; phones show it full screen). */
@media (min-width: 641px) { .window.app-tv:not(.max) { resize: both; overflow: hidden; min-width: 420px; min-height: 300px; } }

/* Merch and cart */
.m-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 290px; }
.m-files { min-height: 0; }
.m-main:has(> .m-detail[hidden]) { grid-template-columns: 1fr; }
.m-empty { margin: var(--s3) var(--s2); text-align: center; }
.sb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--s2); }
.m-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--s2); align-content: start; padding: var(--s2); }
.m-detail .art { max-width: 240px; margin-bottom: var(--s2); }
.m-buy { display: flex; flex-direction: column; gap: var(--s2); }
@container (max-width: 600px) {
  .m-main { grid-template-columns: 1fr; overflow: auto; }
  .m-main > .m-files { overflow: visible; min-height: auto; }
  .m-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .m-main > .preview { overflow: visible; min-height: auto; }
}
.cart { gap: var(--s2); }
.cart-pane { flex: 1; min-height: 0; }
.cart-img { width: 52px; }
.cart-img .thumb-frame { width: 44px; }
.cart input[type=number] { width: 52px; }
.cart-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
.cart-foot p { margin: 0; }

/* Crew and chat */
.crew, .chat { gap: var(--s2); }
.crew > p { margin: 0; }
.chat-log { flex: 1; min-height: 0; padding: var(--s2); }
.chat-log fieldset { margin-bottom: var(--s2); }
.chat-log fieldset p { margin: 0; }
.chat-log ul { margin: var(--s1) 0 0; }
.chat-typing { min-height: 1.4em; }
.chat-send { display: flex; gap: var(--s2); }
.chat-send textarea { flex: 1; min-width: 0; resize: none; }

/* Gallery */
.v-stage { flex: 1; min-height: 0; margin: 0; padding: var(--s3); display: flex; flex-direction: column; align-items: center; gap: var(--s2); overflow: hidden; }
.v-img { flex: 1 1 0; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.v-img > img, .v-img > svg { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.v-cap { text-align: center; }
.v-bar { justify-content: center; }
.v-strip { flex: none; display: flex; gap: var(--s1); padding: var(--s1) var(--s2); overflow-x: auto; }

/* Compose and Notepad */
.compose .compose-fields { padding: var(--s2); }
.c-msg { flex: 1; min-height: 120px; margin: 0 var(--s2) var(--s2); resize: none; }
.app-readme .notepad { flex: 1; min-height: 0; }

/* Ticket wizard */
.wz-page { flex: 1; min-height: 0; overflow: auto; }
.wz-hero { flex: 1; }
.wz-tier label { display: grid; grid-template-columns: 1fr 48px 110px; gap: var(--s2); width: 100%; }
.wz-qty { gap: var(--s2); }
.wz-qty input { width: 60px; }
.wz-total { margin: 0 0 0 auto; }
@container (max-width: 480px) {
  .wz-hero { grid-template-columns: 1fr; }
  .wz-banner { height: 64px; }
  .wz-banner img { width: 200px; transform: translate(-50%, -50%); }
  .wz-body { padding-left: var(--s3); }
  .wz-tier label { grid-template-columns: 1fr auto; }
}

/* Message boxes and small dialogs (sized to content) */
.dlg .window-body { flex: none; padding: var(--s3); }
