:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ece0;
  --border: #e6dccb;
  --text: #2a211b;
  --muted: #7a6b5d;
  --accent: #a8322a;
  --accent-soft: #f6e3df;
  --gold: #c8962b;
  --gold-soft: #fbf1db;
  --sat: #2f6fa8;
  --sun: #b8322a;
  --baik: #2e8b57;
  --cukup: #c27c0e;
  --kurang: #b8322a;
  --besar: #a8322a;
  --biasa: #d08a2c;
  --kajeng: #6b4fa3;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f;
    --surface: #221c17;
    --surface-2: #2b241e;
    --border: #3a3029;
    --text: #f1e9de;
    --muted: #ab9c8c;
    --accent: #e0675c;
    --accent-soft: #3d2420;
    --gold: #e1b450;
    --gold-soft: #3a2f1a;
    --sat: #6fa8dc;
    --sun: #e9776d;
    --baik: #5cc48a;
    --cukup: #e8a93c;
    --kurang: #e9776d;
    --besar: #e0675c;
    --biasa: #e8a24c;
    --kajeng: #a68be0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130f;
  --surface: #221c17;
  --surface-2: #2b241e;
  --border: #3a3029;
  --text: #f1e9de;
  --muted: #ab9c8c;
  --accent: #e0675c;
  --accent-soft: #3d2420;
  --gold: #e1b450;
  --gold-soft: #3a2f1a;
  --sat: #6fa8dc;
  --sun: #e9776d;
  --baik: #5cc48a;
  --cukup: #e8a93c;
  --kurang: #e9776d;
  --besar: #e0675c;
  --biasa: #e8a24c;
  --kajeng: #a68be0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 28px; }
.brand h1 { font-size: 18px; color: var(--accent); }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-left: auto; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: none; padding: 6px 14px; border-radius: 7px;
  cursor: pointer; color: var(--muted); font-weight: 500;
}
.tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface); width: 36px; height: 36px;
  border-radius: 50%; cursor: pointer; font-size: 18px;
}

main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 20px 24px; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; margin-bottom: 10px; }
.card + .card { margin-top: 16px; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 6px 14px;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.icon { width: 36px; height: 36px; padding: 0; font-size: 20px; line-height: 1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
select, input[type="number"], input[type="date"] {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 10px;
}
input[type="number"] { width: 90px; }

/* ---------- Calendar ---------- */
.cal-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.nav-group { display: flex; align-items: center; gap: 8px; }
#monthTitle { font-size: 22px; min-width: 200px; text-align: center; }

.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { margin-bottom: 6px; }
.cal-head div {
  text-align: center; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 6px 0;
}
.cal-head div:nth-child(6) { color: var(--sat); }
.cal-head div:nth-child(7) { color: var(--sun); }

.day {
  position: relative;
  min-height: 112px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.day:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.day.empty { background: transparent; border-style: dashed; cursor: default; box-shadow: none; }
.day.empty:hover { border-color: var(--border); }
.day .num { font-size: 20px; font-weight: 700; line-height: 1.1; }
.day.sat .num { color: var(--sat); }
.day.sun .num { color: var(--sun); }
.day .bali { font-size: 11.5px; font-weight: 500; }
.day .wuku { font-size: 11px; color: var(--muted); }
.day .pio {
  margin-top: auto; font-size: 10.5px; line-height: 1.25; padding: 2px 5px; border-radius: 5px;
  background: var(--gold-soft); color: var(--biasa); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day .pio.besar { background: var(--accent-soft); color: var(--besar); }
.day .pio + .pio { margin-top: 2px; }
.day .kk {
  position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--kajeng);
}
.day.today { border-color: var(--gold); border-width: 2px; padding: 6px 7px; background: var(--gold-soft); }
.day.selected { border-color: var(--accent); border-width: 2px; padding: 6px 7px; box-shadow: 0 0 0 3px var(--accent-soft); }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.besar { background: var(--besar); }
.dot.biasa { background: var(--biasa); }
.dot.kajeng { background: var(--kajeng); }

/* ---------- Detail ---------- */
.detail .d-date { font-size: 13px; color: var(--muted); }
.detail .d-title { font-size: 22px; font-weight: 700; color: var(--accent); margin: 2px 0 14px; }
.rows { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; }
.rows dd small { font-weight: 400; color: var(--muted); }
.dewasa {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  border-left: 4px solid currentColor;
}
.dewasa.baik { color: var(--baik); background: color-mix(in srgb, var(--baik) 10%, transparent); }
.dewasa.cukup { color: var(--cukup); background: color-mix(in srgb, var(--cukup) 10%, transparent); }
.dewasa.kurang { color: var(--kurang); background: color-mix(in srgb, var(--kurang) 10%, transparent); }
.dewasa span { display: block; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--gold-soft); color: var(--biasa);
}
.tag.besar { background: var(--accent-soft); color: var(--besar); }
.tag.kajeng { background: color-mix(in srgb, var(--kajeng) 14%, transparent); color: var(--kajeng); }
.sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---------- Piodalan list ---------- */
.pio-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pio-list li {
  display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.pio-list li:hover { background: var(--surface-2); }
.pio-list .pd { text-align: center; font-weight: 700; font-size: 18px; line-height: 1; }
.pio-list .pd small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.pio-list .pn { font-weight: 600; font-size: 13.5px; }
.pio-list .pn.besar { color: var(--besar); }
.pio-list .ph { font-size: 12px; color: var(--muted); }
.pio-list .none { color: var(--muted); font-size: 13px; cursor: default; display: block; }

/* ---------- Otonan ---------- */
.narrow { max-width: 720px; }
.oto-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.oto-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#otoResult { margin-top: 16px; }
.oto-summary { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; min-width: 150px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; }
.stat.hl { border-color: var(--gold); background: var(--gold-soft); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.n { color: var(--muted); font-variant-numeric: tabular-nums; width: 48px; }
tr.past td { color: var(--muted); }
tr.next td { background: var(--gold-soft); font-weight: 600; }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ---------- Nawa Dewata ---------- */
.nawa-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.nawa-layout .card + .card { margin-top: 0; }
.compass {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  max-width: 420px; margin: 8px auto 0; aspect-ratio: 1;
}
.dewa {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 6px;
}
.dewa:hover { border-color: var(--accent); }
.dewa.active { border-color: var(--accent); border-width: 2px; box-shadow: 0 0 0 3px var(--accent-soft); }
.dewa .sw { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); }
.dewa b { font-size: 14px; }
.dewa small { font-size: 11px; color: var(--muted); }
.nawa-title { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.wuku-chips { display: flex; flex-wrap: wrap; gap: 6px; }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 16px 28px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .cal-layout, .nawa-layout { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1; padding: 6px 2px; font-size: 13px; white-space: nowrap; }
  .theme-toggle { margin-left: auto; }
  main { padding: 16px; }
  #monthTitle { font-size: 18px; min-width: 0; flex: 1; }
  .cal-toolbar .nav-group:first-child { width: 100%; justify-content: space-between; }
  .cal-grid { gap: 3px; }
  .day { min-height: 66px; padding: 4px; border-radius: 7px; }
  .day.today, .day.selected { padding: 3px; }
  .day .num { font-size: 15px; }
  .day .bali { font-size: 9px; line-height: 1.15; overflow-wrap: anywhere; }
  .day .wuku { display: none; }
  .day .pio { font-size: 0; padding: 0; height: 4px; border-radius: 2px; background: var(--biasa); }
  .day .pio.besar { background: var(--besar); }
  .day .kk { top: 5px; right: 5px; width: 6px; height: 6px; }
  .cal-head div { font-size: 10px; }
}
.mt { margin-top: 14px; }

/* ---------- Tentang & Tim ---------- */
.about-hero { text-align: center; padding: 32px 24px; }
.about-name { font-size: 30px; font-weight: 800; color: var(--accent); }
.about-tagline { font-size: 16px; color: var(--gold); font-weight: 600; margin-top: 4px; }
.about-hero p { max-width: 640px; margin: 14px auto 0; color: var(--muted); }
.team-heading { font-size: 18px; margin: 28px 0 14px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.team-grid .card + .card { margin-top: 0; }
.member { text-align: center; display: flex; flex-direction: column; align-items: center; }
.member .avatar {
  width: 112px; height: 112px; border-radius: 50%; object-fit: cover; margin-bottom: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 36px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 3px solid var(--gold-soft);
}
.member h4 { margin: 0; font-size: 16px; }
.member .role { color: var(--accent); font-size: 13px; font-weight: 600; margin-top: 2px; }
.member p { color: var(--muted); font-size: 13.5px; margin: 10px 0 0; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.links a {
  font-size: 12px; font-weight: 600; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
}
.links a:hover { border-color: var(--accent); color: var(--accent); }
