:root {
  color-scheme: light;
  --navy: #1e2a5a;
  --navy-soft: #3b4a85;
  --ink: #1e2a5a;
  --muted: #6b7390;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e3e7f2;
  --blue: #e6efff;
  --peach: #ffe9df;
  --butter: #fff4cc;
  --lavender: #eee9ff;
  --mint: #e2f6ec;
  --mint-ink: #1d6b48;
  --red: #c2413b;
  --radius: 16px;
  --font: 'Be Vietnam Pro', -apple-system, 'SF Pro Text', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
h3 { font-size: 17px; font-weight: 600; }
p { margin: 6px 0; }
a { color: var(--navy-soft); }

.view {
  max-width: 560px;
  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: 14px; 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; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card.empty { text-align: center; padding: 28px 20px; }
.card.empty .btn { margin-top: 12px; }

/* Nút */
.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  border: 0; border-radius: 12px; padding: 10px 14px;
  cursor: pointer; min-height: 40px;
}
.btn:disabled { opacity: 0.55; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-soft { background: var(--blue); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy-soft); padding: 10px 8px; }
.btn-danger-ghost { background: transparent; color: var(--red); }
.btn-block { width: 100%; margin-top: 12px; }
.card > .btn { margin-top: 12px; }
.link-btn {
  display: block; margin: 16px auto; background: none; border: 0;
  color: var(--navy-soft); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer;
}
.banner {
  display: block; width: 100%; text-align: left; margin-bottom: 12px;
  background: var(--butter); color: var(--navy); border: 0; border-radius: 12px;
  padding: 12px 14px; font: inherit; font-weight: 600; cursor: pointer;
}

/* Thẻ nhỏ */
.chip {
  display: inline-block; font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px; background: var(--lavender); color: var(--navy);
}
.chip-soon { background: var(--peach); }
.chip-late { background: var(--red); color: #fff; }
.chip-done { background: var(--mint); color: var(--mint-ink); }
.chip-habit { background: var(--butter); }

/* Thói quen hằng ngày */
.habits { list-style: none; padding: 0; margin: 0; }
.habit { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.habit:first-child { border-top: 0; padding-top: 0; }
.habit b { display: block; }
.habit.is-done b { color: var(--mint-ink); }
.kind-picker { display: flex; gap: 16px; flex-wrap: wrap; }
form:has(input[value='thoi-quen']:checked) .only-course { display: none; }
form:has(input[value='khoa-hoc']:checked) .only-habit { display: none; }

/* Cam kết */
.commit-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.commit .time { font-size: 20px; font-weight: 700; }
.commit.is-done { background: #fbfdfc; border-color: #cdebdc; }
.lesson { color: var(--navy-soft); }
.why, .done-def { border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.why { background: var(--blue); }
.done-def { background: var(--butter); }
.notes { border-left: 3px solid var(--mint); padding-left: 10px; margin-top: 8px; }
.insight { font-style: italic; color: var(--navy-soft); }
.sentence { line-height: 2.4; margin: 0 0 4px; }
.sentence input, .sentence select { width: auto; display: inline-block; margin: 0 2px; }
.sentence input[type='number'] { width: 72px; }
.sentence select { max-width: 100%; }
details > summary { cursor: pointer; font-weight: 600; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ' ▾'; color: var(--muted); }
details[open] > summary { margin-bottom: 10px; }
details.group > summary h2 { display: inline; }

/* Khóa học */
.group { margin-top: 20px; }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 10px; }
.course-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }

/* Biểu mẫu */
label { display: block; font-size: 14px; font-weight: 500; margin-top: 12px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-soft); outline-offset: 0; }
textarea { resize: vertical; }
.error-text { color: var(--red); font-size: 14px; }
.steps { padding-left: 20px; line-height: 1.8; }

/* Màn đăng nhập */
.login { text-align: center; padding-top: 40px; }
.login form { text-align: left; margin-top: 20px; }
.logo-mark {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px;
  background: var(--navy); color: var(--butter); font-size: 34px; font-weight: 700;
  display: grid; place-items: center;
}

/* Thanh tab */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; gap: 4px;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
}
.tab {
  flex: 1; max-width: 180px; font: inherit; font-size: 14px; font-weight: 600;
  background: none; border: 0; border-radius: 12px; padding: 10px 4px; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--blue); color: var(--navy); }

/* Bảng trượt */
.sheet {
  width: min(560px, 100%); max-height: 88vh; margin: auto auto 0;
  border: 0; border-radius: 20px 20px 0 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px);
  background: var(--card); color: var(--ink);
}
.sheet::backdrop { background: rgba(30, 42, 90, 0.35); }
.journal { list-style: none; padding: 0; margin: 0; }
.journal-item { border-bottom: 1px solid var(--line); padding: 10px 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 20;
  max-width: calc(100% - 32px); background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 20px rgba(30, 42, 90, 0.25);
}
.toast-error { background: var(--red); }
