/* ============ Font Nunito: bo tròn, thân thiện, đủ dấu tiếng Việt ============ */
@font-face { font-family: "Nunito"; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(/vendor/fonts/nunito-vietnamese-wght-normal.woff2) format("woff2-variations");
  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: "Nunito"; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(/vendor/fonts/nunito-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(/vendor/fonts/nunito-latin-wght-normal.woff2) format("woff2-variations");
  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; }

/* ============ Màu sắc ============ */
:root {
  --bg: #fff7ee;
  --surface: #ffffff;
  --surface-2: #fff0e3;
  --paper: #ffffff;
  --text: #3a2c26;
  --muted: #8a7568;
  --line: #f1e1d2;
  --accent: #ff7a59;          /* cam san hô */
  --accent-2: #ff9f43;
  --accent-text: #ffffff;
  --accent-soft: #ffe3d8;
  --sky: #4d96ff;
  --sun: #ffcf5c;
  --mint: #5ccfa8;
  --grape: #a77bff;
  --pink: #ff8fb1;
  --danger: #e5484d;
  --tile: #f6e8db;
  --shadow: 0 2px 4px rgb(120 70 30 / .06), 0 8px 24px rgb(120 70 30 / .08);
  --shadow-lg: 0 6px 14px rgb(120 70 30 / .12), 0 22px 44px rgb(120 70 30 / .14);
  --radius: 20px;
  --gap: 4px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);   /* chuyển động có độ "nảy" */
  --ease: cubic-bezier(.22, .8, .26, 1);
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1724;
    --surface: #262033;
    --surface-2: #2f2840;
    --paper: #2c2539;
    --text: #f6efe9;
    --muted: #b6a8bd;
    --line: #3a3149;
    --accent: #ff8a6b;
    --accent-2: #ffad5c;
    --accent-text: #2a120a;
    --accent-soft: #46303a;
    --tile: #332b42;
    --shadow: 0 2px 4px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    --shadow-lg: 0 6px 14px rgb(0 0 0 / .4), 0 22px 44px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(40rem 28rem at 8% -6%, color-mix(in srgb, var(--sun) 22%, transparent), transparent 70%),
    radial-gradient(36rem 26rem at 96% 4%, color-mix(in srgb, var(--pink) 16%, transparent), transparent 70%),
    radial-gradient(40rem 30rem at 60% 110%, color-mix(in srgb, var(--sky) 10%, transparent), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font: 500 15.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 900; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
em.muted { font-style: normal; }
[hidden] { display: none !important; }

/* ============ Nút ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 2px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; text-decoration: none; font-weight: 800;
  white-space: nowrap; transition: transform .25s var(--spring), background .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: var(--shadow); }
.btn:active { transform: scale(.95); transition-duration: .08s; }
.btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-text);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn.primary:hover { box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 50%, transparent); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 14px; }
input:focus-visible, .btn:focus-visible, a:focus-visible, .tile:focus-visible, button:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* ============ Đăng nhập ============ */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 390px; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-lg);
  padding: 34px 26px 28px; text-align: center; animation: pop-in .6s var(--spring) backwards;
}
.login-card h1 { margin: 14px 0 0; font-size: 32px; }
.login-card p { margin: 2px 0 22px; }
.login-logo { border-radius: 18px; animation: wiggle 2.8s ease-in-out 1s infinite; }
form label { display: block; text-align: left; margin-bottom: 14px; }
form label > span { display: block; font-size: 14px; font-weight: 800; margin-bottom: 6px; }
input[type=text], input[type=password] {
  width: 100%; min-height: 48px; padding: 0 16px; font-weight: 600;
  border: 2px solid var(--line); border-radius: 16px; background: var(--bg); transition: border-color .2s, box-shadow .2s;
}
input[type=text]:focus, input[type=password]:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.error { color: var(--danger); margin: 0 0 12px; font-size: 14px; font-weight: 700; animation: shake .4s; }

/* ============ Thanh trên: lời chào + số liệu gọn + tab + ảnh đại diện ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.5) blur(14px); -webkit-backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 2px solid var(--line);
  view-transition-name: topbar;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; flex: 1 1 0; }
.brand img { border-radius: 10px; flex: none; transition: transform .35s var(--spring); }
.brand:hover img { transform: rotate(-10deg) scale(1.1); }
.hi { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.hi b { font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi small { font-size: 12.5px; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wave { display: inline-block; transform-origin: 70% 80%; animation: wave 2.4s ease-in-out .6s 2; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; flex: none; }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-weight: 800; transition: background .25s, color .25s, transform .25s var(--spring);
}
.tabs a:hover { color: var(--text); transform: translateY(-1px); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs a.active .ti, .bottomnav a.active .ti { animation: bounce-once .5s var(--spring); }
.ti { font-size: 17px; line-height: 1; }
.top-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex: 1 1 0; }

/* Ảnh đại diện có vòng dung lượng kho (chỉ hiện cơ bản, chi tiết trong menu) */
.me { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; flex: none; transition: transform .25s var(--spring); }
.me:hover { transform: scale(1.06); }
.me:active { transform: scale(.94); }
.me-ring {
  --pct: 2%;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: conic-gradient(var(--mint) var(--pct), var(--line) 0);
}
.me-ring.warn { background: conic-gradient(var(--accent) var(--pct), var(--line) 0); }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; font-weight: 900; font-size: 16px;
  background: linear-gradient(135deg, var(--grape), var(--sky)); box-shadow: 0 0 0 2px var(--bg);
}
.avatar.big { width: 52px; height: 52px; font-size: 22px; box-shadow: none; flex: none; }

/* Thanh dưới đáy + nút ＋ (điện thoại) */
.bottomnav { display: none; }
@media (max-width: 760px) {
  .topbar { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .tabs, .up-desktop { display: none !important; }
  .hi b { font-size: 16px; }
  .top-actions { flex: none; }
  .bottomnav {
    position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding: 6px 18px max(8px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(1.5) blur(16px); -webkit-backdrop-filter: saturate(1.5) blur(16px);
    border-top: 2px solid var(--line);
    view-transition-name: bottomnav;
  }
  .bottomnav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; text-decoration: none;
    color: var(--muted); font-weight: 800; font-size: 12px; border-radius: 14px; transition: color .2s, transform .25s var(--spring);
  }
  .bottomnav a .ti { font-size: 23px; transition: transform .3s var(--spring); }
  .bottomnav a.active { color: var(--text); }
  .bottomnav a.active .ti { transform: translateY(-2px) scale(1.12); }
  .bottomnav a:active { transform: scale(.92); }
  .fab {
    width: 62px; height: 62px; margin: -26px 18px 0; border-radius: 50%; border: 4px solid var(--bg); cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 32px; font-weight: 900; line-height: 1;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
    display: grid; place-items: center; transition: transform .3s var(--spring), box-shadow .3s;
  }
  .fab:active { transform: scale(.9) rotate(90deg); }
}

/* ============ Nội dung ============ */
main { padding: 16px; max-width: 1600px; margin: 0 auto; outline: none; padding-bottom: 110px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 6px 0 18px; animation: rise .45s var(--ease) backwards; }
.ph-text { flex: 1 1 260px; min-width: 0; }
.page-head h1 { font-size: 26px; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.page-head .sub { color: var(--muted); font-size: 14px; font-weight: 600; margin-top: 2px; }
.page-head .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.back { width: 40px; padding: 0; font-size: 20px; flex: none; }
@media (max-width: 760px) {
  main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  .page-head { gap: 8px; }
  .page-head h1 { font-size: 21px; }
  .page-head .sub { font-size: 13px; }
  .page-head .actions { width: 100%; margin-left: 0; }
  .page-head .actions .btn { flex: 1; }
}
@media (max-width: 380px) { .page-head .actions .lbl { display: none; } }

.empty { text-align: center; padding: 56px 16px; color: var(--muted); animation: rise .5s var(--ease) backwards; }
.empty h2 { color: var(--text); margin: 10px 0 4px; font-size: 24px; }
.empty p { max-width: 440px; margin: 0 auto; }
.empty .btn { margin-top: 18px; }
.empty-art { font-size: 72px; line-height: 1; display: inline-block; animation: float 3s ease-in-out infinite; }

/* Lời chào */
.hello { margin: 10px 0 22px; animation: rise .5s var(--ease) backwards; }
.hello h1 { font-size: clamp(28px, 5.4vw, 40px); margin: 0; line-height: 1.15; }
.hello h1 .wave { display: inline-block; transform-origin: 70% 80%; animation: wave 2.4s ease-in-out .4s 2; }
.hello p { margin: 6px 0 0; color: var(--muted); font-weight: 600; }
.usage { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); max-width: 460px; font-weight: 700; }
.usage .bar { flex: 1; height: 8px; }

/* Ngày này năm xưa */
.memories {
  position: relative; overflow: hidden;
  background: linear-gradient(120deg, color-mix(in srgb, var(--sun) 45%, var(--surface)), color-mix(in srgb, var(--pink) 35%, var(--surface)));
  border-radius: 26px; padding: 18px 18px 14px; margin-bottom: 26px; box-shadow: var(--shadow);
  animation: rise .55s var(--ease) .05s backwards;
}
.memories::after { content: "⭐"; position: absolute; right: 18px; top: 12px; font-size: 26px; animation: twinkle 2.2s ease-in-out infinite; }
.memories h2 { margin: 0; font-size: 22px; }
.memories p { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.mem-strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 8px; scrollbar-width: thin; }
.mem {
  position: relative; flex: none; width: 130px; height: 164px; border-radius: 18px; overflow: hidden;
  border: 3px solid #fff; padding: 0; cursor: pointer; scroll-snap-align: start; background: var(--tile);
  box-shadow: var(--shadow); transition: transform .3s var(--spring);
}
.mem:nth-child(odd) { transform: rotate(-2deg); } .mem:nth-child(even) { transform: rotate(2deg); }
.mem:hover { transform: rotate(0) scale(1.06); }
.mem img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.mem img.ok { opacity: 1; }
.mem-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 8px 7px; color: #fff; font-weight: 900; font-size: 13px; text-align: left;
  background: linear-gradient(transparent, rgb(0 0 0 / .6));
}

.year-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 4px; scrollbar-width: none; }
.year-chips::-webkit-scrollbar { display: none; }
.year-chips a {
  flex: none; padding: 5px 14px; border-radius: 999px; background: var(--surface); text-decoration: none; font-size: 14px; font-weight: 800;
  box-shadow: var(--shadow); transition: transform .25s var(--spring);
}
.year-chips a:nth-child(5n+1) { color: #d9480f; } .year-chips a:nth-child(5n+2) { color: #1971c2; } .year-chips a:nth-child(5n+3) { color: #2b8a3e; }
.year-chips a:nth-child(5n+4) { color: #862e9c; } .year-chips a:nth-child(5n+5) { color: #c2255c; }
.year-chips a:hover { transform: translateY(-2px) scale(1.06); }
@media (prefers-color-scheme: dark) {
  .year-chips a:nth-child(5n+1) { color: #ffa94d; } .year-chips a:nth-child(5n+2) { color: #74c0fc; } .year-chips a:nth-child(5n+3) { color: #8ce99a; }
  .year-chips a:nth-child(5n+4) { color: #e599f7; } .year-chips a:nth-child(5n+5) { color: #faa2c1; }
}

.year { content-visibility: auto; contain-intrinsic-size: auto 900px; }
.year > h2 { font-size: 28px; margin: 22px 0 14px; scroll-margin-top: 130px; display: flex; align-items: center; gap: 12px; }
.year > h2::after { content: ""; flex: 1; height: 3px; border-radius: 3px; background: repeating-linear-gradient(90deg, var(--line) 0 10px, transparent 10px 18px); }

/* ============ Thẻ sự kiện: ảnh polaroid dán băng dính ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 30px 22px; padding-top: 8px; }
@media (max-width: 520px) { .cards { grid-template-columns: 1fr 1fr; gap: 22px 12px; } }
.card {
  --rot: -1.2deg;
  position: relative; display: block; text-decoration: none; background: var(--paper); padding: 9px 9px 0; border-radius: 8px;
  box-shadow: var(--shadow); transform: rotate(var(--rot));
  transition: transform .35s var(--spring), box-shadow .3s;
  animation: card-in .55s var(--spring) backwards; animation-delay: calc(var(--i, 0) * 45ms);
}
.cards .card:nth-child(4n+2) { --rot: 1.4deg; } .cards .card:nth-child(4n+3) { --rot: -.4deg; } .cards .card:nth-child(4n) { --rot: .9deg; }
/* băng dính màu */
.card::before {
  content: ""; position: absolute; z-index: 2; top: -11px; left: 50%; width: 84px; height: 24px; translate: -50% 0; rotate: -3deg;
  background: color-mix(in srgb, var(--tape, var(--sun)) 70%, transparent); border-radius: 3px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .08);
  mask: linear-gradient(90deg, transparent 0 3px, #000 3px calc(100% - 3px), transparent calc(100% - 3px));
}
.cards .card:nth-child(5n+1) { --tape: var(--sun); } .cards .card:nth-child(5n+2) { --tape: var(--mint); }
.cards .card:nth-child(5n+3) { --tape: var(--pink); } .cards .card:nth-child(5n+4) { --tape: var(--sky); } .cards .card:nth-child(5n+5) { --tape: var(--grape); }
.cards .card:hover, .cards .card:focus-visible { transform: rotate(0) translateY(-6px) scale(1.03); box-shadow: var(--shadow-lg); }
.card:active { transform: scale(.97); transition-duration: .1s; }
.card .cover { position: relative; aspect-ratio: 1; background: var(--tile); overflow: hidden; border-radius: 4px; }
.card .count {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 9px; border-radius: 999px;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; font-weight: 800; backdrop-filter: blur(4px);
}
.card .body { padding: 10px 4px 13px; }
.card .title { font-weight: 900; font-size: 16.5px; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 13px; color: var(--muted); margin-top: 3px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .card { padding: 6px 6px 0; } .card .title { font-size: 14.5px; } .card::before { width: 60px; height: 18px; top: -8px; } }

/* ============ Lưới ảnh ============ */
.day { content-visibility: auto; contain-intrinsic-size: auto 500px; margin-bottom: 20px; }
.day > h3 { font-size: 15px; font-weight: 900; margin: 0 0 8px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--gap); }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); --gap: 3px; } main { padding-left: 8px; padding-right: 8px; } }
.tile { position: relative; aspect-ratio: 1; background: var(--tile); overflow: hidden; cursor: pointer; border: 0; padding: 0; display: block; width: 100%; border-radius: 10px; }
.tile img, .card .cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transform: scale(1.04); transition: opacity .4s var(--ease), transform .5s var(--ease);
}
.tile img.ok, .card .cover img.ok { opacity: 1; transform: none; }
.tile:hover img.ok { transform: scale(1.05); }
.tile .vbadge {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 7px 1px 5px; border-radius: 999px;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; gap: 3px;
}
.tile .check {
  position: absolute; top: 7px; left: 7px; width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid #fff; background: rgb(0 0 0 / .2); display: none; box-shadow: 0 1px 3px rgb(0 0 0 / .3);
}
.selecting .tile .check { display: block; }
.tile.sel .check { background: var(--accent); animation: bounce-once .35s var(--spring); }
.tile.sel .check::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 900; display: grid; place-items: center; height: 100%; }
.tile.sel img { transform: scale(.86); border-radius: 10px; }

/* ============ Đợt tải lên ============ */
.batches { display: grid; gap: 10px; }
.batch {
  display: flex; gap: 14px; align-items: center; padding: 10px; text-decoration: none; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .3s var(--spring);
  animation: rise .45s var(--ease) backwards;
}
.batch:hover { transform: translateX(4px); }
.batch .thumb { width: 66px; height: 66px; flex: none; border-radius: 14px; overflow: hidden; background: var(--tile); }
.batch .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.batch .title { font-weight: 900; overflow-wrap: anywhere; }
.batch .meta { font-size: 13px; color: var(--muted); font-weight: 600; }
.filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter button { border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 14px; cursor: pointer; font-size: 14px; font-weight: 800; transition: transform .25s var(--spring); }
.filter button:hover { transform: scale(1.05); }
.filter button.on { background: var(--accent-soft); border-color: var(--accent); }

/* ============ Bản đồ ============ */
.map-mode main { max-width: none; padding: 0; }
.map { height: calc(100dvh - var(--topbar-h, 64px)); width: 100%; background: var(--tile); }
@media (max-width: 760px) {
  .map { height: calc(100dvh - var(--topbar-h, 60px) - 74px - env(safe-area-inset-bottom)); }
}
.map-head {
  position: fixed; z-index: 15; left: 50%; translate: -50% 0; top: calc(var(--topbar-h, 64px) + 12px);
  padding: 8px 16px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; white-space: nowrap;
  animation: drop-in .6s var(--spring) .2s backwards;
}
.pin { position: relative; width: 64px; height: 64px; padding: 0; border: 0; background: none; cursor: pointer; animation: pin-pop .5s var(--spring) backwards; }
.pin:focus-visible { outline: none; }
.pin:focus-visible .pin-ring { outline: 3px solid var(--sky); outline-offset: 2px; }
.pin-ring {
  width: 58px; height: 58px; margin: 3px; border-radius: 50%; overflow: hidden; border: 3px solid #fff;
  box-shadow: 0 3px 10px rgb(0 0 0 / .35); transition: transform .3s var(--spring); background: var(--tile);
}
.pin-ring img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s; }
.pin-ring img.ok { opacity: 1; }
.pin:hover .pin-ring { transform: scale(1.15); }
.maplibregl-marker:hover { z-index: 2; }
.pin-count {
  position: absolute; top: -2px; right: -4px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font: 900 12px/20px var(--font); text-align: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .25);
}
.pin-count.video { background: var(--grape); }
.maplibregl-map { font-family: var(--font); }
.maplibregl-ctrl-group { border-radius: 14px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 40px !important; height: 40px !important; }
.map-home { font-size: 19px; display: grid; place-items: center; }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ============ Bảng trượt từ dưới lên ============ */
.panel-backdrop { position: fixed; inset: 0; z-index: 40; background: rgb(30 15 5 / .35); opacity: 0; transition: opacity .28s; }
.panel-backdrop.open { opacity: 1; }
.panel {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 78dvh; overflow: auto;
  background: var(--bg); border-radius: 28px 28px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / .25);
  padding: 8px 14px max(16px, env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .38s var(--spring);
  max-width: 1100px; margin: 0 auto;
}
.panel.open { transform: none; }
.panel-grip { width: 44px; height: 5px; border-radius: 5px; background: var(--line); margin: 4px auto 6px; }
.panel-head { display: flex; align-items: center; gap: 8px; position: sticky; top: -8px; background: var(--bg); padding: 4px 0 8px; z-index: 1; }
.panel-head h2 { flex: 1; margin: 0; font-size: 18px; }

/* ============ Thanh chọn ============ */
.selbar {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); translate: -50% 0;
  z-index: 30; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; border-radius: 999px;
  background: var(--surface); box-shadow: 0 10px 34px rgb(0 0 0 / .2); max-width: calc(100vw - 16px);
  animation: drop-up .4s var(--spring) backwards;
}
@media (max-width: 760px) {
  .selbar { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
}
.selbar span { font-weight: 900; white-space: nowrap; }
.selbar-actions { display: flex; gap: 6px; }

/* ============ Hộp thoại ============ */
dialog.sheet {
  width: min(500px, calc(100vw - 24px)); border: 0; border-radius: 28px;
  background: var(--surface); color: var(--text); padding: 24px; box-shadow: 0 24px 70px rgb(0 0 0 / .3);
}
dialog.sheet[open] { animation: pop-in .4s var(--spring) backwards; }
dialog::backdrop { background: rgb(30 15 5 / .45); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 4px; font-size: 23px; }
dialog p { margin: 0 0 14px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
.bar { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 999px; transition: width .4s var(--ease);
  background: linear-gradient(90deg, var(--accent), var(--sun), var(--mint), var(--sky), var(--grape));
  background-size: 300% 100%; animation: rainbow 4s linear infinite;
}
.usage .bar-fill { animation: none; background: linear-gradient(90deg, var(--mint), var(--sky)); }
.up-progress p { margin: 10px 0 0; font-size: 14px; font-weight: 700; }
.up-progress p.small { font-size: 13px; margin-top: 2px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-errors { margin: 8px 0 0; padding-left: 18px; max-height: 120px; overflow: auto; font-size: 13px; color: var(--danger); }

/* ============ Trình xem ảnh ============ */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; animation: lb-in .28s var(--ease); }
.lb-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.lb-stage > * { grid-area: 1 / 1; max-width: 100vw; max-height: 100vh; max-height: 100dvh; }
#lb-low { position: relative; z-index: 0; width: 100vw; height: 100vh; height: 100dvh; object-fit: contain; filter: blur(8px); }
#lb-img { position: relative; z-index: 1; width: auto; height: auto; object-fit: contain; opacity: 0; transition: opacity .25s ease, transform .25s var(--ease); }
#lb-img.ok { opacity: 1; }
#lb-video { position: relative; z-index: 2; width: 100vw; height: 100vh; height: 100dvh; background: transparent; touch-action: auto; }
.lb-btn {
  position: relative; z-index: 3; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: rgb(0 0 0 / .45); color: #fff; border: 0; cursor: pointer; font-size: 20px; text-decoration: none;
  backdrop-filter: blur(6px); transition: transform .25s var(--spring), background .2s, opacity .2s;
}
.lb-btn:hover { background: rgb(255 255 255 / .2); transform: scale(1.1); }
.lb-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; }
.lb-prev, .lb-next { position: absolute; top: 50%; translate: 0 -50%; font-size: 30px; line-height: 1; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
@media (hover: none) { .lb-prev, .lb-next { display: none; } }
.lb-bar {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; gap: 12px;
  padding: 44px 16px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgb(0 0 0 / .7));
  pointer-events: none; transition: opacity .25s;
}
.lb-bar > * { pointer-events: auto; }
.lightbox.is-video .lb-bar { bottom: 64px; background: none; }
.lb-info { flex: 1; font-size: 14px; line-height: 1.45; min-width: 0; text-shadow: 0 1px 3px rgb(0 0 0 / .7); font-weight: 600; }
.lb-info b { font-size: 16px; font-weight: 900; }
.lb-info .src { opacity: .75; font-size: 12px; }
.lb-actions { display: flex; gap: 8px; }
.lightbox.chrome-off .lb-bar, .lightbox.chrome-off .lb-btn { opacity: 0; pointer-events: none; }

/* ============ Khác ============ */
.drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: color-mix(in srgb, var(--sky) 22%, transparent); backdrop-filter: blur(4px);
  font-size: 22px; font-weight: 900; pointer-events: none;
}
.drop-overlay > div { background: var(--surface); padding: 26px 34px; border-radius: 28px; border: 3px dashed var(--sky); animation: float 2s ease-in-out infinite; }
.toast {
  position: fixed; left: 50%; translate: -50% 0; bottom: 90px; z-index: 70;
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 800;
  box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); text-align: center; animation: drop-up .35s var(--spring);
}
.confetti { position: fixed; inset: auto 0 0 0; height: 0; z-index: 80; pointer-events: none; }
.confetti span { position: absolute; bottom: 0; border-radius: 2px; }
.loader { display: flex; justify-content: center; gap: 10px; padding: 80px 0; }
.loader span { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); animation: dot 1s var(--ease) infinite; }
.loader span:nth-child(2) { background: var(--sun); animation-delay: .15s; }
.loader span:nth-child(3) { background: var(--sky); animation-delay: .3s; }

/* ============ Chuyển trang mượt ============ */
::view-transition-old(root) { animation: vt-out .18s ease-in both; }
::view-transition-new(root) { animation: vt-in .32s var(--ease) both; }
::view-transition-group(topbar) { animation: none; }

/* ============ Hoạt ảnh ============ */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92) translateY(10px); } }
@keyframes card-in { from { opacity: 0; transform: translateY(26px) rotate(calc(var(--rot) * 4)) scale(.9); } }
@keyframes pin-pop { from { opacity: 0; transform: scale(.3) translateY(10px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-16px); } }
@keyframes drop-up { from { opacity: 0; transform: translateY(16px); } }
@keyframes lb-in { from { opacity: 0; } }
@keyframes vt-out { to { opacity: 0; transform: scale(.985); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes wave { 15% { transform: rotate(16deg); } 30% { transform: rotate(-8deg); } 45% { transform: rotate(14deg); } 60% { transform: rotate(-4deg); } 75%, 100% { transform: none; } }
@keyframes wiggle { 0%, 80%, 100% { transform: none; } 85% { transform: rotate(-8deg); } 90% { transform: rotate(8deg); } 95% { transform: rotate(-4deg); } }
@keyframes bounce-once { 40% { transform: scale(1.3); } }
@keyframes twinkle { 50% { transform: scale(1.25) rotate(15deg); opacity: .7; } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes dot { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }
@keyframes rainbow { to { background-position: 300% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card, .cards .card { transform: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}

/* ============ Menu tài khoản ============ */
.menu-backdrop { position: fixed; inset: 0; z-index: 44; background: rgb(30 15 5 / .18); opacity: 0; transition: opacity .25s; }
.menu-backdrop.open { opacity: 1; }
.menu {
  position: fixed; z-index: 45; top: calc(var(--topbar-h, 64px) + 8px); right: 12px; width: 340px;
  max-height: calc(100dvh - var(--topbar-h, 64px) - 24px); overflow: auto;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 14px; outline: none;
  transform-origin: top right; opacity: 0; transform: scale(.9) translateY(-8px); transition: opacity .2s, transform .3s var(--spring);
}
.menu.open { opacity: 1; transform: none; }
.menu-grip { display: none; }
.menu-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; }
.mh-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.mh-text b { font-size: 18px; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--sky); font-weight: 800; font-size: 13.5px; cursor: pointer; }
.menu-stats { background: var(--surface-2); border-radius: 18px; padding: 12px 14px; display: grid; gap: 7px; }
.ms-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.ms-nums > div { background: var(--surface); border-radius: 14px; padding: 8px 12px; display: flex; align-items: baseline; gap: 6px; }
.ms-nums b { font-size: 20px; font-weight: 900; }
.ms-nums span { color: var(--muted); font-weight: 700; font-size: 13px; }
.ms-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.ms-row span:last-child { color: var(--muted); text-align: right; }
.bar.small-bar { height: 8px; }
.bar.small-bar .bar-fill { animation: none; background: linear-gradient(90deg, var(--mint), var(--sky)); }
.menu-list { display: grid; gap: 2px; margin-top: 10px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; border: 0; background: none; width: 100%;
  text-decoration: none; font-weight: 800; font-size: 15px; cursor: pointer; text-align: left; transition: background .2s, transform .2s var(--spring);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item:active { transform: scale(.98); }
.menu-item.danger { color: var(--danger); }
.mi-ic { font-size: 20px; width: 26px; text-align: center; }
.mi-label { flex: 1; }
.mi-badge { background: var(--accent); color: #fff; font-size: 12px; font-weight: 900; padding: 1px 8px; border-radius: 999px; }
.mi-val { color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.mi-val.warn { color: var(--accent); }
.menu-page { animation: page-in .28s var(--spring); display: grid; gap: 10px; }
.st-head { display: flex; align-items: center; gap: 6px; }
.st-head h3 { margin: 0; font-size: 18px; font-weight: 900; }
.st-back { font-size: 24px; line-height: 1; padding: 4px 12px; }
.st-card { background: var(--surface-2); border-radius: 18px; padding: 12px 14px; display: grid; gap: 8px; }
.st-big { display: flex; align-items: baseline; gap: 8px; }
.st-big b { font-size: 30px; font-weight: 900; }
.st-big b.warn { color: var(--accent); }
.st-big span { color: var(--muted); font-weight: 700; }
.st-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.st-row span { color: var(--muted); font-weight: 700; }
.st-row b { font-weight: 800; white-space: nowrap; }
.bar.small-bar.warn .bar-fill { background: linear-gradient(90deg, var(--sun), var(--accent)); }
@keyframes page-in { from { opacity: 0; transform: translateX(24px); } }
.mi-go { color: var(--muted); font-size: 20px; font-weight: 700; }
.batch .batch-text { flex: 1; min-width: 0; }
@media (max-width: 760px) {
  .menu {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 86dvh; border-radius: 28px 28px 0 0;
    padding: 6px 16px max(18px, env(safe-area-inset-bottom)); transform: translateY(100%); opacity: 1;
    transition: transform .38s var(--spring);
  }
  .menu.open { transform: none; }
  .menu-backdrop { background: rgb(30 15 5 / .4); }
  .menu-grip { display: block; width: 44px; height: 5px; border-radius: 5px; background: var(--line); margin: 6px auto 10px; }
  .menu-item { padding: 14px 12px; font-size: 16px; }
}

/* ============ Hộp tải lên ============ */
.up-sheet { width: min(620px, calc(100vw - 24px)); }
.up-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.up-head h2 { flex: 1; margin: 0; }
.dropzone {
  border: 3px dashed color-mix(in srgb, var(--sky) 55%, var(--line)); border-radius: 22px; padding: 26px 16px; text-align: center;
  background: color-mix(in srgb, var(--sky) 6%, var(--surface)); transition: background .2s;
}
.dropzone:hover { background: color-mix(in srgb, var(--sky) 12%, var(--surface)); }
.dz-art { font-size: 48px; line-height: 1; display: inline-block; animation: float 3s ease-in-out infinite; }
.dz-big { font-weight: 900; font-size: 17px; margin: 10px 0 0; }
.dz-small { margin: 2px 0 10px; }
.dz-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
@media (pointer: coarse) { [data-pick=dir], .dz-big, .dz-small { display: none; } .dz-btns { margin-top: 12px; } }
.up-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; max-height: 40vh; overflow: auto; padding: 2px; margin-bottom: 10px; }
.pv { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; animation: pop-in .35s var(--spring) backwards; }
.pv .pv-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pv-ic { font-size: 26px; opacity: .7; }
.pv.more { font-weight: 900; color: var(--muted); font-size: 18px; }
.pv-x {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; font-weight: 900; display: grid; place-items: center;
}
.pv[data-state] .pv-x { display: none; }
.pv-state { position: absolute; inset: 0; display: none; place-items: center; font-size: 26px; font-weight: 900; color: #fff; }
.pv[data-state] .pv-state { display: grid; }
.pv[data-state=busy] .pv-state { background: rgb(0 0 0 / .35); }
.pv[data-state=busy] .pv-state::after { content: ""; width: 24px; height: 24px; border-radius: 50%; border: 3px solid #fff; border-top-color: transparent; animation: spin .8s linear infinite; }
.pv[data-state=done] .pv-state { background: color-mix(in srgb, var(--mint) 55%, transparent); }
.pv[data-state=done] .pv-state::after { content: "✓"; animation: bounce-once .4s var(--spring); }
.pv[data-state=dup] .pv-state { background: rgb(0 0 0 / .35); }
.pv[data-state=dup] .pv-state::after { content: "="; }
.pv[data-state=fail] .pv-state { background: color-mix(in srgb, var(--danger) 60%, transparent); }
.pv[data-state=fail] .pv-state::after { content: "!"; }
@media (max-width: 760px) {
  dialog.up-sheet {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 28px 28px 0 0; max-height: 92dvh;
    padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  }
  dialog.up-sheet[open] { animation: sheet-up .4s var(--spring) backwards; }
  .up-preview { grid-template-columns: repeat(4, 1fr); max-height: 34vh; }
  .up-sheet .dialog-actions .btn { flex: 1; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Thanh nhỏ khi đang tải lên (thu nhỏ) */
.up-pill {
  position: fixed; z-index: 35; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-weight: 800; font-size: 14px; animation: drop-up .4s var(--spring) backwards;
}
.up-pill-ring {
  --pct: 0%; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: radial-gradient(closest-side, var(--surface) 68%, transparent 70%), conic-gradient(var(--accent) var(--pct), var(--line) 0);
}
@media (max-width: 760px) { .up-pill { left: 50%; right: auto; translate: -50% 0; bottom: calc(88px + env(safe-area-inset-bottom)); } }
