/* Lịch chùa (gói R): tờ lịch bloc kiểu lịch xé Việt trên nền sơn mài, lưới tháng, ngày của tôi, sinh hoạt chùa.
   Chỉ dùng token màu của game.css (--gold, --vermilion, --jade, --cream…). Mọi lớp bắt đầu bằng .lich-. */
.lich-dialog {
  --paper: #f8efdd;
  --paper-2: #efe0c3;
  --ink: #2a1c10;
  --ink-soft: #6b5238;
  padding: 24px 22px 20px;
}
dialog.lich-dialog[open] {
  width: min(560px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: 92dvh;
}
.lich-dialog h2 {
  margin-bottom: 12px;
}
.lich-dialog h3 {
  margin: 18px 0 8px;
  font: 500 18px/1.3 var(--serif);
  color: var(--gold-hi);
}
.lich-dialog .ico {
  width: 18px;
  height: 18px;
}

/* Thanh mục */
.lich-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.lich-tabs button {
  min-height: 38px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--milk);
  white-space: nowrap;
}
.lich-tabs button:hover {
  color: var(--gold-hi);
}
.lich-tabs button[aria-selected='true'] {
  background: var(--selected-fill);
  color: var(--gold-hi);
  box-shadow: var(--glow);
}

/* Nút viên thuốc dùng chung */
.lich-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  color: var(--gold);
  background: rgba(255, 240, 215, 0.035);
  font-size: 13px;
  font-weight: 500;
}
.lich-pill:hover:not(:disabled) {
  color: var(--gold-hi);
  background: rgba(224, 178, 92, 0.12);
}
.lich-pill:disabled {
  cursor: default;
  opacity: 0.45;
}
.lich-pill.is-primary {
  color: #2a1a08;
  border-color: transparent;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
}
.lich-pill.is-primary:hover {
  color: #2a1a08;
  background: linear-gradient(180deg, #f8d68c, var(--gold-hi));
}
.lich-pill.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}
.lich-pill.danger {
  color: #ffd9d4;
  border-color: rgba(184, 55, 45, 0.8);
  background: rgba(184, 55, 45, 0.35);
}

/* ===== Tờ lịch bloc ===== */
.lich-sheet {
  display: grid;
  gap: 14px;
}
.lich-bloc {
  position: relative;
  padding-top: 14px;
  perspective: 900px;
}
/* Gáy lịch: thanh đồng + hai khoen */
.lich-bloc::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-deep));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  z-index: 2;
}
.lich-bloc::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  width: 46%;
  height: 8px;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 8px 4px, #1a120b 3px, transparent 3.5px) left / 50% 100% no-repeat,
    radial-gradient(circle at calc(100% - 8px) 4px, #1a120b 3px, transparent 3.5px) right / 50% 100% no-repeat;
  z-index: 3;
}
.lich-page {
  position: relative;
  margin: 0 auto;
  max-width: 420px;
  padding: 0 0 18px;
  text-align: center;
  color: var(--ink);
  border-radius: 4px 4px 14px 14px;
  background: radial-gradient(ellipse 90% 40% at 50% 30%, rgba(255, 255, 255, 0.55), transparent 70%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  /* Các tờ còn lại bên dưới */
  box-shadow:
    0 3px 0 -1px #e2d0ad,
    0 6px 0 -2px #d3bd94,
    0 9px 0 -3px #c3aa7d,
    0 22px 40px rgba(0, 0, 0, 0.5);
  transform-origin: 50% 0;
  overflow: hidden;
}
.lich-page-head {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 18px 12px 9px;
  background: linear-gradient(180deg, #c3463a, var(--vermilion));
  color: #fbe9c4;
  font: 600 15px/1.2 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--gold);
}
.lich-dot {
  color: var(--gold-hi);
}
.lich-big {
  margin-top: 6px;
  font: 500 clamp(92px, 26vw, 136px) / 1 var(--serif);
  color: var(--ink);
  letter-spacing: -0.03em;
  font-variant-numeric: lining-nums;
}
.lich-page.is-red .lich-big,
.lich-page.is-red .lich-weekday {
  color: var(--vermilion);
}
.lich-weekday {
  margin-top: 2px;
  font: 600 17px/1.3 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.lich-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  margin: 10px 14px 4px;
}
.lich-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 11px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  border: 1px solid rgba(156, 117, 53, 0.45);
  color: #6d4a17;
  background: rgba(224, 178, 92, 0.22);
}
.lich-tag.le,
.lich-tag.quoc-le {
  color: #fff3e0;
  background: var(--vermilion);
  border-color: transparent;
}
.lich-tag.tiet-khi {
  color: #1f5b49;
  background: rgba(95, 181, 154, 0.22);
  border-color: rgba(95, 181, 154, 0.6);
}
.lich-tag.rieng {
  color: #6b2d3c;
  background: rgba(235, 169, 187, 0.35);
  border-color: rgba(200, 110, 135, 0.6);
}
.lich-lunar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 8px 18px 0;
  border-top: 1px dashed rgba(107, 82, 56, 0.45);
  border-bottom: 1px dashed rgba(107, 82, 56, 0.45);
}
.lich-lunar > div {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 10px 6px;
}
.lich-lunar > div + div {
  border-left: 1px dashed rgba(107, 82, 56, 0.45);
}
.lich-lunar small {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.lich-lunar b {
  font: 600 30px/1.1 var(--serif);
  color: var(--ink);
}
.lich-lunar-year b {
  font-size: 22px;
  line-height: 1.5;
}
.lich-lunar span {
  font-size: 13px;
  color: var(--ink-soft);
}
.lich-teaching {
  margin: 14px 22px 0;
  padding: 0;
}
.lich-dialog .lich-teaching p {
  margin: 0;
  font: italic 16px/1.55 var(--serif);
  color: #4f3a26;
}
.lich-teaching::before {
  content: '❀';
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--gold-deep);
}
.lich-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.lich-page.flip-next {
  animation: lich-tear-in 0.42s var(--ease);
}
.lich-page.flip-prev {
  animation: lich-fall-in 0.42s var(--ease);
}
@keyframes lich-tear-in {
  from {
    opacity: 0.3;
    transform: rotateX(-12deg) translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes lich-fall-in {
  from {
    opacity: 0;
    transform: translateY(-18px) rotate(-1.5deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== Lưới tháng ===== */
.lich-month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.lich-month-head h3 {
  margin: 0;
  font-size: 21px;
}
.lich-grid {
  display: grid;
  gap: 4px;
}
.lich-grid-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.lich-grid-week span {
  padding: 2px 0 4px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--milk);
}
.lich-grid-week span:last-child {
  color: #e98b80;
}
.lich-cell {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 52px;
  padding: 4px 0 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 240, 215, 0.03);
}
.lich-cell:hover {
  border-color: var(--line-strong);
  background: rgba(224, 178, 92, 0.09);
}
.lich-cell .d {
  font: 500 18px/1.1 var(--serif);
  color: var(--cream);
}
.lich-cell .l {
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--milk-2);
}
.lich-cell.sun .d,
.lich-cell.le .d {
  color: #ef8f82;
}
.lich-cell.mong .l {
  color: var(--gold);
  font-weight: 600;
}
.lich-cell.ram .l {
  color: var(--gold-hi);
  font-weight: 700;
}
.lich-cell.out {
  opacity: 0.36;
}
.lich-cell.today {
  border-color: var(--gold);
  box-shadow: var(--glow);
}
.lich-cell.selected:not(.today) {
  border-color: var(--line-strong);
  background: rgba(224, 178, 92, 0.1);
}
/* Dấu: rằm = trăng tròn vàng, mùng 1 = vành trăng non, lễ = chấm son, tiết khí = chấm ngọc, ngày riêng = chấm sen */
.lich-cell .mark {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
}
.lich-cell.ram::before,
.lich-cell.mong::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.lich-cell.ram::before {
  background: var(--gold-hi);
  box-shadow: 0 0 6px rgba(243, 201, 115, 0.7);
}
.lich-cell.mong::before {
  border: 1.5px solid var(--gold);
}
.lich-cell.le .mark::before,
.lich-cell.term .mark::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.lich-cell.le .mark::before {
  background: var(--vermilion);
  box-shadow: 0 0 0 1px rgba(255, 220, 200, 0.4);
}
.lich-cell.term .mark::after {
  background: var(--jade);
}
.lich-cell.rieng::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  transform: translateX(-50%);
  background: var(--lotus);
}
.lich-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 12px 2px 4px;
  font-size: 11.5px;
  color: var(--milk);
}
.lich-legend .k {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.lich-legend .k::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.lich-legend .mong::before {
  border: 1.5px solid var(--gold);
}
.lich-legend .ram::before {
  background: var(--gold-hi);
}
.lich-legend .le::before {
  background: var(--vermilion);
}
.lich-legend .term::before {
  background: var(--jade);
}
.lich-legend .rieng::before {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: var(--lotus);
}
.lich-dialog ul.lich-list,
.lich-dialog ul.lich-events,
.lich-dialog ul.lich-mine-list {
  margin: 8px 0 0;
}
.lich-dialog .lich-list li,
.lich-dialog .lich-events li,
.lich-dialog .lich-mine-list li {
  padding: 0;
}
.lich-dialog .lich-list li::before,
.lich-dialog .lich-events li::before,
.lich-dialog .lich-mine-list li::before {
  display: none;
}
.lich-dialog .lich-list li {
  display: grid;
  grid-template-columns: 48px 1fr;
  column-gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}
.lich-list b {
  grid-row: span 2;
  font: 500 15px/1.4 var(--serif);
  color: var(--gold);
}
.lich-list small {
  font-size: 11.5px;
  color: var(--milk-2);
}

/* ===== Ngày của tôi ===== */
.lich-mine > .small {
  margin: 0 0 6px;
}
.lich-empty {
  margin: 10px 0;
  padding: 14px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line-strong);
  color: var(--milk);
  text-align: center;
}
.lich-dialog .lich-mine-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.lich-mine-item .txt {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.lich-mine-item .txt b {
  font: 500 16px/1.35 var(--serif);
  color: var(--cream);
  overflow-wrap: anywhere;
}
.lich-mine-item .txt span {
  font-size: 12.5px;
  color: var(--milk);
}
.lich-mine-item .txt small {
  font-size: 12px;
  color: var(--gold);
}
.lich-mine-item .act {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex: none;
  max-width: 50%;
}
.lich-pill.add {
  margin-top: 12px;
}
.lich-form {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
}
.lich-form h3 {
  margin-top: 0;
}
.lich-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.lich-field {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--milk);
}
.lich-field input,
.lich-dialog .lich-field select,
.lich-ics-row select {
  width: 100%;
  max-width: none;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background-color: rgba(12, 8, 4, 0.5);
  color: var(--cream);
  font-size: 14px;
}
.lich-dialog .lich-field select,
.lich-dialog .lich-ics-row select {
  padding-right: 32px;
}
.lich-field input:focus,
.lich-field select:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: var(--glow);
}
.lich-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
}
.lich-check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--gold);
}
.lich-check input:disabled + span {
  opacity: 0.5;
}
.lich-check span {
  display: grid;
}
.lich-check small {
  font-size: 11.5px;
  color: var(--milk-2);
}
.lich-error:empty {
  display: none;
}
.lich-dialog .lich-error {
  margin: 4px 0;
  color: #ff9f93;
  font-size: 13px;
}
.lich-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.lich-ics {
  margin-top: 18px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.lich-ics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.lich-ics-row select {
  width: auto;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
}
.lich-ics-row .lich-pill {
  flex: 1 1 220px;
}
.lich-dialog .lich-howto li {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--milk);
}

/* ===== Ở chùa ===== */
.lich-temple h3:first-child {
  margin-top: 0;
}
.lich-dialog .lich-events li {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.lich-events .when {
  display: grid;
  line-height: 1.25;
}
.lich-events .when b {
  font: 500 16px/1.3 var(--serif);
  color: var(--gold);
}
.lich-events .when small {
  white-space: nowrap;
  font-size: 11px;
  color: var(--milk-2);
}
.lich-events .txt {
  display: grid;
  min-width: 0;
  line-height: 1.4;
}
.lich-events .txt b {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--cream);
}
.lich-events .txt span {
  font-size: 12px;
  color: var(--milk);
}
.lich-dialog .lich-events li.past {
  opacity: 0.6;
}
.lich-remind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--milk);
  white-space: nowrap;
}
.lich-remind .ico {
  width: 15px;
  height: 15px;
}
.lich-remind:hover {
  color: var(--gold-hi);
  border-color: var(--line-strong);
}
.lich-remind.on {
  color: #2a1a08;
  border-color: transparent;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
}
.lich-prefs {
  margin: 18px 0 6px;
  padding: 10px 14px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-sunk);
}
.lich-prefs legend {
  padding: 0 6px;
  font: 500 16px/1.3 var(--serif);
  color: var(--gold-hi);
}
.lich-prefs .lich-check {
  padding: 6px 0;
}

/* ===== Điện thoại ===== */
@media (max-width: 480px) {
  .lich-dialog {
    padding: 18px 12px 14px;
  }
  dialog.lich-dialog[open] {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: 94dvh;
    border-radius: 20px;
  }
  .lich-dialog h2 {
    font-size: 23px;
    margin-left: 4px;
  }
  .lich-tabs button {
    font-size: 12.5px;
  }
  .lich-cell {
    min-height: 46px;
    border-radius: 8px;
  }
  .lich-cell .d {
    font-size: 16px;
  }
  .lich-grid,
  .lich-grid-row {
    gap: 3px;
  }
  .lich-lunar {
    margin: 8px 10px 0;
  }
  .lich-dialog .lich-events li {
    grid-template-columns: 54px 1fr auto;
    gap: 8px;
  }
  .lich-remind span {
    display: none;
  }
  .lich-remind {
    padding: 0 9px;
  }
  .lich-mine-item {
    flex-wrap: wrap;
  }
  .lich-mine-item .act {
    max-width: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lich-page.flip-next,
  .lich-page.flip-prev {
    animation: none;
  }
  .lich-dialog[open] {
    animation: none;
  }
}

/* ===== Thông báo đẩy (Web Push, tùy chọn — gói R phần 5) ===== */
.lich-push > p.small {
  margin: 2px 0 6px;
}
.lich-push .lich-push-master {
  margin: 4px 0 8px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--selected-fill);
}
.lich-push .lich-push-master b {
  color: var(--gold-hi);
}
.lich-push .lich-push-kind {
  padding: 5px 0 5px 4px;
}
.lich-push-note {
  margin: 4px 0 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--milk);
  background: var(--surface-sunk);
}
.lich-push-status {
  min-height: 1.2em;
  margin: 6px 0 2px;
  font-size: 12.5px;
  color: var(--gold-hi);
}
.lich-push-status:empty {
  display: none;
}
.lich-push-test {
  min-height: 36px;
  margin: 4px 0;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  color: var(--gold);
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.lich-push a {
  color: var(--gold-hi);
}
