/* Reset, chữ, khung app, responsive, chuyển trang. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--f-body);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--ink);
  background: #f6eef6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--secondary); }
h1, h2, h3, h4 { margin: 0; font-family: var(--f-head); line-height: 1.2; }
p { margin: 0; }
img, svg { display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Bố cục desktop: khung điện thoại + bảng điều khiển ---------- */
.stage {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 28px;
  background: radial-gradient(circle at 15% 20%, #ffe0ef 0, transparent 40%), radial-gradient(circle at 85% 80%, #e7e1ff 0, transparent 45%), #fbf6fb;
}
.device {
  --dw: 390px;
  --dh: 844px;
  width: var(--dw);
  height: min(var(--dh), calc(100vh - 56px));
  border-radius: 46px;
  padding: 10px;
  background: #1d1a26;
  box-shadow: 0 30px 80px rgba(60, 40, 90, 0.35), inset 0 0 0 2px #3b3550;
  flex: none;
  position: relative;
}
.device[data-size='sm'] { --dw: 360px; --dh: 740px; }
.device[data-size='lg'] { --dw: 430px; --dh: 932px; }
.device::before { /* tai thỏ */
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  width: 108px;
  height: 30px;
  transform: translateX(-50%);
  background: #1d1a26;
  border-radius: 20px;
  z-index: 20;
}

#app {
  --status-h: 44px;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 36px;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid, var(--bg-bot)) 45%, var(--bg-bot) 100%);
  isolation: isolate;
  container-type: inline-size;
}

.panel { width: 280px; display: flex; flex-direction: column; gap: 14px; }
.panel h1 { font-size: 30px; color: var(--primary); }
.panel h1 i { font-style: normal; font-size: 18px; vertical-align: super; }
.panel p { color: var(--ink-2); font-size: 14px; }
.panel .grp { background: #fff; border-radius: 20px; padding: 14px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px; }
.panel .grp h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); font-family: var(--f-body); }
.panel .seg { width: 100%; }

/* ---------- Điện thoại thật: toàn màn hình ---------- */
@media (max-width: 560px) {
  body { background: var(--bg-top); }
  .stage { padding: 0; display: block; background: none; }
  .panel { display: none; }
  .device { width: 100%; height: 100dvh; padding: 0; border-radius: 0; background: none; box-shadow: none; }
  .device::before { display: none; }
  #app { border-radius: 0; --status-h: env(safe-area-inset-top, 0px); }
  .statusbar { display: none !important; }
}
@media (min-width: 561px) and (max-width: 900px) {
  .panel { display: none; }
}

/* ---------- Thanh trạng thái giả ---------- */
.statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 28px 0 34px;
  font-weight: 600;
  font-size: 15px;
  pointer-events: none;
}
.statusbar .sb-r { display: flex; gap: 5px; align-items: center; }

/* ---------- Màn hình ---------- */
#screens { position: absolute; inset: 0; }
.scr {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid, var(--bg-bot)) 42%, var(--bg-bot) 100%);
  overflow: hidden;
}
.scr::before { /* blob trang trí góc trên */
  content: '';
  position: absolute;
  width: 280px;
  height: 280px;
  right: -90px;
  top: -80px;
  border-radius: 50%;
  background: var(--bg-blob);
  filter: blur(40px);
  opacity: 0.7;
  pointer-events: none;
}
.scr__in {
  position: relative;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: var(--status-h);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior: contain;
}
.scr__in::-webkit-scrollbar { display: none; }
.has-tabbar .scr__in { padding-bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
.scr__in:not(.has-foot) { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.has-tabbar .scr__in { padding-bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom, 0px)); }

/* chuyển trang */
.in-fwd { animation: inFwd 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both; z-index: 2; }
.out-fwd { animation: outFwd 0.28s ease both; }
.in-back { animation: inBack 0.28s ease both; }
.out-back { animation: outBack 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both; z-index: 2; }
.in-fade { animation: fadeIn 0.22s ease both; z-index: 2; }
.out-fade { animation: fadeOut 0.22s ease both; }
@keyframes inFwd { from { transform: translateX(100%); } to { transform: none; } }
@keyframes outFwd { to { transform: translateX(-28%); opacity: 0.6; } }
@keyframes inBack { from { transform: translateX(-28%); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes outBack { to { transform: translateX(100%); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Thanh đáy ---------- */
#tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 6px env(safe-area-inset-bottom, 0px);
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(90, 84, 170, 0.06);
}
#tabbar[hidden] { display: none; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-2); font-size: 11.5px; font-weight: 500; min-height: 44px; }
.tab.is-on { color: var(--primary); font-weight: 600; }
.tab.is-on .ic { stroke-width: 2.1; }

/* ---------- Lớp phủ ---------- */
#overlay { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#overlay > * { pointer-events: auto; }

/* ---------- Tiện ích ---------- */
.pad { padding: 0 var(--gap); }
.pad-t { padding-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.center { text-align: center; }
.c-primary { color: var(--primary); }
.c-secondary { color: var(--secondary); }
.c-success { color: var(--success); }
.c-danger { color: var(--danger); }
.c-accent { color: var(--accent); }
.b { font-weight: 700; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.title-xl { font-family: var(--f-head); font-size: var(--fs-3xl); font-weight: 700; color: var(--primary); line-height: 1.15; }
.title-lg { font-family: var(--f-head); font-size: var(--fs-2xl); font-weight: 700; color: var(--primary); line-height: 1.2; }
.name { font-family: var(--f-name); font-weight: 700; color: var(--secondary); }
.tone-pink { background: var(--primary-soft); color: var(--primary-600); }
.tone-lavender { background: var(--secondary-soft); color: var(--secondary); }
.tone-mint { background: var(--success-soft); color: var(--success); }
.tone-sun { background: var(--accent-soft); color: #c27c00; }
.tone-sky { background: var(--info-soft); color: var(--info); }
.tone-peach { background: #ffe7dc; color: #d9673f; }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-gray { background: #f1edf3; color: var(--ink-2); }
