:root {
  color-scheme: light;
  --ink: #19322b;
  --muted: #40574e;
  --green: #245b49;
  --line: #dce6e0;
  --paper: #fff;
  --wash: #f3e4bd;
  --lacquer: #7a1712;
  --gilt: #f0cf7a;
  --gold: #8a6a35;
  --seal: #b3261e;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 1.125rem; line-height: 1.5; background: var(--wash) url("/images/royal-silk.svg") repeat; }

/* Dancing Script (SIL OFL 1.1, see /fonts/OFL.txt), self-hosted because the CSP only allows this origin. */
@font-face { font-family: "Dancing Script"; font-weight: 700; font-display: swap; src: url("/fonts/dancing-script-700-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Dancing Script"; font-weight: 700; font-display: swap; src: url("/fonts/dancing-script-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid #38866c; outline-offset: 3px; }
svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.symbols, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Red lacquer with gilt, as on the doors and beams of the Huế imperial city, edged with a hồi văn band. */
.topbar { background: linear-gradient(#8a1c15, var(--lacquer)); color: var(--gilt); }
.topbar::after { content: ""; display: block; background: #5f100c url("/images/royal-band.svg") repeat-x center; height: 22px; border-top: 1px solid #c99a3b; border-bottom: 2px solid #c99a3b; }
.topbar-inner, .layout { max-width: 1280px; margin: 0 auto; padding-inline: 32px; }
.topbar-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.text-size { min-width: 56px; font-size: 1.125rem; font-weight: 800; }
/* "A+" scales every rem-based size on the page. */
html.large-text { font-size: 118.75%; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 750; line-height: 1.2; }
/* A red seal and the family name in brush-like script: "Họ Dương" at a glance. */
.family-seal { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 8px; background: linear-gradient(135deg, #f6dc8f, #c99a3b); color: var(--lacquer); font: 700 1.75rem/1 "Dancing Script", cursive; box-shadow: inset 0 0 0 2px #f6dc8f, inset 0 0 0 4px var(--lacquer); transform: rotate(-4deg); }
.family-name { font: 700 2rem/1.1 "Dancing Script", cursive; color: var(--gilt); letter-spacing: .01em; text-shadow: 0 1px 0 #3d0806; }
.brand-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--green); color: #e7f6ee; }

.layout { padding-bottom: 40px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "text" "action"; align-content: center; min-height: 300px; gap: 14px 24px; padding: 24px; margin-top: 20px; border: 1px solid #c99a3b; outline: 1px solid #e6cf95; outline-offset: -6px; border-radius: 16px;
  position: relative; overflow: hidden; background: #fffaf0; }
/* Half of a turning 3D bronze drum peeks in from the right edge of the hero. */
.hero-drum { position: absolute; z-index: 0; top: 50%; right: -150px; width: 520px; aspect-ratio: 1; transform: translateY(-50%); cursor: grab; touch-action: pan-y; }
.hero-drum:active { cursor: grabbing; }
.hero-drum canvas { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity .6s ease-out; }
.hero-drum.ready canvas { opacity: 1; }
.hero-drum.ready .drum-fallback { display: none; }
.drum-fallback { position: absolute; inset: 18%; width: 64%; height: 64%; opacity: .5; }
.hero-text, .hero-action { position: relative; z-index: 1; }
.hero-text { max-width: 62%; }
.hero-text { grid-area: text; }
.hero-text h1, .hero-text p { text-shadow: 0 1px 0 #fffaf0, 0 0 10px #fffaf0, 0 0 18px #fffaf0; }
.hero-action { grid-area: action; justify-self: start; }
/* A small clock in the top-right corner: time on top, solar and lunar day underneath. */
.topbar-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.clock { display: grid; justify-items: end; line-height: 1.15; text-align: right; }
.clock-time { font-size: 1.125rem; font-weight: 750; font-variant-numeric: tabular-nums; color: #fff4d6; }
.clock-date { font-size: .8125rem; font-weight: 600; color: var(--gilt); white-space: nowrap; }
.visit-badge {
  position: fixed;
  z-index: 4;
  top: 50%;
  right: max(8px, env(safe-area-inset-right));
  transform: translateY(-50%);
  display: grid;
  place-content: center;
  gap: 3px;
  width: 4.5rem;
  aspect-ratio: 1;
  border: 1px solid #c99a3b;
  border-radius: 50%;
  background: #5f100c;
  color: #fff4d6;
  box-shadow: 0 2px 8px #33170d33;
  font-size: .6875rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.visit-badge strong { font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.topbar .text-size { background: transparent; color: var(--gilt); border-color: #c99a3b; }
.topbar .text-size:hover, .topbar .text-size[aria-pressed="true"] { background: #ffffff1a; border-color: var(--gilt); }
.topbar :focus-visible { outline-color: var(--gilt); }
h1 { font-size: clamp(1.875rem, 4vw, 2.75rem); line-height: 1.18; margin-bottom: 5px; }
.hero p { color: var(--muted); }

.library { margin-top: 24px; }
.library-heading, .group-heading, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.library-heading { flex-wrap: wrap; }
.library-heading h2, .dialog-heading h2 { font-size: 1.5rem; line-height: 1.3; }
.dialog-heading p { color: var(--muted); font-size: 1rem; margin-top: 4px; }
.button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; min-height: 48px; font-weight: 650; font-size: 1rem; border: 1px solid transparent; text-align: center; }
.button { padding: 8px 14px; }
.hero .button { min-height: 54px; font-size: 1.125rem; }
.primary { background: var(--green); color: #fff; }
.primary:hover:not(:disabled) { background: #184737; }
.secondary, .icon-button { background: var(--paper); border-color: #a4b9ad; color: var(--ink); }
.secondary:hover:not(:disabled), .secondary[aria-pressed="true"], .icon-button:hover:not(:disabled) { background: #e6f2eb; border-color: #9dbdad; }
.icon-button { width: 48px; flex: none; padding: 0; }
.text-button { background: transparent; color: var(--green); }
.text-button:hover:not(:disabled) { background: #e3eee8; }
.danger { background: #a12f29; color: #fff; }
.danger:hover:not(:disabled) { background: #842520; }
.danger-text { color: #a12f29; }
.danger-text:hover:not(:disabled) { background: #f8e7e5; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 14px; }
.search, .filter-options summary { min-height: 48px; padding: 0 12px; color: var(--ink); border: 1px solid #a4b9ad; border-radius: 10px; background: var(--paper); font-size: 1rem; }
.search { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; }
.search input { flex: 1; min-width: 0; width: 100%; background: transparent; border: 0; color: var(--ink); padding-block: 8px; }
.search input::placeholder { color: var(--muted); }
.filter-options { max-width: 100%; }
.filter-options summary { cursor: pointer; line-height: 46px; font-weight: 650; }
.filter-options[open] { flex-basis: 100%; }
.filter-fields { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.filter-fields > label { flex: 1 1 180px; min-width: 0; }
.filter-indicator { margin-inline-start: 8px; color: var(--green); font-size: .875rem; }
.selection-bar { position: sticky; top: 8px; z-index: 2; display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; align-items: center; margin-top: 12px; padding: 8px 10px; border: 1px solid #bdd7c9; border-radius: 12px; background: #eaf4ef; box-shadow: 0 5px 16px #1d3a2510; }
.selection-bar > div { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.selection-bar strong { font-size: 1rem; margin: 0 3px; }
.selection-bar .text-button { padding-inline: 7px; }

.gallery { display: grid; gap: 23px; margin-top: 19px; }
.group-heading { justify-content: flex-start; flex-wrap: wrap; margin-bottom: 9px; }
.group-heading h3 { font-size: 1.125rem; font-weight: 750; }
.group-heading .text-button { margin-left: auto; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.card { position: relative; min-width: 0; }
.photo-button { display: block; padding: 0; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--paper); color: var(--ink); }
.photo-button:hover { border-color: #8bb09f; box-shadow: 0 3px 13px #163c2810; }
.card.selected .photo-button { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); }
.thumbnail { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; background: #e7eee9; color: var(--muted); }
.thumbnail img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-caption { display: block; padding: 10px 12px 11px; }
.photo-caption strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.photo-check { pointer-events: none; position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: #fff; border: 1px solid #839e92; color: transparent; }
.photo-check svg { width: 17px; height: 17px; }
.selected .photo-check { background: var(--green); color: white; border-color: var(--green); }
.placeholder { display: grid; justify-items: center; gap: 8px; padding: 36px 12px; text-align: center; color: var(--muted); border: 1px dashed #abc2b6; border-radius: 13px; }

dialog { width: min(540px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 21px; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); background: var(--paper); box-shadow: 0 20px 80px #0d231e40; }
dialog::backdrop { background: #0e2823a8; }
.dialog-heading { align-items: flex-start; margin-bottom: 16px; }
.dialog-heading div, .dialog-heading h2 { min-width: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.field { display: grid; gap: 5px; font-size: 1rem; font-weight: 650; }
.field input, .field select { padding: 8px 10px; min-height: 48px; width: 100%; min-width: 0; color: var(--ink); border: 1px solid #a4b9ad; border-radius: 9px; background: var(--paper); }
.drop-zone { display: grid; position: relative; justify-items: center; text-align: center; gap: 5px; margin-top: 13px; padding: 17px 10px; border: 1px dashed #8cae9d; border-radius: 12px; background: #eff6f1; color: var(--green); cursor: pointer; }
.drop-zone:focus-within, .drop-zone.dragging { outline: 2px solid var(--green); outline-offset: 2px; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone small { color: var(--muted); }
.queued-files { max-height: min(40vh, 22rem); overflow: auto; }
.queued-summary { margin: 11px 0 4px; font-size: 1rem; font-weight: 650; }
.queue-row { display: flex; align-items: center; gap: 7px; border-bottom: 1px solid var(--line); padding: 4px 0; font-size: 1rem; }
.queue-row > span:first-child:not(.queue-thumb) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-thumb { position: relative; flex: none; display: grid; place-items: center; width: 52px; height: 52px; overflow: hidden; border-radius: 9px; background: #e7eee9; color: var(--muted); }
.queue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-text { display: grid; flex: 1; min-width: 0; }
.queue-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-status { display: flex; align-items: center; gap: 4px; }
.queue-row.done .queue-status, .queue-row.skipped .queue-status { color: var(--green); font-weight: 700; }
.queue-row.failed .queue-status { color: #a12f29; font-weight: 700; }
.queue-row.done .queue-status svg { width: 22px; height: 22px; stroke-width: 2.4; animation: check-pop .32s cubic-bezier(.3, 1.6, .6, 1); }
.queue-row small { color: var(--muted); white-space: nowrap; }
.queue-row svg { width: 16px; }
.upload-progress { display: flex; align-items: center; gap: 9px; font-size: 1rem; margin-top: 12px; }
.upload-progress { flex-wrap: wrap; }
.meter { flex: 1 1 100%; height: 12px; overflow: hidden; border-radius: 99px; background: #dce8e1; }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .3s ease-out; }
.day-picker { margin: 0; padding: 0; border: 0; min-width: 0; }
.day-picker legend { padding: 0; margin-bottom: 6px; font-size: 1rem; font-weight: 650; }
.day-options { display: flex; flex-wrap: wrap; gap: 8px; }
.day-options .button { flex: 1 1 auto; }
.day-options .button[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.day-picker input { margin-top: 8px; width: 100%; min-height: 48px; padding: 8px 10px; border: 1px solid #a4b9ad; border-radius: 9px; }
.day-words { margin-top: 8px; font-size: 1.125rem; font-weight: 700; color: var(--green); }
/* Loading: a spinning bronze drum above skeleton cards shaped like the real ones. */
.drum-spinner { width: 44px; height: 44px; animation: drum-spin 1.8s linear infinite; filter: drop-shadow(0 2px 3px #5f3a0a40); }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 0 16px; font-weight: 650; color: var(--gold); }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.skeleton-card { display: grid; overflow: hidden; border: 1px solid #ecdcb4; border-radius: 13px; background: #fffdf7; }
.skeleton-thumb, .skeleton-line { background: linear-gradient(90deg, #efe2c2 25%, #faf3e2 50%, #efe2c2 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton-thumb { aspect-ratio: 16 / 10; }
.skeleton-line { height: 14px; width: 62%; margin: 12px; border-radius: 99px; }
.queue-status .drum-spinner { width: 18px; height: 18px; filter: none; }
/* While a preview is still loading, the drum turns in the middle of the dark stage. */
.preview-media.loading { position: relative; }
.preview-media.loading::after { content: ""; position: absolute; top: 50%; left: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; background: url("/images/drum-icon.svg") center / contain no-repeat; animation: drum-spin 1.8s linear infinite; }
.error { margin-top: 10px; color: #a12f29; font-size: 1rem; }
.share-status { margin-top: 10px; color: var(--muted); font-size: 1rem; }
.preview-dialog { width: min(1000px, calc(100% - 24px)); }
.preview-stage { position: relative; background: #152b25; color: #ebf5f0; border-radius: 12px; overflow: hidden; }
.preview-media { display: grid; place-items: center; min-height: min(36vh, 290px); padding: 4px; }
.preview-media img, .preview-media video { display: block; max-width: 100%; max-height: 60vh; object-fit: contain; }
.video-tag { font-size: 1rem; font-weight: 650; }
.download-files { max-height: min(55vh, 32rem); }
.download-row { flex-wrap: wrap; }
.download-row span:first-child { flex-basis: min(100%, 12rem); }
.preview-media p { padding: 10px; text-align: center; font-size: 1rem; }
.preview-nav { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preview-nav p { font-size: 1rem; text-align: center; color: var(--muted); }
.preview-details { display: grid; gap: 4px; margin-top: 11px; overflow-wrap: anywhere; color: var(--muted); font-size: 1rem; }
.notification { position: fixed; z-index: 5; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px; background: #183e32; color: #fff; box-shadow: 0 6px 20px #0d231e30; font-size: 1.125rem; line-height: 1.4; }
.notification-action { flex: none; min-height: 44px; padding: 0 14px; border: 2px solid #d7f4e5; border-radius: 10px; background: transparent; color: #fff; font: inherit; font-weight: 750; }
.notification-action:hover { background: #ffffff1f; }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-outline { color: #a12f29; border-color: #e3b5b1; }
.danger-outline[aria-pressed="true"] { background: #f8e7e5; }
/* Choosing what to delete: keep the delete button in reach at the bottom while scrolling through photos. */
.selection-bar.delete-mode { position: fixed; z-index: 4; left: 12px; right: 12px; bottom: 12px; top: auto; margin: 0; padding: 10px 12px; background: #fff; border-color: #e3b5b1; box-shadow: 0 8px 28px #0d231e33; }
.selection-bar.delete-mode #delete-selected { min-height: 54px; padding-inline: 20px; font-size: 1.125rem; }
.library.deleting { padding-bottom: 110px; }
.preview-stage { touch-action: pan-y pinch-zoom; }

/* Motion: short and calm, and skipped entirely when the device asks for reduced motion. */
.thumbnail img, .preview-media img { opacity: 0; transition: opacity .25s ease-out; }
.thumbnail img.loaded, .preview-media img.loaded { opacity: 1; }
.card { transition: opacity .2s ease-in, transform .2s ease-in; }
.card.leaving { opacity: 0; transform: scale(.85); }
dialog[open] { animation: pop-in .18s ease-out; }
dialog[open]::backdrop { animation: fade-in .18s ease-out; }
.notification:not([hidden]) { animation: toast-in .22s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes check-pop { from { transform: scale(.3); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes drum-spin { to { transform: rotate(360deg); } }

/* Footer: internal-use notice on the left, the author on the right. */
.site-footer { margin-top: 32px; background: linear-gradient(var(--lacquer), #5f100c); color: var(--gilt); font-size: 1rem; }
.site-footer::before { content: ""; display: block; height: 22px; background: #5f100c url("/images/royal-band.svg") repeat-x center; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 16px 32px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px; }
.footer-inner a { text-decoration: underline; text-underline-offset: 3px; }
.footer-inner a:hover { color: #fff4d6; }
.footer-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.footer-author { font-size: .9375rem; }
.footer-author strong { font: 700 1.375rem/1 "Dancing Script", cursive; color: #fff4d6; }
.library.deleting + .site-footer, main:has(.library.deleting) + .site-footer { padding-bottom: 110px; }

@media (max-width: 760px) {
  .footer-inner { padding-inline: 16px; flex-direction: column; align-items: flex-start; }
  .topbar-inner, .layout { padding-inline: 16px; }
  .topbar-inner { min-height: 56px; }
  .hero { padding: 16px; margin-top: 14px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "action"; }
  .hero { min-height: 0; align-content: start; }
  .hero-drum { top: 50%; right: -54%; width: 92%; transform: translateY(-50%); }
  .hero-text { max-width: 58%; min-height: 128px; }
  .hero .button { width: 100%; }
  .family-name { font-size: 1.5rem; }
  .family-seal { width: 36px; height: 36px; font-size: 1.5rem; }
  .brand { gap: 8px; min-width: 0; }
  .topbar-tools { gap: 8px; }
  .text-size { min-width: 48px; padding-inline: 8px; }
  .library { margin-top: 20px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 10px; }
  .photo-caption { padding: 8px; }
  .selection-bar { position: static; }
  /* Dialogs become bottom sheets on phones: easier to reach with a thumb. */
  dialog:not(.preview-dialog) { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  dialog[open]:not(.preview-dialog) { animation: sheet-up .24s ease-out; }
}

@media (max-width: 390px) {
  .photo-grid, .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .photo-caption strong { font-size: .9375rem; }
  dialog { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
