/* Nhật ký hoạt động — style theo "Style UI" (Tines: lavender observatory under glass) */
:root {
  /* Màu chủ đạo — đổi theo lựa chọn của người dùng (THEMES trong app.js ghi đè 5 biến này) */
  --ink: #4d3e78;      /* chữ chính, tiêu đề */
  --ink-2: #6956a8;    /* chữ phụ, nhãn */
  --accent: #745fbb;   /* nút chính, mục đang chọn, công tắc */
  --soft: #f3ecf7;     /* nền nhạt của mục đang chọn */
  --line: #eadff8;     /* viền, đường kẻ */
  --parchment: #fcf9f5;
  --pure: #ffffff;
  --crimson: #a53c3a;
  --fern: #1f7a57;

  --serif: 'Lora', 'Source Serif Pro', 'PT Serif', Georgia, serif;
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --r-sm: 7px;
  --r: 14px;
  --r-sheet: 21.6px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.3, .8, .25, 1);
  color-scheme: light;
}
/* Đổi màu chủ đạo mượt */
body, .btn, .tabbar, .seg, .panel, .input, .select, .chip, .cal-d, .days button, .switch input, .pill {
  transition-property: background-color, border-color, color;
  transition-duration: .3s;
}

/* 8 họ màu thẻ: nền pastel + viền 2px đậm (độc lập với màu chủ đạo) */
.fam-pink   { --tint: #ffdce8; --edge: #a54b7a; --fam-ink: #803218; }
.fam-orange { --tint: #feede0; --edge: #b74d1a; --fam-ink: #803218; }
.fam-green  { --tint: #e9f3e7; --edge: #1f7a57; --fam-ink: #195642; }
.fam-blue   { --tint: #dde8fa; --edge: #3c699b; --fam-ink: #2f5580; }
.fam-teal   { --tint: #e2f2ef; --edge: #058380; --fam-ink: #04605d; }
.fam-violet { --tint: #f3ecf7; --edge: #6956a8; --fam-ink: #4d3e78; }
.fam-yellow { --tint: #fdf3d3; --edge: #9a7206; --fam-ink: #664b04; }
.fam-red    { --tint: #fde4e2; --edge: #b3322f; --fam-ink: #7d2220; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0.007em;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.app {
  /* Cắt phần tràn ngang: hiệu ứng trượt khi chuyển tab đẩy hàng chip (sát mép) ra ngoài màn hình,
     làm trang rộng hơn màn hình → trình duyệt điện thoại tự thu nhỏ trang trong lúc chạy hiệu ứng. */
  overflow-x: hidden; overflow-x: clip;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--tabbar-h) + var(--safe-b) + 32px);
}

/* ---------- Header ---------- */
.head { position: relative; padding: 8px 0 20px; }
.eyebrow {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.title {
  font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.05;
  letter-spacing: -0.02em; margin: 8px 0 0; color: var(--ink);
}
.title em { font-style: italic; color: var(--ink-2); }
.sub { margin: 8px 0 0; color: var(--ink-2); font-size: 14px; }
.head-art { position: absolute; right: -4px; top: 0; width: 96px; height: 72px; opacity: .9; pointer-events: none; }

/* ---------- Progress ---------- */
.progress { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.progress-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.progress-txt { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

/* ---------- Home grid (specimen cards) ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card {
  position: relative;
  background: var(--tint, var(--pure));
  border: 2px solid var(--edge, var(--ink));
  border-radius: var(--r);
  padding: 14px;
  text-align: left;
  min-height: 148px;
  display: flex; flex-direction: column; gap: 10px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .12s ease, background-color .2s;
  touch-action: manipulation;
}
.card:active, .card.pressing { transform: scale(0.97); }
.card.flash { animation: flash .6s ease; }
@keyframes flash { 0% { background: var(--pure); } 100% { background: var(--tint); } }
.card .ico {
  width: 52px; height: 52px; border-radius: 12px;
  background: var(--pure); border: 1.5px solid var(--edge);
  display: grid; place-items: center; font-size: 28px; overflow: hidden; flex: none;
}
.card .ico img { width: 100%; height: 100%; object-fit: cover; }
.card .name { font-weight: 600; font-size: 16px; line-height: 1.25; color: var(--ink); word-break: break-word; }
.card .meta { margin-top: auto; font-size: 12.5px; color: var(--ink-2); line-height: 1.3; }
.card .meta b { color: var(--edge); font-weight: 600; }
.card .stamp {
  position: absolute; top: 10px; right: 10px;
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 99px;
  background: var(--edge); color: var(--pure);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.card .bell { position: absolute; top: 14px; right: 12px; width: 16px; height: 16px; color: var(--edge); opacity: .8; }
.card.done .bell { display: none; }

.card-add {
  border: 2px dashed var(--line); background: transparent; border-radius: var(--r);
  min-height: 148px; color: var(--ink-2); font-weight: 600; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.card-add .plus { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink-2); display: grid; place-items: center; }
.card-add .plus svg { width: 20px; height: 20px; }

.hint { text-align: center; font-size: 12px; color: var(--ink-2); margin: 16px 0 0; opacity: .85; }

/* ---------- Banner ---------- */
.banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--pure); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; margin-bottom: 16px; font-size: 14px;
}
.banner .b-txt { flex: 1; }
.banner .b-txt strong { display: block; font-weight: 600; }
.banner .x { flex: none; width: 32px; height: 32px; margin: -4px -6px 0 0; border: 0; border-radius: 10px; background: none; padding: 0; display: grid; place-items: center; color: var(--ink-2); }
.banner .x svg { width: 18px; height: 18px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 32px 16px; color: var(--ink-2); }
.empty svg { width: 140px; height: 96px; margin: 0 auto 12px; display: block; }
.empty h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 6px; }
.empty p { margin: 0 0 16px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border-radius: var(--r);
  font-weight: 600; font-size: 16px; letter-spacing: 0.01em;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--pure); }
.btn-danger { border-color: var(--crimson); color: var(--crimson); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.row-btns { display: flex; gap: 10px; }
.row-btns > * { flex: 1; }

/* ---------- Tab bar (nav pill) ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 12px);
  width: min(calc(100% - 32px), 420px);
  background: var(--pure); border: 1px solid var(--line); border-radius: 18px;
  padding: 5px; display: flex; gap: 4px; z-index: 20;
}
.tabbar button {
  position: relative; z-index: 1;
  flex: 1; border: 0; background: transparent; border-radius: 13px;
  padding: 8px 4px; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em; color: var(--ink-2);
  transition: color .25s;
}
.tabbar button svg { width: 22px; height: 22px; transition: transform .35s var(--ease); }
.tabbar button[aria-current="page"] { color: var(--ink); }
.tabbar button[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); }
.tabbar button:active svg { transform: scale(.9); }

/* Pill trượt: dùng chung cho thanh tab và các nút chọn (.seg). --n = số mục, --i = mục đang chọn */
.pill {
  position: absolute; z-index: 0; pointer-events: none;
  top: var(--pad); bottom: var(--pad); left: var(--pad);
  width: calc((100% - 2 * var(--pad) - (var(--n) - 1) * var(--gap)) / var(--n));
  transform: translateX(calc(var(--i, 0) * (100% + var(--gap))));
  transition: transform .42s var(--ease), background-color .3s;
  background: var(--soft); border-radius: var(--pill-r);
}
.tabbar { --n: 3; --pad: 5px; --gap: 4px; --pill-r: 13px; }

/* ---------- Segmented + chips ---------- */
.seg { position: relative; display: flex; background: var(--pure); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; --pad: 4px; --gap: 4px; --pill-r: 9px; }
.seg button { position: relative; z-index: 1; flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); transition: color .25s; }
.seg button[aria-pressed="true"] { color: var(--ink); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--line); background: var(--pure); color: var(--ink);
  border-radius: 99px; padding: 7px 13px; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.chip .e { font-size: 16px; line-height: 1; }
.chip .e img { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; }
.chip[aria-pressed="true"] { border-color: var(--edge, var(--accent)); background: var(--tint, var(--soft)); font-weight: 600; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chip .rm { flex: none; width: 22px; height: 22px; margin: -2px -6px -2px 0; border: 0; border-radius: 99px; background: none; padding: 0; display: grid; place-items: center; color: var(--ink-2); }
.chip .rm svg { width: 14px; height: 14px; }

/* ---------- History: list ---------- */
.day-group { margin-top: 20px; }
.day-h { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 8px; }
.day-h h3 { font-family: var(--serif); font-weight: 400; font-size: 20px; letter-spacing: -0.01em; margin: 0; }
.day-h span { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.list { background: var(--pure); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.entry {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: transparent; border: 0; border-top: 1px solid var(--line);
}
.entry:first-child { border-top: 0; }
.entry:active { background: var(--soft); }
.entry .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--tint); border: 1.5px solid var(--edge); display: grid; place-items: center; font-size: 20px; overflow: hidden; flex: none; }
.entry .ico img { width: 100%; height: 100%; object-fit: cover; }
.entry .txt { flex: 1; min-width: 0; }
.entry .n { font-weight: 600; font-size: 15px; }
.entry .d { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .t { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; color: var(--ink); }
.entry .src { font-size: 11px; color: var(--ink-2); }

/* ---------- History: calendar ---------- */
.cal { background: var(--pure); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-top: 16px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-nav h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; letter-spacing: -0.015em; margin: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--parchment); display: grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-2); padding: 4px 0; }
.cal-d {
  aspect-ratio: 1 / 1.08; border-radius: 10px; border: 1.5px solid transparent;
  background: transparent; padding: 4px 0 0; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.cal-d.out { opacity: .3; }
.cal-d.future { color: var(--ink-2); opacity: .45; }
.cal-d.today { border-color: var(--line); background: var(--parchment); }
.cal-d.has { background: var(--soft); }
.cal-d.hit { background: var(--tint); border-color: var(--edge); font-weight: 700; }
.cal-d { transition: background-color .25s, border-color .25s, color .25s, transform .2s var(--ease); }
.cal-d:active { transform: scale(.92); }
.cal-d.sel { background: var(--accent) !important; border-color: var(--accent) !important; color: var(--pure); opacity: 1; }
.cal-d .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: 30px; }
.cal-d .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--edge); }
.cal-d.sel .dots i { background: var(--pure); }
.cal-d .cnt { font-size: 10px; font-weight: 700; color: var(--edge); }
.cal-d.sel .cnt { color: var(--pure); }
.stat {
  display: flex; gap: 12px; margin-top: 12px;
}
.stat > div { flex: 1; background: var(--tint, var(--soft)); border: 2px solid var(--edge, var(--line)); border-radius: var(--r); padding: 12px 14px; }
.stat .num { font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -0.02em; line-height: 1; }
.stat .lbl { font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-top: 4px; letter-spacing: 0.02em; }

/* ---------- Settings ---------- */
.section { margin-top: 24px; }
/* Mục đầu tiên ngay dưới tiêu đề trang: chỉ giữ 20px của .head (bằng tab Hôm nay/Lịch sử), không cộng thêm 24px */
.head + .section { margin-top: 0; }
.section > h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; letter-spacing: -0.015em; margin: 0 0 4px; }
.section > p.desc { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.panel { background: var(--pure); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel + .panel { margin-top: 12px; }
.mrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.mrow:first-child { border-top: 0; padding-top: 0; }
.mrow .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--tint); border: 1.5px solid var(--edge); display: grid; place-items: center; font-size: 20px; overflow: hidden; flex: none; }
.mrow .ico img { width: 100%; height: 100%; object-fit: cover; }
.mrow .txt { flex: 1; min-width: 0; }
.mrow .n { font-weight: 600; }
.mrow .d { font-size: 12.5px; color: var(--ink-2); }
.mrow .acts { display: flex; gap: 4px; }
.mini { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--parchment); display: grid; place-items: center; }
.mini svg { width: 16px; height: 16px; }
.mini:disabled { opacity: .35; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 6px 0; }
.kv span:first-child { color: var(--ink-2); }
.kv span:last-child { font-weight: 600; text-align: right; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-right: 6px; vertical-align: 1px; }
.status-dot.ok { background: var(--fern); }
.status-dot.err { background: var(--crimson); }
details.help { margin-top: 12px; font-size: 14px; }
details.help summary { font-weight: 600; cursor: pointer; color: var(--accent); }
details.help ol { padding-left: 20px; margin: 8px 0 0; color: var(--ink); }
details.help li { margin-bottom: 6px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--soft); padding: 1px 5px; border-radius: 5px; }

/* Cài app ra màn hình chính */
.btn svg { width: 20px; height: 20px; flex: none; }
.install-app { display: flex; align-items: center; gap: 14px; }
.install-app img { width: 52px; height: 52px; border-radius: 12px; border: 1px solid var(--line); flex: none; }
.install-app span { display: flex; flex-direction: column; min-width: 0; }
.install-app b { font-weight: 600; font-size: 16px; }
.install-app small { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps { list-style: none; counter-reset: st; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { counter-increment: st; position: relative; padding-left: 40px; min-height: 28px; font-size: 15.5px; line-height: 1.55; }
.steps li::before {
  content: counter(st); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--pure);
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.kbd {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
  height: 28px; padding: 0 7px; margin: -2px 1px 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--pure); color: var(--ink); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.kbd svg { width: 17px; height: 17px; color: var(--accent); }
.install-note { margin: 18px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--soft); font-size: 14px; line-height: 1.5; }

/* ---------- Forms ---------- */
.field { display: block; margin-top: 16px; }
.field:first-child { margin-top: 0; }
.field > .lbl { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }
.input, textarea.input {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--pure);
  font-size: 16px; color: var(--ink); outline: none; appearance: none; -webkit-appearance: none;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--accent); }
/* Ô chọn tự thiết kế (thay <select> của trình duyệt) */
.select {
  width: 100%; min-height: 48px; padding: 12px 14px; display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--pure);
  font-size: 16px; color: var(--ink); text-align: left;
}
.select > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select svg { width: 18px; height: 18px; flex: none; color: var(--ink-2); transition: transform .3s var(--ease); }
.select[aria-expanded="true"] { border-color: var(--accent); }
.select[aria-expanded="true"] svg { transform: rotate(180deg); }
.dropdown {
  position: fixed; z-index: 70; min-width: 180px; max-height: min(320px, 60vh); overflow-y: auto;
  background: var(--pure); border: 1px solid var(--line); border-radius: var(--r); padding: 6px;
  opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top center;
  transition: opacity .18s, transform .28s var(--ease);
}
.dropdown.up { transform-origin: bottom center; transform: translateY(6px) scale(.98); }
.dropdown.show { opacity: 1; transform: none; }
.dropdown button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 44px; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent;
  font-size: 15px; font-weight: 500; color: var(--ink);
}
.dropdown button:active { background: var(--soft); }
.dropdown button > span { flex: 1; }
.dropdown button svg { width: 18px; height: 18px; flex: none; color: var(--accent); opacity: 0; }
.dropdown button[aria-selected="true"] { background: var(--soft); font-weight: 600; }
.dropdown button[aria-selected="true"] svg { opacity: 1; }
@media (hover: hover) { .dropdown button:hover { background: var(--soft); } }
.inline { display: flex; gap: 8px; align-items: center; }
.inline .input { flex: 1; }

.switch { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch .s-txt { flex: 1; }
.switch .s-txt b { display: block; font-weight: 600; font-size: 15px; }
.switch .s-txt small { color: var(--ink-2); font-size: 13px; }
.switch input { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--pure); transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }

.sub-panel { background: var(--parchment); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 4px 0 8px; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-grid button { aspect-ratio: 1; border: 1.5px solid transparent; border-radius: 10px; background: transparent; font-size: 22px; padding: 0; }
.emoji-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--soft); }

.colors { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: clamp(4px, 1.6vw, 10px); padding: 4px; }
.colors button {
  aspect-ratio: 1; width: 100%; max-width: 44px; justify-self: center; padding: 0;
  border-radius: 11px; border: 2px solid var(--edge); background: var(--tint); position: relative;
  transition: transform .2s var(--ease);
}
.colors button:active { transform: scale(.9); }
.colors button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Chọn màu chủ đạo */
.themes { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: clamp(4px, 1.6vw, 10px); padding: 4px; }
.themes button {
  aspect-ratio: 1; width: 100%; max-width: 40px; justify-self: center; padding: 0;
  border-radius: 50%; border: 0; background: var(--sw); position: relative;
  display: grid; place-items: center; color: #fff; transition: transform .2s var(--ease);
}
.themes button:active { transform: scale(.88); }
.themes button svg { width: 55%; height: 55%; opacity: 0; transform: scale(.4); transition: opacity .2s, transform .3s var(--ease); }
.themes button[aria-pressed="true"] { outline: 2px solid var(--sw); outline-offset: 2px; }
.themes button[aria-pressed="true"] svg { opacity: 1; transform: none; }
.theme-name { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.theme-name b { color: var(--ink); font-weight: 600; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days button { min-height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--pure); font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; }
.days button { transition: background-color .2s, border-color .2s, color .2s, transform .15s; }
.days button:active { transform: scale(.94); }
.days button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--pure); }

.times { display: flex; flex-direction: column; gap: 8px; }
.icon-preview { width: 72px; height: 72px; border-radius: 16px; border: 2px solid var(--edge); background: var(--tint); display: grid; place-items: center; font-size: 38px; overflow: hidden; flex: none; }
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Sheet ---------- */
.sheet-back {
  position: fixed; inset: 0; background: rgba(30, 26, 40, 0.38); background: color-mix(in srgb, var(--ink) 42%, transparent); z-index: 40;
  opacity: 0; transition: opacity .2s ease;
}
.sheet-back.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  background: var(--parchment); border-top-left-radius: var(--r-sheet); border-top-right-radius: var(--r-sheet);
  border: 1px solid var(--line); border-bottom: 0;
  max-height: calc(100dvh - var(--safe-t) - 24px); display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet.show { transform: translateY(0); }
.sheet.tall { height: calc(100dvh - var(--safe-t) - 24px); }
.sheet-grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px 8px; flex: none; }
.sheet-head h2 { flex: 1; margin: 0; font-family: var(--serif); font-weight: 400; font-size: 24px; letter-spacing: -0.015em; line-height: 1.1; }
.sheet-body { padding: 8px 16px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.sheet-foot { padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--parchment); flex: none; display: flex; flex-direction: column; gap: 8px; }
.close { flex: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--pure); padding: 0; display: grid; place-items: center; color: var(--ink); }
.close svg { width: 18px; height: 18px; }

.log-hero { display: flex; align-items: center; gap: 14px; padding: 4px 0 12px; }
.log-hero .icon-preview { width: 60px; height: 60px; font-size: 32px; }
.log-hero .t { font-family: var(--serif); font-size: 34px; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.log-hero .d { color: var(--ink-2); font-size: 14px; margin-top: 4px; }

.menu { display: flex; flex-direction: column; background: var(--pure); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.menu button { display: flex; align-items: center; gap: 12px; text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; padding: 15px 16px; font-size: 16px; font-weight: 500; }
.menu button:first-child { border-top: 0; }
.menu button svg { width: 20px; height: 20px; color: var(--ink-2); }
.menu button.danger { color: var(--crimson); }
.menu button.danger svg { color: var(--crimson); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: min(calc(100% - 32px), 420px);
  background: var(--ink); color: var(--pure); border-radius: var(--r);
  padding: 12px 12px 12px 16px; display: flex; align-items: center; gap: 12px;
  font-size: 14.5px; z-index: 60; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast .tt { flex: 1; }
.toast .tt b { font-weight: 600; }
.toast button { border: 1.5px solid rgba(255,255,255,.6); background: transparent; color: var(--pure); border-radius: 10px; padding: 7px 12px; font-weight: 600; font-size: 14px; }

.more { display: flex; justify-content: center; margin-top: 16px; }
.muted { color: var(--ink-2); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Chuyển tab: nội dung trượt nhẹ theo hướng của tab */
#view.enter-r { animation: enterR .38s var(--ease); }
#view.enter-l { animation: enterL .38s var(--ease); }
@keyframes enterR { from { opacity: 0; transform: translateX(18px); } }
@keyframes enterL { from { opacity: 0; transform: translateX(-18px); } }
#view.enter-fade { animation: enterF .3s var(--ease); }
@keyframes enterF { from { opacity: 0; transform: translateY(6px); } }

@media (min-width: 480px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
