:root {
  --bg: #f6eedf;
  --paper: #fffaf1;
  --ink: #2b1a10;
  --muted: #7a6352;
  --line: #e6d6bd;
  --brand: #5b2a12;
  --brand-2: #8a3b17;
  --gold: #c08a1e;
  --gold-soft: #f3e2b8;
  --good: #2f7a3a;
  --good-bg: #e3f1e0;
  --mid: #9a6a00;
  --mid-bg: #fbf0d0;
  --bad: #a3321f;
  --bad-bg: #f8e1da;
  --shadow: 0 1px 2px rgba(60, 30, 10, .08), 0 4px 14px rgba(60, 30, 10, .06);
  --jawa: 'Noto Sans Javanese', 'Javanese Text', 'Noto Sans', sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-tema="gelap"] {
  --bg: #17110c;
  --paper: #221911;
  --ink: #f2e6d4;
  --muted: #b49c84;
  --line: #3a2c20;
  --brand: #e0a45a;
  --brand-2: #f0b86c;
  --gold: #e7b44a;
  --gold-soft: #3a2b14;
  --good: #8fd19a;
  --good-bg: #1d3220;
  --mid: #e8c15a;
  --mid-bg: #3a2f12;
  --bad: #f19a86;
  --bad-bg: #3d1e17;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: calc(68px + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand-2); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; margin-top: 1.2em; }
p { margin: 0 0 .8em; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Header bermotif kawung */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  color: #fff3dc;
  background:
    radial-gradient(circle at 0 0, rgba(255, 220, 150, .13) 9px, transparent 10px) 0 0 / 22px 22px,
    radial-gradient(circle at 100% 100%, rgba(255, 220, 150, .13) 9px, transparent 10px) 0 0 / 22px 22px,
    linear-gradient(135deg, #5b2a12, #7d2f14 60%, #4a1e0b);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: 1; min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand b { font-family: var(--serif); font-size: 1.12rem; letter-spacing: .3px; }
.brand small { opacity: .8; font-size: .74rem; }
.icon-btn { background: rgba(255, 255, 255, .12); border: 0; color: inherit; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; flex: none; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 24px; outline: none; }

/* Tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; color: var(--muted); text-decoration: none; font-size: .7rem; }
.tabbar a.on { color: var(--brand); font-weight: 600; }
.tabbar a.on svg { stroke-width: 2.3; }

/* Kartu */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h2:first-child { margin-top: 0; }
.hero {
  color: #fff4df; border: 0;
  background:
    radial-gradient(circle at 85% 15%, rgba(255, 210, 120, .25), transparent 45%),
    linear-gradient(140deg, #6b2d12, #8e3a16 55%, #5b2a12);
}
.hero .muted { color: #f1d9b5; }
.hero .label { color: #f6cf8a; }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.big { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1.1; margin: 2px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: rgba(255, 255, 255, .1); border-radius: 12px; padding: 8px 10px; }
.card:not(.hero) .stat { background: var(--bg); }
.stat b { display: block; font-size: 1rem; }
.stat span { font-size: .72rem; opacity: .8; }

/* Menu grid */
.menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.menu a {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  text-decoration: none; color: var(--ink); font-size: .8rem; font-weight: 600; box-shadow: var(--shadow);
}
.menu a i { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--gold-soft); color: var(--brand); font-style: normal; }

/* Form */
label.f { display: block; margin-bottom: 10px; font-weight: 600; font-size: .86rem; }
label.f input, label.f select, textarea, .inp {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
textarea { resize: vertical; min-height: 80px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .86rem; margin: 6px 0 12px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); width: 17px; height: 17px; flex: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 11px; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--brand); color: #fff; text-decoration: none;
}
:root[data-tema="gelap"] .btn { color: #1b120b; }
.btn.alt { background: var(--gold-soft); color: var(--brand); }
.btn.block { width: 100%; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btns .btn { flex: 1 1 auto; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--paper); color: var(--brand); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .82rem; cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-tema="gelap"] .chip.on { color: #1b120b; }

/* Hasil */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.b1 { background: var(--good-bg); color: var(--good); }
.b0 { background: var(--mid-bg); color: var(--mid); }
.b-1 { background: var(--bad-bg); color: var(--bad); }
.res { border-left: 4px solid var(--line); padding: 10px 12px; border-radius: 10px; background: var(--bg); margin-bottom: 10px; }
.res.r1 { border-color: var(--good); }
.res.r0 { border-color: var(--mid); }
.res.r-1 { border-color: var(--bad); }
.res h3 { margin: 0 0 4px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.list li:last-child { border-bottom: 0; }
.list li .r { text-align: right; flex: none; }
.note { background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; font-size: .84rem; margin: 10px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* Kalender */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { flex: 1; text-align: center; margin: 0; }
.cal-head small { display: block; font-family: system-ui, sans-serif; font-size: .74rem; color: var(--muted); font-weight: 400; }
.cal-head .icon-btn { background: var(--gold-soft); color: var(--brand); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .dow { text-align: center; font-size: .7rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal .dow.sun, .cal .d.sun .n { color: var(--bad); }
.cal .d {
  border: 1px solid var(--line); background: var(--bg); border-radius: 9px; min-height: 58px; padding: 4px 3px;
  display: flex; flex-direction: column; align-items: center; cursor: pointer; font: inherit; color: var(--ink); position: relative;
}
.cal .d.out { opacity: .35; }
.cal .d .n { font-weight: 700; font-size: .98rem; }
.cal .d .p { font-size: .62rem; color: var(--muted); }
.cal .d .j { font-size: .6rem; color: var(--gold); font-weight: 700; }
.cal .d.today { border: 2px solid var(--brand); }
.cal .d.mine { background: var(--gold-soft); }
.cal .d.keramat::after { content: ''; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-2); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .74rem; color: var(--muted); margin-top: 10px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; background: var(--line); }
.legend .l-today::before { border: 2px solid var(--brand); background: none; }
.legend .l-mine::before { background: var(--gold-soft); border: 1px solid var(--gold); }
.legend .l-ker::before { background: var(--brand-2); border-radius: 50%; }

/* Pustaka */
.art-list a { display: block; text-decoration: none; color: inherit; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.art-list a:last-child { border-bottom: 0; }
.art-list b { display: block; font-family: var(--serif); font-size: 1.02rem; color: var(--brand); }
.art-list small { color: var(--muted); }
.article { font-size: .96rem; }
.article ul, .article ol { padding-left: 1.3em; }
.article li { margin-bottom: .45em; }
.article ol.cols { columns: 2; }
.article .tembang { font-family: var(--serif); font-style: italic; background: var(--bg); border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 8px; }
.pitutur dt { font-family: var(--serif); font-weight: 700; color: var(--brand); margin-top: 10px; }
.pitutur dd { margin: 2px 0 0; }
.tbl-wrap { overflow-x: auto; margin: 8px 0 12px; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--gold-soft); color: var(--brand); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* Aksara */
.jawa { font-family: var(--jawa); }
.aksara-out { font-family: var(--jawa); font-size: 2rem; line-height: 2.2; background: var(--bg); border-radius: 12px; padding: 12px 14px; min-height: 80px; word-break: break-word; }
.aks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.aks-grid div { background: var(--bg); border-radius: 10px; text-align: center; padding: 6px 2px; }
.aks-grid .g { font-family: var(--jawa); font-size: 1.7rem; line-height: 1.8; display: block; }
.aks-grid small { color: var(--muted); font-size: .72rem; }

/* Mangsa */
.mangsa { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.mangsa:last-child { border-bottom: 0; }
.mangsa .no { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--brand); font-weight: 700; }
.mangsa.now { background: var(--gold-soft); border-radius: 12px; padding: 12px; border: 0; }
.mangsa.now .no { background: var(--brand); color: #fff; }
.mangsa i { color: var(--muted); }

/* Sheet & toast */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(20, 10, 5, .5); }
.sheet-body {
  position: relative; background: var(--paper); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); animation: up .22s ease-out;
}
.sheet-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.8rem; color: var(--muted); cursor: pointer; line-height: 1; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); z-index: 50;
  background: #2b1a10; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .88rem; max-width: 90vw;
}
.empty { text-align: center; color: var(--muted); padding: 20px; }
.foot { text-align: center; font-size: .76rem; color: var(--muted); margin-top: 18px; }

@media (min-width: 700px) {
  .cal .d { min-height: 72px; }
  .big { font-size: 2.4rem; }
}
