:root {
  color-scheme: light;
  --navy: #1e2a5a;
  --navy-soft: #3b4a85;
  --ink: #1e2a5a;
  --muted: #6b7390;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e3e7f2;
  --paper: #fffdf8;
  /* Mỗi nhóm một màu pastel */
  --g-viet-tot-hon: #e6efff;
  --g-content: #ffe9df;
  --g-y-tuong: #fff4cc;
  --g-tri-lieu: #e2f6ec;
  --g-viet-sach: #eee9ff;
  --red: #c2413b;
  --radius: 16px;
  --font: 'Be Vietnam Pro', -apple-system, 'SF Pro Text', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; text-wrap: balance; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; margin: 22px 0 10px; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy-soft); margin-bottom: 6px; }
p { margin: 6px 0; }
a { color: var(--navy-soft); }

.view { max-width: 620px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 96px); }
.page-head { margin-bottom: 16px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-size: 14px; }

.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; color: inherit; text-decoration: none; }
.card.empty { text-align: center; padding: 28px 20px; }
.note { background: var(--g-y-tuong); border-radius: 12px; padding: 12px 14px; }
.chip { font-size: 11px; font-weight: 600; background: var(--g-viet-sach); color: #4b3a8c; padding: 2px 8px; border-radius: 99px; vertical-align: middle; }

/* Nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--navy); font: 600 15px var(--font); text-decoration: none; cursor: pointer; }
.btn:focus-visible, .input:focus-visible, .editor:focus-visible, summary:focus-visible { outline: 2px solid var(--navy-soft); outline-offset: 2px; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-danger { color: var(--red); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 14px; margin: 4px 6px 4px 0; }
.btn:disabled { opacity: 0.6; }

/* Đăng nhập */
.login { padding-top: 12vh; display: flex; flex-direction: column; gap: 12px; }
.brand { font-weight: 700; color: var(--navy-soft); letter-spacing: 0.04em; }
.label { font-weight: 600; font-size: 14px; }
.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; font: 17px var(--font); color: var(--ink); background: var(--card); }
.error { color: var(--red); }

/* Trang chính */
.streak .big { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dots { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; margin-top: 12px; }
.dot { aspect-ratio: 1; border-radius: 6px; background: var(--line); }
.dot.on { background: var(--navy-soft); }
.dot.today { outline: 2px solid var(--navy); outline-offset: 1px; }
.group { border-left: 6px solid var(--line); }
.group-head { display: flex; gap: 12px; align-items: flex-start; color: inherit; text-decoration: none; }
.count { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.bar { height: 6px; border-radius: 99px; background: var(--bg); margin-top: 12px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--navy-soft); border-radius: 99px; }
.next { margin-top: 12px; font-weight: 500; }
.group-viet-tot-hon { border-left-color: #a9c4f5; }
.group-content { border-left-color: #f5b99d; }
.group-y-tuong { border-left-color: #f0d266; }
.group-tri-lieu { border-left-color: #93d8b6; }
.group-viet-sach { border-left-color: #c3b4f5; }
.page-head.group-viet-tot-hon, .page-head.group-content, .page-head.group-y-tuong, .page-head.group-tri-lieu, .page-head.group-viet-sach { border-left: 6px solid; padding-left: 12px; }

/* Danh sách đề */
.prompt-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.prompt-item + .prompt-item { border-top: 1px solid var(--line); }
.prompt-item a, .prompt-item.locked span { display: flex; justify-content: space-between; gap: 12px; padding: 13px 16px; color: inherit; text-decoration: none; }
.prompt-item.done a { color: var(--muted); }
.prompt-item.locked { color: var(--muted); }
.video-item { display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.video-item + .video-item { border-top: 1px solid var(--line); }
.video-item input { width: 20px; height: 20px; flex: none; accent-color: var(--navy); }
.video-item a { flex: 1; padding: 13px 0; color: inherit; text-decoration: none; }
.tick { flex: none; font-size: 12px; font-weight: 600; color: #1d6b48; background: var(--g-tri-lieu); border-radius: 99px; padding: 2px 8px; height: fit-content; }

/* Màn hình viết */
.write-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; justify-content: space-between; align-items: center; background: var(--bg); padding: 8px 0; }
.write-top .back { margin: 0; }
.timer { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.timer.over { background: var(--g-tri-lieu); color: #1d6b48; border-color: transparent; }
.prompt summary { cursor: pointer; list-style: none; }
.prompt summary::-webkit-details-marker { display: none; }
.prompt summary b { display: block; }
.prompt-body { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.prompt-title { font-size: 20px; margin-bottom: 8px; }
.lead { color: var(--ink); }
.pblock { margin-top: 14px; }
.pblock ul { margin: 4px 0; padding-left: 20px; }
.pblock.task { background: var(--bg); border-radius: 12px; padding: 12px 14px; }
details.pblock summary { cursor: pointer; font-weight: 600; color: var(--navy-soft); }
.frame { white-space: pre-wrap; font: 14px/1.6 var(--font); background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 6px 0 0; }
.safety { margin-top: 14px; background: var(--g-tri-lieu); border-radius: 12px; padding: 12px 14px; }
.goal { background: var(--g-tri-lieu); color: #1d6b48; border-radius: 12px; padding: 10px 14px; font-weight: 500; }
.editor { width: 100%; min-height: 55vh; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); font: 17px/1.75 var(--font); resize: vertical; }
.write-bottom { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bg); padding: 12px 0 calc(env(safe-area-inset-bottom) + 12px); }

/* Xong buổi viết, đọc lại */
.done { padding-top: 8vh; display: flex; flex-direction: column; gap: 10px; }
.done-stats { font-size: 18px; }
.entry { display: flex; flex-direction: column; gap: 2px; border-left-width: 6px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reading-body { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 14px; font-size: 17px; line-height: 1.75; overflow-wrap: anywhere; }
.donate { background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }

/* Thanh dưới */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--line); padding: 8px max(16px, env(safe-area-inset-left, 0px)) calc(env(safe-area-inset-bottom) + 8px) max(16px, env(safe-area-inset-right, 0px)); }
.tab { flex: 1; max-width: 180px; text-align: center; padding: 10px 4px; white-space: nowrap; font-size: 14px; border-radius: 12px; color: var(--muted); font-weight: 600; text-decoration: none; }
.tab.active { background: var(--g-viet-tot-hon); color: var(--navy); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px); max-width: 520px; margin: 0 auto; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 20; }
.toast-error { background: var(--red); }

.input.time { width: auto; min-width: 120px; }
#remind .label { width: 100%; }

/* Landing page */
.landing { display: flex; flex-direction: column; gap: 36px; }
.hero { padding-top: 6vh; display: flex; flex-direction: column; gap: 14px; }
.hero h1 { font-size: clamp(28px, 7vw, 40px); line-height: 1.2; }
.hero-sub { font-size: 17px; color: var(--muted); max-width: 60ch; }
.land-block { display: flex; flex-direction: column; gap: 12px; }
.land-block h2 { margin: 0; font-size: 20px; }
.land-block.card { padding: 20px; gap: 10px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.land-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.land-groups .card { margin: 0; }
.sample { background: var(--paper); }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Trang quản lý */
.wait-item { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.wait-item .row { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
textarea.input { min-height: 120px; font-size: 15px; resize: vertical; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.word-count { font-size: 16px; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }
