/* Não — giao diện: nền xám xanh nhạt, thẻ trắng bo lớn, điểm nhấn xanh navy */
:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #121a2c;
  --muted: #8a93a8;
  --line: #e3e7ef;
  --navy: #16223f;
  --navy-2: #24345c;
  --accent: #2f4a8a;
  --soft: #e4ebfa;
  --soft-text: #2f4a8a;
  --pin: #fff8e1;
  --danger: #d9474a;
  --ok: #2fa66a;
  --warn: #d99a1c;
  --shadow: 0 1px 2px rgba(18, 26, 44, .04), 0 8px 24px rgba(18, 26, 44, .06);
  --r-lg: 26px;
  --r: 20px;
  color-scheme: light dark;
}
/* Theme tối: tự theo máy (khi chưa chọn) hoặc chọn tay */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1220;
    --card: #141c2e;
    --text: #eef1f8;
    --muted: #7f89a3;
    --line: #222c44;
    --navy: #1d2b52;
    --navy-2: #2c3f72;
    --accent: #9db4ff;
    --soft: #1c2844;
    --soft-text: #a9bdf7;
    --pin: #2a2615;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0b1220;
    --card: #141c2e;
    --text: #eef1f8;
    --muted: #7f89a3;
    --line: #222c44;
    --navy: #1d2b52;
    --navy-2: #2c3f72;
    --accent: #9db4ff;
    --soft: #1c2844;
    --soft-text: #a9bdf7;
    --pin: #2a2615;
    --shadow: none;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* Theme Hồng */
:root[data-theme="pink"] {
  --bg: #fdeef4;
  --card: #ffffff;
  --text: #3a1d2b;
  --muted: #a8788d;
  --line: #f6d3e1;
  --navy: #d23f7c;
  --navy-2: #ff86b2;
  --accent: #d23f7c;
  --soft: #ffe2ee;
  --soft-text: #b42a63;
  --pin: #fff4cc;
  --danger: #e0344f;
  --ok: #2fa66a;
  --warn: #e39a1d;
  --shadow: 0 1px 2px rgba(120, 20, 60, .05), 0 8px 24px rgba(210, 63, 124, .10);
  color-scheme: light;
}
:root[data-theme="pink"] .hero { box-shadow: 0 10px 30px rgba(210, 63, 124, .30); }
:root[data-theme="pink"] .brain-card { background: radial-gradient(120% 160% at 0% 50%, #ff8fb8 0%, #d23f7c 55%, #8e1f52 100%); box-shadow: 0 10px 30px rgba(210, 63, 124, .35); }
:root[data-theme="pink"] .avatar { background: linear-gradient(135deg, #ff8fb8, #c2316d); }
:root[data-theme="pink"] .bar span { background: linear-gradient(90deg, #ff9cc0, #d23f7c); }
:root[data-theme="pink"] .composer-row { box-shadow: 0 6px 30px rgba(210, 63, 124, .18); }
:root[data-theme="pink"] .qa-ic { background: #fff3f7; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Ghép đôi ---------- */
#pair { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); }
.login-box h1 { margin: 12px 0 2px; font-size: 30px; }
.pair-form { margin-top: 24px; display: grid; gap: 12px; }
.hint { margin: 0; font-weight: 600; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who-btn { padding: 14px; border-radius: var(--r); background: var(--card); border: 2px solid var(--line); font-weight: 600; }
.who-btn.active { border-color: var(--navy); background: var(--soft); }
.field { padding: 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); font-size: 16px; outline: none; text-align: center; }
.field:focus { border-color: var(--accent); }
.pair-code { font: 800 44px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 4px; padding: 18px; border-radius: var(--r); background: var(--navy); color: #fff; }
.primary { padding: 14px; border-radius: var(--r); background: var(--navy); color: #fff; font-weight: 600; }
.primary:disabled { opacity: .45; }
.link { color: var(--accent); font-weight: 600; }
.error { color: var(--danger); margin: 0; font-size: 14px; }

/* ---------- Trang chính ---------- */
.page { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 18px calc(130px + env(safe-area-inset-bottom)); }

.hello { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #fff; background: linear-gradient(135deg, #3b5bab, #16223f);
  box-shadow: 0 0 0 3px var(--card);
}
.avatar.honghue { background: linear-gradient(135deg, #e0609a, #7b2d6b); }
.hello-text { flex: 1; min-width: 0; }
.hello-text .muted { font-size: 14px; }
.hello-name { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.round-btn {
  position: relative; width: 46px; height: 46px; border-radius: 50%; background: var(--card);
  display: grid; place-items: center; box-shadow: var(--shadow); color: var(--text);
}
.dot { position: absolute; top: 9px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); border: 2px solid var(--card); }
.dot.ok { background: var(--ok); }
.dot.syncing { background: #4b7bec; animation: pulse 1s infinite alternate; }
.dot.offline { background: var(--warn); }
.dot.error { background: var(--danger); }
@keyframes pulse { to { opacity: .35; } }

/* Thẻ navy "Nhắc nhở sắp tới" */
.hero {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, var(--navy-2) 0%, var(--navy) 60%);
  color: #fff; border-radius: var(--r-lg); padding: 18px 20px; box-shadow: 0 10px 30px rgba(22, 34, 63, .25);
  cursor: pointer;
}
.hero-label { font-size: 14px; opacity: .8; }
.hero-row { display: flex; justify-content: space-between; align-items: center; }
.hero-time { font-size: 40px; font-weight: 700; letter-spacing: -1px; margin-top: 4px; }
.hero-date { font-size: 13px; opacity: .75; }
.hero-icon { color: rgba(255, 255, 255, .16); margin-right: -6px; }
.hero-text { margin-top: 10px; font-size: 15px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-text:empty { display: none; }
.hero-more { margin-top: 6px; font-size: 12px; opacity: .7; }
.hero-more:empty { display: none; }
.hero.hero-empty .hero-time { font-size: 28px; opacity: .6; }

.search {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 0 16px; height: 50px;
  background: var(--card); border-radius: 99px; box-shadow: var(--shadow); color: var(--muted);
}
#search { flex: 1; border: 0; outline: none; background: none; font-size: 16px; color: var(--text); height: 100%; }

.section-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 4px 10px; font-weight: 700; font-size: 15px; }
.quick { background: var(--card); border-radius: var(--r-lg); padding: 2px 10px 14px; margin-top: 16px; box-shadow: var(--shadow); }
.quick .section-head { margin: 14px 8px 10px; }
.quick-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.qa-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--accent); transition: .15s; }
.qa.active { color: var(--text); font-weight: 600; }
.qa.active .qa-ic { background: var(--soft); box-shadow: inset 0 0 0 2px var(--accent); }

.seg { display: flex; background: var(--card); border-radius: 99px; padding: 3px; box-shadow: var(--shadow); }
.seg button { padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--navy); color: #fff; }

/* ---------- Danh sách ---------- */
.day { margin: 18px 6px 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.day:first-child { margin-top: 2px; }
.note {
  position: relative; background: var(--card); border-radius: var(--r);
  padding: 14px 44px 12px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.note.pinned { background: var(--pin); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-text:empty { display: none; }
.note-text a { color: var(--accent); }
.note-meta { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.who-tag { font-weight: 700; }
.who-tag.tuananh { color: #4b7bec; }
.who-tag.honghue { color: #d9488f; }
.note-more { position: absolute; top: 8px; right: 6px; width: 34px; height: 34px; border-radius: 12px; color: var(--muted); font-size: 20px; line-height: 1; }
.note-more:active { background: var(--bg); }
mark { background: color-mix(in srgb, #4b7bec 25%, transparent); color: inherit; border-radius: 3px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.more-btn { display: block; margin: 12px auto; padding: 10px 18px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow); }

.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--soft); color: var(--soft-text); font-weight: 600; }
.tag.time { background: color-mix(in srgb, var(--warn) 16%, transparent); color: color-mix(in srgb, var(--warn) 65%, var(--text)); }
.tag.time.past { opacity: .5; text-decoration: line-through; }
.tag.place { background: color-mix(in srgb, var(--ok) 14%, transparent); color: color-mix(in srgb, var(--ok) 70%, var(--text)); }
.tag.link { background: var(--bg); color: var(--text); }
.note.processing { opacity: .7; }
.note.processing .note-text::after { content: " ⏳"; }

/* Ảnh trong ghi chú */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; margin: 2px 0 8px; }
.thumbs.one { grid-template-columns: 1fr; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--bg); }
.thumbs.one .thumb { aspect-ratio: auto; min-height: 120px; max-height: 320px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs.one .thumb img { height: auto; max-height: 320px; }
.thumb .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; font-weight: 700; font-size: 20px; }

/* Lưới ảnh (bộ lọc Ảnh) */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: var(--r); overflow: hidden; }
.gallery .thumb { border-radius: 0; }

/* ---------- Ô soạn ---------- */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.edit-bar { max-width: 640px; margin: 0 auto 6px; display: flex; justify-content: space-between; font-size: 14px; color: var(--accent); padding: 0 8px; }
.pending-imgs { max-width: 640px; margin: 0 auto 8px; display: flex; gap: 8px; overflow-x: auto; }
.pending-imgs .pi { position: relative; width: 64px; height: 64px; flex: none; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.pending-imgs img { width: 100%; height: 100%; object-fit: cover; }
.pending-imgs .rm { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; }
.composer-row {
  max-width: 640px; margin: 0 auto; display: flex; gap: 6px; align-items: flex-end;
  background: var(--card); border-radius: 30px; padding: 6px; box-shadow: 0 6px 30px rgba(18, 26, 44, .14);
}
.attach { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.attach:active { background: var(--bg); }
#composer {
  flex: 1; resize: none; max-height: 40vh; padding: 11px 4px; border: 0; background: none;
  outline: none; font-size: 16px; line-height: 1.4;
}
.act {
  width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: transform .12s;
}
.act svg { pointer-events: none; }
.act .ic-send { display: none; }
.act.has-text .ic-send { display: block; }
.act.has-text .ic-mic { display: none; }
.act.recording { transform: scale(1.25); background: var(--danger); }

/* ---------- Ghi âm ---------- */
.rec { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; background: rgba(11, 18, 32, .45); pointer-events: none; }
.rec-box { background: var(--card); border-radius: 28px; padding: 26px 30px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); min-width: 240px; max-width: 88vw; }
.rec.cancel .rec-box { outline: 3px solid var(--danger); }
.rec-time { font: 700 32px/1.2 ui-monospace, "SF Mono", Menlo, monospace; margin: 10px 0 4px; }
.rec-text { font-size: 17px; line-height: 1.4; margin: 6px 0 10px; max-height: 30vh; overflow: auto; }
.rec-text:empty { display: none; }
.rec-hint { font-size: 14px; color: var(--muted); }
.rec.cancel .rec-hint { color: var(--danger); font-weight: 600; }
.rec-wave { display: flex; gap: 5px; justify-content: center; height: 34px; align-items: center; }
.rec-wave span { width: 6px; height: 10px; border-radius: 3px; background: var(--danger); animation: wave .9s ease-in-out infinite; }
.rec-wave span:nth-child(2) { animation-delay: .1s } .rec-wave span:nth-child(3) { animation-delay: .2s }
.rec-wave span:nth-child(4) { animation-delay: .3s } .rec-wave span:nth-child(5) { animation-delay: .4s }
@keyframes wave { 50% { height: 32px; } }

/* ---------- Xem ảnh ---------- */
.viewer { position: fixed; inset: 0; z-index: 40; background: #000; display: grid; place-items: center; }
.viewer img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.viewer-btn { position: absolute; color: #fff; background: rgba(255, 255, 255, .15); width: 44px; height: 44px; border-radius: 50%; font-size: 22px; }
.viewer-btn.close { top: calc(env(safe-area-inset-top) + 12px); right: 14px; }
.viewer-btn.prev { left: 10px; top: 50%; }
.viewer-btn.next { right: 10px; top: 50%; }
.viewer-cap { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 16px); left: 16px; right: 16px; color: #fff; text-align: center; font-size: 14px; opacity: .85; }

/* ---------- Bottom sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(11, 18, 32, .4); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet-title { padding: 4px 8px 10px; font-size: 14px; color: var(--muted); white-space: pre-wrap; max-height: 30vh; overflow: auto; }
.sheet-btn { display: block; width: 100%; text-align: left; padding: 14px 10px; border-radius: 14px; font-size: 17px; }
.sheet-btn:active { background: var(--bg); }
.sheet-btn.danger { color: var(--danger); }
.sheet-info { padding: 6px 10px 12px; font-size: 14px; line-height: 1.7; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 12px); z-index: 50; text-align: center;
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px;
  max-width: 90vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}

/* ========== v0.8: thẻ gọn cùng kích thước ========== */
.note {
  display: flex; align-items: center; gap: 12px;
  height: 92px; padding: 12px 10px 12px 14px; overflow: hidden; cursor: pointer;
  border-left: 4px solid transparent;
}
.note.important { background: color-mix(in srgb, var(--danger) 10%, var(--card)); border-left-color: var(--danger); }
.note.important .nc-text { color: color-mix(in srgb, var(--danger) 70%, var(--text)); }
.nc-thumb { width: 64px; height: 64px; flex: none; border-radius: 14px; overflow: hidden; background: var(--bg); position: relative; }
.nc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nc-thumb .count { position: absolute; right: 3px; bottom: 3px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 6px; }
.nc-icon { width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--bg); color: var(--accent); font-size: 18px; }
.nc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.nc-text { font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.nc-meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.nc-meta .tag { padding: 2px 8px; font-size: 11px; flex: none; }
.nc-flags { font-size: 12px; flex: none; }
.tag-btn {
  flex: none; align-self: center; height: 30px; padding: 0 10px; border-radius: 10px;
  background: var(--soft); color: var(--soft-text); font-size: 11px; font-weight: 800; letter-spacing: .5px;
}
.tag-btn:active { transform: scale(.95); }

/* Màn chi tiết */
.detail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.5; padding: 4px 8px 8px; max-height: 40vh; overflow: auto; }
.detail-text a { color: var(--accent); }
.detail-meta { padding: 0 8px 8px; font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.detail-imgs { display: flex; gap: 8px; overflow-x: auto; padding: 0 8px 10px; }
.detail-imgs .thumb { width: 96px; height: 96px; flex: none; }
.sheet .note-tags { padding: 0 8px 6px; margin-top: 0; }
.sheet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 4px 0; }
.sheet-row .sheet-btn { text-align: center; background: var(--bg); }
.sheet-h { font-weight: 800; font-size: 18px; padding: 2px 8px 10px; }
.sheet-sub { font-size: 13px; color: var(--muted); padding: 0 8px 10px; }

/* Bảng xác nhận lời nhắc */
.form { display: grid; gap: 10px; padding: 0 8px 6px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form input, .form textarea, .form select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; outline: none; width: 100%;
}
.form textarea { resize: none; min-height: 64px; }
.when-box { background: var(--navy); color: #fff; border-radius: 18px; padding: 12px 14px; }
.when-big { font-size: 22px; font-weight: 800; }
.when-rel { font-size: 13px; opacity: .8; margin-top: 2px; }
.btn-primary { width: 100%; padding: 14px; border-radius: 16px; background: var(--navy); color: #fff; font-weight: 700; font-size: 16px; }

/* Nút nổi "Nhập vào não" */
.clip-chip {
  position: fixed; right: 14px; z-index: 7;
  bottom: calc(82px + env(safe-area-inset-bottom));
  background: var(--navy); color: #fff; font-size: 13px; font-weight: 700;
  padding: 9px 14px; border-radius: 99px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: chipIn .25s ease-out;
}
.clip-chip::after { content: ""; position: absolute; right: 26px; bottom: -6px; border: 6px solid transparent; border-top-color: var(--navy); border-bottom: 0; }
@keyframes chipIn { from { transform: translateY(10px) scale(.9); opacity: 0; } }
.clip-preview { margin: 0 8px 12px; padding: 12px; background: var(--bg); border-radius: 16px; font-size: 14px; max-height: 26vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.clip-preview img { max-width: 100%; max-height: 22vh; border-radius: 10px; display: block; margin: 0 auto; }
.opt { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px 10px; border-radius: 16px; }
.opt:active { background: var(--bg); }
.opt-ic { width: 42px; height: 42px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--soft); font-size: 20px; }
.opt b { display: block; font-size: 16px; }
.opt span.d { font-size: 13px; color: var(--muted); }

/* ========== v0.9: trang chủ mới, nhiều màn, chuyển động ========== */
.page { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.view { min-height: 100vh; }
.view.enter-fwd { animation: viewIn .34s cubic-bezier(.2, .85, .25, 1) both; }
.view.enter-back { animation: viewBack .34s cubic-bezier(.2, .85, .25, 1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateX(46px); } }
@keyframes viewBack { from { opacity: 0; transform: translateX(-36px); } }

.anim { animation: fadeUp .46s cubic-bezier(.2, .85, .25, 1) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.list .anim { animation-delay: calc(var(--i, 0) * 28ms); }

/* Thẻ Thông tin Não */
.sys-card {
  display: block; width: 100%; text-align: left; margin-bottom: 14px;
  background: var(--card); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow);
  transition: transform .15s;
}
.sys-card:active, .brain-card:active, .hero:active, .note:active, .qa:active .qa-ic, .pw-row:active { transform: scale(.975); }
.sys-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sys-title { font-weight: 800; font-size: 15px; }
.pill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--soft); color: var(--soft-text); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: color-mix(in srgb, var(--ok) 75%, var(--text)); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: color-mix(in srgb, var(--warn) 70%, var(--text)); }
.sys-row { display: flex; justify-content: space-between; margin-top: 12px; }
.sys-right { text-align: right; }
.sys-big { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.sys-sub { font-size: 12px; color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: var(--bg); margin-top: 12px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #4b7bec, var(--navy)); transition: width 1.1s cubic-bezier(.2, .85, .25, 1); }
.sys-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); }
.chev-s { color: var(--accent); font-weight: 700; }

/* Hero sống động hơn */
.hero { background-size: 160% 160%; animation: fadeUp .46s cubic-bezier(.2, .85, .25, 1) both, heroGlow 9s ease-in-out infinite alternate; transition: transform .15s; }
@keyframes heroGlow { from { background-position: 0% 0%; } to { background-position: 100% 60%; } }
.hero-icon svg { animation: tick 2.4s ease-in-out infinite; transform-origin: 50% 55%; }
@keyframes tick { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg); } }

/* Truy cập nhanh: lưới 4 cột */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 4px; padding: 2px 2px 4px; }
.quick-row { display: none; }
.qa-ic { position: relative; transition: transform .15s, background .2s; }
.badge {
  position: absolute; top: -4px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
  background: var(--navy); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--card);
}
.badge.zero { opacity: 0; transform: scale(.6); }
.badge { transition: opacity .2s, transform .2s; }
.k-important .qa-ic { color: var(--danger); }
.k-pw .qa-ic { color: #8a5cf6; }
.k-calendar .qa-ic { color: var(--ok); }
.cat-head { margin: 16px 8px 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.cat-head:empty, .cat-row:empty { display: none; }
.cat-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 6px 4px; }
.cat {
  display: inline-flex; gap: 6px; align-items: center; padding: 7px 12px; border-radius: 99px;
  background: var(--bg); font-size: 13px; font-weight: 600; transition: transform .15s;
}
.cat:active { transform: scale(.95); }
.cat b { font-size: 11px; color: #fff; background: var(--accent); border-radius: 99px; padding: 1px 7px; }

/* Kết quả tìm kiếm ngay trên trang chủ */
.search-results { margin-top: 12px; }
.search-results .more-btn { margin-top: 4px; }
.sr-head { font-size: 12px; font-weight: 700; color: var(--muted); margin: 4px 6px 8px; text-transform: uppercase; letter-spacing: .4px; }

/* Thẻ "Toàn bộ Não" */
.brain-card {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  margin-top: 16px; padding: 14px 18px 14px 14px; border-radius: var(--r-lg);
  background: radial-gradient(120% 160% at 0% 50%, #0d3b8c 0%, #0a1430 55%, #060b1a 100%); color: #fff;
  box-shadow: 0 10px 30px rgba(13, 59, 140, .35); transition: transform .15s;
}
.brain-card img { width: 78px; height: 78px; border-radius: 20px; flex: none; animation: brainGlow 3.2s ease-in-out infinite; }
@keyframes brainGlow { 0%, 100% { filter: drop-shadow(0 0 0 rgba(80, 160, 255, 0)); transform: scale(1); } 50% { filter: drop-shadow(0 0 14px rgba(80, 160, 255, .65)); transform: scale(1.04); } }
.brain-text { flex: 1; }
.brain-title { font-size: 19px; font-weight: 800; }
.brain-sub { font-size: 13px; opacity: .75; margin-top: 2px; }
.chev { font-size: 30px; opacity: .6; }

/* Thanh tiêu đề các màn con */
.vbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.back { width: 42px; height: 42px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 28px; line-height: 1; padding-bottom: 3px; flex: none; }
.vtitle { flex: 1; min-width: 0; font-weight: 800; font-size: 19px; }
.vsub { font-size: 12px; font-weight: 600; color: var(--muted); }
.vbar .seg button { padding: 5px 9px; }
.add-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 24px; flex: none; box-shadow: 0 6px 16px rgba(22, 34, 63, .3); }
.page-list { max-width: 640px; margin: 0 auto; padding: 6px 14px calc(150px + env(safe-area-inset-bottom)); }

/* Mật khẩu */
.pw-note { max-width: 640px; margin: 0 auto; padding: 0 20px 6px; font-size: 12px; color: var(--muted); }
.pw-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin-bottom: 10px;
  background: var(--card); border-radius: var(--r); padding: 12px 16px; box-shadow: var(--shadow); transition: transform .15s;
}
.pw-av { width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; }
.pw-name { flex: 1; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-field { margin: 0 8px 10px; background: var(--bg); border-radius: 16px; padding: 10px 12px; }
.pw-field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.pw-val { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.pw-val span { flex: 1; font-size: 16px; overflow-wrap: anywhere; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.pw-val span.plain { font-family: inherit; }
.mini { padding: 6px 10px; border-radius: 10px; background: var(--card); font-size: 13px; font-weight: 700; flex: none; }
.gen-row { display: flex; gap: 8px; }
.gen-row input { flex: 1; }

/* Màn hệ thống */
.sys-sec { margin: 4px 8px 14px; }
.sys-sec h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 700; text-align: right; }
.dev-item { padding: 10px 12px; background: var(--bg); border-radius: 14px; margin-bottom: 8px; font-size: 13px; }
.dev-item .dn { font-weight: 800; font-size: 15px; }
.dev-item .me { font-size: 11px; background: var(--navy); color: #fff; padding: 1px 7px; border-radius: 99px; margin-left: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 14px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11px; color: var(--muted); }
.sheet { max-height: 88vh; overflow-y: auto; }
.center { text-align: center; }

/* Sheet & backdrop mượt hơn */
.backdrop { animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet { animation: up .3s cubic-bezier(.2, .85, .25, 1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { animation: toastIn .3s cubic-bezier(.2, .85, .25, 1); }
@keyframes toastIn { from { transform: translate(-50%, -14px); opacity: 0; } }
.viewer { animation: fade .2s ease-out; }
.viewer img { animation: zoomIn .28s cubic-bezier(.2, .85, .25, 1); }
@keyframes zoomIn { from { transform: scale(.92); opacity: 0; } }

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

/* ========== v0.9.1: trang chủ gọn trong 1 màn hình ========== */
#v-home .page {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 14px calc(84px + env(safe-area-inset-bottom));
}
#v-home .hello { margin: 0; flex: none; }
#v-home .avatar { width: 40px; height: 40px; font-size: 14px; }
#v-home .hello-name { font-size: 19px; line-height: 1.15; }
#v-home .hello-text .muted { font-size: 12px; }
#v-home .round-btn { width: 40px; height: 40px; }
#v-home .round-btn svg { width: 19px; height: 19px; }
#v-home .dot { top: 6px; right: 7px; }

#v-home .sys-card { margin: 0; padding: 10px 14px; flex: none; border-radius: 20px; }
#v-home .sys-title { font-size: 13px; }
#v-home .sys-row { margin-top: 4px; align-items: baseline; }
#v-home .sys-big { font-size: 17px; }
#v-home .sys-sub { font-size: 11px; }
#v-home .bar { height: 6px; margin-top: 6px; }
#v-home .sys-foot { display: none; }

#v-home .hero { padding: 12px 16px; flex: none; border-radius: 20px; }
#v-home .hero-label { font-size: 12px; }
#v-home .hero-time { font-size: 28px; margin-top: 0; line-height: 1.15; }
#v-home .hero-date { font-size: 12px; }
#v-home .hero-icon svg { width: 46px; height: 46px; }
#v-home .hero-text { margin-top: 4px; font-size: 14px; -webkit-line-clamp: 1; }
#v-home .hero-more { margin-top: 2px; font-size: 11px; }
#v-home .hero.hero-empty .hero-time { font-size: 22px; }

#v-home .quick { margin: 0; padding: 0 8px 10px; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; border-radius: 20px; }
#v-home .quick .section-head { margin: 10px 8px 6px; font-size: 13px; }
#v-home .quick-grid { gap: 6px 2px; flex: none; }
#v-home .qa { gap: 3px; font-size: 11px; }
#v-home .qa-ic { width: 42px; height: 42px; }
#v-home .qa-ic svg { width: 20px; height: 20px; }
#v-home .badge { min-width: 17px; height: 17px; font-size: 10px; top: -3px; right: -5px; }
#v-home .cat-head { display: none; }
#v-home .cat-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 8px 4px 0; gap: 6px; flex: none; }
#v-home .cat-row::-webkit-scrollbar { display: none; }
#v-home .cat { flex: none; padding: 5px 10px; font-size: 12px; }

#v-home .search { margin: 0; height: 44px; flex: none; }
#v-home .brain-card { margin: 0; padding: 8px 14px 8px 8px; flex: none; border-radius: 20px; gap: 12px; }
#v-home .brain-card img { width: 50px; height: 50px; border-radius: 14px; }
#v-home .brain-title { font-size: 16px; }
#v-home .brain-sub { font-size: 12px; }
#v-home .chev { font-size: 24px; }

/* Đang tìm: chỉ giữ ô tìm + kết quả */
#v-home.searching .sys-card, #v-home.searching .hero, #v-home.searching .quick, #v-home.searching .brain-card { display: none; }
#v-home .search-results { margin: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Màn hình thấp (iPhone SE…): cho phép cuộn thay vì bị cắt */
@media (max-height: 640px) {
  #v-home .page { height: auto; overflow: visible; }
}
#v-home .page { justify-content: space-between; gap: 8px; }
#v-home .quick { flex: none; }
#v-home .brain-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#v-home .brain-text { min-width: 0; }
@media (max-height: 700px) {
  #v-home .page { height: auto; min-height: 100dvh; overflow: visible; justify-content: flex-start; }
}


/* ========== v0.10 ========== */
/* Trang chủ khoá cứng: không cuộn, không nảy */
html.lock, html.lock body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.lock body { position: fixed; inset: 0; width: 100%; }
@media (max-height: 700px) {
  #v-home .page { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; justify-content: space-between; }
  #v-home .hero-text, #v-home .hero-more, #v-home .sys-sub { display: none; }
  #v-home .qa-ic { width: 36px; height: 36px; }
  #v-home .quick .section-head { margin: 6px 8px 4px; }
  #v-home .cat-row { padding-top: 4px; }
}
@media (max-height: 620px) { #v-home .cat-row, #v-home .brain-sub { display: none; } }

/* Nút Xong */
.done-btn {
  flex: none; align-self: center; height: 30px; padding: 0 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--ok) 14%, transparent); color: color-mix(in srgb, var(--ok) 80%, var(--text));
  font-size: 11px; font-weight: 800; letter-spacing: .3px; transition: transform .15s, background .2s;
}
.done-btn:active { transform: scale(.92); }
.note { padding-right: 8px; gap: 8px; }
.note .tag-btn { margin-left: -2px; }
.note.done { opacity: .55; }
.note.done .nc-text { text-decoration: line-through; }
.note.done .done-btn { background: var(--ok); color: #fff; }
.note.done-pop { animation: donePop .35s ease-out; }
@keyframes donePop { 40% { transform: scale(1.03); } }

/* Chọn giao diện */
.theme-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 8px 10px; }
.theme-opt { border-radius: 16px; padding: 10px 4px 8px; background: var(--bg); font-size: 12px; font-weight: 700; display: grid; justify-items: center; gap: 6px; border: 2px solid transparent; }
.theme-opt.active { border-color: var(--accent); }
.sw { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.sw.auto { background: linear-gradient(135deg, #eef1f6 50%, #0b1220 50%); }
.sw.light { background: linear-gradient(135deg, #ffffff 50%, #16223f 50%); }
.sw.dark { background: linear-gradient(135deg, #141c2e 50%, #9db4ff 50%); }
.sw.pink { background: linear-gradient(135deg, #ffe2ee 50%, #d23f7c 50%); }
.storage-bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; margin: 6px 0 2px; }
.storage-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
html.theme-anim *, html.theme-anim *::before { transition: background-color .45s, color .45s, border-color .45s, box-shadow .45s !important; }
