:root {
  color-scheme: light;
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --star: #f59e0b;
  --radius: 22px;
  --shadow: 0 18px 45px rgba(15, 23, 42, .10);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

.loading {
  cursor: progress;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.viewer-entry {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .16), transparent 34%),
    var(--bg);
}

.hero-card {
  width: min(100%, 480px);
  padding: 30px;
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.code-card {
  padding: 26px;
}

.code-input {
  height: 58px;
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.small-tip {
  margin-bottom: 0;
  font-size: 13px;
}

.app-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #111827;
  color: var(--star);
  font-size: 28px;
}

.hero-card h1,
.app-header h1,
.mobile-topbar h1 {
  margin: 12px 0 8px;
  line-height: 1.15;
}

.hero-card p,
.muted {
  color: var(--muted);
  line-height: 1.65;
}

.sync-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 8px 0 0;
  padding: 0 12px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: rgba(245, 246, 251, .92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(229, 231, 235, .78);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(22px, 7vw, 34px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
}

.content {
  width: min(100%, 1100px);
  margin: 0 auto;
  padding: 16px;
}

.content.no-top-gap {
  padding-top: 10px;
}

.panel {
  margin-bottom: 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

.panel.compact {
  padding-bottom: 14px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label,
.comment-box,
.rename-form label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.rename-form {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  min-height: 50px;
  padding: 0 14px;
}

textarea {
  min-height: 94px;
  padding: 13px 14px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:active {
  background: var(--primary-dark);
}

.secondary-button {
  background: #eef2ff;
  color: #1e3a8a;
}

.ghost-button {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-button {
  background: #fee2e2;
  color: var(--danger);
}

.small {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 13px;
  font-size: 14px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stats-grid div {
  padding: 14px;
  border-radius: 18px;
  background: #f8fafc;
}

.stats-grid strong {
  display: block;
  font-size: 22px;
}

.stats-grid span,
.album-row span,
.viewer-meta span {
  color: var(--muted);
  font-size: 13px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.hero-card .action-grid {
  grid-template-columns: 1fr;
}

.share-box {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.share-box > div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fafc;
}

.share-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.share-box code {
  overflow: hidden;
  color: #1d4ed8;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-box strong {
  font-size: clamp(30px, 10vw, 48px);
  letter-spacing: .14em;
}

.upload-box {
  display: grid;
  gap: 12px;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-box label {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 20px;
  border: 2px dashed #bfdbfe;
  border-radius: 22px;
  background: #eff6ff;
  text-align: center;
}

.upload-box label strong {
  font-size: 20px;
}

.upload-box label span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.upload-status {
  margin-top: 14px;
}

.upload-status-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.upload-status-actions p {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.upload-status-actions .danger-button {
  flex: 0 0 auto;
}

.file-summary {
  padding: 12px 14px;
  border-radius: 16px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

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

.selected-file-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.selected-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgba(220, 38, 38, .92);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(127, 29, 29, .25);
}

.selected-file-card img,
.zip-preview {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #eef2ff;
}

.zip-preview {
  display: grid;
  place-items: center;
  color: #1e3a8a;
  font-weight: 900;
}

.selected-file-card strong,
.selected-file-card span {
  display: block;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-card strong {
  padding-top: 7px;
  font-size: 12px;
}

.selected-file-card span {
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.selected-more {
  grid-column: 1 / -1;
  padding: 12px;
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.progress-line {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}

.progress-line span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width .2s ease;
}

@media (max-width: 540px) {
  .upload-status-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

.notice {
  padding: 14px;
  border-radius: 16px;
  background: #eff6ff;
  color: #1d4ed8;
  line-height: 1.5;
}

.notice.error {
  background: #fef2f2;
  color: #b91c1c;
}

.error-details {
  margin-top: 12px;
  color: #b91c1c;
  font-size: 14px;
}

.album-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.album-row strong,
.album-row span {
  display: block;
}

.album-row em {
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 13px;
  font-style: normal;
}

.list-empty {
  padding: 30px 10px;
  color: var(--muted);
  text-align: center;
}

.grid-empty {
  grid-column: 1 / -1;
}

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(17, 24, 39, .96);
  color: #fff;
  backdrop-filter: blur(18px);
}

.mobile-topbar > div {
  min-width: 0;
}

.mobile-topbar h1 {
  margin: 0 0 6px;
  font-size: 21px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-topbar p {
  margin: 0;
  color: #d1d5db;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-link {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.filter-tabs {
  position: sticky;
  top: calc(68px + env(safe-area-inset-top));
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 16px;
  background: rgba(245, 246, 251, .92);
  border-bottom: 1px solid rgba(229, 231, 235, .75);
  backdrop-filter: blur(16px);
}

.filter-tabs button {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.filter-tabs button.active {
  background: #111827;
  color: #fff;
}

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

.photo-card {
  position: relative;
  overflow: hidden;
  margin: 0;
  border-radius: 13px;
  background: #e5e7eb;
  aspect-ratio: 1;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-card:active {
  transform: scale(.985);
}

.admin-grid .photo-card {
  aspect-ratio: 1 / 1.16;
  background: #fff;
}

.admin-grid .photo-card img {
  height: calc(100% - 34px);
}

.admin-grid .photo-card p {
  margin: 0;
  padding: 7px 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.star-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 24, 39, .64);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.star-button.on,
.big-star.on,
.badge.starred {
  color: var(--star);
}

.comment-dot,
.badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(17, 24, 39, .72);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.comment-button {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 2;
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 24, 39, .72);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.admin-comment-button {
  bottom: 40px;
}

.card-badges {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 5px;
}

.card-badges .badge {
  position: static;
}

.load-more {
  width: 100%;
  margin-top: 14px;
}

.feedback-list {
  display: grid;
  gap: 10px;
}

.feedback-item {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.feedback-thumb {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
}

.feedback-body {
  min-width: 0;
}

.feedback-body strong,
.feedback-body em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feedback-body strong {
  white-space: nowrap;
}

.feedback-body em {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #020617;
  color: #fff;
}

.viewer-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: calc(48px + env(safe-area-inset-top)) 0 0;
}

.viewer-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewer-close,
.viewer-nav {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(15, 23, 42, .62);
  color: #fff;
}

.viewer-close {
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 30px;
}

.viewer-nav {
  top: 45%;
  width: 40px;
  height: 58px;
  border-radius: 999px;
  font-size: 38px;
}

.viewer-nav.prev {
  left: 8px;
}

.viewer-nav.next {
  right: 8px;
}

.viewer-sheet {
  flex: 0 0 auto;
  padding: 16px 16px max(18px, env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: #fff;
  color: var(--text);
}

.viewer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.viewer-meta strong,
.viewer-meta span {
  display: block;
}

.viewer-meta strong {
  max-width: 54vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.big-star {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 900;
}

.viewer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.viewer-floating-actions {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 22px;
  background: rgba(15, 23, 42, .72);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .28);
}

.viewer-floating-actions .secondary-button {
  background: rgba(255, 255, 255, .92);
  color: #111827;
}

.viewer-comment-preview {
  margin: 0;
  padding: 12px;
  border-radius: 16px;
  background: #f8fafc;
  color: #374151;
  line-height: 1.55;
  white-space: pre-wrap;
}

.prominent-comment {
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 18px;
  background: #eff6ff;
}

.comment-box span {
  font-size: 14px;
}

.comment-box em {
  float: right;
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
}

.admin-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(2, 6, 23, .84);
}

.admin-preview-card {
  position: relative;
  width: min(100%, 900px);
  max-height: 94vh;
  overflow: hidden;
  border-radius: 24px;
  background: #fff;
}

.admin-preview-card > img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #020617;
}

.admin-preview-info {
  padding: 14px 16px 18px;
}

.admin-preview-info strong {
  display: block;
  margin-bottom: 8px;
}

.admin-preview-info p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(17, 24, 39, .94);
  color: #fff;
  font-weight: 800;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 520px) {
  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
  }

  .stats-grid,
  .action-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .hero-card .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rename-form {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .selected-preview-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .content {
    padding: 24px;
  }

  .viewer {
    align-items: center;
  }

  .viewer-stage {
    width: min(100%, 1180px);
  }

  .viewer-sheet {
    width: min(100%, 820px);
    margin-bottom: 16px;
    border-radius: 24px;
  }
}

/* Mobile polish overrides */
.album-row-manage {
  align-items: center;
}

.album-row-main {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.album-row-main strong,
.album-row-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-row-main em {
  color: var(--primary);
  font-size: 13px;
  font-style: normal;
}

.album-delete-btn {
  flex: 0 0 auto;
}

.viewer-body {
  background:
    radial-gradient(circle at 20% -10%, rgba(37, 99, 235, .18), transparent 36%),
    linear-gradient(180deg, #f8fbff 0%, #f3f4f8 42%, #eef1f7 100%);
}

.viewer-body .mobile-topbar {
  margin: 0;
  border-bottom: 0;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .98), rgba(30, 64, 175, .94)),
    #111827;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .2);
}

.viewer-body .filter-tabs {
  gap: 7px;
  padding: 10px 14px;
  background: rgba(248, 251, 255, .9);
}

.viewer-body .filter-tabs button {
  box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
}

.viewer-body .gallery-grid {
  gap: 12px;
}

.viewer-body .photo-card {
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, .13);
  transform: translateZ(0);
}

.viewer-body .photo-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(2, 6, 23, .46));
}

.viewer-body .star-button,
.viewer-body .comment-button {
  z-index: 3;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 18px rgba(2, 6, 23, .2);
}

.viewer-body .comment-button {
  left: 8px;
  bottom: 8px;
  min-height: 36px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .9);
  color: #111827;
  pointer-events: auto;
}

.viewer-body .star-button {
  top: 8px;
  right: 8px;
  background: rgba(17, 24, 39, .7);
  pointer-events: auto;
}

.viewer-body .viewer-sheet {
  box-shadow: 0 -18px 40px rgba(2, 6, 23, .22);
}

.comment-only-viewer {
  justify-content: flex-end;
  background: transparent;
}

.comment-only-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 6, 23, .48);
}

.comment-only-sheet {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: #fff;
  color: var(--text);
  box-shadow: 0 -22px 44px rgba(2, 6, 23, .24);
}

.comment-only-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.comment-only-head p,
.comment-only-head h2 {
  margin: 0;
}

.comment-only-head p {
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.comment-only-head h2 {
  max-width: 72vw;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-only-sheet .viewer-close {
  position: static;
  flex: 0 0 auto;
  background: #f3f4f6;
  color: #111827;
}

.comment-done {
  width: 100%;
  margin-top: 12px;
}

.comment-only-sheet textarea {
  min-height: 150px;
}

@media (max-width: 519px) {
  .viewer-body .content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .viewer-body .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viewer-body .photo-card {
    aspect-ratio: 3 / 4;
  }

  .viewer-body .mobile-topbar {
    padding-left: 16px;
    padding-right: 12px;
  }

  .viewer-body .filter-tabs {
    border-radius: 0 0 22px 22px;
    box-shadow: 0 12px 26px rgba(15, 23, 42, .08);
  }

  .viewer-meta {
    align-items: flex-start;
  }

  .viewer-actions {
    grid-template-columns: 1fr;
  }

  .album-row-manage {
    gap: 10px;
  }
}

/* Viewer rewrite: keep one clean control area below the photo. */
.viewer {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.viewer-stage {
  flex: 1 1 auto;
  min-height: 0;
  padding: calc(54px + env(safe-area-inset-top)) 10px 10px;
}

.viewer-stage img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.viewer-close,
.viewer-nav {
  z-index: 6;
}

.viewer-sheet {
  width: 100%;
  max-height: min(44vh, 360px);
  max-height: min(44dvh, 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -18px 40px rgba(2, 6, 23, .22);
}

.viewer-sheet.comment-open {
  max-height: min(54vh, 460px);
  max-height: min(54dvh, 460px);
}

.viewer-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.viewer-floating-actions,
.comment-only-backdrop,
.comment-only-sheet {
  display: none;
}

.viewer-comment-editor {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 18px;
  background: #eff6ff;
}

.viewer-comment-editor textarea {
  min-height: 98px;
  max-height: 24vh;
  max-height: 24dvh;
}

.viewer-comment-preview {
  max-height: 86px;
  overflow-y: auto;
}

.comment-done {
  width: 100%;
  margin-top: 12px;
}

@media (max-width: 519px) {
  .viewer-stage {
    min-height: 34vh;
    min-height: 34dvh;
    padding: calc(52px + env(safe-area-inset-top)) 8px 8px;
  }

  .viewer-sheet {
    max-height: 48vh;
    max-height: 48dvh;
    padding: 14px 14px max(14px, env(safe-area-inset-bottom));
  }

  .viewer-sheet.comment-open {
    max-height: 58vh;
    max-height: 58dvh;
  }

  .viewer-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .viewer-actions .big-star,
  .viewer-actions .secondary-button {
    min-height: 44px;
    padding: 0 10px;
    border-radius: 14px;
    font-size: 14px;
  }

  .viewer-comment-editor textarea {
    min-height: 90px;
  }
}

/* Final mobile-first polish for the user side. Upload/admin pages are left intact. */
.viewer-body {
  --viewer-card-line: rgba(255, 255, 255, .72);
  background:
    radial-gradient(circle at 14% -8%, rgba(59, 130, 246, .22), transparent 34%),
    radial-gradient(circle at 100% 2%, rgba(245, 158, 11, .16), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #eef3fb 46%, #e8edf7 100%);
}

.viewer-body .app-shell {
  padding-bottom: max(30px, env(safe-area-inset-bottom));
}

.viewer-body .viewer-entry {
  background:
    radial-gradient(circle at 18% 4%, rgba(37, 99, 235, .22), transparent 32%),
    radial-gradient(circle at 88% 18%, rgba(245, 158, 11, .18), transparent 26%),
    linear-gradient(180deg, #f8fbff, #eef3fb);
}

.viewer-body .code-card {
  border: 1px solid rgba(255, 255, 255, .78);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .16);
}

.viewer-body .app-mark {
  background: linear-gradient(135deg, #111827, #1d4ed8);
  color: #fbbf24;
  box-shadow: 0 14px 34px rgba(37, 99, 235, .28);
}

.viewer-body .mobile-topbar {
  z-index: 42;
  align-items: flex-start;
  padding: calc(14px + env(safe-area-inset-top)) 16px 18px;
  border-radius: 0 0 28px 28px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .98), rgba(30, 64, 175, .96) 58%, rgba(37, 99, 235, .94)),
    #111827;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .26);
}

.viewer-body .mobile-topbar h1 {
  max-width: 68vw;
  margin-bottom: 7px;
  font-size: clamp(20px, 5.8vw, 28px);
  letter-spacing: -.03em;
}

.viewer-body .mobile-topbar p {
  max-width: 72vw;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
}

.viewer-body .topbar-link {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
}

.viewer-body .filter-tabs {
  top: calc(78px + env(safe-area-inset-top));
  z-index: 38;
  gap: 5px;
  margin: 10px 12px 8px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .10);
}

.viewer-body .filter-tabs button {
  min-height: 42px;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  transition: transform .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}

.viewer-body .filter-tabs button.active {
  background: linear-gradient(135deg, #111827, #2563eb);
  color: #fff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .28);
}

.viewer-body .filter-tabs button:active,
.viewer-body .photo-card:active {
  transform: scale(.98);
}

.viewer-body .content.no-top-gap {
  padding-top: 10px;
}

.viewer-body .gallery-grid {
  gap: 13px;
}

.viewer-body .photo-card {
  aspect-ratio: 3 / 4;
  border: 1px solid var(--viewer-card-line);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(15, 23, 42, .15);
  transition: transform .16s ease, box-shadow .16s ease;
}

.viewer-body .photo-card img {
  transform: scale(1.001);
  transition: transform .2s ease;
}

.viewer-body .photo-card:active img {
  transform: scale(1.045);
}

.viewer-body .photo-card::after {
  height: 48%;
  background: linear-gradient(180deg, transparent, rgba(2, 6, 23, .58));
}

.viewer-body .star-button {
  top: 10px;
  right: 10px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(15, 23, 42, .52);
  box-shadow: 0 10px 24px rgba(2, 6, 23, .24);
}

.viewer-body .star-button.on {
  border-color: rgba(251, 191, 36, .65);
  background: rgba(255, 251, 235, .95);
  color: #d97706;
}

.viewer-body .comment-button {
  left: 10px;
  bottom: 10px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, .26);
  background: rgba(255, 255, 255, .92);
  color: #111827;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(2, 6, 23, .22);
}

.viewer-body .load-more {
  min-height: 50px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .08);
}

.viewer {
  background:
    radial-gradient(circle at 50% -10%, rgba(37, 99, 235, .22), transparent 32%),
    linear-gradient(180deg, #020617, #0f172a);
}

.viewer-stage {
  padding-left: 12px;
  padding-right: 12px;
}

.viewer-stage img {
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

.viewer-close,
.viewer-nav {
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(15, 23, 42, .70);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
}

.viewer-sheet {
  border: 1px solid rgba(255, 255, 255, .76);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(18px);
}

.viewer-meta strong {
  max-width: 72vw;
  letter-spacing: -.02em;
}

.viewer-actions .big-star,
.viewer-actions .secondary-button {
  min-height: 50px;
  border-radius: 17px;
}

.viewer .big-star {
  background: #111827;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .16);
}

.viewer .big-star.on {
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #b45309;
}

.viewer .secondary-button {
  background: #eef2ff;
  color: #1e3a8a;
}

.viewer-comment-editor {
  border-color: #bfdbfe;
  background:
    linear-gradient(180deg, rgba(239, 246, 255, .96), rgba(255, 255, 255, .98));
}

.viewer-comment-editor textarea {
  border-radius: 16px;
  background: rgba(255, 255, 255, .92);
}

@media (min-width: 520px) {
  .viewer-body .gallery-grid {
    gap: 14px;
  }

  .viewer-body .photo-card {
    border-radius: 22px;
  }
}

@media (min-width: 900px) {
  .viewer-body .filter-tabs {
    width: min(100% - 48px, 820px);
    margin-left: auto;
    margin-right: auto;
  }

  .viewer-body .content.no-top-gap {
    width: min(100%, 1180px);
  }

  .viewer-sheet {
    border-radius: 28px;
  }
}

/* Generated cute decoration asset for user-side UI. */
.viewer-body .code-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.viewer-body .code-deco {
  position: relative;
  margin: -6px -4px 12px;
  overflow: hidden;
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(239, 246, 255, .88), rgba(255, 251, 235, .72)),
    #f8fbff;
}

.viewer-body .code-deco::after {
  content: "";
  position: absolute;
  inset: auto 18px 14px;
  height: 26px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .12);
  filter: blur(14px);
}

.viewer-body .code-deco img {
  position: relative;
  z-index: 1;
  width: min(100%, 320px);
  margin: 0 auto;
  transform: translateY(3px);
}

.viewer-body .code-card-title {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.viewer-body .code-card-title h1 {
  margin-top: 0;
}

.viewer-body .code-card-title p {
  margin: 0;
  font-size: 14px;
}

.viewer-body .code-input {
  height: 62px;
  border-color: rgba(191, 219, 254, .95);
  border-radius: 20px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, rgba(37, 99, 235, .42), rgba(245, 158, 11, .34)) border-box;
  box-shadow: 0 12px 30px rgba(37, 99, 235, .10);
}

.viewer-body .code-card .primary-button {
  min-height: 54px;
  border-radius: 20px;
  background: linear-gradient(135deg, #111827, #2563eb);
  box-shadow: 0 16px 34px rgba(37, 99, 235, .24);
}

.viewer-welcome-card {
  position: relative;
  min-height: 118px;
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
  align-items: center;
  margin: 0 0 14px;
  padding: 16px 12px 16px 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 26px;
  background:
    radial-gradient(circle at 92% 18%, rgba(251, 191, 36, .24), transparent 28%),
    linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(239, 246, 255, .86));
  box-shadow: 0 18px 42px rgba(15, 23, 42, .11);
}

.viewer-welcome-card::before {
  content: "";
  position: absolute;
  inset: auto -28px -44px 34%;
  height: 110px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .12);
  filter: blur(20px);
}

.viewer-welcome-card > div,
.viewer-welcome-card > img {
  position: relative;
  z-index: 1;
}

.viewer-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.viewer-welcome-card strong {
  display: block;
  margin: 8px 0 6px;
  color: #0f172a;
  font-size: 19px;
  letter-spacing: -.03em;
}

.viewer-welcome-card p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.viewer-welcome-card img {
  width: 132px;
  max-width: none;
  justify-self: end;
  transform: translate(16px, 2px);
  filter: drop-shadow(0 14px 24px rgba(37, 99, 235, .16));
}

@media (max-width: 519px) {
  .viewer-body .code-card {
    width: min(100%, 420px);
    padding: 16px;
    border-radius: 32px;
  }

  .viewer-body .code-deco img {
    width: min(100%, 286px);
  }

  .viewer-welcome-card {
    grid-template-columns: 1fr 92px;
    min-height: 112px;
    margin-bottom: 12px;
    padding: 14px 10px 14px 14px;
    border-radius: 24px;
  }

  .viewer-welcome-card strong {
    font-size: 17px;
  }

  .viewer-welcome-card p {
    font-size: 12px;
  }

  .viewer-welcome-card img {
    width: 118px;
    transform: translate(18px, 4px);
  }
}

/* Refined decoration pass: transparent cutout, no pasted square image. */
.viewer-body .code-card {
  width: min(100%, 430px);
  padding: 22px;
}

.viewer-body .code-deco {
  display: none;
}

.viewer-body .code-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 8px;
  align-items: center;
  min-height: 150px;
  margin: -2px -2px 16px;
  padding: 18px 10px 18px 18px;
  overflow: hidden;
  border: 1px solid rgba(219, 234, 254, .9);
  border-radius: 28px;
  background:
    radial-gradient(circle at 86% 20%, rgba(251, 191, 36, .22), transparent 28%),
    radial-gradient(circle at 72% 95%, rgba(37, 99, 235, .14), transparent 32%),
    linear-gradient(135deg, rgba(255, 255, 255, .94), rgba(239, 246, 255, .88));
}

.viewer-body .code-hero::before,
.viewer-body .code-hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.viewer-body .code-hero::before {
  width: 118px;
  height: 118px;
  right: -34px;
  bottom: -34px;
  background: rgba(37, 99, 235, .12);
  filter: blur(8px);
}

.viewer-body .code-hero::after {
  width: 46px;
  height: 46px;
  right: 112px;
  top: 18px;
  background: rgba(251, 191, 36, .18);
}

.viewer-body .code-hero > div,
.viewer-body .code-mascot {
  position: relative;
  z-index: 1;
}

.viewer-body .code-hero .app-mark {
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border-radius: 16px;
  font-size: 24px;
}

.viewer-body .code-hero h1 {
  margin: 0 0 7px;
  font-size: clamp(26px, 7vw, 34px);
  letter-spacing: -.04em;
}

.viewer-body .code-hero p {
  max-width: 230px;
  margin: 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.55;
}

.viewer-body .code-mascot {
  width: 158px;
  max-width: none;
  justify-self: end;
  align-self: end;
  transform: translate(20px, 12px) rotate(1deg);
  filter: drop-shadow(0 16px 22px rgba(37, 99, 235, .18));
  pointer-events: none;
}

.viewer-body .code-card label span {
  padding-left: 3px;
  color: #334155;
}

.viewer-body .small-tip {
  text-align: center;
}

.viewer-welcome-card {
  min-height: 104px;
  grid-template-columns: minmax(0, 1fr) 86px;
  padding: 14px 6px 14px 16px;
}

.viewer-welcome-card img {
  width: 112px;
  transform: translate(20px, 8px) rotate(2deg);
  opacity: .96;
}

@media (max-width: 380px) {
  .viewer-body .code-card {
    padding: 16px;
  }

  .viewer-body .code-hero {
    grid-template-columns: minmax(0, 1fr) 100px;
    min-height: 138px;
    padding: 16px 8px 16px 16px;
    border-radius: 26px;
  }

  .viewer-body .code-hero p {
    max-width: 195px;
    font-size: 13px;
  }

  .viewer-body .code-mascot {
    width: 128px;
    transform: translate(22px, 10px) rotate(1deg);
  }

  .viewer-welcome-card {
    grid-template-columns: minmax(0, 1fr) 74px;
  }

  .viewer-welcome-card img {
    width: 98px;
    transform: translate(18px, 8px) rotate(2deg);
  }
}
