/* Lịch · CB Family */

:root {
  --bg: #0a0908;
  --bg-2: #0f0e0c;
  --surface: #151311;
  --surface-2: #1c1916;
  --line: #262220;
  --line-strong: #3a342e;
  --text: #efe8dc;
  --text-2: #a9a094;
  --text-3: #6f685e;
  --gold: #c9a35c;
  --gold-2: #e8cb8e;
  --gold-soft: rgba(201, 163, 92, 0.12);
  --red: #e36d5d;
  --red-soft: rgba(227, 109, 93, 0.12);
  --blue: #7fa3d6;
  --vn: #e8cb8e;
  --on-gold: #17130d;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);

  --c-birthday: #e59bb0;
  --c-memorial: #b6a3e3;
  --c-anniversary: #e8cb8e;
  --c-event: #7fb8d9;
  --c-other: #9fbf8f;

  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --gutter: clamp(16px, 4vw, 40px);
  --wrap: 1320px;
  --radius: 14px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f2ea;
  --bg-2: #efe9de;
  --surface: #fffdf8;
  --surface-2: #f7f2e8;
  --line: #e6ddcd;
  --line-strong: #d4c8b4;
  --text: #1f1b16;
  --text-2: #5f574c;
  --text-3: #958b7c;
  --gold: #9a7634;
  --gold-2: #8a6a2c;
  --gold-soft: rgba(154, 118, 52, 0.1);
  --red: #c0392b;
  --red-soft: rgba(192, 57, 43, 0.08);
  --blue: #2f5f9e;
  --vn: #8a6a2c;
  --on-gold: #fffdf8;
  --shadow: 0 24px 60px rgba(60, 45, 20, 0.18);

  --c-birthday: #c2466b;
  --c-memorial: #6b51b5;
  --c-anniversary: #a07a2c;
  --c-event: #2a77a8;
  --c-other: #4d7a3c;
  color-scheme: light;
}

[data-c="birthday"] { --c: var(--c-birthday); }
[data-c="memorial"] { --c: var(--c-memorial); }
[data-c="anniversary"] { --c: var(--c-anniversary); }
[data-c="event"] { --c: var(--c-event); }
[data-c="other"] { --c: var(--c-other); }
[data-c="jp"] { --c: var(--red); }
[data-c="vn"] { --c: var(--vn); }
[data-c="gold"] { --c: var(--gold); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 50% -200px, rgba(201, 163, 92, 0.08), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="light"] body { background-image: radial-gradient(1200px 600px at 50% -200px, rgba(154, 118, 52, 0.08), transparent 70%); }

[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

em { font-style: italic; color: var(--gold-2); font-family: var(--serif); }

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}
/* Số ngày dùng font không chân để có chữ số thẳng hàng, dễ đọc */
.solar, .dp-big, .up-date b, .hol-date b, .today-card strong, .title-year { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.display {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.01em;
}
.display em { font-weight: 500; }

/* ---------- Thanh trên ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  color: var(--gold-2);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.brand-name { font-family: var(--serif); font-style: italic; font-size: 24px; color: var(--gold-2); line-height: 1; }

.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  background: none;
  border: 0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  transition: color .2s, background .2s;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--gold-2); background: var(--gold-soft); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-2);
  display: inline-grid; place-items: center;
  transition: color .2s, border-color .2s, background .2s;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--gold-2); border-color: var(--gold); }
.icon-btn svg { width: 18px; height: 18px; }

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 3px 14px 3px 3px;
  max-width: 220px;
}
.user-btn:hover { border-color: var(--gold); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold-2);
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  flex-shrink: 0;
}
.user-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.menu > * {
  text-align: left; background: none; border: 0; border-radius: 8px;
  padding: 10px 12px; font-size: 14px; text-decoration: none; color: var(--text);
}
.menu > *:hover { background: var(--surface-2); color: var(--gold-2); }

main { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter) 80px; }
.boot { padding: 120px 0; text-align: center; color: var(--text-3); letter-spacing: .2em; text-transform: uppercase; font-size: 12px; }

/* ---------- Nút & biểu mẫu ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  border: 1px solid transparent;
  background: none;
  transition: background .2s, color .2s, border-color .2s, opacity .2s;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn-ghost { border-color: var(--line-strong); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-2); }
.btn-danger { border-color: color-mix(in srgb, var(--red) 50%, transparent); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn[disabled] { opacity: .55; pointer-events: none; }

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.field > span {
  font-size: 10.5px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text-3); font-weight: 500;
}
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 11px 13px;
  font-size: 15px;
  transition: border-color .2s, background .2s;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type="date"], input[type="month"] { color-scheme: inherit; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator { filter: invert(0.8) sepia(0.4); }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--gold); flex-shrink: 0; }
.check small { color: var(--text-3); }
.form-error { margin: 0; min-height: 0; color: var(--red); font-size: 13.5px; }
.form-error:empty { display: none; }
.form-hint { margin: 0; color: var(--text-3); font-size: 13px; }
.auth-note { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); line-height: 1.6; }
.auth-note a { color: var(--gold-2); white-space: nowrap; }
.login-btn { padding: 9px 16px; }
.guest-cta { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 8px; padding: 3px; gap: 3px; }
.seg-btn {
  flex: 1; border: 0; background: none; border-radius: 6px;
  padding: 8px 10px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2);
}
.seg-btn[aria-selected="true"], .seg-btn[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold-2); }
.seg-tabs { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0; margin-bottom: 22px; }
.seg-tabs .seg-btn { border-radius: 0; padding: 12px 6px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.seg-tabs .seg-btn[aria-selected="true"] { background: none; border-bottom-color: var(--gold); }

/* ---------- Đăng nhập ---------- */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  padding: clamp(48px, 9vh, 110px) 0;
}
.auth-hero .display { font-size: clamp(56px, 9vw, 116px); margin-bottom: 28px; }
.lead { color: var(--text-2); font-size: 16.5px; max-width: 34em; margin: 0 0 24px; }
.checks { list-style: none; padding: 0; margin: 0 0 32px; display: flex; flex-direction: column; gap: 10px; }
.checks li { position: relative; padding-left: 28px; color: var(--text-2); font-size: 14.5px; }
.checks li::before {
  content: ""; position: absolute; left: 2px; top: 7px;
  width: 11px; height: 6px;
  border-left: 1.5px solid var(--gold); border-bottom: 1.5px solid var(--gold);
  transform: rotate(-45deg);
}
.today-card {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; background: var(--surface);
  font-size: 14px; color: var(--text-2);
}
.today-card strong { font-size: 16px; color: var(--text); font-weight: 500; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(24px, 3.5vw, 40px);
}
.card-title { font-family: var(--serif); font-weight: 500; font-size: 34px; margin: 0 0 22px; line-height: 1.1; }

/* ---------- Đầu tháng ---------- */
.month-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 36px 0 24px;
}
.month-title { font-size: clamp(40px, 6vw, 68px); }
.title-year { font-size: 0.42em; font-weight: 300; color: var(--text-2); letter-spacing: 0.02em; margin-left: 0.25em; vertical-align: 0.35em; }
.month-sub { margin: 10px 0 0; color: var(--text-2); font-size: 14px; }
.month-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-jump input { width: auto; padding: 8px 10px; font-size: 13px; }

/* ---------- Lưới tháng ---------- */
.month-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.cal { min-width: 0; }
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin-bottom: 8px; }
.weekdays div {
  text-align: center; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-3); padding: 6px 0;
}
.weekdays .wd-sun { color: var(--red); }
.weekdays .wd-sat { color: var(--blue); }
.weekdays small { display: block; letter-spacing: 0; font-size: 11px; opacity: .7; }

.grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
  gap: 1px;
  touch-action: pan-y;
}
.cell {
  position: relative;
  background: var(--surface);
  border: 0;
  text-align: left;
  padding: 8px 9px 7px;
  min-height: 118px;
  display: flex; flex-direction: column; gap: 3px;
  transition: background .15s;
  min-width: 0;
  overflow: hidden;
}
.cell:hover { background: var(--surface-2); }
.cell.other { background: var(--bg-2); }
.cell.other > * { opacity: .45; }
.cell-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.solar { font-size: 20px; line-height: 1; font-weight: 400; letter-spacing: -0.01em; }
.lunar { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.lunar.first, .lunar.full { color: var(--gold); font-weight: 500; }
.cell.red .solar { color: var(--red); }
.cell.sat .solar { color: var(--blue); }
.cell.red { background: color-mix(in srgb, var(--surface) 92%, var(--red)); }
.cell.red.other { background: color-mix(in srgb, var(--bg-2) 94%, var(--red)); }
.cell.today .solar {
  display: inline-grid; place-items: center;
  min-width: 30px; height: 30px; margin: -5px 0 -5px -6px; padding: 0 4px;
  border-radius: 999px; background: var(--gold); color: var(--on-gold);
  font-size: 17px; font-weight: 500;
}
.cell.selected { box-shadow: inset 0 0 0 1.5px var(--gold); z-index: 1; }
.tag {
  font-size: 11.5px; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tag-jp { color: var(--red); font-weight: 500; }
.tag-vn { color: var(--vn); }
.chips { display: flex; flex-direction: column; gap: 2px; margin-top: auto; min-width: 0; }
.chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; line-height: 1.5;
  padding: 1px 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.more { font-size: 11px; color: var(--text-3); padding-left: 6px; }
.dots { display: none; gap: 3px; margin-top: auto; flex-wrap: wrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 14px 4px 0; font-size: 12.5px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-red { background: var(--red); }
.lg-vn { background: var(--vn); }
.lg-lunar { border: 1.5px solid var(--gold); border-radius: 50%; }
.lg-today { background: var(--gold); border-radius: 50%; }

/* ---------- Bảng bên ---------- */
.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; }
.panel-title { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 0; line-height: 1.1; }
.panel-meta { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; }
@media (max-width: 640px) { .panel-meta { white-space: normal; letter-spacing: .12em; } }

.dp-date { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.dp-big { font-size: 56px; line-height: .9; font-weight: 300; letter-spacing: -0.03em; }
.dp-big.red { color: var(--red); }
.dp-big.sat { color: var(--blue); }
.dp-weekday { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.dp-full { font-size: 15px; color: var(--text); }
.dp-lunar { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 14px; }
.dp-label { font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.dp-lunar-main { font-family: var(--serif); font-size: 21px; line-height: 1.25; }
.dp-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 10px 0 0; font-size: 13px; }
.dp-meta dt { color: var(--text-3); }
.dp-meta dd { margin: 0; color: var(--text-2); }
.dp-hours { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.dp-hours summary { cursor: pointer; color: var(--text-3); list-style: none; }
.dp-hours summary::-webkit-details-marker { display: none; }
.dp-hours summary::after { content: " ▾"; }
.dp-hours[open] summary::after { content: " ▴"; }
.dp-hours p { margin: 6px 0 0; line-height: 1.7; }
.badges { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.badge { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; border-radius: 8px; padding: 8px 12px; font-size: 13.5px; }
.badge-jp { background: var(--red-soft); color: var(--red); }
.badge-jp small { color: var(--text-2); font-size: 12.5px; }
.badge-vn { background: var(--gold-soft); color: var(--gold-2); }
.dp-events { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ev {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: start;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: var(--bg-2); cursor: pointer; text-align: left; width: 100%;
}
.ev:hover { border-color: var(--line-strong); }
.ev-bar { align-self: stretch; border-radius: 4px; background: var(--c); }
.ev-title { display: block; font-weight: 500; font-size: 14.5px; line-height: 1.4; word-break: break-word; }
.ev-meta { display: block; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.ev-note { display: block; font-size: 13px; color: var(--text-2); margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.minw0 { min-width: 0; }
.jp-text { color: var(--red); }
.ev-count { font-size: 12px; color: var(--gold-2); white-space: nowrap; }
.empty { color: var(--text-3); font-size: 13.5px; margin: 0 0 14px; }
.day-panel .btn { width: 100%; }

.upcoming { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.up {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left;
}
.upcoming li:first-child .up { border-top: 0; padding-top: 0; }
.up-date { text-align: center; line-height: 1.1; }
.up-date b { display: block; font-size: 19px; font-weight: 400; }
.up-date span { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.up-title { font-size: 14px; line-height: 1.4; display: flex; align-items: center; gap: 8px; min-width: 0; }
.up-title i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.up-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-sub { display: block; font-size: 12px; color: var(--text-3); padding-left: 15px; }
.up-left { font-size: 12px; color: var(--text-2); white-space: nowrap; text-align: right; }
.up-left.soon { color: var(--gold-2); }
.up.holiday .up-title i { border-radius: 2px; }

/* ---------- Lịch năm ---------- */
.year-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.ym {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 12px 12px; min-width: 0; display: flex; flex-direction: column;
}
.ym.current { border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.ym-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 8px; min-width: 0; }
.ym-title {
  background: none; border: 0; padding: 0; color: var(--text); text-align: left;
  font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1.1; white-space: nowrap;
}
.ym-title:hover, .ym-title:hover em { color: var(--gold-2); }
.ym-range { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ym-wd, .ym-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ym-wd span { text-align: center; font-size: 10px; letter-spacing: .06em; color: var(--text-3); padding: 0 0 4px; }
.ym-wd .wd-sun { color: var(--red); }
.ym-wd .wd-sat { color: var(--blue); }
.ym-days { row-gap: 2px; }
.ym-cell {
  position: relative; border: 0; background: none; border-radius: 6px; padding: 4px 0 3px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--text);
  font-variant-numeric: tabular-nums; transition: background .15s;
}
.ym-cell:hover { background: var(--surface-2); }
.ym-cell.blank { visibility: hidden; }
.ym-s { font-size: 13.5px; line-height: 1.15; }
.ym-l { font-size: 9.5px; line-height: 1.1; color: var(--text-3); }
.ym-cell.lf .ym-l { color: var(--gold); font-weight: 500; }
.ym-cell.red { color: var(--red); }
.ym-cell.sat { color: var(--blue); }
.ym-cell.jp { background: var(--red-soft); }
.ym-cell.jp:hover { background: color-mix(in srgb, var(--red) 18%, transparent); }
.ym-cell.today { background: var(--gold); color: var(--on-gold); }
.ym-cell.today .ym-l { color: inherit; opacity: .75; }
.ym-cell.vn::after {
  content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 12px; height: 2px; border-radius: 2px; background: var(--vn);
}
.ym-cell.has-ev::before {
  content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--c);
}
.ym-list { list-style: none; margin: 10px 2px 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.ym-list li { display: flex; gap: 8px; font-size: 12px; line-height: 1.5; min-width: 0; }
.ym-list b { color: var(--red); font-weight: 500; min-width: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.ym-list .vn b { color: var(--vn); }
.ym-list span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-ev { background: var(--c-event); border-radius: 50%; }

/* ---------- Ngày lễ trong năm ---------- */
.hol-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.hol-side { display: flex; flex-direction: column; gap: 24px; }
.hol-list { list-style: none; margin: 0; padding: 0; }
.hol {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center;
  padding: 11px 0; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer;
}
.hol-list li:first-child .hol { border-top: 0; padding-top: 2px; }
.hol.past { opacity: .5; }
.hol-date b { font-size: 17px; font-weight: 500; display: block; line-height: 1.2; }
.hol-date span { font-size: 11px; color: var(--text-3); }
.hol-date.red b { color: var(--red); }
.hol-name { font-size: 14.5px; line-height: 1.4; }
.hol-name small { display: block; color: var(--text-3); font-size: 12.5px; }
.hol-left { font-size: 12px; color: var(--text-2); text-align: right; white-space: nowrap; }
.hol-left.soon { color: var(--gold-2); }

/* ---------- Ghi chú ---------- */
.notes-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.search { flex: 1 1 260px; max-width: 420px; }
.chips-filter, .chips-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip {
  border: 1px solid var(--line-strong); background: none; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px;
}
.fchip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-3)); }
.fchip[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-2); background: var(--gold-soft); }
.notes-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.note {
  display: grid; grid-template-columns: 4px 1fr; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; text-align: left; width: 100%; height: 100%; cursor: pointer;
}
.note:hover { border-color: var(--line-strong); }
.note-next { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.note-next b { color: var(--gold-2); font-weight: 500; white-space: nowrap; }
.notes-empty { grid-column: 1 / -1; text-align: center; color: var(--text-3); padding: 60px 0; }

/* ---------- Quản trị ---------- */
.admin-login { display: grid; place-items: center; padding: clamp(40px, 10vh, 120px) 0; }
.admin-login .auth-card { width: min(440px, 100%); }
.admin-table-wrap { padding: 6px 20px; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-3); font-weight: 500; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table td b { color: var(--text); font-weight: 500; }
.admin-table code, .auth-note code { font-size: 13px; color: var(--gold-2); }
.admin-actions { text-align: right; }
.admin-actions .btn { padding: 7px 14px; }
.admin-content { max-width: 760px; gap: 20px; }
.field-default { color: var(--text-3); font-size: 12px; line-height: 1.5; }
@media (max-width: 700px) {
  .admin-table thead { display: none; }
  .admin-table tr { display: grid; grid-template-columns: 1fr auto; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .admin-table tr:last-child { border-bottom: 0; }
  .admin-table td { border: 0; padding: 2px 0; font-size: 13px; }
  .admin-table td[data-label]::before { content: attr(data-label) ": "; color: var(--text-3); }
  .admin-table td:first-child { grid-column: 1; font-size: 15px; }
  .admin-table td:first-child::before { content: none; }
  .admin-table td.admin-actions { grid-column: 2; grid-row: 1 / span 5; align-self: center; }
}

/* Tứ hành xung */
:root { --el-moc: #7fbf8a; --el-hoa: #e8836a; --el-tho: #c9a35c; --el-kim: #b9c2cc; --el-thuy: #6fa8dc; --ok: #7fbf8a; }
:root[data-theme="light"] { --el-moc: #3d8a4c; --el-hoa: #c2502f; --el-tho: #9a7634; --el-kim: #6b7784; --el-thuy: #2f6fa8; --ok: #2f7a3e; }
.el-moc { --e: var(--el-moc); } .el-hoa { --e: var(--el-hoa); } .el-tho { --e: var(--el-tho); } .el-kim { --e: var(--el-kim); } .el-thuy { --e: var(--el-thuy); }

.tv-form { margin-bottom: 16px; }
.tv-form .form-error { margin-top: 10px; }
.tv-form-row { display: grid; grid-template-columns: minmax(0, 1.1fr) auto minmax(0, 1.6fr) auto; gap: 12px; align-items: end; }
.tv-f-cal .seg-btn { white-space: nowrap; }
.tv-f-btns { display: flex; gap: 8px; }
.tv-f-btns .btn { height: 44px; }
.tv-lunar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, .9fr); gap: 8px; }
.tv-lunar select { padding-left: 11px; padding-right: 28px; background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; }

#tuvi-body { display: flex; flex-direction: column; gap: 16px; }

/* Danh sách */
.tv-list { list-style: none; margin: 0; padding: 0; }
.tv-row {
  display: grid; grid-template-columns: 48px minmax(150px, 1.4fr) minmax(110px, .9fr) minmax(150px, 1fr) minmax(110px, .9fr) auto;
  gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); transition: opacity .2s;
}
.tv-row:first-child { border-top: 0; padding-top: 2px; }
.tv-row.off { opacity: .45; }
.tv-avatar {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 26px;
  background: color-mix(in srgb, var(--e) 16%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--e) 55%, transparent);
}
.tv-who, .tv-age { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.tv-who b { font-family: var(--serif); font-size: 21px; font-weight: 500; }
.tv-who small, .tv-age small, .tv-src { color: var(--text-3); font-size: 12.5px; }
.tv-age b { font-weight: 500; color: var(--gold-2); }
.tv-el { justify-self: start; font-size: 13px; padding: 4px 10px; border-radius: 999px; color: var(--e); background: color-mix(in srgb, var(--e) 13%, transparent); white-space: nowrap; }
.tv-acts { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.tv-acts .btn { padding: 7px 12px; font-size: 11px; }
.tv-del:hover { color: var(--red); border-color: var(--red); }
.tv-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; margin-right: 4px; }
.tv-switch input { width: 17px; height: 17px; accent-color: var(--gold); margin: 0; }

/* Biểu đồ */
.tv-charts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.tv-chart { margin: 0; display: flex; flex-direction: column; }
.tv-svg { width: 100%; max-width: 380px; align-self: center; height: auto; overflow: visible; }
.tv-svg text { text-anchor: middle; font-family: var(--sans); }
.wring { fill: none; stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 4; }
.wn circle { fill: var(--bg-2); stroke: var(--line-strong); stroke-width: 1; }
.wn .wn-emoji { font-size: 20px; opacity: .35; }
.wn .wn-name { font-size: 10.5px; fill: var(--text-3); }
.wn.on circle { fill: var(--gold-soft); stroke: var(--gold); stroke-width: 2; }
.wn.on .wn-emoji { opacity: 1; }
.wn.on .wn-name { fill: var(--gold-2); font-weight: 600; }
.wl { stroke-width: 2.5; stroke-linecap: round; }
.wl.hop { stroke: var(--ok); }
.wl.luchop { stroke: var(--el-thuy); }
.wl.xung { stroke: var(--red); }
.wl.xung2 { stroke: var(--red); stroke-dasharray: 5 5; opacity: .7; }
.el-line { stroke-width: 2; fill: none; }
.el-line.sinh { stroke: var(--line-strong); }
.el-line.sinh.active { stroke: var(--ok); stroke-width: 3; }
.el-line.khac { stroke: var(--line); stroke-dasharray: 4 5; }
.el-line.khac.active { stroke: var(--red); opacity: .75; }
.m-sinh { fill: var(--ok); } .m-mute { fill: var(--line-strong); } .m-khac { fill: var(--red); }
.en circle { fill: var(--bg-2); stroke: color-mix(in srgb, var(--e) 40%, transparent); stroke-width: 1.5; }
.en .en-emoji { font-size: 20px; opacity: .45; }
.en .en-name { font-size: 11px; fill: var(--text-3); }
.en.on circle { fill: color-mix(in srgb, var(--e) 18%, var(--surface)); stroke: var(--e); stroke-width: 2.5; }
.en.on .en-emoji { opacity: 1; }
.en.on .en-name { fill: var(--text); font-weight: 600; }
.en.on .en-badge circle { fill: var(--e); stroke: var(--surface); stroke-width: 2; }
.en.on .en-badge text { font-size: 11px; font-weight: 700; fill: #111; }
.tv-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-3); }
.tv-legend li { display: inline-flex; align-items: center; gap: 7px; }
.lg-line { display: inline-block; width: 22px; height: 0; border-top: 3px solid; }
.lg-line.hop, .lg-line.sinh { border-color: var(--ok); }
.lg-line.luchop { border-color: var(--el-thuy); }
.lg-line.xung { border-color: var(--red); }
.lg-line.xung2, .lg-line.khac { border-color: var(--red); border-top-style: dashed; }
.tv-chart figcaption { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--text-2); }
.tv-chart figcaption b { color: var(--text); font-weight: 500; }

/* Bảng ngũ hành */
.tv-et-wrap { overflow-x: auto; }
.tv-et { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tv-et thead th { text-align: left; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-3); font-weight: 500; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tv-et tbody th, .tv-et td { text-align: left; vertical-align: top; padding: 12px; border-bottom: 1px solid var(--line); font-weight: 400; }
.tv-et tbody tr:last-child th, .tv-et tbody tr:last-child td { border-bottom: 0; }
.tv-et tbody tr.has th { background: var(--gold-soft); }
.tv-et tbody th { width: 26%; }
.tv-et small { display: block; color: var(--text-3); font-size: 12.5px; line-height: 1.5; margin-top: 4px; }
.tv-et .tv-el { display: inline-block; }
.tv-et-rel { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tv-et td.sinh .tv-et-rel::before { content: "➜"; color: var(--ok); font-weight: 700; }
.tv-et td.khac .tv-et-rel::before { content: "✕"; color: var(--red); font-weight: 700; }
.tv-et small.tv-et-who { color: var(--gold-2); }
.tv-et small.tv-et-who::before { content: "👤 "; }
.tv-et-sub { margin: 18px 0 8px; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-3); font-weight: 500; }
.tv-et-grid { border-collapse: separate; border-spacing: 4px; font-size: 12.5px; min-width: 100%; }
.tv-et-grid th { font-weight: 500; color: var(--text-2); padding: 4px 8px; white-space: nowrap; }
.tv-et-grid thead th { text-align: center; }
.tv-et-grid thead th span { display: block; font-size: 11.5px; }
.tv-et-grid tbody th { text-align: left; }
.tv-et-grid td { text-align: center; border-radius: 8px; padding: 9px 6px; white-space: nowrap; min-width: 82px; }
.et-sinh { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); font-weight: 500; }
.et-duoc-sinh { background: color-mix(in srgb, var(--ok) 9%, transparent); color: var(--ok); }
.et-khac { background: color-mix(in srgb, var(--red) 20%, transparent); color: var(--red); font-weight: 500; }
.et-bi-khac { background: var(--red-soft); color: color-mix(in srgb, var(--red) 75%, var(--text-2)); }
.et-binh-hoa { background: var(--surface-2); color: var(--text-3); }
@media (max-width: 640px) {
  .tv-et thead { display: none; }
  .tv-et tbody tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
  .tv-et tbody th { grid-column: 1 / -1; width: auto; border-bottom: 0; padding-bottom: 4px; }
  .tv-et td { border-bottom: 0; padding-top: 4px; }
}

/* Ai hỗ trợ ai */
.tv-support { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.tv-support li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.tv-support li.empty { display: block; background: none; border: 0; padding: 0; }
.tv-sp-who { white-space: nowrap; }
.tv-sp-who b { font-weight: 500; }
.tv-sp-arrow { font-size: 14px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); white-space: nowrap; }
.tv-support small { flex-basis: 100%; color: var(--text-3); font-size: 12.5px; line-height: 1.5; }

/* Bảng hợp – xung */
.tv-matrix-wrap { overflow-x: auto; }
.tv-matrix { border-collapse: separate; border-spacing: 4px; font-size: 13px; min-width: 100%; }
.tv-matrix th { font-weight: 500; color: var(--text-2); white-space: nowrap; padding: 4px 8px; text-align: center; }
.tv-matrix th span { display: block; font-size: 18px; }
.tv-matrix tbody th { text-align: left; }
.tv-matrix tbody th span { display: inline; margin-right: 6px; }
.tv-cell { text-align: center; border-radius: 8px; padding: 8px 6px; font-size: 18px; line-height: 1.2; min-width: 84px; }
.tv-cell small { display: block; font-size: 10.5px; letter-spacing: .04em; margin-top: 2px; }
.tv-cell.self { color: var(--text-3); font-size: 14px; background: var(--bg-2); }
.lv-great { background: color-mix(in srgb, var(--ok) 24%, transparent); color: var(--ok); }
.lv-good { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.lv-neutral { background: var(--surface-2); color: var(--text-2); }
.lv-warn { background: var(--gold-soft); color: var(--gold-2); }
.lv-bad { background: var(--red-soft); color: var(--red); }
.tv-scale { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; font-size: 12px; }
.tv-scale span { padding: 3px 10px; border-radius: 999px; }

/* Từng cặp */
.tv-pairs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.tv-pair { border: 1px solid var(--line); border-left: 3px solid currentColor; border-radius: 10px; padding: 12px 14px; background: var(--bg-2); color: var(--text-3); }
.tv-pair.lv-great, .tv-pair.lv-good, .tv-pair.lv-neutral, .tv-pair.lv-warn, .tv-pair.lv-bad { background: var(--bg-2); }
.tv-pair-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--text); }
.tv-pair-who { font-size: 14.5px; }
.tv-pair-who b { font-weight: 500; }
.tv-pair-who span { color: var(--text-3); }
.tv-pair ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tv-pair ul li { position: relative; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.tv-pair ul li::before { position: absolute; left: 0; top: 0; font-weight: 700; content: "•"; color: var(--text-3); }
.tv-pair ul li.good::before { content: "+"; color: var(--ok); }
.tv-pair ul li.bad::before { content: "!"; color: var(--red); }
.tv-badge { font-size: 11px; letter-spacing: .04em; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.tv-badge.great { background: color-mix(in srgb, var(--ok) 24%, transparent); color: var(--ok); }
.tv-badge.good { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.tv-badge.neutral { background: var(--surface-2); color: var(--text-2); }
.tv-badge.warn { background: var(--gold-soft); color: var(--gold-2); }
.tv-badge.bad { background: var(--red-soft); color: var(--red); }

/* Giải thích */
.tv-explain summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.tv-explain summary::-webkit-details-marker { display: none; }
.tv-explain summary::after { content: "▾"; color: var(--text-3); }
.tv-explain[open] summary::after { content: "▴"; }
.tv-ex-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 16px 0 12px; }
.tv-ex-grid > div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.tv-ex-icon { display: block; font-size: 22px; margin-bottom: 6px; }
.tv-ex-grid b { font-weight: 500; }
.tv-ex-grid p { margin: 6px 0 0; font-size: 13px; line-height: 1.6; color: var(--text-2); }

@media (max-width: 1100px) {
  .tv-row { grid-template-columns: 48px minmax(0, 1fr) auto; row-gap: 6px; }
  .tv-age, .tv-el, .tv-src { grid-column: 2 / -1; }
  .tv-age { flex-direction: row; gap: 8px; align-items: baseline; }
  .tv-acts { grid-column: 3; grid-row: 1; }
}
@media (max-width: 1000px) {
  .tv-form-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tv-f-date, .tv-f-btns { grid-column: 1 / -1; }
  .tv-f-btns .btn { flex: 1; }
  .tv-charts { grid-template-columns: minmax(0, 1fr); }
  .tv-ex-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .tv-form-row { grid-template-columns: minmax(0, 1fr); }
  .tv-lunar { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
  .tv-lunar input { grid-column: 1 / -1; }
  .tv-row { grid-template-columns: 44px minmax(0, 1fr); }
  .tv-avatar { width: 44px; height: 44px; font-size: 23px; }
  .tv-acts { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start; flex-wrap: wrap; }
  .tv-support, .tv-pairs { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Hộp thoại ---------- */
.dialog {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
.dialog-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head .card-title { margin: 0; font-size: 30px; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }
.lunar-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; }
.lunar-inputs > label { min-width: 0; }
.lunar-inputs + .check { margin-top: 10px; }
.date-preview { margin: -6px 0 0; font-size: 13.5px; color: var(--gold-2); min-height: 1.4em; }
.readonly-note { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--gold-soft); color: var(--gold-2); font-size: 13.5px; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.sub-title { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px; }
.pchip { border: 1px solid var(--line-strong); background: none; border-radius: 999px; padding: 7px 12px; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; }
.pchip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.pchip[aria-pressed="true"] { border-color: var(--c); color: var(--text); background: color-mix(in srgb, var(--c) 14%, transparent); }
fieldset[disabled] { opacity: .7; }

/* ---------- Thông báo ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100vw - 32px); }
.toast {
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font-size: 14px; box-shadow: var(--shadow);
  animation: toast-in .25s var(--ease);
  max-width: 100%;
}
.toast.error { border-color: color-mix(in srgb, var(--red) 60%, transparent); color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Đáp ứng màn hình ---------- */
@media (max-width: 1180px) {
  .year-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .month-layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; min-width: 0; }
  .hol-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; padding-top: 36px; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 0; row-gap: 6px; }
  .tabs { order: 3; width: calc(100% + var(--gutter) * 2); margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter) 8px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 7px 10px; font-size: 11px; letter-spacing: 0.06em; white-space: nowrap; flex-shrink: 0; }
  .user-name { display: none; }
  .user-btn { padding: 3px; }
  .cell { min-height: 92px; }
  .chip span { font-size: 11px; }
}

@media (max-width: 760px) {
  .year-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .ym { padding: 10px 6px 8px; }
  .ym-head { flex-direction: column; gap: 0; margin-bottom: 6px; }
  .ym-title { font-size: 18px; }
  .ym-range { font-size: 10px; }
  .ym-wd span { font-size: 9px; letter-spacing: 0; }
  .ym-cell { padding: 3px 0 4px; border-radius: 4px; }
  .ym-s { font-size: 12px; }
  .ym-l { display: none; }
  .legend-lunar-year { display: none !important; }
  .ym-cell.has-ev::before { top: 1px; right: 1px; width: 4px; height: 4px; }
  .ym-list li { font-size: 11px; gap: 6px; }
  .ym-list b { min-width: 14px; }
  .month-head { padding: 22px 0 16px; align-items: flex-start; flex-direction: column; }
  .month-nav { width: 100%; }
  .month-jump { margin-left: auto; }
  .side { grid-template-columns: minmax(0, 1fr); }
  .panel { min-width: 0; }
  .topbar-inner { column-gap: 10px; }
  .topbar-actions { gap: 6px; }
  .login-btn { padding: 8px 12px; letter-spacing: 0.12em; }
  .weekdays div { font-size: 10px; letter-spacing: .08em; }
  .weekdays small { display: none; }
  .grid { border-radius: 10px; }
  .cell { min-height: 64px; padding: 5px 4px 5px; gap: 1px; align-items: center; text-align: center; }
  .cell-top { flex-direction: column; align-items: center; gap: 1px; }
  .solar { font-size: 16px; }
  .cell.today .solar { min-width: 26px; height: 26px; margin: 0; font-size: 15px; }
  .lunar { font-size: 10px; }
  .tag, .chips { display: none; }
  .dots { display: flex; justify-content: center; }
  .cell.has-jp::after, .cell.has-vn::before {
    content: ""; position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
    width: 14px; height: 2px; border-radius: 2px; background: var(--red);
  }
  .cell.has-vn::before { background: var(--vn); }
  .cell.has-jp.has-vn::after { transform: translateX(-115%); width: 10px; }
  .cell.has-jp.has-vn::before { transform: translateX(15%); width: 10px; }
  .cell.has-jp .dots, .cell.has-vn .dots { margin-bottom: 4px; }
  .month-nav { gap: 6px; }
  .month-nav .btn { padding: 10px 14px; }
  .month-jump input { max-width: 150px; font-size: 12.5px; }
  .panel { padding: 16px; }
  .dp-big { font-size: 48px; }
  .notes-list { grid-template-columns: 1fr; }
  .auth-hero .display { font-size: 60px; }
  .dialog-body { padding: 18px; }
  /* Ngày + tháng một hàng, năm xuống hàng dưới */
  .lunar-inputs { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .lunar-inputs > label:last-child { grid-column: 1 / -1; }
  .lunar-inputs select { padding-left: 11px; padding-right: 28px; background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; }
}

@media (max-width: 340px) {
  /* Màn hình rất hẹp: xếp dọc ngày, tháng, năm âm lịch */
  .lunar-inputs { grid-template-columns: minmax(0, 1fr); }
  .dialog-body { padding: 16px 14px; }
  .dialog-head .card-title { font-size: 26px; }
  .seg-btn { letter-spacing: 0.06em; padding: 8px 6px; }
}

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