/* App layout on top of the design system's bundle.css. These replace the previews' inline styles (CSP forbids them). */
[hidden] { display: none !important; }
body { min-height: 100vh; }
a { color: var(--lamp-ink); }
p { margin: 0; }

/* ---------- Login ---------- */
.wt-login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
.wt-login__inner { width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--space-8); align-items: center; }
.wt-login__logo { font-size: 26px; }
.wt-login__form { width: 100%; gap: 18px; }
.wt-center { text-align: center; }

/* ---------- Page bits ---------- */
.wt-page--narrow { max-width: 760px; }
.wt-form { gap: 18px; }
.wt-gap-top { margin-top: var(--space-6); }
.wt-gap-top-sm { margin-top: var(--space-4); }
.wt-admin-tabs { margin: var(--space-4) 0 var(--space-6); }
.wt-admin-grid { display: grid; grid-template-columns: 340px 1fr; gap: var(--space-6); align-items: start; }
.wt-admin-grid--even { grid-template-columns: 1fr 1fr; }
.wt-admin-grid > * { min-width: 0; } /* let the table scroll inside its card instead of widening the page */
.wt-nowrap { flex-wrap: nowrap; }
.wt-actions { justify-content: flex-end; flex-wrap: nowrap; }
.wt-right { text-align: right; }
.wt-table-wrap { overflow-x: auto; }
.wt-table td { white-space: nowrap; }
.wt-card__foot { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); }
.wt-secret { color: var(--ink); word-break: break-all; }
.wt-empty { padding: var(--space-12) var(--space-6); text-align: center; }
.wt-empty .wt-h2 { margin-bottom: var(--space-2); }
.wt-user-menu { gap: var(--space-2); }

.wt-grow { flex: 1; min-width: 0; }
.wt-topbar .wt-search { min-width: 220px; }
.wt-link-quiet { text-decoration: none; }

/* ---------- Library ---------- */
.wt-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wt-poster--stack img { border-radius: var(--radius-md); }
button.wt-vcard { background: none; border: 0; padding: 0; text-align: left; font: inherit; cursor: pointer; }
.wt-vcard:hover .wt-vcard__title, .wt-vcard:focus-visible .wt-vcard__title { color: var(--lamp-ink); }
.wt-vcard__title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wt-lib-tabs { margin-bottom: var(--space-6); }
.wt-series-hero { display: grid; grid-template-columns: 360px 1fr; gap: 40px; margin-top: 20px; align-items: end; }
.wt-series-hero .wt-stack { gap: 14px; }
.wt-season-tabs { margin-bottom: var(--space-3); }

/* ---------- Dialogs ---------- */
.wt-dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); padding: 0; width: min(960px, calc(100vw - 32px)); box-shadow: var(--shadow-pop); overflow: hidden; }
.wt-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.wt-dialog__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); }
.wt-dialog video { display: block; width: 100%; max-height: 75vh; background: var(--player-bg); }
.wt-dialog--form { width: min(520px, calc(100vw - 32px)); }

/* ---------- Upload ---------- */
.wt-meta-row { gap: var(--space-4); align-items: flex-end; flex-wrap: nowrap; }
.wt-drop { cursor: pointer; }
.wt-drop--over { border-color: var(--lamp); }
.wt-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.wt-upload .wt-progress { grid-column: span 2; }
.wt-self-start { align-self: flex-start; }

/* ---------- Dashboard ---------- */
.wt-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.wt-dash-grid { display: grid; grid-template-columns: 3fr 2fr; gap: var(--space-4); margin-top: var(--space-4); align-items: start; }
.wt-dash-grid > * { min-width: 0; }
.wt-card__body--tight { padding-bottom: var(--space-2); }
.wt-legend__lib { background: var(--lamp); }

/* ---------- Room ---------- */
.wt-room-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.wt-topbar--room { height: 56px; padding: 0 var(--space-6); flex: none; gap: var(--space-4); }
.wt-room { flex: 1; min-height: 0; }
.wt-room__main { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; min-height: 0; }
.wt-room__main .wt-player { width: 100%; max-height: calc(100dvh - 56px - 48px - 96px); }
.wt-player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--player-bg); }
.wt-player:fullscreen { max-height: none; border-radius: 0; }
.wt-player__empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: var(--space-6); color: var(--player-ink); }
.wt-controls { transition: opacity 0.25s; }
.wt-player--idle { cursor: none; }
.wt-player--idle .wt-controls:not(:has(:focus-visible)) { opacity: 0; pointer-events: none; }
.wt-flash { position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%; background: var(--scrim); color: var(--player-ink); display: grid; place-items: center; pointer-events: none; opacity: 0; z-index: 1; }
.wt-flash .wt-ico { width: 32px; height: 32px; }
.wt-flash--go { animation: wt-flash 0.5s ease-out; }
@keyframes wt-flash { from { opacity: 1; transform: scale(0.8); } to { opacity: 0; transform: scale(1.4); } }
@media (prefers-reduced-motion: reduce) { .wt-flash--go { animation-name: wt-fade; } }
@keyframes wt-fade { from { opacity: 1; } to { opacity: 0; } }
.wt-seek__input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.wt-seek:has(.wt-seek__input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.wt-sync--off .wt-dot { background: var(--lamp); }
.wt-spinner { animation: wt-spin 0.9s linear infinite; }
@keyframes wt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wt-spinner { animation-duration: 3s; } }
.wt-room__scroll { overflow-y: auto; }
.wt-room__sidehead { max-height: 32vh; overflow-y: auto; }
.wt-room__tabs .wt-tab { gap: 6px; }
.wt-member__vol { width: 72px; }
.wt-msg--cont { margin-top: calc(-1 * var(--space-2)); }
.wt-msg__gutter { width: 32px; flex: none; }
.wt-msg--error { color: var(--danger); }
.wt-qitem[role="button"] { cursor: pointer; }
.wt-add-list { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; }
.wt-gate--page { position: fixed; z-index: 10; background: rgba(0, 0, 0, 0.78); }
.wt-gate__hint { display: flex; gap: var(--space-2); }
.wt-drawer-btn { display: none; }
.wt-nowplaying { align-items: flex-start; flex-wrap: nowrap; }

/* ---------- Room picker + active rooms ---------- */
.wt-picker { display: flex; flex-direction: column; gap: var(--space-1); }
.wt-picker .wt-btn { justify-content: flex-start; height: auto; padding: 10px; text-align: left; white-space: normal; }
.wt-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }
button.wt-roomcard--new { cursor: pointer; font: inherit; min-height: 150px; }

/* ---------- Phones (F-P1): from 360 px up ---------- */
@media (max-width: 1100px) {
  .wt-admin-grid, .wt-dash-grid { grid-template-columns: 1fr; }
  .wt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .wt-room-page { height: auto; overflow: visible; }
  .wt-room { display: flex; flex-direction: column; padding: 0; gap: 0; }
  .wt-room__main { gap: 0; }
  .wt-room__main .wt-player { border-radius: 0; max-height: none; }
  .wt-nowplaying { padding: var(--space-3) var(--space-4); }
  .wt-room__side { border-radius: 0; border-left: 0; border-right: 0; height: 75dvh; }
  .wt-topbar--room { padding: 0 var(--space-4); }
  .wt-series-hero { grid-template-columns: 1fr; gap: var(--space-6); }
  .wt-series-hero .wt-poster { max-width: 360px; }
}
/* Phone held sideways: video only; chat, queue and voice slide in as a drawer (F-P1). */
@media (orientation: landscape) and (max-height: 540px) {
  .wt-topbar--room, .wt-nowplaying { display: none; }
  .wt-room-page { height: 100dvh; overflow: hidden; }
  .wt-room__main .wt-player { height: 100dvh; aspect-ratio: auto; border-radius: 0; }
  .wt-room__side { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 85vw); height: auto; z-index: 5; transform: translateX(100%); transition: transform 0.2s; box-shadow: var(--shadow-pop); }
  .wt-room__side.wt-open { transform: none; }
  .wt-drawer-btn { display: grid; }
}
@media (max-width: 640px) {
  .wt-stats { grid-template-columns: 1fr; }
  .wt-topbar { padding: var(--space-2) var(--space-4); gap: var(--space-3); flex-wrap: wrap; height: auto; min-height: 64px; }
  .wt-topbar .wt-search { order: 10; flex-basis: 100%; max-width: none; min-width: 0; }
  .wt-ep { grid-template-columns: 24px 112px 1fr; gap: var(--space-3); }
  .wt-ep > :last-child { grid-column: 2 / -1; }
  .wt-meta-row { flex-wrap: wrap; }
  .wt-page { padding: var(--space-4); }
  .wt-card__body { padding: var(--space-4); }
  .wt-topbar__name { display: none; }
  .wt-btn { min-height: 40px; }
  .wt-table th:first-child, .wt-table td:first-child { padding-left: var(--space-4); }
  .wt-table th:last-child, .wt-table td:last-child { padding-right: var(--space-4); }
}
