:root {
  --blue: #18a8e8;
  --blue-dark: #087cb4;
  --ink: #17212b;
  --muted: #687889;
  --line: #dce8f0;
  --bg: #f5f9fc;
  --panel: #ffffff;
  --danger: #c62828;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue-dark); text-decoration: none; }
button, .upload-button { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 9px 12px; cursor: pointer; font: inherit; }
button:hover, .upload-button:hover { border-color: var(--blue); }
button.primary { border: 0; background: var(--blue); color: #fff; }
button.danger { color: var(--danger); }
input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 12px; font: inherit; background: #fff; }
.logo { width: 172px; aspect-ratio: 1121 / 628; height: auto; object-fit: contain; display: block; }
.logo.small { width: 142px; aspect-ratio: 1121 / 628; }
.brand-text { font-size: 22px; font-weight: 800; color: var(--blue-dark); }
.top-logo { width: 138px; max-height: 56px; object-fit: contain; object-position: left center; }
.auth-logo-wrap { display: flex; justify-content: center; align-items: center; width: 100%; margin: 0 0 10px; }
.auth-logo { width: 172px; aspect-ratio: 1121 / 628; max-height: 99px; margin: 0 auto; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: 0 16px 50px rgba(23, 33, 43, .08); }
.auth-card h1 { margin: 10px 0 20px; font-size: 26px; text-align: center; }
.form { display: grid; gap: 12px; margin-bottom: 16px; }
.status { color: var(--danger); min-height: 20px; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 72px); }
.sidebar { background: #fbfdff; border-right: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.quota, .release { margin-top: 14px; color: var(--muted); display: grid; gap: 6px; font-size: 14px; }
.panel { padding: 18px; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.path { color: var(--muted); margin-bottom: 12px; }
.files { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.files th, .files td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.files th { background: #f9fcfe; color: var(--muted); font-weight: 600; }
.files td:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
.file-name-button { border: 0; padding: 0; background: transparent; color: var(--ink); font-weight: 600; text-align: left; }
.file-name-button:hover { color: var(--blue-dark); border: 0; }
.empty { color: var(--muted); text-align: center; }
.upload-list { display: grid; gap: 8px; margin-bottom: 12px; }
.upload-row { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(120px, 240px) auto; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.upload-row.failed { border-color: #f0b6b6; color: var(--danger); }
progress { width: 100%; height: 12px; accent-color: var(--blue); }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(10, 20, 30, .72); }
.modal-backdrop[hidden] { display: none; }
.preview-modal { width: min(1080px, 96vw); max-height: 92vh; background: #0b1117; color: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.modal-head { height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.modal-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-stage { display: grid; place-items: center; min-height: 280px; max-height: calc(92vh - 54px); padding: 12px; }
.preview-image { max-width: 100%; max-height: calc(92vh - 78px); object-fit: contain; }
.preview-video { width: 100%; max-height: calc(92vh - 78px); background: #000; }
.preview-loading, .preview-error { color: #dbeafe; padding: 30px; text-align: center; }
.preview-error { color: #fecaca; }

@media (max-width: 760px) {
  .topbar { height: auto; align-items: flex-start; flex-direction: column; padding: 12px; }
  .top-logo { width: 126px; max-height: 48px; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .files { display: block; overflow-x: auto; }
  .upload-row { grid-template-columns: 1fr; }
  .auth-logo { width: min(205px, 88%); }
}

/* Cloudex desktop-style refresh */
:root {
  --blue: #18a8e8;
  --blue-dark: #0878d7;
  --blue-soft: #eaf7ff;
  --ink: #111827;
  --muted: #667085;
  --line: #d9e4ef;
  --bg: #f7fbff;
  --panel: #ffffff;
  --danger: #b42318;
  --ok: #16a34a;
  --shadow: 0 18px 55px rgba(15, 23, 42, .08);
  --soft-shadow: 0 8px 28px rgba(15, 23, 42, .06);
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(24, 168, 232, .08), transparent 34vw),
    var(--bg);
}

button,
.upload-button {
  min-height: 40px;
  border-radius: 8px;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, transform .12s ease;
}

button:hover,
.upload-button:hover {
  background: var(--blue-soft);
  border-color: rgba(24, 168, 232, .62);
}

button:active,
.upload-button:active {
  transform: translateY(1px);
}

button.primary {
  background: linear-gradient(180deg, #20b5f2 0%, #0785df 100%);
  box-shadow: 0 10px 22px rgba(8, 133, 223, .22);
}

input,
select {
  min-height: 42px;
  border-radius: 8px;
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}

input:focus,
select:focus {
  border-color: rgba(24, 168, 232, .72);
  box-shadow: 0 0 0 4px rgba(24, 168, 232, .12);
}

.auth-page {
  place-items: start center;
  padding-top: 72px;
}

.auth-card {
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-top: 14px;
  letter-spacing: 0;
}

.auth-logo {
  width: 230px;
  max-height: 112px;
}

.topbar {
  height: 70px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .03);
}

.top-logo {
  width: 136px;
  max-height: 58px;
}

.top-actions {
  gap: 10px;
}

.top-actions span {
  color: var(--muted);
  font-size: 14px;
}

.layout {
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 70px);
  background: var(--panel);
}

.sidebar {
  padding: 18px 10px;
  gap: 6px;
  background: linear-gradient(180deg, #f7fbff 0%, #fff 100%);
}

.sidebar button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  min-height: 46px;
  border: 0;
  background: transparent;
  font-weight: 600;
  text-align: left;
}

.sidebar button::before {
  width: 24px;
  color: var(--blue-dark);
  text-align: center;
  font-size: 20px;
}

.sidebar button:nth-of-type(1)::before { content: "▱"; }
.sidebar button:nth-of-type(2)::before { content: "↑"; }

.sidebar button:hover {
  background: linear-gradient(90deg, #e5f5ff 0%, #f3fbff 100%);
}

.quota,
.release {
  margin: 14px 8px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.quota strong {
  color: var(--ink);
}

.panel {
  padding: 24px;
  background: linear-gradient(135deg, #fff 0%, #fbfdff 100%);
}

.toolbar {
  min-height: 62px;
  margin: 0 0 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.path {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-bottom: 14px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.files {
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.files th {
  background: #fbfdff;
}

.files th,
.files td {
  padding: 13px 14px;
  border-color: #edf2f7;
}

.files tr:hover td {
  background: #f5fbff;
}

.file-name-button {
  min-height: 30px;
}

.file-name-button::before {
  content: "□";
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 8px;
  border-radius: 7px;
  background: #eef7ff;
  color: var(--blue-dark);
  font-size: 17px;
}

.upload-row {
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

progress {
  height: 10px;
}

.preview-modal {
  border-radius: 8px;
}

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

  .panel {
    padding: 14px;
  }
}

/* User dashboard, closer to the desktop client render */
body:has(.cloud-dashboard) {
  overflow: hidden;
}

body:has(.cloud-dashboard) .topbar {
  height: 56px;
}

body:has(.cloud-dashboard) .top-logo {
  width: 116px;
}

body:has(.cloud-dashboard) .layout {
  min-height: calc(100vh - 56px);
  grid-template-columns: minmax(0, 1fr);
}

body:has(.cloud-dashboard) .sidebar[hidden] {
  display: none;
}

body:has(.cloud-dashboard) .sidebar {
  padding: 16px 8px;
  border-right: 1px solid var(--line);
}

body:has(.cloud-dashboard) .sidebar button {
  min-height: 40px;
  margin-bottom: 4px;
  padding-left: 44px;
}

.cloud-dashboard {
  min-height: 150px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  align-items: center;
  gap: 24px;
  padding: 10px 18px 22px;
  border-bottom: 1px solid var(--line);
}

.connect-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.connect-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(22, 163, 74, .24);
}

.connect-card h1 {
  margin: 0 0 10px;
  font-size: 24px;
  letter-spacing: 0;
}

.connect-card p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.quota-ring {
  width: 142px;
  height: 142px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background: conic-gradient(var(--blue) var(--used), #e8edf3 0);
  position: relative;
}

.quota-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: #fff;
}

.quota-ring > div {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 5px;
  text-align: center;
}

.quota-ring span,
.quota-ring small {
  color: var(--muted);
  font-size: 12px;
}

.quota-ring strong {
  font-size: 30px;
  line-height: 1;
}

.sync-card {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.sync-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.sync-head strong {
  color: var(--ink);
  font-size: 18px;
}

.sync-progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf3;
}

.sync-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0b8de3, #20b5f2);
}

body:has(.cloud-dashboard) .panel {
  height: calc(100vh - 56px);
  padding: 0;
  overflow: auto;
}

body:has(.cloud-dashboard) .toolbar {
  min-height: 42px;
  margin: 0;
  padding: 8px 22px;
  border-bottom: 0;
  gap: 6px;
}

body:has(.cloud-dashboard) .toolbar button,
body:has(.cloud-dashboard) .toolbar .upload-button {
  min-height: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

body:has(.cloud-dashboard) .toolbar button:not(.tool-button)::before,
body:has(.cloud-dashboard) .toolbar .upload-button::before {
  display: inline-grid;
  place-items: center;
  width: 15px;
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 800;
}

body:has(.cloud-dashboard) .toolbar button[onclick="loadFiles()"]::before { content: "↻"; }
body:has(.cloud-dashboard) .toolbar button[onclick="createFolder()"]::before { content: "+"; }
body:has(.cloud-dashboard) .toolbar .upload-button::before { content: "⇧"; }

body:has(.cloud-dashboard) .tool-button span {
  display: inline-grid;
  place-items: center;
  width: 15px;
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 800;
}

body:has(.cloud-dashboard) .path {
  min-height: 30px;
  margin: 0 22px 8px;
  padding: 0 10px;
  font-size: 12px;
}

body:has(.cloud-dashboard) .upload-list {
  margin: 0 22px 12px;
}

body:has(.cloud-dashboard) .files {
  width: calc(100% - 44px);
  margin: 0 22px 22px;
  box-shadow: none;
}

body:has(.cloud-dashboard) .files th,
body:has(.cloud-dashboard) .files td {
  height: 38px;
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 12px;
}

body:has(.cloud-dashboard) .files th {
  height: 34px;
  font-size: 12px;
}

body:has(.cloud-dashboard) .file-name-button {
  min-height: 24px;
  font-size: 12px;
  font-weight: 650;
}

body:has(.cloud-dashboard) .file-name-button::before {
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 6px;
  font-size: 12px;
}

body:has(.cloud-dashboard) .files td:last-child {
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

body:has(.cloud-dashboard) .files td:last-child button {
  min-height: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border-radius: 6px;
  border-color: #d8e5f0;
  background: #fff;
  color: #1f3448;
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .035);
}

body:has(.cloud-dashboard) .files td:last-child button::before {
  display: inline-grid;
  place-items: center;
  width: 12px;
  color: currentColor;
  font-size: 12px;
  font-weight: 800;
}

body:has(.cloud-dashboard) .files td:last-child button[onclick^="openFolder"]::before { content: "↗"; }
body:has(.cloud-dashboard) .files td:last-child button[onclick^="previewFile"]::before { content: "▶"; }
body:has(.cloud-dashboard) .files td:last-child button[onclick^="downloadFile"]::before { content: "↓"; }
body:has(.cloud-dashboard) .files td:last-child button[onclick^="deleteFile"]::before { content: "×"; }

body:has(.cloud-dashboard) .files td:last-child button:hover {
  border-color: rgba(24, 168, 232, .55);
  background: #eef9ff;
  color: var(--blue-dark);
  box-shadow: 0 5px 14px rgba(8, 133, 223, .10);
}

body:has(.cloud-dashboard) .files td:last-child button.danger {
  border-color: #f0c8c5;
  background: #fffafa;
  color: var(--danger);
  box-shadow: none;
}

body:has(.cloud-dashboard) .files td:last-child button.danger:hover {
  border-color: #e59a95;
  background: #fff1f0;
  color: #a31712;
}

.profile-settings-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  color: var(--blue-dark);
  font-size: 16px;
}

.top-albums-button {
  width: auto;
  min-width: max-content;
  min-height: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.top-albums-button span {
  font-size: 14px;
}

body:has(.cloud-dashboard) .top-actions .top-albums-button {
  box-sizing: border-box;
  width: auto !important;
  min-width: 118px !important;
  max-width: none;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 12px !important;
  overflow: visible;
  justify-content: center;
}

.profile-modal {
  width: min(760px, calc(100vw - 28px));
  max-height: 90vh;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(15, 23, 42, .24);
}

.profile-modal .modal-head {
  background: #fff;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.profile-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  overflow: auto;
  max-height: calc(90vh - 108px);
}

.settings-card {
  display: grid;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.settings-card h2 {
  margin: 0;
  font-size: 15px;
}

.settings-form {
  display: grid;
  gap: 8px;
}

.settings-form input {
  min-height: 36px;
  font-size: 13px;
}

.settings-form button,
.settings-card > button {
  min-height: 32px;
  height: 32px;
  font-size: 12px;
}

.quota-settings-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #edf2f7;
  color: var(--muted);
  font-size: 13px;
}

.quota-settings-line strong {
  color: var(--ink);
}

.clients-card {
  grid-column: 1 / -1;
}

.client-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.client-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
}

.client-link span {
  min-width: 34px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  padding: 4px 5px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
}

.client-link.disabled {
  opacity: .62;
}

.settings-status {
  min-height: 32px;
  padding: 0 14px 12px;
  color: var(--danger);
  font-size: 13px;
}

.album-sort {
  width: auto;
  min-height: 30px;
  margin-left: 10px;
  padding: 0 8px;
  font-size: 12px;
}

.album-view {
  width: calc(100% - 44px);
  margin: 0 22px 24px;
}

.album-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.album-section-head > div {
  display: grid;
  gap: 3px;
}

.album-section-head strong {
  font-size: 15px;
}

.album-section-head span {
  color: var(--muted);
  font-size: 12px;
}

.album-section-head button {
  min-height: 30px;
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.album-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .045);
}

.album-cover {
  width: 100%;
  height: 122px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(135deg, #eff9ff, #ffffff);
  color: var(--blue);
  font-size: 40px;
  overflow: hidden;
}

.album-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-card-body {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.album-title {
  justify-content: flex-start;
  min-height: 24px;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}

.album-card-body span,
.photo-page-head span,
.photo-meta span {
  color: var(--muted);
  font-size: 12px;
}

.album-card-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
}

.album-card-actions button,
.photo-remove,
.album-pagination button {
  min-height: 26px;
  height: 26px;
  padding: 0 9px;
  font-size: 11px;
}

.photo-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.photo-page-head > div:first-child {
  display: grid;
  gap: 3px;
}

.album-edit-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.album-edit-actions button {
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
}

.photo-tile {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.photo-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #f4f9fd;
  color: var(--muted);
  overflow: hidden;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-meta {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
}

.photo-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.photo-remove {
  margin: 0 9px 9px;
}

.photo-edit-actions {
  display: grid;
  gap: 5px;
  padding: 0 9px 9px;
}

.photo-edit-actions button {
  min-height: 26px;
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.photo-edit-actions .photo-remove {
  width: 100%;
  margin: 0;
}

.album-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.album-pagination span,
.album-empty {
  color: var(--muted);
  font-size: 13px;
}

.album-empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.photo-picker-modal {
  width: min(1120px, calc(100vw - 28px));
  max-height: 92vh;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0,0,0,.24);
}

.photo-picker-modal .modal-head {
  background: #fff;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.photo-picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.photo-picker-toolbar > div {
  display: flex;
  gap: 8px;
}

.photo-picker-toolbar span {
  color: var(--muted);
  font-size: 13px;
}

.photo-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
  max-height: calc(92vh - 174px);
  overflow: auto;
  padding: 14px;
  background: #f8fbfe;
}

.picker-photo-tile {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.picker-photo-tile.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(24, 168, 232, .18);
}

.picker-photo-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #eef7fd;
  color: var(--muted);
  overflow: hidden;
}

.picker-photo-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.picker-photo-tile label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  font-size: 12px;
}

.picker-photo-tile label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-picker-modal .album-pagination {
  padding: 11px 14px 14px;
  margin-top: 0;
  border-top: 1px solid var(--line);
}

@media (max-width: 760px) {
  body:has(.cloud-dashboard) {
    overflow: auto;
  }

  body:has(.cloud-dashboard) .topbar {
    height: auto;
    min-height: 52px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
  }

  body:has(.cloud-dashboard) .top-logo {
    width: 92px;
    max-height: 38px;
  }

  body:has(.cloud-dashboard) .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px 28px auto;
    min-width: 0;
    width: 100%;
    justify-content: stretch;
    align-items: center;
    gap: 6px;
  }

  body:has(.cloud-dashboard) .top-actions span {
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  body:has(.cloud-dashboard) .top-actions button {
    min-height: 28px;
    height: 28px;
    padding: 0 9px;
    font-size: 12px;
  }

  .profile-settings-button {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
  }

  body:has(.cloud-dashboard) .top-actions .top-albums-button {
    width: 30px;
    min-width: 30px;
    max-width: 30px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    justify-content: center;
    overflow: hidden;
    font-size: 0;
  }

  .top-albums-button span {
    font-size: 14px;
  }

  .profile-settings-grid,
  .client-links {
    grid-template-columns: 1fr;
  }

  body:has(.cloud-dashboard) .layout {
    grid-template-columns: 1fr;
  }

  body:has(.cloud-dashboard) .panel {
    height: auto;
  }

  .cloud-dashboard {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 12px;
    padding: 12px 16px 18px;
  }

  .connect-card {
    align-items: flex-start;
    gap: 10px;
  }

  .connect-icon {
    width: 34px;
    height: 34px;
    font-size: 11px;
  }

  .connect-card h1 {
    margin: 0 0 4px;
    font-size: 21px;
  }

  .connect-card p {
    font-size: 14px;
    line-height: 1.25;
  }

  .quota-ring {
    justify-self: start;
    width: 138px;
    height: 138px;
    margin-left: 10px;
  }

  .sync-card {
    padding: 14px 16px;
  }

  body:has(.cloud-dashboard) .toolbar {
    padding: 10px 16px;
    gap: 7px;
  }

  body:has(.cloud-dashboard) .toolbar button,
  body:has(.cloud-dashboard) .toolbar .upload-button {
    min-height: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  body:has(.cloud-dashboard) .path {
    margin: 0 16px 10px;
  }

  body:has(.cloud-dashboard) .upload-list {
    margin: 0 16px 10px;
  }

  body:has(.cloud-dashboard) .files {
    width: calc(100% - 32px);
    margin: 0 16px 18px;
    display: block;
    border: 0;
    background: transparent;
  }

  body:has(.cloud-dashboard) .files thead {
    display: none;
  }

  body:has(.cloud-dashboard) .files tbody,
  body:has(.cloud-dashboard) .files tr,
  body:has(.cloud-dashboard) .files td {
    display: block;
    width: 100%;
  }

  body:has(.cloud-dashboard) .files tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .045);
  }

  body:has(.cloud-dashboard) .files td {
    height: auto;
    min-height: 30px;
    padding: 7px 10px;
    border-bottom: 1px solid #edf2f7;
    white-space: normal;
  }

  body:has(.cloud-dashboard) .files td:nth-child(1) {
    font-weight: 700;
  }

  body:has(.cloud-dashboard) .files td:nth-child(2)::before { content: "Тип: "; color: var(--muted); }
  body:has(.cloud-dashboard) .files td:nth-child(3)::before { content: "Размер: "; color: var(--muted); }
  body:has(.cloud-dashboard) .files td:nth-child(4)::before { content: "Дата: "; color: var(--muted); }

  body:has(.cloud-dashboard) .files td:last-child {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 0;
    background: #fbfdff;
  }

  body:has(.cloud-dashboard) .files td:last-child button {
    min-height: 26px;
    height: 26px;
    padding: 0 8px;
    font-size: 11px;
  }

  .album-view {
    width: calc(100% - 32px);
    margin: 0 16px 18px;
  }

  .album-grid {
    grid-template-columns: 1fr;
  }

  .album-section-head {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
  }

  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .photo-meta {
    padding: 6px;
  }

  .photo-edit-actions {
    padding: 0 6px 6px;
  }

  .photo-page-head,
  .album-pagination {
    flex-wrap: wrap;
  }

  .album-edit-actions {
    width: 100%;
    margin-left: 0;
  }

  .album-edit-actions button {
    flex: 1 1 auto;
  }

  .photo-picker-modal {
    width: calc(100vw - 16px);
    max-height: 94vh;
  }

  .photo-picker-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
  }

  .photo-picker-toolbar > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .photo-picker-toolbar button {
    min-height: 30px;
    height: 30px;
    padding: 0 8px;
    font-size: 11px;
  }

  .photo-picker-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    max-height: calc(94vh - 190px);
    padding: 10px;
  }

  .picker-photo-tile label {
    padding: 5px;
    font-size: 10px;
  }
}

/* Final top account bar sizing */
body:has(.cloud-dashboard) .top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

body:has(.cloud-dashboard) .top-actions #profile {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body:has(.cloud-dashboard) .top-actions .top-albums-button {
  flex: 0 0 auto;
  width: auto !important;
  min-width: 112px !important;
  max-width: none !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 10px !important;
  overflow: visible !important;
  font-size: 12px !important;
  white-space: nowrap;
}

body:has(.cloud-dashboard) .top-actions .top-albums-button span {
  font-size: 14px !important;
}

@media (max-width: 760px) {
  body:has(.cloud-dashboard) .top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    width: 100%;
    min-width: 0;
  }

  body:has(.cloud-dashboard) .top-actions #profile {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 64px;
    font-size: 12px;
  }

  body:has(.cloud-dashboard) .top-actions .top-albums-button {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 108px !important;
    max-width: 112px !important;
    height: 28px !important;
    min-height: 28px !important;
    padding: 0 8px !important;
    overflow: visible !important;
    font-size: 12px !important;
    line-height: 1 !important;
    white-space: nowrap;
  }

  body:has(.cloud-dashboard) .top-actions .top-albums-button span {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 14px;
    min-width: 14px;
    margin-right: 4px;
    font-size: 12px !important;
    line-height: 1 !important;
  }

  body:has(.cloud-dashboard) .top-actions .profile-settings-button {
    flex: 0 0 28px;
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
  }

  body:has(.cloud-dashboard) .top-actions > button:last-child {
    flex: 0 0 auto;
    height: 28px;
    min-height: 28px;
    padding: 0 8px;
  }
}
