/* Álbumes — one stylesheet for home, admin and the three album themes. */

/* ---------- Tokens ---------- */
:root {
  --bg: #f6f3ee;
  --bg-2: #eee8de;
  --ink: #2a2622;
  --muted: #6f675e;
  --faint: #9a9086;
  --line: #e2dbd0;
  --card: #fffdf9;
  --field: #fbf9f5;
  --accent: #2f7a55;
  --accent-strong: #256646;
  --accent-ink: #ffffff;
  --soft: #e6f0e9;
  --danger: #b8433c;
  --danger-soft: #fbeae8;
  --warn-soft: #fdf0cf;
  --warn-ink: #7a5a08;
  --violet-soft: #ece6f8;
  --violet-ink: #51408a;
  --sk-a: #ece5da;
  --sk-b: #f6f1e9;
  --shadow-sm: 0 1px 2px rgba(60, 40, 10, 0.06), 0 2px 8px rgba(60, 40, 10, 0.05);
  --shadow: 0 12px 32px rgba(60, 40, 10, 0.12), 0 2px 6px rgba(60, 40, 10, 0.06);
  --shadow-lg: 0 24px 60px rgba(40, 25, 5, 0.22), 0 4px 12px rgba(40, 25, 5, 0.1);
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-hand: 'Caveat', 'Bradley Hand', 'Comic Sans MS', cursive;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --gutter: 16px;
  --toast-offset: 16px;
  --lang-idle: #5f574e;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --bg-2: #25221e;
    --ink: #efe9e0;
    --muted: #a79e92;
    --faint: #7f766b;
    --line: #36312b;
    --card: #23201c;
    --field: #1d1b18;
    --accent: #5cb487;
    --accent-strong: #71c498;
    --accent-ink: #10231a;
    --soft: #223429;
    --danger: #e27a72;
    --danger-soft: #3a2422;
    --warn-soft: #3b3220;
    --warn-ink: #f0cf7a;
    --violet-soft: #2e2840;
    --violet-ink: #c9bdf0;
    --sk-a: #26231f;
    --sk-b: #302c27;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
    --lang-idle: #a79e92;
    color-scheme: dark;
  }
}

/* Album pages paint their own world, always light chrome for sheets and dialogs. */
.album-page {
  --bg: #fbf8f3;
  --bg-2: #f1ebe1;
  --ink: #2a2622;
  --muted: #6f675e;
  --faint: #9a9086;
  --line: #e5ddd0;
  --card: #fffdf8;
  --field: #fbf8f2;
  --accent: #2f7a55;
  --accent-strong: #256646;
  --accent-ink: #ffffff;
  --soft: #e6f0e9;
  --danger: #b8433c;
  --danger-soft: #fbeae8;
  --shadow-sm: 0 1px 2px rgba(60, 40, 10, 0.06), 0 2px 8px rgba(60, 40, 10, 0.05);
  --shadow: 0 12px 32px rgba(60, 40, 10, 0.12), 0 2px 6px rgba(60, 40, 10, 0.06);
  --shadow-lg: 0 24px 60px rgba(40, 25, 5, 0.22), 0 4px 12px rgba(40, 25, 5, 0.1);
  --fab-bg: var(--accent);
  --fab-ink: var(--accent-ink);
  --lang-idle: #5f574e;
  color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

html.is-locked,
html.is-locked body {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Safety net: nothing inside the app may widen the page sideways (clip, unlike hidden, keeps sticky working). */
#app {
  overflow-x: clip;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.15;
  text-wrap: balance;
}

p {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

code {
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

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

.muted {
  color: var(--muted);
}

.eyebrow {
  font: 800 12px/1.3 var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.icon {
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

.inline-icon {
  vertical-align: -3px;
  margin: 0 1px;
}

.noscript {
  max-width: 480px;
  margin: 24px auto;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: 700 15px/1.2 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.btn:hover {
  border-color: var(--faint);
}

.btn:active:not([disabled]) {
  transform: scale(0.97);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.is-busy[disabled] {
  opacity: 0.85;
  cursor: progress;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not([disabled]) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover:not([disabled]) {
  background: var(--bg-2);
}

.btn.ghost-danger {
  color: var(--danger);
}

.btn.ghost-danger:hover:not([disabled]) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.btn.small {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 10px;
}

.btn.big {
  min-height: 54px;
  padding: 14px 24px;
  font-size: 17px;
  border-radius: 16px;
}

.btn.block {
  width: 100%;
}

.btn.is-done {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.primary.is-done {
  color: var(--accent-ink);
}

@media (pointer: coarse) {
  .btn.small {
    min-height: 44px;
  }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  transition: background-color 0.15s;
}

.icon-btn:hover {
  background: rgba(127, 110, 90, 0.12);
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  opacity: 0.8;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Fields ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  padding: 0;
}

.field-label .optional {
  font-weight: 600;
  color: var(--muted);
}

.field-label .count {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.field-label .count.is-near {
  color: var(--danger);
}

.field-label code {
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 6px;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--field);
  color: var(--ink);
  font-size: 16px; /* prevents iOS zoom on focus */
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--faint);
  opacity: 1;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
  background: var(--card);
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.input:disabled {
  opacity: 0.7;
}

textarea.input {
  min-height: 76px;
  max-height: 320px;
  resize: vertical;
  field-sizing: content; /* grows with the text where supported */
}

input[type='date'].input {
  min-width: 0;
  display: block;
}

input[type='date'].input::-webkit-date-and-time-value {
  text-align: left;
}

.field-error,
.form-error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.form-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--danger-soft);
}

.hint {
  font-size: 13.5px;
  color: var(--muted);
}

.hint-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 14.5px;
}

/* ---------- Skeletons ---------- */
.sk {
  display: block;
  background: linear-gradient(100deg, var(--sk-a) 30%, var(--sk-b) 50%, var(--sk-a) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: 10px;
}

.sk-line {
  height: 14px;
  width: 80%;
  margin-top: 10px;
  border-radius: 7px;
}

.sk-line.short {
  width: 50%;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

/* ---------- Language switcher ---------- */
.lang {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(127, 110, 90, 0.12);
}

.lang button {
  min-width: 48px;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: 800 12.5px/1 var(--font-body);
  letter-spacing: 0.08em;
  color: var(--lang-idle);
  transition: background-color 0.15s, color 0.15s;
}

.lang button[aria-pressed='true'] {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* In dark mode the card color is too close to the track; invert so the active language stands out. */
@media (prefers-color-scheme: dark) {
  body:not(.album-page) .lang button[aria-pressed='true'] {
    background: var(--ink);
    color: var(--bg);
  }
}

@media (pointer: coarse) {
  .lang button {
    min-height: 44px;
  }
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--toast-offset) + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 var(--gutter);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(460px, 100%);
  padding: 12px 18px 12px 14px;
  border-radius: 16px;
  background: #2a2622;
  color: #fbf7f0;
  box-shadow: 0 12px 30px rgba(20, 12, 4, 0.28);
  font: 700 15px/1.35 var(--font-body);
  animation: toast-in 0.32s var(--ease);
}

.toast .icon {
  color: #8fd3ad;
}

.toast-error {
  background: #7d2a24;
}

.toast-error .icon {
  color: #ffc9c2;
}

.toast-info .icon {
  color: #f2c14e;
}

.toast.is-leaving {
  animation: toast-out 0.25s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Dialogs & sheets ---------- */
dialog {
  color: var(--ink);
}

.sheet-dialog,
.confirm-dialog {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  overflow: visible;
}

.sheet-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(28, 20, 12, 0.48);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sheet-dialog[open]::backdrop,
.confirm-dialog[open]::backdrop {
  animation: fade-in 0.25s ease-out;
}

.sheet-dialog.is-closing::backdrop,
.confirm-dialog.is-closing::backdrop {
  animation: fade-out 0.22s ease-in forwards;
}

.sheet-dialog {
  width: 100%;
  max-width: 600px;
  margin: auto auto 0;
}

.sheet-dialog[open] {
  animation: sheet-up 0.36s var(--ease);
}

.sheet-dialog.is-closing {
  animation: sheet-down 0.24s ease-in forwards;
}

.sheet {
  display: flex;
  flex-direction: column;
  max-height: 94vh;
  max-height: 94dvh;
  background: var(--card);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.sheet-grabber {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  margin: 8px auto 0;
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 10px 12px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.sheet-head-text {
  flex: 1;
  min-width: 0;
  padding-top: 6px;
}

.sheet-title {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sheet-title:focus {
  outline: none;
}

.sheet-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14.5px;
}

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px var(--gutter) 20px;
  -webkit-overflow-scrolling: touch;
}

.sheet-body-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 20px 22px;
}

.sheet-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
  flex: none;
}

.sheet-foot .btn.primary {
  flex: 1;
  min-height: 52px;
  font-size: 16.5px;
  border-radius: 14px;
}

@media (min-width: 640px) {
  .sheet-dialog {
    margin: auto;
    width: calc(100% - 48px);
  }
  .sheet-dialog[open] {
    animation: pop-in 0.26s var(--ease);
  }
  .sheet-dialog.is-closing {
    animation: pop-out 0.2s ease-in forwards;
  }
  .sheet {
    border-radius: 24px;
    max-height: min(88dvh, 900px);
  }
  .sheet-grabber {
    display: none;
  }
  .sheet-head {
    padding: 16px 12px 14px 24px;
  }
  .sheet-body {
    padding: 18px 24px 22px;
  }
  .sheet-foot {
    padding: 14px 24px;
    justify-content: flex-end;
  }
  .sheet-foot .btn.primary {
    flex: 0 1 auto;
    min-width: 200px;
  }
}

.confirm-dialog {
  width: min(420px, calc(100% - 32px));
  margin: auto;
}

.confirm-dialog[open] {
  animation: pop-in 0.22s var(--ease);
}

.confirm-dialog.is-closing {
  animation: pop-out 0.18s ease-in forwards;
}

.confirm-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 22px 18px;
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.confirm-title {
  font-size: 21px;
  font-weight: 700;
}

.confirm-body {
  color: var(--muted);
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 440px) {
  .confirm-actions .btn {
    flex: 1 1 140px;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

@keyframes pop-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

/* ---------- Decorative polaroids with illustrated scenes ---------- */
.deco-pola {
  position: relative;
  display: block;
  width: 100%;
  padding: 8% 8% 0;
  background: #fffdf7;
  box-shadow: 0 1px 1px rgba(60, 40, 10, 0.08), 0 12px 26px rgba(60, 40, 10, 0.2);
  container-type: inline-size;
}

.deco-tape {
  position: absolute;
  z-index: 1;
  top: -5%;
  left: 50%;
  width: 46%;
  height: 11%;
  transform: translateX(-50%) rotate(-4deg);
  background: rgba(247, 215, 116, 0.85);
}

.deco-line {
  display: block;
  height: 24cqw;
  background: linear-gradient(#d8cdbb, #d8cdbb) no-repeat 8% 52% / 52% 2px, linear-gradient(#e6ddcf, #e6ddcf) no-repeat 8% 72% / 30% 2px;
}

.scene {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: radial-gradient(circle at var(--sx, 72%) 30%, var(--sun) 0 11%, transparent 11.5%), linear-gradient(180deg, var(--sky1), var(--sky2) 62%);
}

.scene::before {
  content: '';
  position: absolute;
  left: -15%;
  right: -15%;
  bottom: -38%;
  height: 70%;
  border-radius: 50%;
  background: var(--hill);
}

.scene::after {
  content: '';
  position: absolute;
  left: var(--dx, 30%);
  bottom: 16%;
  width: 16%;
  aspect-ratio: 1.4;
  background: var(--dog);
  border-radius: 48% 52% 40% 40%;
  box-shadow: 9cqw -5cqw 0 -2.4cqw var(--dog);
}

.scene-dawn { --sky1: #f9d9b8; --sky2: #f6b98f; --sun: #fff3d6; --hill: #6d9c6a; --dog: #5a3d2b; --sx: 22%; --dx: 52%; }
.scene-noon { --sky1: #bfe2f2; --sky2: #e4f3f5; --sun: #fff6c9; --hill: #7fb069; --dog: #c98b4f; --sx: 72%; --dx: 26%; }
.scene-gold { --sky1: #f4c27a; --sky2: #f7e0a8; --sun: #fffbe8; --hill: #8a9b4e; --dog: #2f2a26; --sx: 30%; --dx: 58%; }
.scene-mint { --sky1: #cfeadf; --sky2: #eef7f1; --sun: #fdf6d3; --hill: #4f8a6b; --dog: #e2c39b; --sx: 76%; --dx: 24%; }
.scene-dusk { --sky1: #c9b6e4; --sky2: #f3c6c0; --sun: #fff0e0; --hill: #577a5c; --dog: #3b3030; --sx: 50%; --dx: 34%; }
.scene-cloud { --sky1: #d9dee3; --sky2: #eef0f1; --sun: #ffffff; --hill: #6f9a7e; --dog: #8c6a4d; --sx: 78%; --dx: 22%; }

/* ---------- Notices & empty states ---------- */
.notice-body {
  background: radial-gradient(110% 70% at 50% 0%, var(--soft), transparent 65%), var(--bg);
}

.notice-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(32px + env(safe-area-inset-top)) var(--gutter) calc(32px + env(safe-area-inset-bottom));
}

.notice {
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.notice-art {
  width: 148px;
  margin-bottom: 14px;
}

.notice-art .deco-pola {
  transform: rotate(-5deg);
}

.notice h1 {
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.notice p {
  color: var(--muted);
  max-width: 36ch;
}

.notice-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.notice .lang {
  margin-top: 18px;
}

.notice-admin {
  margin-top: 6px;
  font-size: 14.5px;
}

.notice-admin a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  color: var(--accent);
  font-weight: 700;
}

.notice-inline {
  padding: 64px var(--gutter) 24px;
}

.empty {
  max-width: 460px;
  margin: 12px auto 28px;
  padding: 20px var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.empty-art {
  position: relative;
  width: 150px;
  margin-bottom: 16px;
}

.empty-art .deco-pola {
  transform: rotate(-4deg);
}

.empty-art.is-action {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.empty-art.is-action:active .empty-plus {
  transform: scale(0.94);
}

.empty-plus {
  position: absolute;
  z-index: 2;
  right: -16px;
  bottom: 14px;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--fab-bg, var(--accent));
  color: var(--fab-ink, var(--accent-ink));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s var(--ease);
}

.empty-title {
  font-size: 27px;
  font-weight: 700;
}

.empty-body {
  color: var(--muted);
  max-width: 34ch;
}

.empty .btn {
  margin-top: 10px;
}

.inline-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
}

.inline-error p {
  flex: 1 1 220px;
}

/* =====================================================================
   Home
   ===================================================================== */
.home-page {
  background: radial-gradient(120% 70% at 50% 0%, var(--soft) 0%, transparent 62%), var(--bg);
}

.home {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 38px;
  padding: calc(40px + env(safe-area-inset-top)) var(--gutter) calc(32px + env(safe-area-inset-bottom));
  text-align: center;
}

.home-art {
  position: relative;
  width: min(310px, 82vw);
  aspect-ratio: 1.45;
}

.home-art .deco-pola {
  position: absolute;
  width: 44%;
  animation: drop-in 0.7s var(--ease) both;
}

.home-art .p1 {
  left: 1%;
  top: 16%;
  transform: rotate(-9deg);
  animation-delay: 0.05s;
}

.home-art .p2 {
  left: 26%;
  top: 0;
  width: 48%;
  z-index: 2;
  transform: rotate(2deg);
  animation-delay: 0.18s;
}

.home-art .p2 .deco-tape {
  background: rgba(170, 210, 180, 0.9);
}

.home-art .p3 {
  right: 1%;
  top: 18%;
  transform: rotate(9deg);
  animation-delay: 0.3s;
}

.home-art .p3 .deco-tape {
  background: rgba(240, 170, 160, 0.85);
}

@keyframes drop-in {
  from {
    opacity: 0;
    translate: 0 -18px;
  }
}

.home-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 440px;
}

.home-text.is-ready > * {
  animation: rise-in 0.5s var(--ease) both;
}

.home-text.is-ready > :nth-child(2) { animation-delay: 0.05s; }
.home-text.is-ready > :nth-child(3) { animation-delay: 0.1s; }
.home-text.is-ready > :nth-child(4) { animation-delay: 0.15s; }
.home-text.is-ready > :nth-child(5) { animation-delay: 0.2s; }

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.home-title {
  font: 800 clamp(48px, 14vw, 70px) / 1 var(--font-display);
  letter-spacing: -0.03em;
}

.home-lead {
  font-size: 18.5px;
  color: var(--muted);
  max-width: 30ch;
  margin-bottom: 10px;
}

.home-hint {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 36ch;
  margin-top: 12px;
  font-size: 14.5px;
  color: var(--muted);
  text-align: left;
}

.home-hint .icon {
  margin-top: 3px;
  color: var(--accent);
}

.home-foot {
  margin-top: 20px;
}

/* =====================================================================
   Admin
   ===================================================================== */
.admin-page {
  background: var(--bg);
}

.admin-boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.admin-boot-mark {
  width: 96px;
  animation: breathe 1.6s ease-in-out infinite;
}

.admin-boot-mark .deco-pola {
  transform: rotate(-5deg);
}

@keyframes breathe {
  50% {
    opacity: 0.55;
    transform: scale(0.97);
  }
}

.admin-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 8px max(var(--gutter), env(safe-area-inset-left));
  background: rgba(246, 243, 238, 0.86);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

@media (prefers-color-scheme: dark) {
  .topbar {
    background: rgba(27, 25, 22, 0.86);
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font: 800 21px/1 var(--font-display);
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--muted);
  margin-right: 4px;
}

.av-admin {
  background: var(--accent);
  color: var(--accent-ink);
}

@media (max-width: 520px) {
  .hide-sm {
    display: none;
  }
}

.admin-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px max(var(--gutter), env(safe-area-inset-left)) 56px max(var(--gutter), env(safe-area-inset-right));
}

.admin-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 16px;
  padding: 8px var(--gutter) calc(24px + env(safe-area-inset-bottom));
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 26px;
}

.page-head h1 {
  font-size: clamp(32px, 8vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 6px;
}

.page-head .muted {
  max-width: 52ch;
}

@media (max-width: 520px) {
  .page-head > .btn {
    width: 100%;
  }
}

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

.album-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s;
  animation: rise-in 0.4s var(--ease) both;
}

a.album-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

a.album-card:focus-visible {
  outline-offset: 3px;
}

.album-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-2);
}

.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 25%;
  transition: transform 0.5s var(--ease);
}

a.album-card:hover .album-cover img {
  transform: scale(1.03);
}

.album-cover.is-empty {
  display: grid;
  place-items: center;
  padding: 7% 20%;
  background: var(--bg-2) radial-gradient(var(--line) 1px, transparent 1.3px) 0 0 / 12px 12px;
}

.album-cover.is-empty .mini {
  border-radius: 12px;
  box-shadow: var(--shadow);
  transform: rotate(-2deg);
  transition: transform 0.4s var(--ease);
}

a.album-card:hover .album-cover.is-empty .mini {
  transform: rotate(0deg) scale(1.03);
}

.album-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 16px;
}

.album-card h2 {
  display: -webkit-box;
  overflow: hidden;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.meta {
  color: var(--muted);
  font-size: 14.5px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
}

.tag.collab {
  background: var(--soft);
  color: var(--accent);
}

.tag.public {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.album-card.is-skeleton {
  box-shadow: none;
  animation: none;
}

.album-card.is-skeleton .album-cover {
  border-radius: 0;
}

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

/* ----- Detail ----- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin: -8px 0 4px -6px;
  padding: 0 8px 0 2px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-head-text {
  min-width: 0;
}

.detail-head h1 {
  font-size: clamp(30px, 7.5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 6px;
  overflow-wrap: anywhere;
}

.slug {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .detail-head > .btn {
    width: 100%;
  }
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

@media (min-width: 920px) {
  .detail-grid {
    grid-template-columns: 1.1fr 1fr;
  }
}

.detail-col,
.access {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.panel-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  background: var(--soft);
  color: var(--accent);
}

.panel-head h2 {
  font-size: 20px;
  font-weight: 700;
  margin-top: 1px;
}

.panel-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14.5px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 520px) {
  .form-actions .btn {
    width: 100%;
  }
}

.detail-skeleton {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-skeleton .sk-title {
  height: 42px;
  width: min(70%, 420px);
  border-radius: 12px;
}

.sk-panel {
  min-height: 220px;
}

.sk-block {
  height: 160px;
}

/* ----- Tokens ----- */
.tok-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tok {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1.5px dashed var(--line);
  background: var(--card);
  transition: border-color 0.3s, background-color 0.3s;
}

.tok.is-new {
  border-style: solid;
  border-color: var(--accent);
  background: var(--soft);
  animation: glow 1.4s var(--ease) 1;
}

@keyframes glow {
  0% {
    box-shadow: 0 0 0 0 rgba(47, 122, 85, 0.35);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(47, 122, 85, 0);
  }
}

.tok-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tok-label {
  font-size: 17px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.tok-meta {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: -4px;
}

.tok-hint {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--accent);
  font-weight: 700;
  font-size: 14.5px;
}

.tok-hint .icon {
  margin-top: 2px;
}

.tok-lost {
  align-items: flex-start;
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.tok-lost .icon {
  flex: none;
  margin-top: 1px;
}

.tok-url {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  font: 16px/1.3 ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
}

.tok-url:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
}

.tok-actions {
  display: flex;
  gap: 8px;
}

.tok-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 10px;
}

.tok-manage {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin: -4px -6px -6px 0;
}

.tok-manage .btn {
  color: var(--muted);
  font-size: 13.5px;
}

.tok-manage .btn.ghost-danger {
  color: var(--danger);
}

.tok-manage .btn.primary {
  color: var(--accent-ink);
}

@media (max-width: 380px) {
  .tok-manage .btn {
    flex: 1;
    padding-inline: 6px;
  }
}

.role {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.role.collab {
  background: var(--soft);
  color: var(--accent);
}

.role.public {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.inline-form-row {
  display: flex;
  gap: 8px;
}

.inline-form-row .input {
  flex: 1;
  min-width: 0;
}

@media (max-width: 440px) {
  .inline-form-row {
    flex-direction: column;
  }
}

.revoked {
  padding: 0;
  gap: 0;
}

.revoked summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 20px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: var(--muted);
}

.revoked summary::-webkit-details-marker {
  display: none;
}

.revoked summary span {
  flex: 1;
}

.revoked .chev {
  transition: transform 0.2s;
}

.revoked[open] .chev {
  transform: rotate(90deg);
}

.revoked-list {
  list-style: none;
  margin: 0;
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.revoked-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  opacity: 0.85;
}

.revoked-list strong {
  text-decoration: line-through;
  text-decoration-color: var(--faint);
}

.revoked-list small {
  color: var(--muted);
  margin-left: auto;
}

/* ----- Theme picker ----- */
.theme-picker {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.theme-picker legend {
  margin-bottom: 8px;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.theme-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 7px 10px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.theme-option:hover {
  border-color: var(--faint);
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
}

.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.theme-option .mini {
  margin-bottom: 4px;
}

.theme-name {
  font-weight: 800;
  font-size: 14.5px;
  padding-inline: 3px;
}

.theme-desc {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--muted);
  padding-inline: 3px;
}

@media (max-width: 400px) {
  .theme-desc {
    display: none;
  }
}

.mini {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 10px;
}

.mini i {
  display: block;
}

.mini-scrapbook {
  background: #e9dcc3 radial-gradient(#d4c09c 1px, transparent 1.3px) 0 0 / 8px 8px;
}

.mini-pola {
  position: absolute;
  width: 38%;
  padding: 5% 5% 13%;
  background: #fffdf7;
  box-shadow: 0 3px 7px rgba(60, 40, 10, 0.22);
}

.mini-pola::before {
  content: '';
  position: absolute;
  top: -7%;
  left: 28%;
  width: 44%;
  height: 11%;
  background: rgba(170, 210, 180, 0.9);
  transform: rotate(-4deg);
}

.mini-pola i {
  aspect-ratio: 1;
  background: linear-gradient(180deg, #bfe2f2, #e4f3f5 58%, #7fb069 58%);
}

.mini-pola.a {
  left: 11%;
  top: 17%;
  transform: rotate(-7deg);
}

.mini-pola.b {
  right: 11%;
  top: 24%;
  transform: rotate(6deg);
}

.mini-pola.b::before {
  background: rgba(247, 215, 116, 0.9);
}

.mini-pola.b i {
  background: linear-gradient(180deg, #f4c27a, #f7e0a8 58%, #8a9b4e 58%);
}

.mini-diario {
  display: flex;
  flex-direction: column;
  gap: 7%;
  padding: 10%;
  background: #fbf8f3;
  border: 1px solid #ece4d7;
}

.mini-month {
  display: block;
  width: 36%;
  height: 7%;
  min-height: 4px;
  border-radius: 3px;
  background: #2f7a55;
}

.mini-feature {
  display: block;
  flex: 1.3;
  border-radius: 5px;
  background: linear-gradient(180deg, #cfeadf, #eef7f1 58%, #4f8a6b 58%);
}

.mini-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8%;
  flex: 1;
}

.mini-row i {
  border-radius: 4px;
  background: linear-gradient(180deg, #f9d9b8, #f6b98f 58%, #6d9c6a 58%);
}

.mini-row i + i {
  background: linear-gradient(180deg, #c9b6e4, #f3c6c0 58%, #577a5c 58%);
}

.mini-muro {
  background: #1f3b2e;
}

.mini-badge {
  position: absolute;
  left: 9%;
  top: 9%;
  width: 15%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f2c14e;
}

.mini-muro::after {
  content: '';
  position: absolute;
  left: 29%;
  top: 13%;
  width: 40%;
  height: 7%;
  border-radius: 3px;
  background: rgba(243, 239, 230, 0.8);
}

.mini-cols {
  position: absolute;
  left: 9%;
  right: 9%;
  top: 34%;
  bottom: -6%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6%;
}

.mini-cols > span {
  display: flex;
  flex-direction: column;
  gap: 9%;
}

.mini-cols i {
  border-radius: 4px;
  background: #fffaf0;
}

.mini-cols > span:nth-child(1) i:first-child { flex: 1.4; background: linear-gradient(180deg, #f9d9b8 62%, #fffaf0 62%); }
.mini-cols > span:nth-child(1) i:last-child { flex: 1; }
.mini-cols > span:nth-child(2) i:first-child { flex: 0.8; background: linear-gradient(180deg, #cfeadf 62%, #fffaf0 62%); }
.mini-cols > span:nth-child(2) i:last-child { flex: 1.6; }
.mini-cols > span:nth-child(3) i:first-child { flex: 1.2; background: linear-gradient(180deg, #f4c27a 62%, #fffaf0 62%); }
.mini-cols > span:nth-child(3) i:last-child { flex: 1; }

/* ----- Cover picker ----- */
.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  transition: opacity 0.2s;
}

.cover-grid.is-saving {
  opacity: 0.6;
  pointer-events: none;
}

.cover-opt {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cover-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cover-opt img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 25%;
}

.cover-opt:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
}

.cover-opt:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.cover-auto-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  text-align: center;
  color: var(--muted);
  line-height: 1.15;
}

.cover-auto-text strong {
  font-size: 12.5px;
  color: var(--ink);
}

.cover-auto-text small {
  font-size: 11px;
}

.cover-check {
  position: absolute;
  right: 5px;
  top: 5px;
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.cover-opt:has(input:checked) .cover-check {
  display: grid;
}

/* ----- Danger zone ----- */
.danger-zone {
  margin-top: 18px;
  border-color: rgba(184, 67, 60, 0.35);
}

.danger-zone .panel-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 520px;
}

.danger-form .form-actions {
  justify-content: flex-start;
}

/* ----- Login ----- */
.login {
  flex: 1;
  display: grid;
  place-items: center;
  padding: calc(28px + env(safe-area-inset-top)) var(--gutter) 16px;
  background: radial-gradient(100% 60% at 50% 0%, var(--soft), transparent 70%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 24px 26px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card.is-shaking {
  animation: shake 0.4s;
}

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-art {
  width: 92px;
  margin: -4px 0 14px;
}

.login-art .deco-pola {
  transform: rotate(-6deg);
}

.login-card h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  text-align: left;
}

.pwd-wrap {
  position: relative;
}

.pwd-wrap .input {
  padding-right: 52px;
}

.pwd-toggle {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.login-form .btn {
  margin-top: 6px;
}

/* =====================================================================
   Album page (shared chrome)
   ===================================================================== */
.album-main {
  min-height: 100vh;
  min-height: 100dvh;
  /* viewport-fit=cover: keep photos and text clear of the notch / Dynamic Island in landscape. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.album-page.can-upload {
  --toast-offset: 92px;
}

.album-page.can-upload .album-main {
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.viewer-bar {
  display: flex;
  justify-content: center;
  padding: 14px var(--gutter) 0;
}

.viewer-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

a.viewer-pill {
  min-height: 44px;
}

.viewer-pill-cta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-left: 8px;
  margin-left: 2px;
  border-left: 1px solid currentColor;
  border-left-color: rgba(0, 0, 0, 0.15);
  color: var(--accent);
  white-space: nowrap;
}

@media (max-width: 400px) {
  .viewer-pill > span:first-of-type {
    display: none;
  }
  a.viewer-pill .viewer-pill-cta {
    border: 0;
    padding: 0;
  }
}

.fab {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 28px 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--fab-bg);
  color: var(--fab-ink);
  font: 800 17px/1 var(--font-body);
  letter-spacing: 0.01em;
  box-shadow: 0 12px 28px rgba(20, 30, 20, 0.28), 0 3px 8px rgba(20, 30, 20, 0.18);
  animation: fab-in 0.5s var(--ease) 0.2s both;
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}

.fab:active {
  transform: translateX(-50%) scale(0.96);
}

.fab:focus-visible {
  outline: 3px solid var(--fab-ink);
  outline-offset: 3px;
}

@keyframes fab-in {
  from {
    opacity: 0;
    translate: 0 24px;
  }
}

@media (min-width: 900px) {
  .fab {
    left: auto;
    right: 32px;
    bottom: 32px;
    transform: none;
  }
  .fab:active {
    transform: scale(0.96);
  }
  .album-page.can-upload {
    --toast-offset: 24px;
  }
}

.install-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 560px;
  margin: 4px var(--gutter) 8px;
  padding: 14px 6px 14px 14px;
  border-radius: 18px;
  background: #fffdf8;
  color: #2a2622;
  box-shadow: 0 8px 22px rgba(40, 25, 5, 0.14);
  animation: rise-in 0.5s var(--ease) 0.3s both;
}

@media (min-width: 592px) {
  .install-banner {
    margin-inline: auto;
  }
}

.install-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: #e6f0e9;
  color: #2f7a55;
}

.install-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-top: 1px;
}

.install-text strong {
  font-size: 15.5px;
}

.install-text p {
  font-size: 14.5px;
  color: #6f675e;
}

.install-text .btn {
  margin-top: 8px;
}

.install-close {
  margin-top: -6px;
  color: #8a7f72;
}

.album-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px var(--gutter) 28px;
}

.album-foot-brand {
  font: 600 13px/1 var(--font-display);
  letter-spacing: 0.02em;
  color: var(--lang-idle);
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 59, 46, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  pointer-events: none;
  animation: fade-in 0.15s ease-out;
}

.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 44px;
  border-radius: 24px;
  border: 2.5px dashed #2f7a55;
  background: #fffdf8;
  color: #2f7a55;
  font: 800 19px/1.3 var(--font-body);
  box-shadow: var(--shadow-lg);
}

/* Grid photos fade in once loaded. Crops favor the upper third, where faces usually are. */
.pola-photo img,
.entry-photo img,
.tile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 25%;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.5s var(--ease);
}

.pola-photo img.is-loaded,
.entry-photo img.is-loaded,
.tile-photo img.is-loaded {
  opacity: 1;
}

/* The title button stretches over its card so the whole card opens the photo. */
.stretch {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-align: inherit;
  cursor: pointer;
}

.stretch::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.stretch:focus-visible {
  outline: none;
}

.pola:has(.stretch:focus-visible),
.entry:has(.stretch:focus-visible),
.tile:has(.stretch:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 5px;
}

.av {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  color: #fff;
  font: 800 11px/1 var(--font-body);
}

.by {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

/* Hearts */
.heart-btn {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  background: none;
  color: inherit;
  font: 800 13px/1 var(--font-body);
  font-variant-numeric: tabular-nums;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.heart-btn .icon-heart,
.heart-badge .icon-heart {
  transition: transform 0.2s var(--ease);
}

.heart-btn.is-on,
.heart-badge {
  color: #d64541;
}

.heart-btn.is-on .icon-heart,
.heart-badge .icon-heart {
  fill: currentColor;
}

.is-popping .icon-heart {
  animation: heart-pop 0.5s var(--ease);
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.45); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.heart-mini {
  min-width: 44px;
  min-height: 44px;
  margin: -10px -10px -10px 0;
  padding: 4px 10px;
  border-radius: 999px;
  color: #756a5e;
}

.heart-mini:hover {
  background: rgba(214, 69, 65, 0.08);
}

.heart-mini.is-on {
  color: #d64541;
}

.heart-pill {
  min-height: 44px;
  padding: 0 16px 0 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
}

.heart-pill .icon-heart {
  color: #d64541;
}

.heart-pill .heart-n {
  min-width: 24px;
  padding: 3px 7px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--bg-2);
  font-size: 13px;
  text-align: center;
}

.heart-pill.is-on .heart-n {
  background: rgba(214, 69, 65, 0.14);
}

.heart-pill.is-on {
  border-color: #f1c2bd;
  background: #fdeeec;
  color: #b8322e;
}

.heart-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: 800 12.5px/1 var(--font-body);
}

/* ---------- Album skeleton (server-rendered, replaced on load) ---------- */
.sk-pola,
.sk-entry,
.sk-tile {
  pointer-events: none;
}

.sk-pola .pola-photo,
.sk-entry .entry-photo,
.sk-tile .tile-photo {
  border-radius: 0;
}

.sk-entry .entry-photo {
  border-radius: 14px;
}

/* =====================================================================
   Theme: Scrapbook
   ===================================================================== */
.theme-scrapbook {
  --lang-idle: #5e4a33;
  --accent: #2f5d43;
  --accent-strong: #264d37;
  --fab-bg: #2f5d43;
  --fab-ink: #fffdf7;
  --sk-a: #e4d6ba;
  --sk-b: #efe6d4;
  background-color: #e9dcc3;
  background-image: radial-gradient(#d9c7a6 1px, transparent 1.2px);
  background-size: 14px 14px;
  color: #3a2f22;
}

.theme-scrapbook .viewer-pill {
  background: rgba(255, 253, 247, 0.72);
  color: #4a3a28;
}

.sb-head {
  max-width: 760px;
  margin: 0 auto;
  padding: 30px var(--gutter) 6px;
  text-align: center;
}

.sb-title {
  font: 700 clamp(46px, 13vw, 70px) / 0.95 var(--font-hand);
  color: #2f5d43;
  letter-spacing: 0.005em;
  overflow-wrap: anywhere;
}

.sb-desc {
  max-width: 34ch;
  margin: 10px auto 0;
  font: 500 clamp(22px, 5.6vw, 26px) / 1.15 var(--font-hand);
  color: #6a5236;
  overflow-wrap: anywhere;
}

.sticker {
  display: inline-block;
  margin-top: 16px;
  padding: 3px 16px 5px;
  border-radius: 4px;
  background: #f7d774;
  color: #4a3a10;
  font: 700 23px/1.1 var(--font-hand);
  transform: rotate(-3deg);
  box-shadow: 0 2px 5px rgba(90, 60, 10, 0.18);
}

.sb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 44px 30px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 36px 24px 20px;
}

.pola {
  position: relative;
  padding: 10px 10px 14px;
  background: #fffdf7;
  box-shadow: 0 1px 1px rgba(60, 40, 10, 0.08), 0 10px 24px rgba(60, 40, 10, 0.18);
  transform: rotate(var(--r, 0deg));
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.pola:hover {
  transform: rotate(0deg) scale(1.025);
  box-shadow: 0 2px 2px rgba(60, 40, 10, 0.08), 0 18px 34px rgba(60, 40, 10, 0.22);
}

.tape {
  position: absolute;
  z-index: 2;
  top: -12px;
  left: 50%;
  width: 90px;
  height: 26px;
  transform: translateX(-50%) rotate(var(--tr, -4deg));
  background: var(--tape, rgba(170, 210, 180, 0.8));
  clip-path: polygon(3% 0, 97% 0, 100% 18%, 97% 36%, 100% 54%, 97% 72%, 100% 90%, 97% 100%, 3% 100%, 0 82%, 3% 64%, 0 46%, 3% 28%, 0 10%);
  pointer-events: none;
}

.pola-photo {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--sk-a);
}

.pola-title {
  margin: 12px 2px 0;
  font: 700 27px/1.05 var(--font-hand);
  color: #2e271f;
  overflow-wrap: anywhere;
}

.pola-desc {
  margin: 4px 2px 0;
  font: 500 20px/1.15 var(--font-hand);
  color: #6a5a47;
  overflow-wrap: anywhere;
}

.pola-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 10px 2px 0;
  font: 500 18px/1 var(--font-hand);
  color: #7a6446;
}

.pola-by {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pola-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.sk-pola .sk-line {
  margin-left: 2px;
}

@media (max-width: 519px) {
  .sb-grid {
    grid-template-columns: 1fr;
    gap: 42px;
    padding: 34px 24px 12px;
  }
  .pola {
    width: 88%;
    max-width: 340px;
  }
  .pola:nth-child(odd) {
    justify-self: start;
  }
  .pola:nth-child(even) {
    justify-self: end;
  }
}

.theme-scrapbook .empty-title {
  font: 700 38px/1 var(--font-hand);
  color: #2f5d43;
}

.theme-scrapbook .empty-body {
  font: 500 22px/1.2 var(--font-hand);
  color: #6a5236;
}

.theme-scrapbook .notice h1 {
  font: 700 40px/1 var(--font-hand);
  color: #2f5d43;
}

.theme-scrapbook .notice p {
  color: #6a5236;
}

.theme-scrapbook .album-foot .lang {
  background: rgba(106, 82, 54, 0.12);
}

/* =====================================================================
   Theme: Diario
   ===================================================================== */
.theme-diario {
  --sk-a: #efe8dc;
  --sk-b: #f8f3ea;
  background: #fbf8f3;
  color: #2b2621;
}

.theme-diario .viewer-pill {
  background: #f1ebe1;
  color: #4a4238;
}

.dy-head,
.dy-body {
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: clamp(var(--gutter), 4vw, 48px);
}

.dy-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding-top: 34px;
}

.dy-head::after {
  content: '';
  flex-basis: 100%;
  height: 1px;
  margin-top: 8px;
  background: #e6ddcf;
}

.dy-head-main {
  min-width: 0;
  max-width: 720px;
}

.dy-title {
  font: 600 clamp(34px, 8.5vw, 52px) / 1.04 var(--font-display);
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.dy-title em {
  font-style: italic;
  color: #2f7a55;
}

.dy-desc {
  margin-top: 12px;
  max-width: 58ch;
  font-size: 17px;
  color: #6d645a;
  overflow-wrap: anywhere;
}

.dy-meta {
  color: #6f675e;
  font-size: 14px;
  padding-bottom: 6px;
}

.month {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 28px;
  padding-top: 34px;
}

.month-label {
  position: sticky;
  top: 18px;
  align-self: start;
  font: 600 25px/1.1 var(--font-display);
  color: #2f7a55;
}

.month-label small {
  display: block;
  margin-bottom: 3px;
  font: 800 12px/1.2 var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6f675e;
}

.entries {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px 24px;
}

.entry {
  position: relative;
  min-width: 0;
}

.entry.feature {
  grid-column: 1 / -1;
}

.entry-photo {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 16px;
  background: var(--sk-a);
}

.entry.feature .entry-photo {
  aspect-ratio: 16 / 9;
}

.entry:hover .entry-photo img.is-loaded {
  transform: scale(1.03);
}

.entry-title {
  margin-top: 14px;
  font: 600 21px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.entry.feature .entry-title {
  font-size: clamp(22px, 5vw, 28px);
}

.entry-desc {
  margin-top: 5px;
  max-width: 62ch;
  color: #6d645a;
  overflow-wrap: anywhere;
}

.entry .by {
  margin-top: 9px;
  font-size: 13px;
  color: #6f675e;
}

.entry .heart-badge {
  margin-left: 4px;
}

.sk-entry .sk-line {
  margin-top: 14px;
}

@media (max-width: 700px) {
  .month {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-top: 26px;
  }
  .month-label {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-inline: calc(-1 * clamp(var(--gutter), 4vw, 48px));
    padding: 12px clamp(var(--gutter), 4vw, 48px) 10px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(251, 248, 243, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #efe7da;
    font-size: 22px;
  }
  .month-label small {
    order: 2;
    margin: 0;
  }
  .entries {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  .entry.feature .entry-photo {
    aspect-ratio: 4 / 3;
  }
}

.theme-diario .empty-title,
.theme-diario .notice h1 {
  font-family: var(--font-display);
  font-weight: 600;
}

.theme-diario .album-foot {
  border-top: 1px solid #ece4d7;
  max-width: 1080px;
  margin: 40px auto 0;
}

/* =====================================================================
   Theme: Muro
   ===================================================================== */
.theme-muro {
  --lang-idle: #c9d8ce;
  --accent: #2f7a55;
  --fab-bg: #f2c14e;
  --fab-ink: #1f3b2e;
  --sk-a: #2a4a3a;
  --sk-b: #335746;
  background: #1f3b2e;
  color: #f3efe6;
}

.theme-muro .viewer-pill {
  background: rgba(255, 255, 255, 0.08);
  color: #d6e2da;
}

.theme-muro .viewer-pill-cta {
  color: #f2c14e;
  border-left-color: rgba(255, 255, 255, 0.2);
}

.theme-muro :focus-visible {
  outline-color: #f2c14e;
}

.theme-muro .tile:has(.stretch:focus-visible) {
  outline-color: #f2c14e;
}

.wall-head,
.wall-body {
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.wall-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 30px;
  padding-bottom: 22px;
}

.badge {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  flex: none;
  border-radius: 50%;
  background: #f2c14e;
  color: #1f3b2e;
  font: 800 21px/1 var(--font-display);
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 5px rgba(242, 193, 78, 0.16);
}

.wall-head-text {
  min-width: 0;
}

@media (max-width: 560px) {
  .wall-head {
    align-items: flex-start;
    gap: 14px;
  }

  .badge {
    width: 52px;
    height: 52px;
    margin-top: 2px;
    font-size: 17px;
    box-shadow: 0 0 0 4px rgba(242, 193, 78, 0.16);
  }
}

.wall-title {
  font: 800 clamp(27px, 7vw, 40px) / 1.08 var(--font-display);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.wall-desc {
  margin-top: 4px;
  color: #b9cbbf;
  overflow-wrap: anywhere;
}

.wall-meta {
  margin-top: 4px;
  color: #8fae9c;
  font-size: 14px;
  font-weight: 700;
}

.chips {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter)) 18px;
  padding: 2px var(--gutter) 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid #4d6c5c;
  border-radius: 999px;
  background: transparent;
  color: #d6e2da;
  font: 700 14px/1 var(--font-body);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover {
  border-color: #8fae9c;
}

.chip[aria-pressed='true'] {
  background: #f2c14e;
  border-color: #f2c14e;
  color: #1f3b2e;
  font-weight: 800;
}

.masonry {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.masonry-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.masonry-col:only-child {
  max-width: 560px;
}

.tile {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #fffaf0;
  color: #2a2622;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: rise-in 0.45s var(--ease) both;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
}

.tile-photo {
  overflow: hidden;
  background: var(--sk-a);
}

.tile-body {
  padding: 12px 14px 12px;
}

.tile-title {
  font: 700 16.5px/1.25 var(--font-body);
  overflow-wrap: anywhere;
}

.tile-desc {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  font-size: 14px;
  color: #6d645a;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.tile-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12.5px;
  color: #6f675e;
}

.by-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sk-tile {
  background: #284636;
  box-shadow: none;
  animation: none;
}

.sk-tile .tile-body {
  padding-bottom: 16px;
}

@media (max-width: 559px) {
  .masonry,
  .masonry-col {
    gap: 10px;
  }
  .tile {
    border-radius: 15px;
  }
  .tile-body {
    padding: 10px 11px 10px;
  }
  .tile-title {
    font-size: 15px;
  }
  .tile-desc {
    font-size: 13px;
    -webkit-line-clamp: 2;
  }
  .tile-foot {
    margin-top: 8px;
  }
  .tile .av {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
}

.theme-muro .empty-body,
.theme-muro .notice p {
  color: #b9cbbf;
}

.theme-muro .album-foot .lang {
  background: rgba(255, 255, 255, 0.08);
}

.theme-muro .album-foot .lang button[aria-pressed='true'] {
  background: #f2c14e;
  color: #1f3b2e;
}

/* =====================================================================
   Lightbox
   ===================================================================== */
.lb {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #14110e;
  color: #f5efe6;
  overflow: hidden;
}

.lb[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: fade-in 0.2s ease-out;
}

.lb.is-closing {
  animation: fade-out 0.18s ease-in forwards;
}

.lb::backdrop {
  background: #14110e;
}

.lb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(6px + env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) 6px max(18px, env(safe-area-inset-left));
}

.lb-count {
  font-size: 14px;
  font-weight: 700;
  color: #cfc6ba;
  font-variant-numeric: tabular-nums;
}

.lb-close {
  color: #f5efe6;
}

.lb-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* The close button sits against the screen edge; an outer ring gets clipped there. */
.lb-close:focus-visible {
  outline-offset: -3px;
}

.lb-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}

.lb-img {
  position: absolute;
  inset: 0 8px;
  width: calc(100% - 16px);
  height: 100%;
  object-fit: contain;
  transition: transform 0.28s var(--ease), opacity 0.28s ease;
  -webkit-user-drag: none;
}

.lb-spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  color: #f5efe6;
}

.lb-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 17, 14, 0.45);
  color: #fff;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: opacity 0.2s, background-color 0.2s;
}

.lb-nav:hover:not(:disabled) {
  background: rgba(20, 17, 14, 0.7);
}

.lb-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.lb-prev {
  left: max(10px, env(safe-area-inset-left));
}

.lb-next {
  right: max(10px, env(safe-area-inset-right));
}

@media (hover: none) and (max-width: 700px) {
  .lb-nav {
    width: 44px;
    height: 44px;
    margin-top: -22px;
    background: rgba(20, 17, 14, 0.32);
  }
}

.lb-info {
  max-height: 50vh;
  max-height: 50dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px max(20px, env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-right));
  border-radius: 22px 22px 0 0;
  background: #fffdf8;
  color: #2b2621;
  animation: sheet-up 0.3s var(--ease);
}

.lb-title {
  font: 600 25px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.lb-desc {
  margin-top: 6px;
  color: #6d645a;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.lb-by {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  color: #6f675e;
}

.lb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.lb-edit,
.lb-confirm,
.lb-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Editing on a phone: the photo shrinks to a strip and the form gets the height; Save stays in view. */
.lb.is-editing[open] {
  grid-template-rows: auto minmax(0, 88px) minmax(0, 1fr);
}

.lb.is-editing .lb-nav {
  display: none; /* jumping to another photo would drop the edit */
}

.lb.is-editing .lb-info {
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow: hidden;
}

.lb-edit {
  flex: 1;
  min-height: 0;
}

.lb-edit-fields {
  flex: 1;
  min-height: 0;
  margin: -4px -4px 0;
  padding: 4px 4px 2px;
  overflow: auto;
  overscroll-behavior: contain;
}

.lb-edit .lb-form-actions {
  flex: none;
  margin-top: 0;
  padding-top: 12px;
  border-top: 1px solid #eee6da;
}

.lb-edit-title {
  font-size: 21px;
  font-weight: 700;
}

.lb-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .lb-form-actions .btn {
    flex: 1;
  }
}

@media (min-width: 900px) {
  .lb[open],
  .lb.is-editing[open] {
    grid-template-columns: minmax(0, 1fr) 390px;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .lb-top {
    grid-column: 1 / -1;
  }
  .lb-stage {
    grid-column: 1;
    grid-row: 2;
  }
  .lb-img {
    inset: 0 24px 24px;
    width: calc(100% - 48px);
    height: calc(100% - 24px);
  }
  .lb-info {
    grid-column: 2;
    grid-row: 2;
    max-height: none;
    border-radius: 22px 0 0 0;
    padding: 28px 28px 28px;
    animation: none;
  }
}

.lb .toasts {
  top: calc(60px + env(safe-area-inset-top));
  bottom: auto;
}

/* Phone in landscape: the photo takes the full height on the left, details (and the close button) on the right. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1100px) {
  .lb[open],
  .lb.is-editing[open] {
    grid-template-columns: minmax(0, 1fr) min(340px, 42vw);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .lb-top {
    grid-column: 2;
    grid-row: 1;
    padding: calc(8px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 2px 16px;
    background: #fffdf8;
    color: #2b2621;
    border-radius: 18px 0 0 0;
  }
  .lb-count {
    color: #6f675e;
  }
  .lb-close {
    color: #2b2621;
  }
  .lb-close:hover {
    background: rgba(0, 0, 0, 0.06);
  }
  .lb-stage {
    grid-column: 1;
    grid-row: 1 / -1;
  }
  .lb-img {
    inset: auto;
    top: 6px;
    left: max(6px, env(safe-area-inset-left));
    width: calc(100% - 6px - max(6px, env(safe-area-inset-left)));
    height: calc(100% - 12px - env(safe-area-inset-bottom));
  }
  .lb-info {
    grid-column: 2;
    grid-row: 2;
    max-height: none;
    border-radius: 0;
    padding: 6px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) 16px;
    animation: none;
  }
  .lb .toasts {
    top: calc(12px + env(safe-area-inset-top));
  }
}

/* =====================================================================
   Upload sheet
   ===================================================================== */
.up-batch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 16px;
  background: var(--soft);
}

.up-batch .input {
  background: var(--card);
}

.up-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.up-card {
  position: relative;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px 14px;
  padding: 14px;
  border-radius: 20px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  animation: rise-in 0.35s var(--ease) both;
  transition: border-color 0.2s, background-color 0.2s, opacity 0.2s;
}

.up-card.is-leaving {
  animation: card-out 0.25s ease-in forwards;
}

@keyframes card-out {
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

.up-preview {
  position: relative;
  width: 92px;
  height: 92px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--bg-2);
  box-shadow: 0 1px 2px rgba(60, 40, 10, 0.12);
}

.up-preview .sk {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.up-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fade-in 0.35s ease-out;
}

.up-preview.is-broken {
  display: grid;
  place-items: center;
  color: var(--faint);
}

.up-fields {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  padding-right: 34px;
}

.up-title,
.up-desc,
.up-status {
  grid-column: 1 / -1;
}

.up-status:empty {
  display: none;
}

.up-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  color: var(--muted);
}

.up-name {
  display: none;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.up-note .spinner {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

.progress {
  display: block;
  height: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #58b184);
  transition: width 0.25s ease;
}

.up-ok {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 800;
}

.up-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--danger);
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.35;
}

.up-error .icon {
  margin-top: 1px;
}

.up-status .btn {
  margin-top: 10px;
}

.up-card[data-status='done'] {
  border-color: rgba(47, 122, 85, 0.35);
  background: var(--soft);
}

.up-card[data-status='done'] .up-desc {
  display: none;
}

.up-card[data-status='error'] {
  border-color: rgba(184, 67, 60, 0.45);
  background: var(--danger-soft);
}

.up-card[data-status='uploading'] {
  border-color: var(--accent);
}

.up-card:has([aria-invalid='true']) {
  border-color: var(--danger);
}

.up-card[data-status='unreadable'] {
  align-items: center;
  background: var(--bg-2);
}

.up-card[data-status='unreadable'] .field,
.up-card[data-status='unreadable'] .up-title,
.up-card[data-status='unreadable'] .up-desc {
  display: none;
}

.up-card[data-status='unreadable'] .up-name {
  display: block;
}

.up-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  margin-top: 14px;
  border: 2px dashed var(--line);
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font: 800 15.5px/1 var(--font-body);
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.up-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--soft);
}

.up-submit .spinner {
  width: 17px;
  height: 17px;
}

@media (max-width: 380px) {
  .up-card {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }
  .up-preview {
    width: 76px;
    height: 76px;
  }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .pola,
  .pola:hover {
    transform: rotate(var(--r, 0deg));
  }
}
