/* Mặt sau — giao diện "sổ dán sticker": nền sữa, khối pastel viền ca cao, bóng lệch như sticker dán lên sổ. */

@font-face { font-family: 'Baloo 2'; font-weight: 400 800; font-display: swap; src: url(fonts/baloo-2-vietnamese-wght-normal.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: 'Baloo 2'; font-weight: 400 800; font-display: swap; src: url(fonts/baloo-2-latin-ext-wght-normal.woff2) format('woff2'); 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: 'Baloo 2'; font-weight: 400 800; font-display: swap; src: url(fonts/baloo-2-latin-wght-normal.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; }
@font-face { font-family: 'Mali'; font-weight: 400; font-display: swap; src: url(fonts/mali-vietnamese-400-normal.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: 'Mali'; font-weight: 400; font-display: swap; src: url(fonts/mali-latin-ext-400-normal.woff2) format('woff2'); 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: 'Mali'; font-weight: 400; font-display: swap; src: url(fonts/mali-latin-400-normal.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; }
@font-face { font-family: 'Mali'; font-weight: 600; font-display: swap; src: url(fonts/mali-vietnamese-600-normal.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: 'Mali'; font-weight: 600; font-display: swap; src: url(fonts/mali-latin-600-normal.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; }

/* ---------- Màu và kích thước ---------- */
:root {
  --bg: #FFF9EE;
  --surface: #FFFFFF;
  --paper: #FFFDF7;
  --ink: #4A3B2C;
  --muted: #76624F;
  --outline: #4A3B2C;
  --shadow: #4A3B2C;
  --line: #EFE3CF;
  --dash: #E8D7BD;
  --margin-line: #F4B7C6;
  --pink: #FFD3DD;
  --pink-strong: #FFB4C8;
  --mint: #D4F0DF;
  --butter: #FFE7A6;
  --sky: #D6ECFF;
  --lavender: #E6DEFF;
  --danger: #B3261E;
  --link: #A63D5E;
  --scrim: rgba(74, 59, 44, 0.45);
  --ui: 'Baloo 2', ui-rounded, system-ui, sans-serif;
  --hand: 'Mali', 'Baloo 2', cursive;
  --row: 34px;
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #231B17; --surface: #2F2520; --paper: #2A211C; --ink: #FBEFE3; --muted: #D2BEAB;
    --outline: #E9D6C3; --shadow: #0E0A08; --line: #3D3129; --dash: #4D3F35; --margin-line: #7A4655;
    --pink: #6E3B4C; --pink-strong: #8F4762; --mint: #2E5A45; --butter: #6A5420; --sky: #2D4A66; --lavender: #463B6E;
    --danger: #FFB4AB; --link: #FFB0C8; --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #231B17; --surface: #2F2520; --paper: #2A211C; --ink: #FBEFE3; --muted: #D2BEAB;
  --outline: #E9D6C3; --shadow: #0E0A08; --line: #3D3129; --dash: #4D3F35; --margin-line: #7A4655;
  --pink: #6E3B4C; --pink-strong: #8F4762; --mint: #2E5A45; --butter: #6A5420; --sky: #2D4A66; --lavender: #463B6E;
  --danger: #FFB4AB; --link: #FFB0C8; --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Nền tảng ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 500 16px/1.5 var(--ui);
}
a { color: var(--link); }
button, input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 20px; line-height: 1.25; font-weight: 800; }
.lede { margin: 4px 0 0; color: var(--muted); font-weight: 600; max-width: 60ch; }
.msg { margin: 12px 0; font-size: 15px; font-weight: 600; }
.msg.error { color: var(--danger); }
.msg.loading { color: var(--muted); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border: 2px solid var(--outline); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: 700 15px/1 var(--ui); text-decoration: none; cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shadow); }
.btn.primary { background: var(--pink-strong); font-weight: 800; }
.btn.quiet { border-color: transparent; background: transparent; box-shadow: none; padding: 0 12px; }
.btn.quiet:hover { background: var(--line); transform: none; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.big { min-height: 52px; font-size: 17px; width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; box-shadow: 2px 2px 0 var(--shadow); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Thanh trên cùng ---------- */
.m3-top-app-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1120px; margin: 0 auto; padding: 12px 16px;
  background: var(--bg);
}
.top-bar-start, .top-bar-end { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-link { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand-mascot { width: 48px; height: 48px; margin: -4px 0; }
.brand-title { font-weight: 800; font-size: 26px; letter-spacing: -0.01em; white-space: nowrap; }
.top-links { display: flex; gap: 6px; margin-right: 4px; }
.m3-header-action-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px;
  border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 15px;
}
.m3-header-action-btn:hover { background: var(--line); }
.m3-header-action-btn svg { width: 20px; height: 20px; }
.m3-icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 2px solid var(--outline); border-radius: 50%; background: var(--surface); color: var(--ink);
  box-shadow: 2px 2px 0 var(--shadow); cursor: pointer;
}
.m3-icon-btn svg { width: 20px; height: 20px; }
.moon-icon, .sound-off-icon { display: none; }
:root[data-theme="dark"] .sun-icon { display: none; }
:root[data-theme="dark"] .moon-icon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun-icon { display: none; }
  :root:not([data-theme="light"]) .moon-icon { display: block; }
}
.sound-btn.is-muted .sound-on-icon { display: none; }
.sound-btn.is-muted .sound-off-icon { display: block; }
.user-chip {
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 6px;
  border: 2px solid var(--outline); border-radius: 999px; background: var(--mint);
  box-shadow: 2px 2px 0 var(--shadow); font-size: 15px; white-space: nowrap;
}
.user-chip b { font-weight: 800; }
.user-dot {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--outline); background: var(--surface); font-weight: 800; font-size: 14px;
}
@media (max-width: 820px) {
  .top-links { display: none; }
  .brand-title { font-size: 24px; }
}
@media (max-width: 380px) {
  .theme-btn { display: none; }
  .user-chip { padding-right: 6px; }
  .user-chip b { display: none; }
}

/* ---------- Khung trang ---------- */
.m3-main-container { max-width: 1120px; margin: 0 auto; padding: 8px 16px 48px; }
@media (max-width: 820px) { .m3-main-container { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); } }
.m3-loading-state { display: grid; place-items: center; gap: 8px; padding: 18vh 0; color: var(--muted); font-weight: 700; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 18px; }
.nav-back-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.nav-back-row .btn.quiet { padding-left: 6px; }
.photo-date-badge { font-size: 14px; font-weight: 700; color: var(--muted); }

/* ---------- Thông báo ---------- */
.m3-notify-banner { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.m3-notify-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px;
  margin: 4px 0 6px; padding: 12px 14px 12px 16px;
  border: 2px solid var(--outline); border-radius: var(--r-md); background: var(--surface);
}
.m3-notify-inner p { margin: 0; flex: 1 1 240px; font-weight: 600; font-size: 15px; line-height: 1.4; }
.m3-notify-banner[data-state="off"] .m3-notify-inner { background: var(--butter); box-shadow: 3px 3px 0 var(--shadow); }
.m3-notify-banner[data-state="on"] .m3-notify-inner { border-style: dashed; border-color: var(--dash); padding-block: 6px; }
.m3-notify-banner[data-state="on"] .m3-notify-inner p { color: var(--muted); }
.m3-notify-inner .msg { flex-basis: 100%; margin: 0; }

/* ---------- Danh sách ảnh ---------- */
.feed {
  list-style: none; margin: 0; padding: 12px 0 0;
  display: grid; gap: 28px 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
}
@media (max-width: 520px) { .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; } }
.feed > li > a { display: block; color: inherit; text-decoration: none; }
.print {
  position: relative; padding: 8px 8px 10px;
  background: var(--surface); border: 2px solid var(--outline); border-radius: var(--r-md);
  box-shadow: 3px 3px 0 var(--shadow); transform: rotate(-1.2deg);
  transition: transform .15s ease;
}
.feed > li:nth-child(even) .print { transform: rotate(1.2deg); }
.print::before {
  content: ''; position: absolute; top: -10px; left: 50%; width: 56px; height: 18px; margin-left: -28px;
  background: var(--pink); border: 2px dashed var(--pink-strong); border-radius: 4px; transform: rotate(-4deg);
}
.feed > li:nth-child(3n+2) .print::before { background: var(--mint); border-color: #8FCFAE; transform: rotate(5deg); }
.feed > li:nth-child(3n) .print::before { background: var(--butter); border-color: #E7C766; transform: rotate(-2deg); }
.feed a:hover .print, .feed a:focus-visible .print { transform: rotate(0) translateY(-3px); }
/* Lọc theo nguồn ảnh */
.feed-filter { display: flex; gap: 8px; margin: -6px 0 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; }
.feed-filter::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; height: 38px; padding: 0 14px; border: 2px solid var(--outline); border-radius: 999px;
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer;
}
.filter-chip span { margin-left: 2px; padding: 0 7px; border-radius: 999px; background: var(--line); font-size: 12px; font-weight: 800; }
.filter-chip.is-active { background: var(--pink); font-weight: 800; box-shadow: 2px 2px 0 var(--shadow); }
.filter-chip.is-active span { background: var(--surface); }
.filter-chip[disabled] { opacity: .45; cursor: default; }

/* Nhãn nguồn ảnh */
.photo-wrap { position: relative; }
.src-badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px;
  border: 1.5px solid var(--outline); font-size: 12px; font-weight: 800; white-space: nowrap;
}
.src-badge.is-gphotos { background: var(--sky); }
.src-badge.is-upload { background: var(--butter); }
.photo-wrap .src-badge { position: absolute; left: 6px; bottom: 6px; }
@media (max-width: 520px) { .photo-wrap .src-badge { font-size: 11px; height: 22px; padding: 0 7px; } }
.source-note {
  margin: 10px 2px 0; padding: 10px 12px; border: 2px dashed var(--dash); border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--muted);
}

.photo-wrap img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-sm); background: var(--line); }
.print .note {
  margin: 8px 2px 0; min-height: 2.6em; font: 400 17px/1.3 var(--hand); color: var(--pen-of, var(--ink));
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.print .note .sticker-img { width: 40px; height: 40px; vertical-align: middle; }
.print .note .comment-sticker-wrap { margin: 0; }
.feed-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; font-weight: 600; }
.feed-meta b { font-weight: 800; }
.fresh-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; flex: none;
  border: 1.5px solid var(--outline); border-radius: 999px; background: var(--pink); font-weight: 800;
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--link); }
.empty-card {
  display: grid; justify-items: center; gap: 10px; text-align: center; max-width: 520px; margin: 24px auto;
  padding: 28px 22px; border: 2px dashed var(--outline); border-radius: var(--r-lg); background: var(--surface);
}
.empty-card p { margin: 0; color: var(--muted); font-weight: 600; }

/* Cún Mốc và Vịt Bông đi dạo quanh giao diện */
.title-doodle { width: 52px; height: 52px; vertical-align: -14px; margin-left: 2px; }
.notify-doodle { width: 56px; height: 56px; flex: none; margin: -6px 0; }
.login-doodles { display: flex; justify-content: center; margin: -64px 0 0; }
.login-doodles img { width: 104px; height: 104px; }
.login-doodles img + img { margin-left: -18px; transform: scaleX(-1); }
.m3-login-card { margin-top: 14vh; }

/* ---------- Một tấm ảnh ---------- */
.m3-segmented-control { display: none; }
.photo-page-grid { display: grid; gap: 28px; align-items: start; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.photo-sticky-wrap { position: sticky; top: 84px; }
.photo-card-polaroid {
  padding: 10px; background: var(--surface); border: 2px solid var(--outline); border-radius: var(--r-lg);
  box-shadow: 4px 4px 0 var(--shadow);
}
.photo-frame { position: relative; cursor: zoom-in; border-radius: var(--r-md); overflow: hidden; background: var(--line); }
.photo-frame img { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.photo-zoom-hint {
  position: absolute; right: 10px; bottom: 10px; padding: 2px 10px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--outline); font-size: 13px; font-weight: 700; opacity: 0;
  transition: opacity .15s ease;
}
.photo-frame:hover .photo-zoom-hint { opacity: 1; }
.photo-actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-actions-row:empty { display: none; }
.m3-mobile-flip-btn { display: none; }
.mobile-photo-context-bar { display: none; }

@media (max-width: 820px) {
  .m3-segmented-control {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; margin-bottom: 14px;
    border: 2px solid var(--outline); border-radius: 999px; background: var(--surface);
  }
  .m3-segment-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px;
    border: 2px solid transparent; border-radius: 999px; background: transparent; font-weight: 700; cursor: pointer;
  }
  .m3-segment-btn svg { width: 18px; height: 18px; }
  .m3-segment-btn.is-active { background: var(--pink); border-color: var(--outline); font-weight: 800; }
  .photo-page-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .photo-page-grid[data-mobile-tab="photo"] .back-section { display: none; }
  .photo-page-grid[data-mobile-tab="comments"] .photo-col { display: none; }
  .photo-sticky-wrap { position: static; }
  .m3-mobile-flip-btn { display: inline-flex; flex: 1 1 auto; }
  .mobile-photo-context-bar {
    display: flex; align-items: center; gap: 10px; margin: -4px 0 8px; padding: 8px 10px;
    border: 2px solid var(--outline); border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
  }
  .context-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 2px solid var(--outline); }
  .context-info { display: flex; flex-direction: column; line-height: 1.2; }
  .context-title { font-weight: 800; }
  .context-sub { font-size: 13px; color: var(--muted); font-weight: 600; }
  .back-section .back-header { display: none; }
}

/* Mặt sau: giấy kẻ dòng có lề hồng */
.back-section {
  position: relative; padding: 14px 16px 16px 60px;
  border: 2px solid var(--outline); border-radius: var(--r-lg); box-shadow: 4px 4px 0 var(--shadow);
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, transparent 46px, var(--margin-line) 46px, var(--margin-line) 48px, transparent 48px),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--row) - 1px), var(--line) calc(var(--row) - 1px), var(--line) var(--row));
  background-position: 0 0, 0 12px;
}
.back-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--row); margin-bottom: 4px; }
.back-header h2 { font-size: 18px; }
.comment-count-chip { padding: 0 10px; border-radius: 999px; background: var(--butter); border: 1.5px solid var(--outline); font-size: 13px; font-weight: 800; }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.who-line { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); line-height: 24px; }
.who-line b { font-size: 14px; font-weight: 800; color: var(--pen-of, var(--ink)); }
.thread .text {
  margin: 0; font: 400 20px/var(--row) var(--hand); color: var(--pen-of, var(--ink));
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.thread li, .print .note, .inbox-line { --pen-of: var(--pen, var(--ink)); }
:root[data-theme="dark"] .thread li, :root[data-theme="dark"] .print .note, :root[data-theme="dark"] .inbox-line { --pen-of: color-mix(in oklab, var(--pen) 45%, white); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .thread li, :root:not([data-theme="light"]) .print .note, :root:not([data-theme="light"]) .inbox-line { --pen-of: color-mix(in oklab, var(--pen) 45%, white); }
}
.blank-back { margin: 0; font: 400 19px/var(--row) var(--hand); color: var(--muted); }

/* Nhãn dán trong lời bình */
.sticker-img { display: inline-block; width: 76px; height: 76px; object-fit: contain; vertical-align: bottom; margin: 2px 2px 0; }
.text.only-stickers .sticker-img { width: 120px; height: 120px; margin-top: 4px; }
.sticker-missing { font: 600 14px var(--ui); color: var(--muted); }
.comment-sticker-wrap { display: inline-block; margin: 2px 0; transform: rotate(var(--rot, -1.5deg)); }
.sticker-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 12px 2px 6px; border-radius: 999px;
  background: var(--st-bg); color: var(--st-color); border: 2px solid var(--outline);
  font: 800 13px/1.6 var(--ui); white-space: nowrap;
}
.sticker-badge svg { width: 22px; height: 22px; flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .thread li.new { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
  @keyframes pop { from { opacity: 0; transform: scale(.9) translateY(6px); } }
}

/* ---------- Khung viết lời bình ---------- */
.composer { position: relative; margin-top: 14px; padding-top: 10px; border-top: 2px dashed var(--dash); }
.composer-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-width: 0; }
.toggle-drawer-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; flex: none;
  border: 2px solid var(--outline); border-radius: 999px; background: var(--butter);
  font-weight: 800; font-size: 14px; box-shadow: 2px 2px 0 var(--shadow); cursor: pointer;
}
.toggle-drawer-btn svg { width: 18px; height: 18px; }
.toggle-drawer-btn[aria-expanded="true"] { background: var(--pink); }
.quick-emojis { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.quick-emojis::-webkit-scrollbar { display: none; }
.quick-emoji-btn {
  flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.quick-emoji-btn:hover { background: var(--line); }
.composer textarea {
  display: block; width: 100%; min-height: calc(var(--row) * 2); resize: vertical; margin: 0; padding: 0;
  border: 0; background: transparent; font: 400 20px/var(--row) var(--hand); color: var(--link);
}
.composer textarea:focus { outline: none; }
.composer textarea:focus-visible { box-shadow: 0 2px 0 var(--link); }
.composer textarea::placeholder { color: var(--muted); opacity: .9; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.composer-hint { font-size: 13px; font-weight: 600; color: var(--muted); }
@media (max-width: 520px) { .composer-hint { display: none; } .composer-bottom { justify-content: flex-end; } }

/* Ngăn nhãn dán */
.drawer-popover {
  position: absolute; left: -44px; right: 0; bottom: calc(100% + 8px); z-index: 30;
  display: flex; flex-direction: column; max-height: min(460px, 62vh);
  background: var(--surface); border: 2px solid var(--outline); border-radius: var(--r-lg);
  box-shadow: 4px 4px 0 var(--shadow);
}
.drawer-popover[hidden] { display: none; }
@media (max-width: 820px) {
  .drawer-popover {
    position: fixed; left: 0; right: 0; bottom: 0; max-height: 72vh;
    border-radius: 28px 28px 0 0; border-bottom: 0; box-shadow: 0 -4px 0 var(--shadow);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 6px 16px; }
.drawer-title { font-size: 20px; font-weight: 800; }
.drawer-head .btn { background: var(--mint); }
.drawer-tabs { display: flex; gap: 6px; padding: 2px 14px 10px; overflow-x: auto; scrollbar-width: none; flex: none; }
.drawer-tabs::-webkit-scrollbar { display: none; }
.drawer-tab {
  flex: none; height: 38px; padding: 0 14px; border: 2px solid var(--outline); border-radius: 999px;
  background: var(--surface); font-weight: 700; font-size: 14px; cursor: pointer;
}
.drawer-tab.is-active { background: var(--pink); font-weight: 800; box-shadow: 2px 2px 0 var(--shadow); }
.drawer-content { overflow-y: auto; padding: 2px 14px 14px; }
.stickers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; }
.sticker-item-btn {
  position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; padding: 6px;
  border: 2px solid var(--line); border-radius: var(--r-md); background: var(--bg); cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.sticker-item-btn:hover { border-color: var(--outline); transform: translateY(-2px); }
.sticker-item-btn img, .sticker-item-btn svg { width: 100%; height: 100%; object-fit: contain; }
.sticker-anim-tag {
  position: absolute; top: 3px; right: 3px; padding: 0 6px; border-radius: 999px;
  background: var(--butter); border: 1.5px solid var(--outline); font-size: 11px; font-weight: 800; line-height: 18px;
}
.emoji-category-title { margin: 8px 0 4px; font-size: 14px; font-weight: 800; color: var(--muted); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px; }
.emoji-btn { height: 42px; border: 0; border-radius: 12px; background: transparent; font-size: 24px; cursor: pointer; }
.emoji-btn:hover { background: var(--line); }

/* ---------- Bộ nhãn dán ---------- */
.pack-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.pack-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; align-items: center; padding: 12px;
  background: var(--surface); border: 2px solid var(--outline); border-radius: var(--r-lg); box-shadow: 3px 3px 0 var(--shadow);
}
.pack-card.is-hidden { opacity: .65; box-shadow: none; border-style: dashed; }
.pack-preview {
  display: grid; grid-template-columns: repeat(2, 40px); gap: 4px; padding: 6px;
  border-radius: var(--r-sm); background: var(--bg);
}
.pack-preview img { width: 40px; height: 40px; object-fit: contain; }
.pack-empty { grid-column: span 2; width: 84px; font-size: 12px; text-align: center; color: var(--muted); }
.pack-info h2 { font-size: 19px; }
.pack-info p { margin: 2px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.pack-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }

.import-form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin-top: 16px; }
.field-label { font-weight: 800; margin-bottom: -8px; }
.field {
  height: 50px; padding: 0 16px; border: 2px solid var(--outline); border-radius: var(--r-md);
  background: var(--surface); font-size: 16px; font-weight: 600;
}
.drop-help { font-size: 14px; color: var(--muted); font-weight: 600; line-height: 1.4; }
.import-count { font-size: 18px; margin-bottom: 8px; }
.import-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.import-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 2px solid var(--outline); border-radius: var(--r-md); background: var(--surface);
}
.import-row img, .import-thumb { width: 48px; height: 48px; flex: none; object-fit: contain; border-radius: 10px; background: var(--bg); }
.import-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.import-text b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-text span { font-size: 13px; font-weight: 600; color: var(--muted); }
.import-tag { flex: none; padding: 0 8px; border: 1.5px solid var(--outline); border-radius: 999px; font-size: 12px; font-weight: 800; line-height: 20px; background: var(--surface); }
.import-row.is-done .import-text span { color: #2C7A4E; }
.import-row.is-skip, .import-row.is-fail { border-style: dashed; }
.import-row.is-skip .import-text span, .import-row.is-fail .import-text span { color: var(--danger); }
.import-row.is-skip .import-tag, .import-row.is-fail .import-tag { background: var(--pink); }
:root[data-theme="dark"] .import-row.is-done .import-text span { color: #9BE0B8; }

/* ---------- Tìm theo ảnh, đăng nhập ---------- */
.m3-dropzone {
  position: relative; display: grid; justify-items: center; gap: 10px; text-align: center;
  padding: 26px 18px; border: 2.5px dashed var(--outline); border-radius: var(--r-lg); background: var(--surface); cursor: pointer;
}
.m3-dropzone.over, .m3-dropzone:hover { background: var(--pink); }
.m3-dropzone p { margin: 0; color: var(--muted); font-weight: 600; }
.m3-dropzone-icon { width: 96px; height: 96px; }
.album-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; }
.album-picks p { flex: 1 1 260px; margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
/* Điện thoại không chọn được thư mục hay .zip dễ dàng: dùng "Chọn ảnh" hoặc chia sẻ từ Google Photos */
@media (hover: none) and (pointer: coarse) { .album-picks { display: none; } }

/* ---------- Viết chung cho nhiều ảnh ---------- */
.batch-layout { display: grid; gap: 28px; align-items: start; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.batch-back { position: sticky; top: 84px; }
.batch-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.batch-count { font-size: 18px; }
.batch-tools { display: flex; flex-wrap: wrap; gap: 6px; }
#batch-progress:empty { display: none; }
.batch-grid {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: grid; gap: 14px 12px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
}
.batch-grid > li { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.batch-check {
  position: relative; display: block; width: 100%; padding: 5px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--outline); border-radius: var(--r-sm);
  box-shadow: 2px 2px 0 var(--shadow); transition: transform .12s ease, opacity .12s ease;
}
.batch-check img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--line); }
.batch-check img:not([src]) { visibility: hidden; }
.batch-check:hover:not([disabled]) { transform: translateY(-2px); }
.batch-check[disabled] { cursor: default; }
.batch-tile:not(.is-selected) .batch-check { opacity: .55; box-shadow: none; border-style: dashed; }
.batch-tile.is-reading .batch-check, .batch-tile.is-checking .batch-check { opacity: 1; border-style: solid; }
.batch-tick {
  position: absolute; top: -8px; right: -8px; display: grid; place-items: center; width: 28px; height: 28px;
  border: 2px solid var(--outline); border-radius: 50%; background: var(--surface); color: transparent;
  font-size: 15px; font-weight: 800;
}
.batch-tile.is-selected .batch-tick { background: var(--pink-strong); color: var(--ink); }
.batch-tile.is-selected .batch-check::before {
  content: ''; position: absolute; z-index: 1; top: -8px; left: 50%; width: 40px; height: 14px; margin-left: -20px;
  background: var(--pink); border: 2px dashed var(--pink-strong); border-radius: 3px; transform: rotate(-4deg);
}
.batch-grid > li:nth-child(even).is-selected .batch-check::before { background: var(--mint); border-color: #8FCFAE; transform: rotate(4deg); }
.batch-tile.send-done .batch-check { border-color: #2C7A4E; }
.batch-tile-status { min-height: 24px; }
.batch-chip {
  display: inline-flex; align-items: center; max-width: 100%; height: 24px; padding: 0 9px;
  border: 1.5px solid var(--outline); border-radius: 999px; background: var(--surface); color: var(--ink);
  font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none;
}
.batch-chip.is-new { background: var(--butter); }
.batch-chip.is-known { background: var(--sky); }
.batch-chip.is-done { background: var(--mint); }
.batch-chip.is-busy { border-style: dashed; color: var(--muted); }
.batch-chip.is-error { background: var(--pink); color: var(--danger); border-style: dashed; }
.batch-back .batch-back-header { display: flex; }
.batch-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.batch-result[hidden] { display: none; }
.batch-result p { margin: 0; font: 400 19px/var(--row) var(--hand); color: #2C7A4E; }
:root[data-theme="dark"] .batch-result p { color: #9BE0B8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .batch-result p { color: #9BE0B8; } }
.batch-jump { display: none; }
@media (max-width: 820px) {
  .batch-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .batch-back { position: static; }
  .batch-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
  /* Nút nổi phía trên thanh điều hướng, dẫn xuống khung viết khi lưới ảnh dài */
  .batch-jump {
    display: inline-flex; position: sticky; z-index: 5; bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    width: 100%; margin-top: 16px;
  }
}
.m3-login-card {
  max-width: 420px; margin: 8vh auto 0; padding: 28px 24px; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 2px solid var(--outline); border-radius: var(--r-lg); box-shadow: 4px 4px 0 var(--shadow);
}
.m3-login-card label { margin-top: 12px; font-weight: 800; }
.m3-login-card input {
  height: 50px; padding: 0 16px; border: 2px solid var(--outline); border-radius: var(--r-md);
  background: var(--bg); font-size: 16px; font-weight: 600;
}
.m3-login-card .btn { margin-top: 14px; width: 100%; }

/* ---------- Thanh điều hướng dưới (điện thoại) ---------- */
.logged-out .m3-bottom-nav, .logged-out .top-links, .logged-out .theme-btn ~ .sound-btn ~ .who { display: none !important; }
.m3-bottom-nav { display: none; }
@media (max-width: 820px) {
  .m3-bottom-nav {
    position: fixed; z-index: 25; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center; height: 68px;
    background: var(--surface); border: 2px solid var(--outline); border-radius: 26px; box-shadow: 3px 3px 0 var(--shadow);
  }
  .m3-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 700;
  }
  .m3-nav-indicator { display: grid; place-items: center; width: 52px; height: 30px; border: 2px solid transparent; border-radius: 999px; }
  .m3-nav-indicator svg { width: 20px; height: 20px; }
  .m3-nav-item.is-active { font-weight: 800; }
  .m3-nav-item.is-active .m3-nav-indicator { background: var(--pink); border-color: var(--outline); }
}

/* ---------- Xem ảnh phóng to ---------- */
.m3-lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.m3-lightbox[hidden] { display: none; }
.m3-lightbox-scrim { position: absolute; inset: 0; background: var(--scrim); }
.m3-lightbox-content { position: relative; max-width: min(1100px, 100%); max-height: 100%; }
.m3-lightbox-content img {
  display: block; max-width: 100%; max-height: calc(100dvh - 32px); object-fit: contain;
  border: 3px solid var(--surface); border-radius: var(--r-md); background: var(--surface);
}
.m3-lightbox-close {
  position: absolute; top: -10px; right: -10px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 2px solid var(--outline); border-radius: 50%; background: var(--surface); color: var(--ink);
  box-shadow: 2px 2px 0 var(--shadow); cursor: pointer;
}
.m3-lightbox-close svg { width: 20px; height: 20px; }

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

/* ---------- Ảnh: lưới theo ngày ---------- */
@media (max-width: 1100px) and (min-width: 821px) {
  .top-links .m3-header-action-btn { padding: 0 10px; }
  .top-links .m3-header-action-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.album-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 8px; margin: -6px 0 6px; }
.album-chips::-webkit-scrollbar { display: none; }
.album-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border: 2px solid var(--outline); border-radius: 999px; background: var(--surface); color: var(--ink);
  font: 700 14px/1 var(--ui); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.album-chip span:not(.sr-only) { padding: 0 7px; border-radius: 999px; background: var(--line); font-size: 12px; font-weight: 800; line-height: 18px; }
.album-chip.is-active { background: var(--pink); font-weight: 800; box-shadow: 2px 2px 0 var(--shadow); }
.album-chip.is-add { background: var(--mint); padding: 0 12px; }
.album-chip.is-add span:not(.sr-only) { background: none; padding: 0; font-size: 14px; line-height: 1; }
.album-chip svg { width: 16px; height: 16px; }

.lib-day { margin: 10px 0 18px; }
.lib-day-title { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font-size: 18px; }
.lib-day-title span { font-size: 13px; font-weight: 600; color: var(--muted); }
.lib-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(31%, 150px), 1fr)); }
@media (max-width: 520px) { .lib-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; } }
.lib-tile {
  position: relative; display: block; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 12px;
  background: var(--line); border: 2px solid transparent; color: var(--ink);
}
.lib-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.lib-tile:hover img { transform: scale(1.04); }
.lib-tile:focus-visible { outline-offset: 1px; }
.lib-count {
  position: absolute; left: 5px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px 0 5px;
  border: 1.5px solid var(--outline); border-radius: 999px; background: var(--surface); font-size: 12px; font-weight: 800;
}
.lib-count svg { width: 13px; height: 13px; }
.lib-count.is-unread { background: var(--pink-strong); }
.lib-check {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #FFFFFF; background: rgba(0, 0, 0, .25); box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
}
.lib-tile.is-selected { border-color: var(--outline); }
.lib-tile.is-selected img { transform: scale(.9); border-radius: 8px; }
.lib-tile.is-selected .lib-check { background: var(--link); }
.lib-tile.is-selected .lib-check::after { content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid #FFF; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.lib-more { display: flex; margin: 8px auto 0; }
.select-bar {
  position: fixed; z-index: 26; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; width: min(640px, calc(100vw - 24px));
  padding: 10px 12px; border: 2px solid var(--outline); border-radius: 22px; background: var(--butter); box-shadow: 3px 3px 0 var(--shadow);
}
.select-bar[hidden] { display: none; }
.select-bar #select-count { flex: 1 1 100%; text-align: center; font-weight: 800; }
@media (min-width: 821px) { .select-bar { bottom: 20px; } .select-bar #select-count { flex: 0 1 auto; } }

/* ---------- Album ---------- */
.album-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(46%, 200px), 1fr)); }
.album-card { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; }
.album-cover {
  display: block; aspect-ratio: 1 / 1; overflow: hidden; border: 2px solid var(--outline); border-radius: var(--r-md);
  background: var(--surface); box-shadow: 3px 3px 0 var(--shadow); transition: transform .15s ease;
}
.album-card:nth-child(odd) .album-cover { transform: rotate(-1deg); }
.album-card:hover .album-cover { transform: translateY(-3px); }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-cover img.is-empty { object-fit: contain; padding: 18%; }
.album-name { margin-top: 6px; font-weight: 800; font-size: 17px; line-height: 1.25; }
.album-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.photo-albums { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Hộp chọn album */
.pick-album { position: fixed; inset: 0; z-index: 70; display: grid; place-items: end center; }
@media (min-width: 821px) { .pick-album { place-items: center; } }
.pick-scrim { position: absolute; inset: 0; background: var(--scrim); }
.pick-sheet {
  position: relative; width: min(480px, 100vw); max-height: 80vh; overflow-y: auto; padding: 18px 16px 16px;
  background: var(--surface); border: 2px solid var(--outline); border-radius: 26px 26px 0 0; box-shadow: 0 -4px 0 var(--shadow);
}
@media (min-width: 821px) { .pick-sheet { border-radius: 26px; box-shadow: 4px 4px 0 var(--shadow); } }
.pick-sheet h2 { margin-bottom: 10px; }
.pick-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pick-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px; text-align: left; cursor: pointer;
  border: 2px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--ink);
}
.pick-item:hover, .pick-item:focus-visible { border-color: var(--outline); }
.pick-item img, .pick-noimg { width: 48px; height: 48px; flex: none; border-radius: 10px; object-fit: cover; background: var(--line); }
.pick-item span { display: flex; flex-direction: column; line-height: 1.25; }
.pick-item small { color: var(--muted); font-weight: 600; }
.pick-empty { color: var(--muted); font-weight: 600; padding: 4px 2px; }
.pick-new { display: flex; gap: 8px; }
.pick-new .field { flex: 1; min-width: 0; }
.pick-close { width: 100%; margin-top: 8px; }

.app-toast {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100vw - 32px); padding: 10px 16px; border: 2px solid var(--outline); border-radius: 999px;
  background: var(--mint); color: var(--ink); font-weight: 800; box-shadow: 3px 3px 0 var(--shadow);
}
.app-toast[hidden] { display: none; }
@media (min-width: 821px) { .app-toast { bottom: 28px; } }

/* ---------- Chuông thông báo ---------- */
.bell-btn { position: relative; text-decoration: none; }
.bell-btn.is-active { background: var(--butter); }
.bell-btn.has-unread svg { transform-origin: 50% 10%; }
@media (prefers-reduced-motion: no-preference) {
  .bell-btn.has-unread svg { animation: bell-ring 2.6s ease-in-out infinite; }
}
@keyframes bell-ring {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(14deg); }
  90% { transform: rotate(-12deg); }
  94% { transform: rotate(8deg); }
}
.bell-count {
  position: absolute; top: -6px; right: -8px; min-width: 22px; height: 22px; padding: 0 5px;
  display: grid; place-items: center; border: 2px solid var(--outline); border-radius: 999px;
  background: var(--pink-strong); color: var(--ink); font-size: 12px; font-weight: 800; line-height: 1;
}
.bell-count[hidden] { display: none; }
.logged-out .bell-btn { display: none; }

/* ---------- Trang thông báo ---------- */
.inbox-section { margin: 18px 0 10px; font-size: 18px; font-weight: 800; color: var(--muted); }
.inbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.inbox-item {
  position: relative; border: 2px solid var(--outline); border-radius: var(--r-md);
  background: var(--surface); box-shadow: 3px 3px 0 var(--shadow);
}
.inbox-item.is-unread { background: var(--paper); border-left-width: 8px; border-left-color: var(--pink-strong); }
.inbox-link { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; color: inherit; text-decoration: none; }
.inbox-link:hover .inbox-thumb, .inbox-link:focus-visible .inbox-thumb { transform: rotate(-3deg) scale(1.03); }
.inbox-thumb {
  flex: none; width: 72px; height: 72px; overflow: hidden; display: grid; place-items: center;
  border: 2px solid var(--outline); border-radius: var(--r-sm); background: var(--line); transition: transform .15s ease;
}
.inbox-thumb img { width: 100%; height: 100%; object-fit: cover; }
.inbox-thumb svg { width: 28px; height: 28px; }
.inbox-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.inbox-head { font-size: 15px; line-height: 1.35; }
.inbox-head b { font-weight: 800; }
.inbox-time { margin-left: 4px; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.inbox-line {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--hand); font-size: 15px; color: var(--muted);
}
.inbox-line b { font-family: var(--ui); font-size: 13px; color: var(--pen-of, var(--ink)); }
.inbox-line.is-new { color: var(--ink); font-weight: 600; }
.inbox-line .sticker-img { width: 28px; height: 28px; vertical-align: middle; }
.inbox-line .comment-sticker-wrap { margin: 0; }
.inbox-line .sticker-badge { transform: scale(.8); transform-origin: left center; }
.inbox-item .fresh-badge { flex: none; align-self: center; }
.inbox-gp {
  display: inline-flex; align-items: center; gap: 4px; margin: -4px 0 10px 96px;
  color: var(--link); font-size: 13px; font-weight: 700; text-decoration: none;
}
.inbox-gp:hover { text-decoration: underline; }
.inbox-gp svg { width: 14px; height: 14px; }
@media (max-width: 520px) {
  .inbox-thumb { width: 60px; height: 60px; }
  .inbox-gp { margin-left: 84px; }
  .inbox-item .fresh-badge { position: absolute; top: -10px; right: 8px; }
}
.inbox-line.is-new::before {
  content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: middle;
  border-radius: 50%; background: var(--link); border: 1.5px solid var(--outline);
}

/* ---------- Nhãn dán vẽ tay trong giao diện tối ----------
   Nét vẽ màu nâu đậm chìm vào nền tối: ô nhãn dán dùng nền giấy sáng, nhãn trong lời bình có viền sáng. */
:root[data-theme="dark"] .sticker-item-btn, :root[data-theme="dark"] .pack-preview { background: #F6EAD8; }
:root[data-theme="dark"] :is(.sticker-img, .title-doodle, .empty-illustration, .brand-mascot, .login-doodles img, .inbox-line img) {
  filter: drop-shadow(0 0 1px #FFF4E4) drop-shadow(0 0 1px #FFF4E4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sticker-item-btn, :root:not([data-theme="light"]) .pack-preview { background: #F6EAD8; }
  :root:not([data-theme="light"]) :is(.sticker-img, .title-doodle, .empty-illustration, .brand-mascot, .login-doodles img, .inbox-line img) {
    filter: drop-shadow(0 0 1px #FFF4E4) drop-shadow(0 0 1px #FFF4E4);
  }
}

/* Phần tử có thuộc tính hidden luôn ẩn, kể cả khi lớp CSS đặt display (vd. nút "Xem thêm ảnh cũ hơn"). */
[hidden] { display: none !important; }

/* ---------- Trang một ảnh: ảnh luôn nằm cạnh lời bình ---------- */
/* Cột ảnh cao bằng cột lời bình để ảnh dính lại khi cuộn qua chuỗi lời bình dài. */
.photo-page-grid > .photo-col { align-self: stretch; }
@media (min-width: 821px) {
  .photo-sticky-wrap .photo-frame img { max-height: calc(100vh - 260px); }
}
@media (max-width: 820px) {
  .m3-segmented-control { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .m3-segment-btn { padding: 0 6px; font-size: 14px; white-space: nowrap; }
  .m3-segment-btn span { overflow: hidden; text-overflow: ellipsis; }
  /* "Cạnh nhau": ảnh nhỏ dính ở trên, lời bình cuộn bên dưới */
  .photo-page-grid[data-mobile-tab="both"] { gap: 10px; }
  .photo-page-grid[data-mobile-tab="both"] .photo-sticky-wrap {
    position: sticky; top: 64px; z-index: 5; padding-bottom: 6px; background: var(--bg);
  }
  .photo-page-grid[data-mobile-tab="both"] .photo-card-polaroid { padding: 6px; }
  .photo-page-grid[data-mobile-tab="both"] .photo-frame img { max-height: 34vh; }
  .photo-page-grid[data-mobile-tab="both"] :is(.photo-actions-row, .source-note, .photo-albums, .photo-zoom-hint, .mobile-photo-context-bar) { display: none; }
}

/* ---------- Lời bình: chọn cách xem ---------- */
.view-tabs {
  display: inline-flex; gap: 4px; padding: 4px; border: 2px solid var(--outline); border-radius: 999px; background: var(--surface);
}
.view-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border: 2px solid transparent; border-radius: 999px; background: transparent; color: var(--ink);
  font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.view-tab svg { width: 18px; height: 18px; }
.view-tab.is-active { background: var(--pink); border-color: var(--outline); font-weight: 800; }
@media (max-width: 520px) { .view-tabs { width: 100%; } .view-tab { flex: 1; justify-content: center; padding: 0 8px; } }

/* ---------- Ảnh cạnh lời bình ---------- */
.side-list { display: grid; gap: 22px; padding-top: 6px; }
.side-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 12px;
  border: 2px solid var(--outline); border-radius: var(--r-lg); background: var(--surface); box-shadow: 4px 4px 0 var(--shadow);
}
.side-row.has-unread { border-left-width: 8px; border-left-color: var(--pink-strong); }
.side-photo { position: relative; display: grid; place-items: center; min-height: 220px; border-radius: var(--r-md); overflow: hidden; background: var(--line); }
.side-photo img { display: block; width: 100%; height: 100%; max-height: 460px; object-fit: contain; }
.side-photo .src-badge { position: absolute; left: 8px; top: 8px; }
.side-back {
  display: flex; flex-direction: column; min-width: 0; max-height: 460px; padding: 6px 4px 6px 18px;
  border-left: 2px solid var(--margin-line);
  background: repeating-linear-gradient(var(--paper) 0 calc(var(--row) - 1px), var(--line) calc(var(--row) - 1px) var(--row));
}
.side-head { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; }
.side-head > b { font-weight: 800; }
.side-head .btn { margin-left: auto; }
.side-thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-right: 6px; }
.side-thread li.is-unread .text { font-weight: 600; }
.new-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--link); border: 1.5px solid var(--outline); align-self: center; }
@media (max-width: 640px) {
  .side-row { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .side-photo img { max-height: 46vh; }
  .side-back { max-height: 340px; padding-left: 12px; }
}

/* Gợi ý thêm album từ link chia sẻ */
.album-link-hint {
  margin: -6px 0 18px; padding: 10px 14px; border: 2px dashed var(--dash); border-radius: var(--r-md);
  color: var(--muted); font-size: 14px; line-height: 1.5;
}

/* ---------- Nút xoá ---------- */
.btn.danger { color: var(--danger); }
.btn.danger svg { width: 18px; height: 18px; }
.btn.danger:disabled { opacity: .5; cursor: not-allowed; }
:root[data-theme="dark"] .btn.danger { color: #FFB4AB; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger { color: #FFB4AB; } }
.photo-danger { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 2px dashed var(--dash); }
.danger-note { color: var(--muted); font-size: 13px; font-weight: 600; }
.album-item { position: relative; }
.album-del {
  position: absolute; top: 8px; right: 8px; z-index: 2; display: grid; place-items: center; width: 34px; height: 34px;
  border: 2px solid var(--outline); border-radius: 50%; background: var(--surface); color: var(--danger);
  box-shadow: 2px 2px 0 var(--shadow); cursor: pointer;
}
.album-del svg { width: 17px; height: 17px; }
.album-del:hover { background: var(--pink); }
:root[data-theme="dark"] .album-del { color: #FFB4AB; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .album-del { color: #FFB4AB; } }
.select-bar { flex-wrap: wrap; }
