:root {
  --apple-blue: #007aff;
  --tile-radius: 28px;
  --glass: rgba(2, 6, 23, 0.72);
  --glass-border: rgba(255, 255, 255, 0.18);
  --bg-1: rgba(14, 165, 233, 0.88);
  --bg-2: rgba(37, 99, 235, 0.78);
  --bg-3: rgba(236, 72, 153, 0.42);
  --bg-4: rgba(6, 182, 212, 0.38);
  --bg-base: #020617;
}

html, body {
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  color: #f5f5f7;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-base);
}

.icloud-bg {
  background-color: var(--bg-base);
  background-image:
    radial-gradient(900px 620px at 8% -8%, var(--bg-1), transparent 56%),
    radial-gradient(820px 580px at 92% 4%, var(--bg-2), transparent 52%),
    radial-gradient(760px 520px at 78% 108%, var(--bg-3), transparent 56%),
    radial-gradient(640px 460px at 18% 118%, var(--bg-4), transparent 50%),
    linear-gradient(180deg, #0b1b3a 0%, #071024 38%, var(--bg-base) 100%);
}

.icloud-bg::before {
  content: "";
  position: fixed;
  inset: -22%;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 28%, rgba(56, 189, 248, 0.32), transparent 34%),
    radial-gradient(circle at 78% 22%, rgba(99, 102, 241, 0.3), transparent 32%),
    radial-gradient(circle at 62% 78%, rgba(236, 72, 153, 0.22), transparent 30%);
  filter: blur(48px);
  animation: aurora 18s ease-in-out infinite alternate;
}

body.theme-ocean {
  --bg-1: rgba(14, 165, 233, 0.88);
  --bg-2: rgba(37, 99, 235, 0.78);
  --bg-3: rgba(99, 102, 241, 0.4);
  --bg-4: rgba(6, 182, 212, 0.38);
  --bg-base: #020617;
}
body.theme-aurora {
  --bg-1: rgba(236, 72, 153, 0.72);
  --bg-2: rgba(139, 92, 246, 0.78);
  --bg-3: rgba(56, 189, 248, 0.4);
  --bg-4: rgba(251, 146, 60, 0.28);
  --bg-base: #0b0614;
}
body.theme-sunset {
  --bg-1: rgba(249, 115, 22, 0.78);
  --bg-2: rgba(244, 63, 94, 0.62);
  --bg-3: rgba(251, 191, 36, 0.32);
  --bg-4: rgba(37, 99, 235, 0.28);
  --bg-base: #14080c;
}
body.theme-midnight {
  --bg-1: rgba(37, 99, 235, 0.55);
  --bg-2: rgba(30, 64, 175, 0.62);
  --bg-3: rgba(88, 28, 135, 0.42);
  --bg-4: rgba(14, 165, 233, 0.28);
  --bg-base: #020617;
}
body.theme-forest {
  --bg-1: rgba(16, 185, 129, 0.62);
  --bg-2: rgba(13, 148, 136, 0.5);
  --bg-3: rgba(5, 150, 105, 0.32);
  --bg-4: rgba(37, 99, 235, 0.28);
  --bg-base: #02140f;
}
body.theme-rose {
  --bg-1: rgba(244, 63, 94, 0.7);
  --bg-2: rgba(219, 39, 119, 0.58);
  --bg-3: rgba(251, 146, 60, 0.32);
  --bg-4: rgba(139, 92, 246, 0.3);
  --bg-base: #14060c;
}

@keyframes aurora {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

.glass-tile {
  position: relative;
  overflow: hidden;
  border-radius: var(--tile-radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(48px) saturate(190%);
  -webkit-backdrop-filter: blur(48px) saturate(190%);
}

.glass-tile:hover {
  background: rgba(2, 6, 23, 0.82);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  grid-auto-rows: minmax(168px, auto);
  gap: 16px;
}

.tile-profile,
.tile-notes,
.tile-apps {
  grid-row: span 2;
}

.tile-photos,
.tile-drive,
.tile-film,
.tile-mail {
  grid-column: span 2;
  grid-row: span 2;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
  .tile-photos,
  .tile-drive,
  .tile-film,
  .tile-mail {
    grid-column: span 2;
  }
}

@media (max-width: 767px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: 10px;
  }
  .tile-photos,
  .tile-drive,
  .tile-film,
  .tile-mail,
  .tile-profile,
  .tile-notes,
  .tile-apps,
  .tile-reminders,
  .tile-calendar,
  .tile-music {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
  }
}

.photo-mosaic {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  height: 100%;
}

.photo-mosaic img:first-child {
  grid-row: span 2;
}

.app-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 11px;
  text-align: center;
}

.cal-day.today {
  background: var(--apple-blue);
  color: white;
  border-radius: 999px;
}

.minus-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #8e8e93;
  color: #1c1c1e;
  display: none;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  border: 0;
}

.editing .minus-btn {
  display: grid;
}

.editing .glass-tile {
  animation: jiggle 0.22s ease-in-out infinite;
}

.editing .glass-tile:nth-child(2n) {
  animation-duration: 0.26s;
  animation-delay: -0.04s;
}

.editing .glass-tile:nth-child(3n) {
  animation-duration: 0.24s;
  animation-delay: -0.08s;
}

@keyframes jiggle {
  0% { transform: rotate(-0.7deg) translateY(0); }
  50% { transform: rotate(0.7deg) translateY(-0.4px); }
  100% { transform: rotate(-0.7deg) translateY(0); }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 2px;
}

.photo-grid > button.flex,
.photo-grid > button.file-row {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  height: 52px;
  min-height: 52px;
  flex-direction: row;
  justify-content: flex-start;
  padding: 0 14px;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.photo-grid > button.flex .text-2xl,
.photo-grid > button.file-row .text-2xl {
  font-size: 16px;
  line-height: 1;
}

.photo-grid > button.flex span.w-full,
.photo-grid > button.file-row span.w-full {
  font-size: 14px;
  text-align: left;
}

@media (max-width: 767px) {
  .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
  }
  .photo-grid > button.flex,
  .photo-grid > button.file-row {
    height: 42px;
    min-height: 42px;
    padding: 0 10px;
    gap: 8px;
  }
  .photo-grid > button.flex .text-2xl,
  .photo-grid > button.file-row .text-2xl {
    font-size: 13px;
  }
  .photo-grid > button.flex span.w-full,
  .photo-grid > button.file-row span.w-full {
    font-size: 12px;
  }
  .album-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 10px;
    padding: 12px 10px 6px;
  }
  .album-cover {
    border-radius: 14px;
  }
  .album-title {
    font-size: 13px;
    margin-top: 6px;
  }
  .app-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .toolbar-btn {
    width: 30px;
    height: 30px;
  }
  .toolbar-btn svg {
    width: 18px;
    height: 18px;
  }
  .select-tools {
    gap: 14px;
    padding: 6px 12px 8px;
  }
  .select-tools button {
    font-size: 13px;
  }
  .library-title {
    font-size: 18px;
  }
  .select-btn {
    font-size: 14px;
    padding: 4px 10px;
  }
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.check-ring {
  width: 22px;
  height: 22px;
  border: 1.5px solid rgba(255,255,255,.92);
  box-shadow: 0 0 0 1px rgba(0,0,0,.18);
}

.sheet-closed { transform: translateY(110%); }
.sheet-open { transform: translateY(0); }

.tile-hidden { display: none !important; }

.select-btn {
  color: #007aff;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px 16px;
  padding: 18px 20px 8px;
}

.album-card {
  text-align: left;
  background: transparent;
}

.album-cover {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 22px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.18), rgba(255,255,255,0.04) 42%, rgba(0,0,0,0.35)),
    linear-gradient(180deg, #3b82f6, #1e1b4b);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, transparent 32%, rgba(0,0,0,0.28) 100%);
  pointer-events: none;
}

.album-kind-youtube .album-cover {
  background: linear-gradient(160deg, #ef4444, #7f1d1d);
}

.album-title {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.album-meta {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

.download-sheet {
  width: min(420px, 100%);
  border-radius: 18px;
  background: rgba(28, 28, 30, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  backdrop-filter: blur(40px) saturate(160%);
  -webkit-backdrop-filter: blur(40px) saturate(160%);
}

.download-option {
  display: flex;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.download-option:last-of-type {
  border-bottom: 0;
}

.download-dot {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,0.45);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.download-option.active .download-dot {
  border-color: var(--apple-blue);
}

.download-option.active .download-dot span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--apple-blue);
}

.theme-dot {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}

.theme-dot.active {
  border-color: #fff;
}

.theme-ocean-dot { background: linear-gradient(135deg, #7dd3fc, #2563eb); }
.theme-aurora-dot { background: linear-gradient(135deg, #f472b6, #8b5cf6); }
.theme-sunset-dot { background: linear-gradient(135deg, #fb923c, #f43f5e); }
.theme-midnight-dot { background: linear-gradient(135deg, #1e3a8a, #020617); }
.theme-forest-dot { background: linear-gradient(135deg, #34d399, #064e3b); }
.theme-rose-dot { background: linear-gradient(135deg, #fb7185, #9d174d); }

.library-view {
  color: #fff;
  background:
    radial-gradient(120% 70% at 50% -18%, rgba(255, 255, 255, 0.1), transparent 46%),
    linear-gradient(180deg, #1c1c1e 0%, #0a0a0a 28%, #000 100%);
}

.library-sidebar {
  background: linear-gradient(180deg, rgba(22, 22, 24, 0.94), rgba(0, 0, 0, 0.92));
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}

.library-header {
  background: linear-gradient(180deg, rgba(28, 28, 30, 0.92), rgba(0, 0, 0, 0.78));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.library-title {
  color: #fff;
  text-shadow: 0 0 22px rgba(255, 255, 255, 0.28);
}

.library-main {
  background: #000;
}

.library-view .nav-item {
  color: #fff;
}

.library-view [data-count] {
  color: rgba(255, 255, 255, 0.72);
}

.toolbar-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #007aff;
  filter: drop-shadow(0 0 8px rgba(0, 122, 255, 0.55));
  border-radius: 10px;
}

.toolbar-btn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar-btn:hover:not(:disabled) {
  background: rgba(0, 122, 255, 0.12);
}

.toolbar-btn:disabled {
  opacity: 0.28;
  filter: none;
}

.toolbar-btn.is-favorite {
  color: #007aff;
}

.toolbar-btn.is-favorite svg {
  fill: #007aff;
  stroke: #007aff;
}

.select-tools {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 8px 20px 10px;
  background: #000;
}

.select-tools button {
  color: #007aff;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 0 12px rgba(0, 122, 255, 0.35);
}

.select-tools button:hover {
  color: #4da3ff;
}

.select-btn {
  color: #007aff;
  background: transparent;
  border: 0;
  box-shadow: none;
  font-weight: 600;
  text-shadow: 0 0 12px rgba(0, 122, 255, 0.45);
}

.photo-grid button.is-focused {
  outline: 2px solid #007aff;
  outline-offset: -2px;
}

.fav-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 18px;
  height: 18px;
  color: #007aff;
  filter: drop-shadow(0 0 6px rgba(0, 122, 255, 0.7));
}

.fav-badge svg {
  width: 18px;
  height: 18px;
  fill: #007aff;
}

.search-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(118, 118, 128, 0.24);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: rgba(235, 235, 245, 0.55);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 16px;
  -webkit-appearance: none;
}

#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

#search-input::placeholder {
  color: rgba(235, 235, 245, 0.55);
}

.search-clear {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(235, 235, 245, 0.3);
  color: #000;
  font-size: 11px;
  line-height: 18px;
}

.upload-progress {
  margin: 0 12px 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(28, 28, 30, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.upload-progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

#upload-progress-label,
#download-progress-label {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

#upload-progress-dest,
#download-progress-dest {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-align: right;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

#upload-progress-bar,
#download-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #007aff;
  box-shadow: 0 0 10px rgba(0, 122, 255, 0.55);
  transition: width 0.18s ease-out;
}
