.gp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 10px;
  margin-top: 12px;
}
.gp-browse input, .gp-browse select {
  min-height: 44px;
}
.gp-thumbnail {
  aspect-ratio: 16 / 9;
  margin-bottom: 8px;
  background: #151121;
  border: 1px solid #4b3d72;
  border-radius: 8px;
  overflow: hidden;
}
.gp-thumbnail:empty::after {
  content: '▶';
  display: grid;
  height: 100%;
  place-items: center;
  color: #caa4ff;
}
.gp-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gp-card button, #gpLoadPreview {
  min-height: 44px;
}
.gp-card button[aria-pressed="true"] {
  border-color: #e6ccff;
  background: #63469b;
}
.gp-card strong {
  overflow-wrap: anywhere;
}
#gpManualPanel {
  margin: 12px 0;
  align-items: center;
}
#gpManualPreview {
  max-width: 220px;
  width: 100%;
}
#gpSearch {
  width: min(240px, 65vw);
}
.gp-private {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #4b3d72;
  border-radius: 8px;
}
.gp-private summary {
  padding: 8px 0;
  cursor: pointer;
}
.gp-private progress {
  width: 100%;
  margin-top: 12px;
}
.gp-private button, .gp-private input {
  min-height: 44px;
}
.gp-cloud-group {
  margin: 12px 0;
  padding: 0 10px 10px;
  border: 1px solid #4b3d72;
  border-radius: 8px;
}
.gp-cloud-group > summary {
  padding: 12px 0;
  min-height: 44px;
  cursor: pointer;
}
.gp-original small {
  overflow-wrap: anywhere;
}
#gpCloudPreview video {
  width: min(100%, 300px);
  max-height: 45vh;
  margin: 0 0 8px;
  background: #151121;
}
.gp-cloud-group .gp-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 285px), 1fr));
}
.view-section[data-view="gameplay"] {
  margin-left: max(0px, calc(env(safe-area-inset-left, 0px) - 15px));
  margin-right: max(0px, calc(env(safe-area-inset-right, 0px) - 15px));
  padding-bottom: max(15px, env(safe-area-inset-bottom, 0px));
}
.view-section[data-view="gameplay"] .gp-settings > label,
.view-section[data-view="gameplay"] .gp-settings select {
  min-width: 0;
  max-width: 100%;
}
.gp-cloud-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 4px 8px;
  padding: 8px;
  content-visibility: auto;
  contain-intrinsic-size: auto 150px;
}
.gp-cloud-card.gp-selected {
  border: 2px solid #d37aff;
  box-shadow: 0 0 12px #a64dff65;
  padding: 7px;
  background: #352449;
}
.gp-cloud-pick {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 80px;
  padding: 4px;
  border: 0;
  background: transparent;
  text-align: left;
}
.gp-cloud-info {
  min-width: 0;
  overflow-wrap: anywhere;
}
.gp-cloud-info > strong, .gp-cloud-info > .gp-cloud-meta {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.3;
  overflow: hidden;
}
.gp-cloud-info small {
  margin: 0;
  font-size: .75rem;
  line-height: 1.35;
}
.gp-cloud-info > .gp-cloud-meta { margin: 2px 0; }
.gp-cloud-duration {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 5px;
}
.gp-cloud-thumb {
  display: block;
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  background: #151121;
  font-size: .72rem;
  text-align: center;
  align-content: center;
}
.gp-cloud-thumb.gp-portrait {
  width: auto;
  height: 86px;
  max-width: 100%;
  justify-self: center;
}
.gp-cloud-thumb img {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}
.gp-linked-thumb { width: 100%; height: 100%; object-fit: cover; }
.gp-frame-strip { width: 200%; max-width: none; height: 200%; }
.gp-cloud-check { display: none; color: #f0c4ff; font-size: .75rem; }
.gp-selected .gp-cloud-check { display: inline; }
.gp-cloud-actions {
  display: flex;
  flex-direction: column;
  align-self: center;
}
.gp-cloud-actions button {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  font-size: 1.1rem;
  line-height: 1;
  background: transparent;
  color: #dec9ef;
}
.gp-cloud-actions button[aria-pressed="true"] {
  background: transparent;
  color: #ffd380;
  box-shadow: none;
}
.gp-cloud-actions button:focus-visible,
.gp-cloud-pick:focus-visible { outline: 2px solid #d37aff; }
.gp-cloud-card > :is(.gp-original, .gp-contact-sheet, .gp-card-status, .gp-batch-item) {
  grid-column: 1 / -1;
  min-width: 0;
}
.gp-cloud-card .gp-original { padding-top: 6px; border-top: 1px solid #4b3d72; }
.gp-contact-sheet img { width: min(100%, 448px); display: block; margin: 6px auto; border-radius: 6px; }
.gp-card-status:empty { display: none; }
#gpBatch button { min-height: 44px; }
.gp-batch-item {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-self: end;
  min-height: 44px;
  font-size: .75rem;
}
.gp-batch-item input { width: 20px; height: 20px; }

@media (max-width: 360px) {
  .gp-cloud-card { grid-template-columns: minmax(0, 1fr); }
  .gp-cloud-actions {
    flex-direction: row;
    justify-content: flex-end;
    border-top: 1px solid #4b3d72;
  }
}

.gp-ai-panel {
  box-sizing: border-box;
  width: min(440px, calc(100% - max(20px, env(safe-area-inset-left, 0px)) - max(20px, env(safe-area-inset-right, 0px))));
  max-height: calc(100% - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  scroll-padding-block-end: max(14px, env(safe-area-inset-bottom, 0px));
  border: 1px solid #906bc0;
  border-radius: 14px;
  background: #251b35;
  color: #f3ebfb;
}
.gp-ai-panel::backdrop { background: #100a1bc9; }
.gp-ai-panel h3, .gp-ai-panel p { margin: 0 0 8px; }
.gp-ai-panel p, .gp-ai-panel dd { overflow-wrap: anywhere; }
.gp-ai-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.gp-ai-panel button { min-height: 44px; }
.gp-ai-panel fieldset { min-inline-size: 0; border: 0; padding: 0; margin: 8px 0; }
.gp-ai-panel legend { margin-bottom: 6px; }
.gp-ai-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.gp-ai-tiles button {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 6px;
  border: 2px solid #715694;
  background: #21162f;
  color: #f3ebfb;
  touch-action: manipulation;
}
.gp-ai-tiles canvas {
  display: block;
  width: 100%;
  height: clamp(52px, 20vw, 96px);
  object-fit: contain;
  border-radius: 4px;
  background: #150d21;
}
.gp-ai-tiles button > * { pointer-events: none; }
.gp-ai-frame-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 22px;
  font-size: .82rem;
}
.gp-ai-check { visibility: hidden; color: #f2ceff; font-weight: 700; }
.gp-ai-tiles button[aria-pressed="true"] {
  border-color: #d37aff;
  background: #352449;
  box-shadow: 0 0 12px #a64dff65;
}
.gp-ai-tiles button[aria-pressed="true"] .gp-ai-check { visibility: visible; }
.gp-ai-tiles button:focus-visible { outline: 2px solid #d37aff; outline-offset: 2px; }
#gpAiSelected { min-height: 1.25em; color: #f2ceff; }
#gpAiRun { width: 100%; touch-action: manipulation; }
.gp-ai-confirmation {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #906bc0;
  border-radius: 8px;
  background: #30203f;
}
#gpAiStatus { margin-top: 10px; }
#gpAiResult { display: grid; grid-template-columns: minmax(86px, 1fr) minmax(0, 1.5fr); gap: 6px 10px; }
#gpAiResult dd { margin: 0; }
#gpAiRun:not(:disabled) {
  background: #6737a0;
  border-color: #d37aff;
  color: #fff;
}
#gpAiRetry { margin-bottom: 6px; }
#vrReview select { min-height: 44px; max-width: 100%; }
#vrItems > div { border-top: 1px solid #715694; padding: 6px 0; overflow-wrap: anywhere; }
[data-view="director"] > label { display: block; margin: 8px 0; }
[data-view="director"] input, [data-view="director"] button, [data-view="director"] select { min-height: 44px; }
[data-view="director"] label, [data-view="director"] input, [data-view="director"] select { min-width: 0; max-width: 100%; }
[data-view="director"] strong { overflow-wrap: anywhere; }
[data-view="director"] a { color: #d7afff; }

.gp-batch-item:has(input:checked) {
  border: 1px solid #d37aff;
  background: #352449;
  box-shadow: 0 0 12px #a64dff65;
  border-radius: 8px;
  padding: 0 6px;
}
.gp-batch-item input { accent-color: #a34ff0; }
