:root {
  /* Bố cục: tờ lịch bloc bên trái là tâm điểm, lưới tháng và ô đổi ngày bên phải,
     lễ tết sắp tới chạy ngang phía dưới. Thu về một cột trên điện thoại. */
  --bg: #F1F2F7;
  --surface: #FFFFFF;
  --ink: #1A2040;
  --muted: #5B6282;
  --line: #DADFEA;
  --son: #C22A2A;
  --son-soft: #FBEAE8;
  --band: #C22A2A;
  --on-band: #FFF4EF;
  --accent: #2C4A9A;
  --accent-soft: #E6EBF8;
  --on-accent: #FFFFFF;
  --gold: #946610;
  --good: #1F7A4D;
  --good-soft: #E3F3EA;
  --moon-lit: #F0CF6E;
  --moon-dark: #283058;
  --shadow: 0 1px 0 rgba(26, 32, 64, 0.05), 0 18px 36px -22px rgba(26, 32, 64, 0.45);

  --font-num: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-display: "Alegreya", Georgia, "Times New Roman", serif;
  --font-body: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-han: "Noto Serif SC", "Songti SC", "SimSun", serif;

  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1227;
    --surface: #171C38;
    --ink: #ECE8DC;
    --muted: #9EA4C3;
    --line: #2B3158;
    --son: #F27171;
    --son-soft: #3B1F2E;
    --band: #8F2431;
    --on-band: #FFEDE8;
    --accent: #9FB4F8;
    --accent-soft: #252D57;
    --on-accent: #0E1227;
    --gold: #E8C266;
    --good: #6DD3A0;
    --good-soft: #17352E;
    --moon-lit: #F4DD94;
    --moon-dark: #2B3262;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 20px 44px -22px rgba(0, 0, 0, 0.85);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0E1227;
  --surface: #171C38;
  --ink: #ECE8DC;
  --muted: #9EA4C3;
  --line: #2B3158;
  --son: #F27171;
  --son-soft: #3B1F2E;
  --band: #8F2431;
  --on-band: #FFEDE8;
  --accent: #9FB4F8;
  --accent-soft: #252D57;
  --on-accent: #0E1227;
  --gold: #E8C266;
  --good: #6DD3A0;
  --good-soft: #17352E;
  --moon-lit: #F4DD94;
  --moon-dark: #2B3262;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 20px 44px -22px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-body);
  padding-inline: 16px;
  padding-block: 0 48px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap {
  max-width: 1160px;
  margin-inline: auto;
}

h1,
h2,
h3 {
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

.label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.han {
  font-family: var(--font-han);
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Đầu trang */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-block: 28px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.brand-moon {
  flex: none;
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn svg {
  flex: none;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn:disabled:hover {
  border-color: var(--line);
}

.btn-danger {
  color: var(--son);
}

.btn-danger:hover {
  border-color: var(--son);
}

.btn-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.mast-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Bố cục chính */

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 370px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.side {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.panel {
  min-width: 0;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
}

.panel-head p {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Tờ lịch */

.sheet {
  position: relative;
  background: var(--surface);
  border-radius: 6px 6px 12px 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet-band {
  position: relative;
  background: var(--band);
  color: var(--on-band);
  padding: 26px 20px 12px;
  text-align: center;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Hai lỗ đóng gáy của tờ lịch xé */
.sheet-band::before,
.sheet-band::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
}

.sheet-band::before {
  left: calc(50% - 64px);
}

.sheet-band::after {
  right: calc(50% - 64px);
}

.sheet-body {
  padding: 18px 24px 24px;
  display: grid;
  gap: 18px;
}

.sheet-body.is-turning {
  animation: turn 0.32s ease-out;
}

@keyframes turn {
  from {
    opacity: 0.35;
    transform: translateY(-8px) rotate(-0.6deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.sheet-solar {
  text-align: center;
  color: var(--ink);
}

.sheet-solar.is-red {
  color: var(--son);
}

.sheet-day {
  display: block;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: clamp(7.5rem, 34vw, 10.5rem);
  line-height: 0.82;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums;
}

.sheet-weekday {
  display: block;
  margin-top: 8px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.45rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.chip-red {
  background: var(--son-soft);
  color: var(--son);
}

.chip-good {
  background: var(--good-soft);
  color: var(--good);
}

.chip-gold {
  background: transparent;
  color: var(--gold);
  box-shadow: inset 0 0 0 1px currentColor;
}

/* Sự kiện cá nhân: viền xanh, cùng màu với dấu chấm trên lưới tháng. */
.chip-personal {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px currentColor;
}

/* Khối văn khấn và sự kiện của bạn trên tờ lịch */

.sheet-block {
  display: grid;
  gap: 8px;
}

.row-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--bg);
  text-align: left;
  transition: background-color 0.12s;
}

.row-btn:hover {
  background: var(--accent-soft);
}

.row-main {
  flex: 1;
  display: grid;
  min-width: 0;
}

.row-main b {
  font-weight: 600;
  font-size: 0.92rem;
}

.row-main span {
  color: var(--muted);
  font-size: 0.8rem;
}

.row-main .row-note {
  color: var(--ink);
}

.row-arrow {
  flex: none;
  width: 18px;
  height: 18px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row-action {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
}

.sheet-lunar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.lunar-date {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 14px;
}

.lunar-date .label {
  grid-column: 1 / -1;
}

.lunar-day {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 4.2rem;
  line-height: 0.85;
  color: var(--accent);
}

.lunar-day.is-gold {
  color: var(--gold);
}

.lunar-month {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}

.lunar-year {
  color: var(--muted);
  font-size: 0.9rem;
}

.moon {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  max-width: 96px;
}

.moon svg {
  display: block;
}

.m-dark {
  fill: var(--moon-dark);
}

.m-lit {
  fill: var(--moon-lit);
}

.moon-name {
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px 16px;
  margin: 0;
  font-size: 0.92rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 500;
  min-width: 0;
}

.facts dd small {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.82rem;
}

.hours {
  display: grid;
  gap: 8px;
}

.hours-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hours-grid li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.85rem;
}

.hours-grid b {
  font-weight: 600;
}

.hours-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Lưới tháng */

.month-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.month-title {
  flex: 1 1 200px;
  min-width: 0;
}

.month-title h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.15;
}

.month-title p {
  color: var(--muted);
  font-size: 0.85rem;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 0.15s;
}

.icon-btn:hover {
  border-color: var(--accent);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field {
  height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}

.field:hover {
  border-color: var(--muted);
}

#jump-year {
  width: 5.5em;
  font-variant-numeric: tabular-nums;
}

.calendar {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 10px;
}

.weekdays,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.weekdays {
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.weekdays span {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.weekdays span:last-child {
  color: var(--son);
}

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 62px;
  padding: 6px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: center;
  transition: background-color 0.12s;
}

.day:hover {
  background: var(--accent-soft);
}

.d-sol {
  position: relative;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 1.45rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.d-lun {
  font-size: 0.72rem;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.day.is-moon .d-lun {
  color: var(--gold);
  font-weight: 700;
}

.day.is-red .d-sol {
  color: var(--son);
}

.d-dots {
  position: absolute;
  top: 0;
  right: -8px;
  display: grid;
  gap: 2px;
}

.d-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--son);
}

.d-dot.is-mine {
  background: var(--accent);
}

.day.is-out {
  opacity: 0.4;
}

.day.is-today {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.day.is-selected {
  background: var(--accent);
  box-shadow: none;
  opacity: 1;
}

.day.is-selected .d-sol,
.day.is-selected .d-lun {
  color: var(--on-accent);
}

.day.is-selected .d-dot {
  background: var(--on-accent);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend .i-event {
  background: var(--son);
}

.legend .i-mine {
  background: var(--accent);
}

.legend .i-today {
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--accent);
  width: 12px;
  height: 12px;
}

.legend .i-moon {
  background: var(--gold);
}

/* Đổi ngày */

.convert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.convert-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}

.convert-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.convert-card label {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.convert-card .field {
  width: 100%;
  color: var(--ink);
}

.lunar-fields {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 8px;
}

.check {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  font-size: 0.85rem !important;
  color: var(--ink) !important;
}

.check input {
  flex: none;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

/* .check đặt display bằng !important (để đè kiểu label trong ô đổi ngày), nên phải ẩn lại cho rõ. */
.check[hidden] {
  display: none !important;
}

.check-block {
  align-items: flex-start !important;
}

.check-block input {
  margin-top: 2px;
}

.check-block span {
  display: grid;
}

.check small {
  color: var(--muted);
  font-size: 0.78rem;
}

.result {
  display: grid;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  min-height: 92px;
}

.result-main {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.25;
}

.result-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.result-error {
  color: var(--son);
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.link-btn {
  justify-self: start;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Sự kiện: sắp tới, của tôi, văn khấn */

.events {
  margin-top: 36px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  flex: none;
  margin-bottom: -1px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-weight: 600;
  color: var(--muted);
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.pane-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.list-label {
  margin: 20px 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.list-label:first-child {
  margin-top: 0;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 16px;
  text-align: center;
}

.empty b {
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.empty p {
  max-width: 46ch;
  color: var(--muted);
}

.up-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.up-list li {
  border-bottom: 1px solid var(--line);
}

.up-item {
  display: grid;
  grid-template-columns: 7.2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 6px;
  border: 0;
  background: none;
  text-align: left;
  border-radius: 8px;
}

.up-item:hover {
  background: var(--surface);
}

.up-date {
  display: grid;
  line-height: 1.1;
}

.up-date b {
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.up-date span {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.up-name {
  display: grid;
  min-width: 0;
}

.up-name b {
  font-weight: 600;
}

.up-name span {
  font-size: 0.8rem;
  color: var(--muted);
}

.up-item.is-off .up-name b {
  color: var(--son);
}

.up-item.is-mine .up-name b::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.1em;
}

.up-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.up-count.is-soon {
  color: var(--accent);
}

/* Giới thiệu app Android */

.app-promo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  margin-top: 36px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.promo-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
}

.promo-icon svg {
  width: 26px;
  height: 26px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.promo-text {
  flex: 1 1 320px;
  min-width: 0;
}

.promo-text h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}

.promo-text p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 70ch;
}

/* Huy hiệu Google Play chính thức: không đổi màu hay sửa ảnh, cao tối thiểu 28px,
   chừa khoảng trống ít nhất 1/4 chiều cao quanh huy hiệu (theo hướng dẫn của Google). */
.play-badge {
  flex: none;
  display: block;
  border-radius: 8px;
}

.play-badge img {
  display: block;
  width: auto;
  height: 48px;
}

.st-badge {
  justify-self: start;
}

.st-badge img {
  height: 40px;
}

.foot {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 70ch;
}

/* Hộp thoại */

.dlg {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dlg[open] {
  display: flex;
  flex-direction: column;
}

.dlg::backdrop {
  background: rgba(14, 18, 39, 0.55);
}

.dlg-small {
  width: min(420px, calc(100vw - 32px));
}

.dlg-reader {
  width: min(760px, calc(100vw - 32px));
}

.dlg-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.dlg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}


.dlg-head h2,
.dlg-head-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
}

.dlg-body {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 16px 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dlg-body > h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
}

.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 18px;
}

.dlg .field {
  width: 100%;
  color: var(--ink);
}

textarea.field {
  height: auto;
  padding: 8px 10px;
  line-height: 1.5;
  resize: vertical;
}

.field[aria-invalid="true"] {
  border-color: var(--son);
}

.fld {
  display: grid;
  gap: 4px;
}

.fld > label,
.ev-date label {
  font-size: 0.78rem;
  color: var(--muted);
}

.fld-error,
.fld-hint {
  font-size: 0.8rem;
}

.fld-error {
  color: var(--son);
}

.fld-error:empty,
.fld-hint:empty {
  display: none;
}

.fld-hint {
  color: var(--muted);
}

.fld-hint.is-error {
  color: var(--son);
}

.ev-date {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr) minmax(0, 1.2fr);
  gap: 8px;
}

.ev-date label {
  display: grid;
  gap: 4px;
}

.ev-next {
  color: var(--accent);
  font-weight: 500;
}

.ev-next:empty {
  display: none;
}

/* Nhóm nút chọn một (radio) */

.seg {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.seg legend {
  margin-bottom: 6px;
  padding: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.seg-row {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}

/* Chia đều khi đủ chỗ; nhãn dài ("Theo hệ thống") thì nút đó rộng ra, không cắt chữ. */
.seg-item {
  position: relative;
  flex: 1 1 0;
  min-width: max-content;
}

.seg-item input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg-item span {
  display: block;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.seg-item input:checked + span {
  background: var(--surface);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.seg-item input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dạng chip xuống dòng được, cho các bản khấn */
.seg-wrap .seg-row {
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
}

.seg-wrap .seg-item {
  flex: 0 1 auto;
}

.seg-wrap .seg-item span {
  border: 1px solid var(--line);
  background: var(--surface);
}

.seg-wrap .seg-item input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: none;
}

/* Màn đọc bài khấn */

.pr-body {
  gap: 18px;
}


.pr-top {
  display: grid;
  gap: 8px;
}

.pr-top h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.2;
}

.pr-date {
  color: var(--accent);
  font-size: 0.92rem;
}

.pr-styles:empty {
  display: none;
}

.pr-actions,
.pr-inserts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pr-text {
  display: grid;
  gap: 0.9em;
  line-height: 1.5;
}

.pr-text b {
  font-weight: 600;
}

.pr-missing {
  color: var(--muted);
}

.pr-foot {
  display: grid;
  gap: 4px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.pr-edit-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
}

#pr-draft {
  min-height: 50vh;
  font-size: 1rem;
}

/* Cài đặt */

.st-body {
  flex: 1;
  gap: 16px;
  background: var(--bg);
}

.st-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.st-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}

.st-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.st-row div {
  display: grid;
  min-width: 0;
}

.st-row b {
  font-weight: 500;
}

.st-row span {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.st-text {
  color: var(--muted);
  font-size: 0.9rem;
}

.st-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.st-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Thông báo nhỏ, có thể kèm nút Hoàn tác */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.toast-btn {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-soft);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Màn hình hẹp */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sheet {
    max-width: 460px;
    width: 100%;
    margin-inline: auto;
  }
}

@media (max-width: 640px) {
  .convert-grid,
  .up-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-promo {
    align-items: flex-start;
    padding: 16px;
  }

  /* Chữ chiếm phần còn lại của hàng đầu (sau biểu tượng 48px và khoảng cách 18px), huy hiệu xuống hàng dưới. */
  .promo-text {
    flex-basis: calc(100% - 66px);
  }

  .promo-badge {
    margin-left: 66px;
  }

  .calendar {
    padding: 6px;
  }

  .weekdays,
  .days {
    gap: 2px;
  }

  .day {
    min-height: 52px;
    padding: 5px 5px 6px;
  }

  .d-sol {
    font-size: 1.25rem;
  }

  .d-lun {
    font-size: 0.66rem;
  }

  .d-dots {
    right: -6px;
  }

  .d-dot {
    width: 5px;
    height: 5px;
  }

  /* Hộp thoại lớn phủ toàn màn hình như trên app */
  .dlg:not(.dlg-small) {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .dlg-body {
    padding: 14px 16px 20px;
  }

  .pr-top h2 {
    font-size: 1.4rem;
  }

  .up-item {
    grid-template-columns: 6.6rem minmax(0, 1fr) auto;
    gap: 10px;
  }

  .sheet-body {
    padding: 16px 18px 20px;
  }
}

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