/* Dialogs (instead of the browser's prompt and confirm). */
/* Dialogs (instead of the browser's prompt and confirm) */
dialog {
    background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
    padding: var(--s4); width: min(420px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog form { gap: var(--s3); }
dialog h3 { margin: 0; font-size: var(--fs-l); }

#toast {
    position: fixed; bottom: calc(var(--s3) + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--bad-solid); color: var(--bad-text);
    padding: var(--s2) var(--s4); border-radius: var(--radius); border: 1px solid var(--bad-line); box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    display: none; max-width: 80vw; z-index: 20;
}
#toast.ok { background: var(--good-solid); color: var(--good-text); border-color: var(--good-line); }

/* The file viewer (components/viewer.js): the whole window, the file as big as fits. */
dialog.viewer {
    width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
    border: 0; border-radius: 0; background: #000; display: none; flex-direction: column;
}
dialog.viewer[open] { display: flex; overscroll-behavior: contain; }
dialog.viewer::backdrop { background: rgba(0,0,0,.8); }
.viewer-bar {
    display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3);
    padding-top: calc(var(--s2) + env(safe-area-inset-top)); min-width: 0;
}
.viewer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: var(--fs-m); }
.viewer-count { white-space: nowrap; }
.viewer-bar .spacer { flex: 1; }
.viewer-body { flex: 1; display: flex; align-items: center; min-height: 0; padding-bottom: env(safe-area-inset-bottom); }
.viewer-stage { flex: 1; height: 100%; min-width: 0; display: flex; align-items: center; justify-content: center; padding: var(--s2); }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.viewer-stage audio { width: min(480px, 100%); }
.viewer-text {
    width: min(900px, 100%); max-height: 100%; overflow: auto; margin: 0; padding: var(--s3);
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); white-space: pre-wrap; word-break: break-word;
}
.viewer-caption {
    margin: 0; padding: var(--s2) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); text-align: center;
    color: #c9d0d4; font-size: var(--fs-s); line-height: 1.45; max-height: 30vh; overflow-y: auto;
}
.viewer-caption[hidden] { display: none; }
/* the caption keeps clear of the home bar instead */
.viewer:has(.viewer-caption:not([hidden])) .viewer-body { padding-bottom: 0; }
.viewer-prev, .viewer-next { font-size: var(--fs-2xl); align-self: stretch; padding: 0 var(--s3); color: var(--text); }
.viewer-prev:disabled, .viewer-next:disabled { visibility: hidden; }
@media (max-width: 640px) {
    .viewer-prev, .viewer-next { display: none; }   /* a swipe instead */
    .viewer-bar a.viewer-open { display: none; }
    .viewer-stage { padding: 0; }   /* the image as wide as the screen */
    .viewer-bar .button { padding: 6px 10px; font-size: var(--fs-s); }
    .viewer-close { font-size: var(--fs-xl); min-width: 44px; min-height: 44px; }
}
/* A long form in two columns (environments.js: the AWS environment form); one on a phone. */
dialog:has(form.cols) { width: min(780px, calc(100vw - 32px)); }
form.cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s4); row-gap: var(--s3); align-items: start; }
form.cols > h3, form.cols > .help, form.cols > .span, form.cols > .key-part, form.cols > .f:has(.queue-rows), form.cols > .row { grid-column: 1 / -1; }
form.cols .pair, form.cols .key-part { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s4); row-gap: var(--s2); }
form.cols .pair[hidden] { display: none; }
form.cols .key-part > h4, form.cols .key-part > .help { grid-column: 1 / -1; margin: 0; }
form.cols .queue-rows { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s4); }
@media (max-width: 640px) { form.cols, form.cols .pair, form.cols .key-part, form.cols .queue-rows { grid-template-columns: 1fr; } }
