/* Dialogs: the modal frame, album settings with its preview, import and sync. */

.modal {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100% - 24px - var(--safe-top) - var(--safe-bottom));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal:not([open]) {
  display: none;
}
.modal-wide {
  width: min(920px, calc(100% - 24px));
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 4px 20px;
}
.modal-title {
  font-size: 1.15rem;
  margin: 0;
  overflow-wrap: anywhere;
}
.modal-body {
  padding: 8px 20px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px calc(14px + var(--safe-bottom) * 0);
  border-top: 1px solid var(--line);
}
.modal-foot.inline {
  border: 0;
  padding: 8px 0 0;
}
.modal-foot .hint {
  margin-right: auto;
}
.modal-confirm {
  width: min(440px, calc(100% - 24px));
}
@media (max-width: 600px) {
  .modal {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    max-height: calc(100% - 20px - var(--safe-top));
  }
  .modal-body {
    padding-bottom: calc(18px + var(--safe-bottom));
  }
  .modal-foot {
    padding-bottom: calc(14px + var(--safe-bottom));
  }
}
html.modal-open {
  overflow: hidden;
}

/* ---- Settings inside dialogs ---- */
.set-section {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.set-section:first-child {
  border-top: 0;
  padding-top: 0;
}
.set-section h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}
.set-field {
  margin-bottom: 14px;
}
.set-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.set-control {
  display: grid;
  gap: 6px;
  justify-items: start;
}
.set-control select.input {
  max-width: 260px;
}

.album-settings {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.as-preview {
  position: sticky;
  top: 0;
}
@media (max-width: 760px) {
  .album-settings {
    grid-template-columns: 1fr;
  }
  .as-preview {
    position: static;
  }
}
.overlay-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  container-type: size;
  color: #fff;
  margin-bottom: 10px;
}
.preview-pic,
.preview-pic > img,
.preview-pic > canvas,
.preview-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
}
.preview-pic > img {
  object-fit: cover;
}
.preview-overlay {
  container-type: size;
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 32px);
  gap: 4px;
  padding: 6px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.pos-cell {
  border: 0;
  border-radius: 6px;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.pos-cell:not(.empty):hover {
  background: var(--line);
}
.pos-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
}
.pos-cell.on {
  background: var(--accent);
}
.pos-cell.on .pos-dot {
  background: var(--accent-ink);
  opacity: 1;
}

.flag-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  width: 100%;
}
.flag-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 600;
}
.flag-toggle canvas {
  width: 36px;
  height: 24px;
  border-radius: 3px;
  flex: none;
}
.flag-toggle span:nth-child(2) {
  flex: 1;
}
.flag-toggle:not(.on) {
  opacity: 0.5;
}
.flag-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
}
.flag-toggle.on .flag-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.picker-grid {
  max-height: 60vh;
  overflow-y: auto;
}

.upload-report h3 {
  font-size: 1rem;
  margin-top: 12px;
}
.report-list {
  padding-left: 18px;
  max-height: 40vh;
  overflow-y: auto;
  font-size: 0.92rem;
}
.report-list li {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

/* ---- Import ---- */
.import .segmented {
  margin: 8px 0 12px;
}
.import-detail {
  margin-bottom: 14px;
}

/* ---- Sync ---- */
.sync-back {
  margin: 0 0 8px -8px;
}
.sync-code-block {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 8px 0 16px;
}
.sync-qr {
  width: min(280px, 80vw);
  height: auto;
  border-radius: 8px;
}
.sync-code-block details {
  width: 100%;
}
.sync-code {
  font: 0.8rem/1.3 ui-monospace, Menlo, monospace;
  word-break: break-all;
  margin: 8px 0;
}
.sync-paste {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
}
.sync-paste .input {
  flex: 1;
  margin: 0;
}
.sync-scan {
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin: 8px 0;
  aspect-ratio: 4 / 3;
  max-width: 420px;
}
.sync-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sync-error {
  color: var(--danger);
}
.sync-status {
  min-height: 1.4em;
}
.sync-how {
  margin-top: 14px;
}
.sync-how summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.sync-notes {
  padding-left: 18px;
}
.sync-details {
  white-space: pre-wrap;
  font-size: 0.75rem;
  background: var(--surface-2);
  padding: 10px;
  border-radius: 8px;
  max-height: 240px;
  overflow: auto;
}
.sync-known {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.sync-label {
  font-weight: 700;
  margin: 0;
}
.sync-device-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.sync-device-btn > span {
  flex: 1;
  display: grid;
}
.sync-other {
  margin: 12px 0 0;
}
.sync-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 10px 0 14px;
}
@media (max-width: 640px) {
  .sync-preview {
    grid-template-columns: 1fr;
  }
}
.sync-side {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}
.sync-side h3 {
  font-size: 0.95rem;
}
.sync-counts {
  font-weight: 600;
}
.sync-group summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
}
.sync-type-name {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 6px 0 2px;
  font-weight: 700;
}
.sync-type ul {
  margin: 0 0 6px;
  padding-left: 18px;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}
.sync-changes {
  color: var(--muted);
}
.sync-added summary {
  color: var(--ok);
}
.sync-removed summary {
  color: var(--danger);
}
.sync-done {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--ok);
}
.sync-done p {
  color: var(--text);
}
