:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --text: #2a1f1a;
  --muted: #7a6a5f;
  --line: #e7dccd;
  --accent: #b3261e;
  --accent-soft: #fbe7e4;
  --gold: #c58a12;
  --gold-soft: #fdf2d6;
  --good: #2f7d4f;
  --good-soft: #e3f3e8;
  --sun: #c0392b;
  --sat: #2c6db3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 6px 24px rgba(60, 30, 10, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120f;
    --surface: #211a16;
    --surface-2: #2b221d;
    --text: #f2e9e1;
    --muted: #a8968a;
    --line: #3a2f28;
    --accent: #ff7a6b;
    --accent-soft: #3a1f1b;
    --gold: #f0bb4a;
    --gold-soft: #33291a;
    --good: #6fcf97;
    --good-soft: #1d3326;
    --sun: #ff8a7a;
    --sat: #7fb2ef;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1120px; margin: 0 auto; padding: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 18px; }
.brand-by { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }

.hero { max-width: 1120px; margin: 0 auto; padding: 0 16px 14px; }
.hero h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.noscript { max-width: 1088px; margin: 0 auto 16px; padding: 12px 16px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; }

.btn {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); padding: 8px 14px;
}
.btn:hover { border-color: var(--accent); }
.btn-ghost { color: var(--accent); font-weight: 600; }
.btn-icon { width: 40px; height: 40px; padding: 0; font-size: 22px; line-height: 1; }

/* Layout */
.layout {
  max-width: 1120px; margin: 0 auto; padding: 0 16px 24px;
  display: grid; gap: 16px;
  grid-template-columns: 340px 1fr;
  grid-template-areas: "day cal" "conv conv" "about about";
  align-items: start;
}
.day-card { grid-area: day; }
.calendar { grid-area: cal; }
.converter { grid-area: conv; }

.day-card, .calendar, .converter {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* Day card */
.day-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.day-head { text-align: center; }
.weekday { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.solar-big { font-size: 84px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; margin: 6px 0; }
.solar-sub { color: var(--muted); }

.lunar-box { background: var(--gold-soft); border-radius: 12px; padding: 12px; text-align: center; }
.lunar-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 700; }
.lunar-big { font-size: 40px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.lunar-sub { color: var(--muted); font-size: 14px; }

.holiday {
  background: var(--accent-soft); color: var(--accent); border-radius: 10px;
  padding: 8px 12px; font-weight: 600; text-align: center;
}

.facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.facts div { border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-weight: 600; }
.tag-good { color: var(--good); }
.tag-bad { color: var(--muted); }

.hours-title { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.hours ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hours li { background: var(--surface-2); border-radius: 8px; padding: 6px 4px; text-align: center; font-size: 13px; }
.hours li b { display: block; font-size: 14px; }
.hours li span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Calendar */
.calendar { padding: 16px; display: flex; flex-direction: column; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-title { display: flex; gap: 8px; }
.cal-title select, .cal-title input {
  font: inherit; font-weight: 700; font-size: 18px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.cal-title input { width: 96px; }
.cal-caption { text-align: center; color: var(--muted); margin: 8px 0 12px; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays div { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.weekdays .sun { color: var(--sun); }
.weekdays .sat { color: var(--sat); }

.cell {
  position: relative; min-height: 72px; border-radius: 10px; border: 1px solid transparent;
  background: var(--surface-2); padding: 6px 8px; cursor: pointer; text-align: left;
  font: inherit; color: var(--text); display: flex; flex-direction: column; justify-content: space-between;
}
.cell:hover { border-color: var(--line); }
.cell.other { opacity: .38; }
.cell .s { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cell .l { font-size: 12px; color: var(--muted); align-self: flex-end; font-variant-numeric: tabular-nums; }
.cell .l.lunar-first, .lunar-first { color: var(--accent); font-weight: 700; }
.cell.sun .s { color: var(--sun); }
.cell.sat .s { color: var(--sat); }
.cell.today { background: var(--accent-soft); }
.cell.today .s { color: var(--accent); }
.cell.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cell .marks { position: absolute; top: 8px; right: 8px; display: flex; gap: 3px; }
.cell .hname {
  font-size: 11px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.dot-hd { background: var(--gold); }
.dot-hol { background: var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Converter */
.converter { padding: 16px 20px 20px; }
.converter h2 { margin: 0 0 12px; font-size: 18px; }
.conv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.conv { background: var(--surface-2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.conv h3 { margin: 0; font-size: 15px; color: var(--accent); }
.conv label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.conv label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.conv input[type=date], .conv input[type=number] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
.row3 { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.conv output { font-weight: 600; min-height: 1.5em; }
.conv output a { color: var(--accent); }
.conv output .err { color: var(--sun); font-weight: 500; }

.about {
  grid-area: about; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px 20px;
}
.about h2 { margin: 0 0 8px; font-size: 18px; }
.about > p { margin: 0 0 12px; color: var(--muted); max-width: 75ch; }
.about strong { color: var(--text); }
.faq details { border-top: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 6px 0 0; color: var(--muted); max-width: 75ch; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 16px 28px; }
.foot p { margin: 4px 0; }
.foot a { color: var(--accent); text-decoration: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dot-xau { background: #8a7a70; }
}

/* Responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "day" "cal" "conv" "about"; }
  .conv-grid { grid-template-columns: 1fr; }
  .solar-big { font-size: 72px; }
}
@media (max-width: 480px) {
  .hero h1 { font-size: 22px; }
  .grid { gap: 3px; }
  .cell { min-height: 54px; padding: 4px 5px; }
  .cell .s { font-size: 16px; }
  .cell .l { font-size: 11px; }
  .cell .hname { display: none; }
  .cell .marks { top: 5px; right: 5px; }
  .calendar { padding: 12px 10px; }
  .cal-title select, .cal-title input { font-size: 16px; }
  .cal-title input { width: 80px; }
}

/* Tốt xấu */
.verdict { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.verdict-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.verdict-sub { color: var(--muted); font-size: 13px; }
.badge { border-radius: 999px; padding: 3px 12px; font-weight: 700; font-size: 14px; background: var(--surface-2); }
.badge.tot { background: var(--good-soft); color: var(--good); }
.badge.xau { background: var(--accent-soft); color: var(--accent); }
.advice { margin: 0; font-size: 14px; }
.advice b { color: var(--muted); font-weight: 600; }
.dot-tot { background: var(--good); }
.dot-xau { background: var(--muted); opacity: .6; }
