:root {
  --bg: #17121f;
  --bg2: #1f1829;
  --card: #261d33;
  --card2: #2f2540;
  --text: #f6eff9;
  --muted: #a99bb8;
  --line: #3a2e4b;
  --accent: #ff5d7a;
  --accent2: #ffb067;
  --accent-ink: #1a0f14;
  --ok: #5fd39a;
  --warn: #ffcf5c;
  --bad: #ff7a7a;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fff7f5; --bg2: #fff0ed; --card: #ffffff; --card2: #fff4f1; --text: #2a1f2d; --muted: #7d6b82;
    --line: #f0d9d5; --accent: #e23d5e; --accent2: #f08a3c; --accent-ink: #ffffff; --ok: #1f9d68; --warn: #b9831a; --bad: #d13b3b;
    --shadow: 0 6px 20px rgba(120, 60, 70, 0.12);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
#app { max-width: 540px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
main.no-tabs { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 16px 0 6px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.gap-lg > * + * { margin-top: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card.accent { border-color: var(--accent); }
.card.warn { border-color: var(--warn); }
.card h3:first-child { margin-top: 0; }

.btn {
  appearance: none; border: 0; border-radius: 14px; padding: 12px 16px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--card2); color: var(--text); border: 1px solid var(--line); min-height: 44px;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-ink); border: 0; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.ghost { background: transparent; }
.btn.block { display: block; width: 100%; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .chip:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent2); outline-offset: 2px;
}

label.field { display: block; margin: 12px 0; font-weight: 600; font-size: 0.9rem; }
label.field > span { display: block; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="datetime-local"],
input[type="number"], input[type="time"], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 36px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 20px; height: 20px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 10px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 999px; padding: 6px 12px;
  font: inherit; font-size: 0.9rem; cursor: pointer; min-height: 36px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.err { color: var(--bad); font-size: 0.9rem; margin: 8px 0; }
.note { background: var(--card2); border: 1px dashed var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 0.9rem; margin: 10px 0; }
.banner { background: var(--card2); border-bottom: 1px solid var(--line); padding: 8px 16px; font-size: 0.85rem; text-align: center; }
.banner.warn { background: #3b2f12; color: var(--warn); }
@media (prefers-color-scheme: light) { .banner.warn { background: #fff4d6; } }

.badge { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--bad); border-color: var(--bad); }
.badge.accent { color: var(--accent); border-color: var(--accent); }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--card2); display: inline-grid; place-items: center; font-size: 1.4rem; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 2.2rem; }

/* Thanh tab */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: var(--bg2); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs-inner { display: flex; width: 100%; max-width: 540px; }
.tab {
  flex: 1; text-align: center; padding: 8px 2px; color: var(--muted); text-decoration: none; font-size: 0.72rem;
  background: none; border: 0; font-family: inherit; cursor: pointer; position: relative;
}
.tab .ico { display: block; font-size: 1.35rem; line-height: 1.2; }
.tab.on { color: var(--accent); font-weight: 700; }
.tab .dot { position: absolute; top: 6px; right: calc(50% - 22px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 0.65rem; line-height: 16px; padding: 0 4px; }

.fab {
  position: fixed; right: max(16px, calc(50% - 254px)); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 15;
  width: 56px; height: 56px; border-radius: 50%; font-size: 1.8rem; border: 0; cursor: pointer; box-shadow: var(--shadow);
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-ink);
}

/* Bottom sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); border: 1px solid var(--line);
}
.sheet h2 { margin-top: 0; }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 0.9rem; max-width: 90%; box-shadow: var(--shadow); }

.cover { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; font-size: 1.5rem; font-weight: 700; color: var(--accent); }

/* Màn hình đầy đủ (đăng nhập, khóa) */
.hero { text-align: center; padding: 32px 0 8px; }
.hero .logo { font-size: 3rem; }
.pin { letter-spacing: 0.6em; text-align: center; font-size: 1.6rem; }
.code-box {
  font: 700 1.1rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; text-align: center; padding: 16px 8px;
  background: var(--bg2); border: 2px dashed var(--accent); border-radius: 14px; word-break: break-all; user-select: all;
}
.safety { font: 600 1rem ui-monospace, monospace; text-align: center; letter-spacing: 0.06em; padding: 10px; background: var(--bg2); border-radius: 10px; }
.steps { display: flex; gap: 6px; justify-content: center; margin: 8px 0 16px; }
.steps i { width: 28px; height: 5px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--accent); }

/* Lịch */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 0.72rem; color: var(--muted); padding: 4px 0; }
.cal button.day {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); color: var(--text);
  font: inherit; font-size: 0.85rem; cursor: pointer; position: relative; padding: 0;
}
.cal button.day.out { opacity: 0.35; }
.cal button.day.today { border-color: var(--accent2); }
.cal button.day.sel { outline: 2px solid var(--accent); }
.cal button.day.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--bg2)); }
.cal button.day.l2 { background: color-mix(in srgb, var(--accent) 60%, var(--bg2)); color: var(--accent-ink); }
.cal button.day .pl { position: absolute; bottom: 2px; left: 0; right: 0; font-size: 0.6rem; line-height: 1; }

/* Điểm và hint */
.score-big { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.face { font-size: 3rem; text-align: center; line-height: 1.1; transition: transform 0.15s; }
.hint { display: flex; align-items: center; gap: 10px; background: var(--bg2); border-radius: 12px; padding: 10px 12px; }
.hint .ic { font-size: 1.5rem; }
.locked { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; color: var(--muted); }
.blur-text { filter: blur(5px); user-select: none; }
.preview { background: var(--bg2); border: 1px dashed var(--accent2); border-radius: 14px; padding: 12px; }
.preview h3 { margin-top: 0; font-size: 0.85rem; color: var(--accent2); }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; }
.bars .bar { flex: 1; background: linear-gradient(to top, var(--accent), var(--accent2)); border-radius: 6px 6px 0 0; min-height: 3px; position: relative; }
.bars .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 0.7rem; color: var(--muted); }
.barlabels { display: flex; gap: 6px; }
.barlabels span { flex: 1; text-align: center; font-size: 0.65rem; color: var(--muted); }

.gift { font-size: 2.4rem; text-align: center; }
@keyframes unwrap { 0% { transform: scale(0.6) rotate(-8deg); opacity: 0; } 60% { transform: scale(1.15) rotate(4deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
.reveal-anim { animation: unwrap 0.9s ease-out; }
@media (prefers-reduced-motion: reduce) { .reveal-anim { animation: none; } }

.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
a { color: var(--accent); }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.kbd { font-family: ui-monospace, monospace; background: var(--bg2); padding: 1px 6px; border-radius: 6px; }
details summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
