/* Family Media: styles that MudBlazor components don't cover.
   Colors come from the MudTheme through --mud-palette-* variables. */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- App shell ---------- */
.app-bar { border-bottom: 1px solid var(--mud-palette-lines-default); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 16px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--mud-palette-primary); color: var(--mud-palette-primary-text);
}
.brand-name { letter-spacing: -0.01em; }
.app-search { max-width: 560px; flex: 1 1 280px; }
.app-search .mud-input-root { border-radius: 22px; }
.nav-menu { padding: 16px 12px; }
.nav-menu .mud-nav-link { border-radius: 24px; min-height: 48px; font-weight: 500; }
.nav-menu .mud-nav-link.active { background: color-mix(in srgb, var(--mud-palette-primary) 12%, white); color: var(--mud-palette-primary); font-weight: 700; }
.nav-menu .mud-nav-group:has(.mud-nav-link.active) > .mud-nav-link { background: color-mix(in srgb, var(--mud-palette-primary) 12%, white); color: var(--mud-palette-primary); font-weight: 700; }
.main-content { background: var(--mud-palette-background); min-height: 100vh; }

/* ---------- Page structure ---------- */
.page-pad { padding: 16px 24px 96px; }
.storage-folder { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-top: 16px; }
.storage-folder-text { flex: 1 1 240px; min-width: 0; }
.storage-folder-groups .storage-folder:first-child { margin-top: 0; }
.page-title { margin-right: 8px; letter-spacing: -0.015em; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding-bottom: 8px; }
.toolbar-spacer { flex: 1 1 0; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 64px 16px; text-align: center; }

/* ---------- Timeline ---------- */
.timeline-layout { display: flex; align-items: flex-start; }
.timeline-main { flex: 1 1 0; min-width: 0; }
.day-group { margin-bottom: 24px; scroll-margin-top: 80px; }
.day-header { display: flex; align-items: baseline; gap: 12px; padding: 8px 0 12px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--tile-min, 180px)), 1fr)); gap: 8px; }
.media-grid--dense { gap: 4px; }

.display-settings-page { container-type: inline-size; }
.display-settings-paper { width: 100%; max-width: 1100px; }
.display-settings-layout { display: grid; grid-template-columns: minmax(260px, 0.8fr) minmax(340px, 1.2fr); gap: 32px; }
.display-settings-controls, .display-preview { min-width: 0; }
.display-preview-frame { height: 300px; overflow: auto; border-radius: 8px; background: var(--mud-palette-background); }
.display-preview-grid { width: calc(100cqw - 64px); }
.display-preview-frame .tile { cursor: default; }

@media (max-width: 1100px) {
  .display-settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 959.98px) {
  .display-preview-grid { width: 100cqw; }
}

.tile {
  position: relative; display: block; width: 100%; aspect-ratio: 1 / 1;
  padding: 0; border: 0; border-radius: 6px; overflow: hidden; cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:focus-visible { outline: 3px solid var(--mud-palette-primary); outline-offset: 2px; }
.tile-wrap { position: relative; min-width: 0; }
.tile--selected { outline: 4px solid #d32f2f; outline-offset: -4px; }
.tile-favorite {
  position: absolute; left: 6px; bottom: 6px; z-index: 1; display: grid; place-items: center;
  width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.8); border-radius: 50%;
  background: rgba(20,24,34,.82); color: #fff; cursor: pointer;
}
.tile-favorite--active { color: #ffd54f; }
.tile-favorite:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.tile-badge {
  position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 2px;
  height: 22px; padding: 0 8px 0 4px; border-radius: 11px; font-size: 12px; font-weight: 600;
}
.tile-badge .mud-icon-root { font-size: 14px; }
.tile-badge--dark { background: rgba(20, 24, 34, 0.78); color: #fff; }
.tile-badge--light { background: #fff; color: var(--mud-palette-drawer-text); }
.tile-progress { position: absolute; left: 0; right: 0; bottom: 0; }
.tile-check {
  position: absolute; top: 6px; left: 6px; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #d32f2f;
  box-shadow: 0 1px 6px rgba(0,0,0,.65);
}

.scrubber { flex: 0 0 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 8px 0 0; position: sticky; top: 80px; }
.scrubber-item {
  width: 100%; min-height: 28px; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--mud-palette-text-secondary);
}
.scrubber-item:hover { color: var(--mud-palette-primary); }
.scrubber-item--year { font-weight: 700; color: var(--mud-palette-text-primary); margin-top: 6px; }

/* ---------- Upload ---------- */
.upload-destination { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.upload-album { flex: 1 1 220px; min-width: 0; }
.drop-zone {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 24px; text-align: center; border: 2px dashed var(--mud-palette-text-secondary);
  border-radius: 12px; background: var(--mud-palette-background);
}
.drop-zone--over { border-color: var(--mud-palette-primary); background: color-mix(in srgb, var(--mud-palette-primary) 8%, white); }
.drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; }
.drop-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%;
  background: color-mix(in srgb, var(--mud-palette-primary) 12%, white); color: var(--mud-palette-primary);
}
.drop-buttons { position: relative; z-index: 2; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding-top: 4px; }
.selected-summary { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.queue-summary { display: flex; flex-wrap: wrap; gap: 4px; }
.queue-hint { flex: 1 1 240px; margin-right: 8px; }
.upload-list, .upload-card-list { list-style: none; margin: 0; padding: 0; }
.upload-list { max-height: 400px; overflow-y: auto; }
.upload-row { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 6px 0; }
.upload-thumb { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 6px; }
.upload-main { flex: 1 1 0; min-width: 0; }
.upload-name { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 600; }
.upload-size { font-size: 12px; font-weight: 400; color: var(--mud-palette-text-secondary); }
.upload-progress { display: flex; align-items: center; gap: 10px; padding-top: 6px; font-size: 12px; color: var(--mud-palette-text-secondary); }
.upload-progress .mud-progress-linear { flex: 1 1 0; }
.upload-note { font-size: 12px; color: var(--mud-palette-text-secondary); }
.upload-note--skipped { color: var(--mud-palette-warning); }
.upload-note--failed { color: var(--mud-palette-error); }
.only-phone { display: none; }

.upload-card {
  position: fixed; right: 24px; bottom: 24px; z-index: 1300; width: 344px; overflow: hidden;
  border-radius: 8px; background: var(--mud-palette-surface); box-shadow: var(--mud-elevation-8);
}
.upload-card-head { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 16px; }
.upload-card-title { flex: 1 1 0; min-width: 0; }
.upload-card-list { padding: 4px 16px 12px; }

/* ---------- Viewer and info panel ---------- */
/* Viewer has no app bar, so drop the layout's reserved top padding and sit flush under the window. */
.mud-main-content.viewer-main {
  background: #12151c;
  padding-top: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}
.viewer { display: flex; height: 100%; background: #12151c; color: #e6e9f2; outline: none; }
.viewer--loading { align-items: center; justify-content: center; }
.viewer-stage { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; }
.viewer-title { flex: 1 1 0; min-width: 0; }
.viewer-date { font-weight: 700; color: #fff; }
.viewer-file { font-size: 12px; color: #b5bccb; }
.viewer-photo-row { flex: 1 1 0; min-height: 0; display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.viewer-nav { background: rgba(255, 255, 255, 0.12); flex: 0 0 auto; }
.viewer-photo {
  position: relative; flex: 1 1 0; align-self: stretch; min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.viewer-photo img,
.viewer-photo video {
  width: 100%; height: 100%; min-width: 0; min-height: 0;
  object-fit: contain; display: block; border-radius: 8px;
}
.viewer-quality {
  position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 4px;
  padding: 4px 4px 4px 12px; border-radius: 20px; background: rgba(20, 24, 34, 0.82); color: #fff; font-size: 13px; font-weight: 600;
}
.viewer-quality button {
  height: 32px; padding: 0 12px; border: 0; border-radius: 16px; cursor: pointer;
  background: rgba(255, 255, 255, 0.16); color: #fff; font: inherit; font-size: 13px; font-weight: 600;
}
.viewer-video-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 6px 8px 0;
}
.viewer-video-actions button {
  padding: 7px 14px; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 16px;
  background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer; font: inherit; font-size: 13px;
}
.viewer-video-actions button:hover { background: rgba(255, 255, 255, 0.2); }
.viewer-strip { display: flex; justify-content: center; gap: 8px; padding: 8px 16px 16px; overflow-x: auto; }
.strip-thumb { flex: 0 0 auto; width: 80px; height: 80px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; cursor: pointer; outline: 2px solid transparent; outline-offset: 2px; }
.strip-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.strip-thumb--current { outline-color: #fff; }

.viewer-info {
  flex: 0 0 380px; overflow-y: auto; background: var(--mud-palette-surface);
  color: var(--mud-palette-text-primary); border-left: 1px solid var(--mud-palette-lines-default);
}
.info-sheet { border-radius: 20px 20px 0 0; }
.info-panel { background: var(--mud-palette-surface); color: var(--mud-palette-text-primary); }
.info-header { display: flex; align-items: center; min-height: 64px; padding: 0 8px 0 20px; border-bottom: 1px solid var(--mud-palette-lines-default); }
.info-section { padding: 12px 20px; }
.info-row { display: flex; align-items: center; gap: 16px; padding: 12px 8px 12px 20px; }
.info-section .info-row { padding-left: 0; padding-right: 0; }
.info-row-icon { color: var(--mud-palette-text-secondary); }
.info-row-text { flex: 1 1 0; min-width: 0; }
.info-row-primary { font-size: 15px; font-weight: 600; }
.info-row-secondary { font-size: 13px; color: var(--mud-palette-text-secondary); }
.map-placeholder { position: relative; height: 132px; border-radius: 8px; background: #dce5df; }
.map-pin {
  position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--mud-palette-primary); color: #fff;
}
.location-switch { margin-top: 4px; }
.metadata-open { margin: 4px 0 0 30px; }
.info-table { margin-left: 38px; }
.info-table .mud-table-cell { border: 0; padding: 4px 0; font-size: 13px; }
.info-key { color: var(--mud-palette-text-secondary); }
.info-value { text-align: right; font-weight: 500; }
.album-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-left: 38px; }
.add-album { border-style: dashed; }
.storage-list { list-style: none; margin: 0 0 0 38px; padding: 0; }
.storage-list li { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.storage-key { flex: 1 1 0; color: var(--mud-palette-text-secondary); }
.storage-value { font-weight: 500; }
.info-actions { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px 24px; }

.metadata-page { max-width: 920px; }
.metadata-head { display: flex; align-items: flex-start; gap: 4px; }
.metadata-head-text { flex: 1 1 0; min-width: 0; padding-top: 8px; }
.metadata-count { margin-top: 4px; }
.metadata-search { max-width: 420px; }
.metadata-group { margin-top: 28px; }
.metadata-table { width: 100%; }
.metadata-key { width: 34%; color: var(--mud-palette-text-secondary); vertical-align: top; }
.metadata-value { font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Albums ---------- */
.sort-select { max-width: 220px; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.album-card { border-radius: 12px; overflow: hidden; }
.album-cover {
  display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px;
  width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; background: #fff; cursor: pointer;
}
.album-cover span:first-child { grid-row: 1 / span 2; }
.album-cover span { min-width: 0; min-height: 0; overflow: hidden; }
.album-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.album-cover:focus-visible { outline: 3px solid var(--mud-palette-primary); outline-offset: -3px; }
.album-info { display: flex; align-items: center; gap: 4px; padding: 12px 4px 12px 16px; }
.album-text { flex: 1 1 0; min-width: 0; }
.album-title { font-weight: 700; }
.album-new {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 260px; padding: 16px; border: 2px dashed var(--mud-palette-text-secondary); border-radius: 12px;
  background: transparent; color: var(--mud-palette-drawer-text); font: inherit; font-weight: 700; cursor: pointer;
}
.album-new-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%;
  background: color-mix(in srgb, var(--mud-palette-primary) 12%, white); color: var(--mud-palette-primary);
}

/* ---------- Phone ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200; display: flex; height: 64px;
  background: var(--mud-palette-surface); border-top: 1px solid var(--mud-palette-lines-default);
}
.bn-item {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 500; color: var(--mud-palette-drawer-text); text-decoration: none;
}
.bn-item.active { color: var(--mud-palette-primary); font-weight: 700; }
.bn-item--disabled { opacity: 0.5; }
.bn-pill { display: flex; align-items: center; justify-content: center; width: 56px; height: 28px; border-radius: 14px; }
.bn-item.active .bn-pill { background: color-mix(in srgb, var(--mud-palette-primary) 12%, white); }
.fab-album { position: fixed !important; right: 16px; bottom: 140px; z-index: 1250; }
.fab-album { bottom: 80px; }

@media (max-width: 959.98px) {
  .page-pad { padding: 8px 0 160px; }
  .toolbar { padding: 0 16px 8px; }
  .page-title { width: 100%; }
  .day-header { padding-left: 16px; padding-right: 16px; }
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; padding: 0 16px; }
  .only-phone { display: flex; }
  .viewer-photo-row { padding: 0; }
  .viewer-photo img,
  .viewer-photo video { border-radius: 0; }
  .viewer-nav { display: none; }
  .upload-card {
    left: 0; right: 0; bottom: 64px; width: auto; border-radius: 0; box-shadow: none;
    border-top: 1px solid var(--mud-palette-lines-default);
  }
  .upload-card-list { display: none; }
}

@media (max-width: 599.98px) {
  .media-grid { gap: 2px; }
  .tile { border-radius: 0; }
  .tile-badge { left: auto; right: 6px; bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

.loading-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--mud-palette-background, #F6F7FB);
}
.auth-wait {
  max-width: 420px;
  text-align: center;
}
.auth-wait h1 { font-size: 1.4rem; margin-bottom: 8px; }
.auth-wait p { margin: 0 0 12px; }
.auth-wait button {
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--mud-palette-primary, #425ce8);
  color: var(--mud-palette-primary-text, #fff);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.auth-wait button:focus-visible { outline: 3px solid var(--mud-palette-primary, #425ce8); outline-offset: 3px; }
.auth-hint { color: var(--mud-palette-text-secondary, #5B6475); }

/* ---------- iPhone USB preview ---------- */
.phone-gallery-page { max-width: 1280px; margin: 0 auto; }
.phone-gallery-hint { color: var(--mud-palette-text-secondary); margin-bottom: 20px; }
.phone-import-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.phone-import-toolbar .mud-input-control { min-width: 170px; }
.phone-selectable { position: relative; min-width: 0; }
.phone-selectable > input { position: absolute; z-index: 2; top: 8px; left: 8px; width: 20px; height: 20px; accent-color: #425ce8; }
.phone-imported-mark { position: absolute; right: 4px; top: 4px; padding: 2px 5px; border-radius: 4px; background: #1c6b42; color: white; font-size: 11px; }
.phone-live-mark { position: absolute; left: 4px; bottom: 26px; padding: 2px 5px; border-radius: 4px; background: #2c3446; color: white; font-size: 11px; }
.phone-gallery-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px;
  margin-bottom: 24px;
}
.phone-folder-select { width: min(100%, 350px); }
.phone-gallery-count { color: var(--mud-palette-text-secondary); }
.phone-gallery-section { margin-bottom: 28px; }
.phone-gallery-heading {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.phone-gallery-heading .mud-typography-body2 { color: var(--mud-palette-text-secondary); }
.phone-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.phone-media-card { min-width: 0; }
.phone-media-image {
  position: relative; display: grid; place-items: center; overflow: hidden;
  width: 100%; aspect-ratio: 1; border-radius: 8px;
  background: var(--mud-palette-background-gray, #f0f2f5); color: var(--mud-palette-text-secondary);
}
.phone-media-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.phone-video-mark {
  position: absolute; right: 6px; bottom: 6px; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(20,24,34,.8); color: #fff;
}
.phone-media-name {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 5px 2px 0; font-size: 13px;
}
.phone-load-more { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.phone-gallery-end { margin: 28px 0; text-align: center; color: var(--mud-palette-text-secondary); }

/* Split layout: fixed top header, scrollable thumbnail grid */
.mud-main-content:has(.phone-gallery-page--split) {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.page-pad.phone-gallery-page--split,
.phone-gallery-page--split {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 16px 24px 8px;
  box-sizing: border-box;
}

.phone-gallery-page--split .phone-gallery-header {
  flex: 0 0 auto;
  min-height: 0;
  z-index: 2;
}

.phone-gallery-scroll {
  flex: 1 1 0;
  min-height: 160px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  padding-bottom: 24px;
}

@media (max-width: 959.98px) {
  .mud-main-content:has(.phone-gallery-page--split) {
    height: calc(100dvh - 64px);
  }

  .page-pad.phone-gallery-page--split,
  .phone-gallery-page--split {
    padding: 8px 12px 8px;
  }

  .phone-gallery-page--split .phone-gallery-header {
    flex: 0 1 auto;
    overflow-y: auto;
  }
  .phone-gallery-page--split .phone-gallery-hint { margin-bottom: 8px; }
  .phone-gallery-page--split .phone-import-toolbar,
  .phone-gallery-page--split .phone-gallery-controls { margin-bottom: 8px; }
}

@media (max-width: 599.98px) {
  .phone-gallery-page { padding-left: 12px; padding-right: 12px; }
  .phone-media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .phone-media-image { border-radius: 4px; }
  .phone-media-name { font-size: 11px; }
}
