/* =========================================================================
   IPHONE PHOTO 2.0 - giao diện "ổ ảnh cá nhân": sáng, sạch, ảnh là nhân vật chính.
   Không phụ thuộc CDN/font ngoài. Sáng/Tối theo hệ thống, có thể chọn tay (theme.js).
   ========================================================================= */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4a5bd8;
  --primary-2: #3e4ec4;
  --primary-soft: #eceffd;
  --primary-ink: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #c2410c;
  --warn-soft: #fff4e5;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --fav: #e11d48;
  --toast-bg: #1f2430;
  --toast-fg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 6px 24px rgba(17, 24, 39, .07);
  --shadow-lg: 0 10px 40px rgba(17, 24, 39, .16);
  --radius: 14px;
  --radius-sm: 10px;
  --tile-radius: 8px;
  --tile-gap: 4px;
  --sidebar-w: 248px;
  --appbar-h: 64px;
  --bottomnav-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17191e; --surface: #1e2127; --surface-2: #262a31; --surface-3: #31353e;
    --text: #e4e6eb; --text-2: #c3c7cf; --muted: #8d939e; --border: #2c3038;
    --primary: #8794f5; --primary-2: #9ca6fa; --primary-soft: #272c48; --primary-ink: #14161b;
    --toast-bg: #e4e6eb; --toast-fg: #17191e;
    --danger: #f87171; --danger-soft: #3a1d20; --warn: #fb923c; --warn-soft: #3a2a1a;
    --ok: #4ade80; --ok-soft: #173023; --fav: #fb7185;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35);
    --shadow-lg: 0 14px 44px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17191e; --surface: #1e2127; --surface-2: #262a31; --surface-3: #31353e;
  --text: #e4e6eb; --text-2: #c3c7cf; --muted: #8d939e; --border: #2c3038;
  --primary: #8794f5; --primary-2: #9ca6fa; --primary-soft: #272c48; --primary-ink: #14161b;
  --toast-bg: #e4e6eb; --toast-fg: #17191e;
  --danger: #f87171; --danger-soft: #3a1d20; --warn: #fb923c; --warn-soft: #3a2a1a;
  --ok: #4ade80; --ok-soft: #173023; --fav: #fb7185;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35);
  --shadow-lg: 0 14px 44px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--primary); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }
h1, h2, h3, h4 { letter-spacing: -.01em; }
input, select, button, textarea { font: inherit; color: inherit; }
input[type=search], input[type=text], input[type=password], input[type=date], input[type=number], input[type=tel], input:not([type]), select, textarea {
  font-size: 16px; /* iOS: không tự phóng to khi nhập */
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%; min-height: 44px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
::selection { background: color-mix(in srgb, var(--primary) 25%, transparent); }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14.5px; white-space: nowrap;
  user-select: none; -webkit-user-select: none; transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon { width: 40px; padding: 0; }
.btn.light { background: rgba(255, 255, 255, .12); border-color: transparent; color: #fff; }
.btn.light:hover { background: rgba(255, 255, 255, .22); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; min-height: 32px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button svg { width: 17px; height: 17px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.badge { background: var(--surface-2); border-radius: 99px; padding: 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .4s; }
.bar-fill.warning { background: var(--warn); }
.bar-fill.critical { background: var(--danger); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.alert.critical { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert.info { background: var(--primary-soft); border-color: transparent; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--surface-3); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 80%, #fff), var(--primary-2));
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }
/* ảnh đại diện: luôn tròn, không méo */
.avatar { overflow: hidden; }
.avatar.has-img { background: var(--surface-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar-edit { position: relative; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; }
.avatar-edit:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.avatar-pen {
  position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.avatar-pen svg { width: 14px; height: 14px; }
/* avatar nhỏ góc trên sidebar (thay icon máy ảnh) - cùng nguồn với mọi avatar khác */
.sb-brand .avatar.sbt { width: 32px; height: 32px; font-size: 12px; text-decoration: none; }
.sb-brand .avatar.sbt:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* hộp chọn ảnh đại diện từ thư viện */
.ap-search { max-width: none; margin: 4px 0 12px; }
.ap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; max-height: 56vh; overflow-y: auto; border-radius: 12px; }
.ap-tile { aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--surface-2); min-height: 44px; }
.ap-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.ap-tile:hover img { transform: scale(1.04); }
.ap-tile:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.ap-empty { text-align: center; padding: 24px 8px; }
.ap-more { display: flex; justify-content: center; margin-top: 10px; }
.avatar-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.crop-stage { position: relative; width: min(280px, 72vw); aspect-ratio: 1; margin: 14px auto 10px; border-radius: 16px; overflow: hidden; background: var(--surface-2); touch-action: none; cursor: grab; }
.crop-stage:active { cursor: grabbing; }
.crop-stage canvas { width: 100%; height: 100%; display: block; }
.crop-ring { position: absolute; inset: 0; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .45); }
.crop-zoom { display: flex; align-items: center; gap: 10px; max-width: 280px; margin: 0 auto; color: var(--muted); }
.crop-zoom input { flex: 1; accent-color: var(--primary); }

/* ---------- khung trang: sidebar + nội dung ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 12px calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
  transition: width .2s;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.sb-brand img { width: 30px; height: 30px; border-radius: 8px; }
.sb-brand .bn { flex: 1; min-width: 0; }
/* câu nhận diện - cùng kiểu thư pháp với trang đăng nhập (login.css .login-quote): font hệ thống có dấu tiếng Việt, không tải font ngoài */
.sb-quote {
  font-family: "Palatino Linotype", Cambria, "Times New Roman", Times, serif;
  font-style: italic; font-weight: 500; font-size: 15px; line-height: 1.3; letter-spacing: .01em;
  color: var(--text-2); text-wrap: balance; overflow-wrap: break-word;
}
body.sb-collapsed .sb-brand .bn { display: none; }
.sb-toggle { border: 0; background: none; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.sb-toggle:hover { background: var(--surface-2); color: var(--text); }
.sb-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; }
.sb-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; white-space: nowrap; }
.sb-nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-2); text-decoration: none; font-weight: 550; font-size: 14.5px; white-space: nowrap;
}
.sb-nav a svg { color: var(--muted); }
.sb-nav a:hover { background: var(--surface-2); }
.sb-nav a.on { background: var(--primary-soft); color: var(--primary); }
.sb-nav a.on svg { color: var(--primary); }
.sb-nav a span.t { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-count { font-size: 12px; color: var(--muted); font-weight: 600; }
.sb-foot { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 12px; }
.sb-storage { padding: 0 8px; display: grid; gap: 7px; font-size: 12.5px; color: var(--muted); text-decoration: none; }
.sb-storage b { color: var(--text); font-weight: 600; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.sb-user:hover { background: var(--surface-2); }
.sb-user span.who { display: grid; min-width: 0; line-height: 1.25; }
.sb-user b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.sb-collapsed { --sidebar-w: 72px; }
body.sb-collapsed .sidebar .t, body.sb-collapsed .sb-label, body.sb-collapsed .sb-brand b, body.sb-collapsed .sb-count,
body.sb-collapsed .sb-storage, body.sb-collapsed .sb-user .who { display: none; }
body.sb-collapsed .sb-nav a { justify-content: center; padding: 10px; }
body.sb-collapsed .sb-brand { flex-direction: column; padding-bottom: 10px; }
body.sb-collapsed .sb-user { justify-content: center; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .2s; }
.appbar {
  position: sticky; top: 0; z-index: 20; height: calc(var(--appbar-h) + var(--safe-top));
  display: flex; align-items: center; gap: 14px; padding: var(--safe-top) 28px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.3) blur(12px); -webkit-backdrop-filter: saturate(1.3) blur(12px);
}
.appbar.scrolled { box-shadow: 0 1px 0 var(--border); }
.ab-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.ab-title h1 { font-size: 22px; font-weight: 750; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-mobile-brand { display: none; }
.ab-search { position: relative; width: min(420px, 38vw); }
.ab-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.ab-search input { padding-left: 38px; min-height: 40px; background: var(--surface); border-radius: 99px; }
.ab-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.avatar-btn { border: 0; background: none; padding: 2px; border-radius: 50%; cursor: pointer; }
.avatar-btn:focus-visible { outline: 2px solid var(--primary); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
}
.menu .menu-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.menu .menu-head .who { display: grid; min-width: 0; line-height: 1.3; }
.menu .menu-head small { color: var(--muted); }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; background: none; border: 0; border-radius: 9px; text-align: left; cursor: pointer; color: var(--text); text-decoration: none; font-size: 14.5px; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .danger { color: var(--danger); }
.menu svg { width: 18px; height: 18px; color: var(--muted); }

.content { padding: 4px 28px calc(110px + var(--safe-bottom)); max-width: 1680px; }

/* ---------- đầu mỗi màn ---------- */
.vhead { display: grid; gap: 12px; margin: 4px 0 16px; }
.vhead-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vhead-row .grow { flex: 1; }
.vhead .sub { color: var(--muted); font-size: 14px; margin: 0; }
.banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.banner .bi { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.banner .bt { flex: 1; min-width: 0; }
.banner .bt b { display: block; }
.banner .bt span { color: var(--muted); font-size: 14px; }
.banner.warn .bi { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

/* ---------- gallery ---------- */
.group { margin-bottom: 26px; }
.group-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 10px; position: relative; }
.group-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.group-head .gcount { color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: var(--tile-gap); }
body.dense .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; border-radius: var(--tile-radius);
  background: var(--surface-2); border: 0; padding: 0; cursor: pointer; display: block; width: 100%;
  transition: transform .18s ease, border-radius .18s;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s, transform .35s ease; }
.tile img.ok { opacity: 1; }
.tile .noimg { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; font-size: 12px; color: var(--muted); text-align: center; word-break: break-all; }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.28), transparent 32%, transparent 70%, rgba(0,0,0,.28)); opacity: 0; transition: opacity .2s; pointer-events: none; }
.vbadge { position: absolute; right: 7px; bottom: 6px; z-index: 2; display: inline-flex; align-items: center; gap: 3px; color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.vbadge svg { width: 13px; height: 13px; fill: #fff; stroke: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.favdot { position: absolute; left: 7px; bottom: 6px; z-index: 2; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.55)); }
.favdot svg { width: 16px; height: 16px; fill: #fff; stroke: none; }
.tdays { position: absolute; left: 6px; bottom: 6px; z-index: 2; background: rgba(0,0,0,.55); color: #fff; font-size: 11.5px; font-weight: 600; border-radius: 99px; padding: 1px 8px; }
.tick {
  position: absolute; left: 7px; top: 7px; z-index: 3; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.95); background: rgba(0,0,0,.18); display: grid; place-items: center;
  opacity: 0; transition: opacity .15s, background .15s; cursor: pointer;
}
.tick svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 3; opacity: 0; }
.qfav {
  position: absolute; right: 6px; top: 6px; z-index: 3; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.qfav svg { width: 19px; height: 19px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.qfav.on svg { fill: #fff; }
@media (hover: hover) and (pointer: fine) {
  .tile:hover::after { opacity: 1; }
  .tile:hover .tick, .tile:hover .qfav { opacity: 1; }
  .tile:hover img.ok { transform: scale(1.025); }
}
body.selecting .tick { opacity: 1; }
body.selecting .qfav { display: none; }
.tile.sel { border-radius: calc(var(--tile-radius) + 4px); transform: scale(.9); }
.tile.sel .tick { background: var(--primary); border-color: var(--primary); opacity: 1; }
.tile.sel .tick svg { opacity: 1; }
.tile.sel::after { opacity: 0 !important; }
.tile:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* danh sách (Thư mục - kiểu Danh sách) */
.llist { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lhead, .lrow { display: grid; grid-template-columns: 52px minmax(0, 1fr) 120px 150px 100px 44px; align-items: center; gap: 12px; padding: 8px 14px; }
.lhead { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.lrow { border-bottom: 1px solid var(--border); cursor: pointer; min-height: 60px; }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: var(--surface-2); }
.lrow.sel { background: var(--primary-soft); }
.licon { width: 44px; height: 44px; border-radius: 9px; background: var(--surface-2); position: relative; overflow: hidden; display: grid; place-items: center; color: var(--primary); }
.licon img { width: 100%; height: 100%; object-fit: cover; }
.licon .tick { left: 10px; top: 10px; }
.lrow.sel .licon .tick { opacity: 1; background: var(--primary); border-color: var(--primary); }
.lrow.sel .licon .tick svg { opacity: 1; }
body.selecting .lrow .tick { opacity: 1; }
.lname { min-width: 0; display: grid; }
.lname b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lname small { display: none; color: var(--muted); }
.lcell { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lmore { border: 0; background: none; width: 36px; height: 36px; border-radius: 9px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.lmore:hover { background: var(--surface-3); }

/* ---------- thư mục ---------- */
.crumbs { display: flex; align-items: center; gap: 2px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; min-width: 0; }
.crumbs::-webkit-scrollbar { display: none; }
.crumbs button { border: 0; background: none; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14.5px; }
.crumbs button:last-child { color: var(--text); }
.crumbs button:hover { background: var(--surface-2); }
.crumbs .sep { color: var(--muted); opacity: .6; }
.fsearch { position: relative; max-width: 360px; flex: 1 1 220px; }
.fsearch svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.fsearch input { padding-left: 38px; min-height: 40px; }
.sec-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 2px 12px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 18px 16px; margin-bottom: 28px; }
.fcard { position: relative; cursor: pointer; border-radius: var(--radius); outline: none; }
.fcover {
  aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2);
  display: grid; place-items: center; color: var(--primary); position: relative; transition: transform .2s, box-shadow .2s;
}
.fcover img { width: 100%; height: 100%; object-fit: cover; }
.fcover > svg { width: 44px; height: 44px; stroke-width: 1.4; opacity: .85; }
.fcard.inbox .fcover { background: var(--primary-soft); }
.fcover .fstack { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.5); color: #fff; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; display: flex; align-items: center; gap: 4px; }
.fcover .fstack svg { width: 13px; height: 13px; }
.finfo { padding: 8px 2px 0; display: grid; gap: 1px; }
.fname { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmeta, .fpath { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmore {
  position: absolute; right: 8px; top: 8px; z-index: 2; width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.92); color: #111; cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow-sm);
  opacity: 0; transition: opacity .15s;
}
.fcard:hover .fmore, .fcard:focus-within .fmore { opacity: 1; }
@media (hover: none) { .fmore { opacity: 1; } }
@media (hover: hover) { .fcard:hover .fcover { transform: translateY(-2px); box-shadow: var(--shadow); } }
.fcard:focus-visible .fcover { outline: 3px solid var(--primary); outline-offset: 2px; }
.drop-ok .fcover, .drop-ok.lrow, .crumbs button.drop-ok { outline: 3px dashed var(--primary); outline-offset: 2px; background: var(--primary-soft); }

/* ---------- trang chủ ---------- */
.home-hello h2 { font-size: 24px; margin: 4px 0 2px; font-weight: 740; }
.home-hello p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
/* 4 chỉ số NHỎ - không chiếm chỗ của ảnh */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; max-width: 980px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-items: center;
  text-decoration: none; color: inherit; min-width: 0; transition: border-color .15s;
}
a.stat:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.stat .si { grid-row: span 2; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat .si svg { width: 17px; height: 17px; }
.stat b { font-size: 17px; font-weight: 720; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .bar { grid-column: 1 / -1; margin-top: 8px; height: 4px; }
.sec-row { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 12px; }
.sec-row h3 { margin: 0; font-size: 16px; font-weight: 700; }
.sec-row a { font-weight: 600; text-decoration: none; font-size: 14px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: var(--tile-gap); margin-bottom: 32px; }
body.dense .home-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }

/* ---------- tìm kiếm ---------- */
.search-big { position: relative; max-width: 720px; }
.search-big svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 22px; height: 22px; }
.search-big input { min-height: 52px; padding-left: 50px; border-radius: 16px; font-size: 17px; box-shadow: var(--shadow-sm); }
.sugg { display: grid; gap: 14px; margin: 18px 0 8px; }
.sugg h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.search-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0 6px; }
.search-filters label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
.search-filters input[type=date] { min-height: 36px; padding: 5px 10px; width: auto; font-size: 14px; }

/* ---------- tài khoản & quản trị ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 4px; font-size: 16.5px; }
.panel > p.muted { margin: 0 0 14px; font-size: 14px; }
.profile { display: flex; align-items: center; gap: 18px; }
.profile h2 { margin: 0; font-size: 22px; }
.profile .muted { margin: 2px 0 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.kv div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.kv b { font-size: 18px; }
.kv span { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 5px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.field input, .field select { font-weight: 400; }
.field small { font-weight: 400; color: var(--muted); }
.linklist { display: grid; }
.linklist a, .linklist button {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--border);
  background: none; text-decoration: none; color: var(--text); cursor: pointer; text-align: left; font-size: 15px; width: 100%;
}
.linklist a:last-child, .linklist button:last-child { border-bottom: 0; }
.linklist svg { color: var(--muted); }
.linklist .t { flex: 1; }
.linklist .danger { color: var(--danger); }
.token-new { display: flex; gap: 8px; align-items: center; margin: 10px 0; padding: 10px; background: var(--surface-2); border-radius: 10px; }
.token-new code { flex: 1; word-break: break-all; font-size: 13px; }
.token-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.token-list li { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 9px 12px; background: var(--surface-2); border-radius: 10px; font-size: 13.5px; }
.token-list .revoked { text-decoration: line-through; color: var(--muted); }
/* Quản trị tài khoản: tổng quan nhỏ + danh sách là phần chính */
.ad-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 8px; }
.ad-stats { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; min-width: 0; max-width: 860px; }
.ad-stats div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 9px 14px; display: grid; min-width: 0; }
.ad-stats b { font-size: 18px; font-weight: 720; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-stats span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-note { margin: 0 0 14px; }
.utags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.utag.ok { background: var(--ok-soft); color: var(--ok); }
.uuse .ucount { color: var(--text-2); font-weight: 600; }
.uuse .udates { font-size: 12.5px; }
@media (min-width: 1200px) { .ulist .ucard { grid-template-columns: auto minmax(0, 1fr) 260px 400px; } }
@media (max-width: 899px) {
  .ad-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); flex-basis: 100%; }
  .ad-head .btn { width: 100%; }
}
.ulist { display: grid; gap: 10px; }
.ucard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(180px, 260px) auto; gap: 14px; align-items: center;
}
.ucard.locked { opacity: .72; }
.uname { min-width: 0; }
.uname b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.uname small { color: var(--muted); }
.utag { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.utag.admin { background: var(--primary-soft); color: var(--primary); }
.utag.locked { background: var(--danger-soft); color: var(--danger); }
.uuse { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.uact { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pw-box { font: 600 18px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border-radius: 12px; padding: 14px; text-align: center; letter-spacing: .04em; word-break: break-all; user-select: all; }

.uphone { display: block; width: fit-content; font-size: 13px; color: var(--text-2); text-decoration: none; font-variant-numeric: tabular-nums; }
.uphone:hover { color: var(--primary); }
.ureq { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; font-weight: 650; color: var(--warn); }
.ureq svg { width: 15px; height: 15px; flex: none; }

/* ---------- gói & nâng dung lượng ---------- */
.quota-alert { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.quota-alert .btn { flex: none; }
.plan .plan-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.plan .plan-head > div { display: grid; gap: 2px; }
.plan .plan-head b { font-size: 18px; }
.plan .plan-use { text-align: right; }
.plan .alert { margin: 12px 0 0; }
.plan-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.plan-foot .muted { flex: 1; min-width: 160px; }
.ug-card { max-width: 520px; }
.ug-card .alert { margin: 4px 0 12px; }
.ug-use { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; margin: 6px 0 12px; }
.ug-use-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ug-use b { font-size: 18px; font-variant-numeric: tabular-nums; }
.ug-lead { font-weight: 600; color: var(--text) !important; }
.ug-steps { margin: 8px 0 14px; padding-left: 22px; display: grid; gap: 4px; font-size: 14px; color: var(--text-2); }
.ug-sec { border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.ug-sec h4 { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-size: 15px; }
.ug-k { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 750; }
.ug-contact { display: grid; gap: 2px; margin-bottom: 12px; font-size: 15px; }
.ug-phone { font-size: 17px; letter-spacing: .02em; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }
.ug-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ug-btns .btn { flex: 1 1 160px; min-height: 44px; justify-content: center; text-decoration: none; }
/* QR: dùng NGUYÊN ảnh SO TAI KHOAN.jpg (không sửa ảnh), khung chỉ hiện phần tên + số tài khoản + mã QR;
   chạm để xem toàn bộ ảnh. Vùng hiện (theo ảnh gốc 1242x2424): x 180..1062, y 300..1510 */
.ug-qr { display: block; width: 100%; max-width: 300px; margin: 0 auto; padding: 0; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; background: #fff; cursor: zoom-in; aspect-ratio: 882 / 1210; }
.ug-qr img { display: block; width: 140.82%; max-width: none; height: auto; margin: -34.01% 0 0 -20.41%; }
.ug-qr:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.ug-tap { text-align: center; margin: 8px 0 6px !important; }
.ug-note { font-size: 14px; line-height: 1.5; margin: 6px 0 0 !important; }
.ug-req { margin-top: 4px; display: grid; gap: 8px; }
.qr-full { position: fixed; inset: 0; z-index: 80; background: rgba(8, 9, 12, .94); display: grid; grid-template-rows: 1fr auto; padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom)); }
.qr-full-img { min-height: 0; overflow: auto; display: grid; place-items: center; }
.qr-full-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; background: #fff; }
.qr-full-bar { display: flex; gap: 10px; justify-content: center; padding-top: 12px; }
.qr-full-bar .btn { min-width: 130px; min-height: 44px; justify-content: center; text-decoration: none; }

.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
[data-x="mw420"] { max-width: 420px; }
[data-x="mw560"] { max-width: 560px; }
[data-x="m0"] { margin: 0; }
[data-x="mt2"] { margin: 2px 0 0; }
[data-x="mt10"] { margin: 10px 0 0; }
[data-x="mt12"] { margin-top: 12px; }

/* ---------- empty ---------- */
.empty { text-align: center; color: var(--muted); padding: 64px 20px; display: grid; justify-items: center; gap: 10px; }
.empty .ei { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); margin-bottom: 4px; }
.empty .ei svg { width: 30px; height: 30px; stroke-width: 1.6; }
.empty b { color: var(--text); font-size: 16.5px; font-weight: 680; }
.empty p { margin: 0; max-width: 420px; font-size: 14.5px; }
.empty .btn { margin-top: 8px; }
.group { content-visibility: auto; contain-intrinsic-size: auto 600px; }
.sentinel { height: 40px; display: grid; place-items: center; }

/* ---------- thanh chọn nhiều ---------- */
.selbar {
  position: fixed; z-index: 45; left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2); transform: translateX(-50%);
  bottom: calc(22px + var(--safe-bottom)); display: flex; align-items: center; gap: 4px;
  background: var(--text); color: var(--bg); border-radius: 18px; padding: 6px 8px 6px 14px; box-shadow: var(--shadow-lg);
  max-width: calc(100vw - var(--sidebar-w) - 24px);
}
.selbar .sel-count { font-weight: 700; white-space: nowrap; padding-right: 8px; }
.selbar button { border: 0; background: none; color: inherit; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 12px; cursor: pointer; font-size: 11.5px; font-weight: 600; min-width: 58px; }
.selbar button:hover:not(:disabled) { background: color-mix(in srgb, var(--bg) 14%, transparent); }
.selbar button:disabled { opacity: .4; cursor: default; }
.selbar button.danger { color: var(--selbar-danger, #ff9b9b); }
:root[data-theme="dark"] .selbar { --selbar-danger: #c62828; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .selbar { --selbar-danger: #c62828; } }
.selbar .sel-sep { width: 1px; align-self: stretch; background: color-mix(in srgb, var(--bg) 25%, transparent); margin: 4px 4px; }

/* ---------- hộp thoại / bảng trượt ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(15, 18, 25, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px); overflow: auto; animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-card.wide { max-width: 560px; }
.modal-card h3 { margin: 0 0 6px; font-size: 18px; }
.modal-card p { margin: 0 0 4px; color: var(--text-2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal-head h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .btn { min-height: 44px; }
.sheet-grip { display: none; }
.action-list { display: grid; gap: 4px; margin: 10px 0; }
.action-list button { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border: 0; background: none; border-radius: 12px; cursor: pointer; font-size: 15.5px; text-align: left; color: var(--text); }
.action-list button:hover { background: var(--surface-2); }
.action-list button.danger { color: var(--danger); }
.action-list label { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border-radius: 12px; cursor: pointer; font-size: 15.5px; }
.action-list label:hover { background: var(--surface-2); }
.action-list .ai { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.picker-card { padding-bottom: 14px; }
.picker-list { list-style: none; margin: 8px 0; padding: 0; max-height: 48vh; overflow: auto; border-radius: 12px; border: 1px solid var(--border); }
.picker-list li { border-bottom: 1px solid var(--border); }
.picker-list li:last-child { border-bottom: 0; }
.picker-list button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border: 0; background: none; cursor: pointer; text-align: left; min-height: 52px; }
.picker-list button:hover { background: var(--surface-2); }
.picker-list .fold, .picker-list .inbox { color: var(--primary); }
.picker-list .pname { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-list .pcount { color: var(--muted); font-size: 13px; }
.picker-list .empty-row { padding: 18px; text-align: center; color: var(--muted); }
.picker-foot { display: flex; gap: 8px; justify-content: space-between; }
.picker-foot .btn.primary { flex: 1; max-width: 70%; overflow: hidden; text-overflow: ellipsis; }

/* ---------- tiến trình upload ---------- */
.uploader {
  position: fixed; right: 22px; bottom: calc(22px + var(--safe-bottom)); z-index: 50; width: min(400px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 14px 16px;
}
.up-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.up-title { font-weight: 700; }
.up-actions { display: flex; gap: 4px; }
.uploader .bar { margin: 10px 0 6px; }
.up-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 34vh; overflow: auto; display: grid; gap: 6px; }
.uploader.collapsed .up-list { display: none; }
.up-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 8px; font-size: 13px; align-items: center; }
.up-x { width: 26px; height: 26px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.up-x:hover { background: var(--surface-2); color: var(--danger); }
.up-x svg { width: 15px; height: 15px; }
.up-item .st { font-variant-numeric: tabular-nums; }
.up-item .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-item .st { color: var(--muted); }
.up-item .st.ok { color: var(--ok); }
.up-item .st.dup { color: var(--muted); }
.up-item .st.err { color: var(--danger); }
.up-item .mini { grid-column: 1 / -1; height: 3px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.up-item .mini i { display: block; height: 100%; width: 0; background: var(--primary); }
.up-item .msg { grid-column: 1 / -1; color: var(--danger); }

/* ---------- trình xem ảnh ---------- */
.viewer { position: fixed; inset: 0; z-index: 70; background: #050608; color: #fff; display: block; overscroll-behavior: contain; }
.v-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 24px; background: linear-gradient(180deg, rgba(0,0,0,.6), transparent);
  transition: opacity .2s;
}
.v-title { flex: 1; min-width: 0; }
.v-title div:first-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-title .small { color: rgba(255,255,255,.7); }
.v-tools { display: flex; gap: 4px; }
.vbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: #fff; display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; }
.vbtn:hover { background: rgba(255,255,255,.14); }
.vbtn svg { width: 21px; height: 21px; }
.vbtn.on svg { fill: var(--fav); stroke: var(--fav); }
.vbtn.danger:hover { background: rgba(220, 38, 38, .5); }
.v-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; touch-action: pan-y pinch-zoom; }
.v-stage .v-inner { width: 100%; height: 100%; display: grid; place-items: center; will-change: transform; }
.v-stage img, .v-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-select: none; }
.v-stage video { width: 100%; height: 100%; }
.v-msg { padding: 24px; text-align: center; max-width: 420px; color: rgba(255,255,255,.85); }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; transition: opacity .2s, background .15s; }
.v-nav:hover { background: rgba(255,255,255,.22); }
.v-nav.prev { left: 18px; }
.v-nav.next { right: 18px; }
.viewer.chrome-hidden .v-top, .viewer.chrome-hidden .v-nav { opacity: 0; pointer-events: none; }
.v-info {
  position: absolute; z-index: 4; right: 0; top: 0; bottom: 0; width: min(380px, 100%); overflow: auto;
  background: var(--surface); color: var(--text); padding: calc(18px + var(--safe-top)) 20px calc(20px + var(--safe-bottom)); box-shadow: var(--shadow-lg);
}
@media (min-width: 900px) {
  .viewer.info-open .v-stage, .viewer.info-open .v-top { right: min(380px, 100%); }
  .viewer.info-open .v-nav.next { right: calc(min(380px, 100%) + 18px); }
}
.v-info h3 { margin: 4px 0 14px; font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
.v-info dl { margin: 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px 12px; font-size: 14px; }
.v-info dt { color: var(--muted); }
.v-info dd { margin: 0; word-break: break-word; }

/* ---------- thông báo nhỏ ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bottom)); z-index: 90; background: var(--toast-bg); color: var(--toast-fg); padding: 11px 18px; border-radius: 14px; font-size: 14.5px; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); animation: pop .2s; }
.toast.err { background: var(--danger); }

/* ---------- thanh điều hướng đáy (iPhone) ---------- */
.bottomnav { display: none; }

/* ---------- đăng nhập ---------- */
.login-body { display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-bottom)); background: var(--bg); min-height: 100vh; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 32px 26px 24px; box-shadow: var(--shadow); text-align: center; }
.login-logo { border-radius: 18px; box-shadow: var(--shadow); }
.login-card h1 { margin: 16px 0 0; font-size: 22px; letter-spacing: .04em; }
.login-tag { margin: 0 0 6px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); font-weight: 650; }
.login-card p.muted { margin: 0; }
.login-card form { display: grid; gap: 12px; text-align: left; margin: 22px 0 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.login-card .btn { min-height: 48px; font-size: 16px; }

/* ---------- trang Quản lý khách (manage.html) dùng lại các lớp này ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + var(--safe-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; }
.brand-name { font-weight: 800; letter-spacing: .02em; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; position: relative; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 14px 16px calc(120px + var(--safe-bottom)); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search input { padding-left: 40px; }

/* =========================================================================
   iPhone / màn hình hẹp: không sidebar, có thanh điều hướng đáy
   ========================================================================= */
@media (max-width: 899px) {
  :root { --appbar-h: 54px; --tile-gap: 2px; --tile-radius: 3px; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .appbar { padding: var(--safe-top) calc(14px + var(--safe-right)) 0 calc(16px + var(--safe-left)); gap: 8px; }
  .ab-title h1 { font-size: 20px; }
  .ab-search, #upload-btn, #avatar-wrap { display: none; }
  .content { padding: 2px calc(12px + var(--safe-right)) calc(var(--bottomnav-h) + 90px + var(--safe-bottom)) calc(12px + var(--safe-left)); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .home-grid { grid-template-columns: repeat(3, 1fr); }
  #ph-controls { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 8px; }
  #ph-controls::-webkit-scrollbar { display: none; }
  .seg button { padding: 5px 10px; }
  .vhead { gap: 10px; margin-bottom: 12px; }
  .group { margin-bottom: 18px; }
  .group-head { margin-bottom: 8px; }
  .group-head h3 { font-size: 15px; }
  .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
  .stat { padding: 9px 11px; column-gap: 10px; }
  .stat .si { width: 28px; height: 28px; }
  .stat b { font-size: 15.5px; }
  .home-hello h2 { font-size: 21px; }
  .home-hello p { margin-bottom: 12px; }
  .lhead { display: none; }
  .lrow { grid-template-columns: 52px minmax(0, 1fr) 40px; padding: 8px 10px; }
  .lrow .lcell { display: none; }
  .lname small { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kv div { padding: 10px 12px; }
  .panel { padding: 16px; border-radius: 16px; }
  .profile .avatar.lg { width: 60px; height: 60px; font-size: 22px; }
  .ucard { grid-template-columns: auto minmax(0, 1fr); }
  .ucard .uuse, .ucard .uact { grid-column: 1 / -1; }
  .uact { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .toast { bottom: calc(var(--bottomnav-h) + 16px + var(--safe-bottom)); }
  .tick { width: 22px; height: 22px; left: 5px; top: 5px; }
  .qfav { display: none; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--bottomnav-h) + var(--safe-bottom)); padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
    background: color-mix(in srgb, var(--surface) 92%, transparent); border-top: 1px solid var(--border);
    backdrop-filter: saturate(1.3) blur(14px); -webkit-backdrop-filter: saturate(1.3) blur(14px);
  }
  .bottomnav a, .bottomnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 10.5px; font-weight: 600; cursor: pointer; min-width: 0;
  }
  .bottomnav a.on { color: var(--primary); }
  .bottomnav svg { width: 24px; height: 24px; }
  .bottomnav .bn-plus span.pl {
    width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; margin-top: -4px;
    background: var(--primary); color: var(--primary-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 45%, transparent);
  }
  .bottomnav .bn-plus svg { width: 24px; height: 24px; stroke-width: 2.4; }
  body.selecting .bottomnav { display: none; }
  .selbar {
    left: 8px; right: 8px; transform: none; max-width: none; bottom: calc(8px + var(--safe-bottom));
    border-radius: 18px; justify-content: space-between; padding: 6px;
  }
  .selbar .sel-count { display: none; }
  .selbar button { min-width: 0; flex: 1; padding: 6px 4px; }
  .selbar .sel-sep { display: none; }
  .uploader { right: 8px; left: 8px; width: auto; bottom: calc(var(--bottomnav-h) + 8px + var(--safe-bottom)); }
  /* bảng trượt từ dưới lên */
  .modal { place-items: end center; padding: 0; }
  .modal-card, .modal-card.wide {
    max-width: none; border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + var(--safe-bottom));
    max-height: 88vh; animation: slideup .22s ease;
  }
  .modal.center { place-items: center; padding: 16px; }
  .modal.center .modal-card { border-radius: 20px; padding: 22px; animation: pop .18s ease; }
  @keyframes slideup { from { transform: translateY(40%); opacity: .4; } }
  .sheet-grip { display: block; width: 38px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 0 auto 12px; }
  .modal.center .sheet-grip { display: none; }
  .modal-actions .btn { flex: 1; }
  .v-top { padding: calc(6px + var(--safe-top)) 6px 24px; }
  .v-nav { display: none; }
  .v-tools {
    position: fixed; left: 0; right: 0; bottom: 0; justify-content: space-around; padding: 16px 8px calc(10px + var(--safe-bottom));
    background: linear-gradient(0deg, rgba(0,0,0,.6), transparent); transition: opacity .2s;
  }
  .viewer.chrome-hidden .v-tools { opacity: 0; pointer-events: none; }
  .v-info { top: auto; width: 100%; max-height: 62vh; border-radius: 20px 20px 0 0; padding-top: 16px; }
  .banner { padding: 12px; gap: 10px; }
  .banner .bi { width: 34px; height: 34px; }
}
@media (min-width: 900px) {
  .only-mobile { display: none !important; }
}
@media (max-width: 899px) {
  .only-desktop { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
