:root {
  --bg: #f3f6f4; --card: #ffffff; --ink: #18221d; --muted: #64706a; --line: #dfe6e2;
  --brand: #0f9d6b; --brand-ink: #ffffff; --brand-soft: #e3f5ed; --warn: #b45309; --warn-soft: #fff4e0;
  --bad: #c0392b; --chip: #eef2f0; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1412; --card: #18201c; --ink: #e8efeb; --muted: #95a39b; --line: #2a3530;
    --brand: #22b07c; --brand-soft: #173a2c; --warn: #f0b35a; --warn-soft: #3a2c14; --bad: #ff7a6b; --chip: #232d28; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 96px; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 19px; text-decoration: none; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.save { font-size: 13px; color: var(--muted); }
main { max-width: 640px; margin: 0 auto; padding: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
h1 { font-size: 26px; margin: 8px 0 4px; line-height: 1.2; }
h2 { font-size: 18px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
small { font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 16px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); min-height: 44px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.big { width: 100%; font-size: 18px; padding: 18px; border-radius: 16px; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

input.in { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
input.in:focus { outline: 2px solid var(--brand); outline-offset: -1px; background: var(--card); }
label.lbl { font-size: 13px; color: var(--muted); display: block; margin: 0 0 4px; }

.steps { display: flex; gap: 6px; margin: 0 0 14px; position: sticky; top: 57px; z-index: 4; background: var(--bg); padding: 6px 0; }
.steps button { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 6px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.steps button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.items .it { display: grid; grid-template-columns: 1fr 64px 120px 36px; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.items .it:last-child { border-bottom: 0; }
.items .it input { min-height: 40px; padding: 8px; }
.items .it .qty { text-align: center; }
.items .it .price { text-align: right; }
.items .head { font-size: 12px; color: var(--muted); padding: 0 0 2px; border: 0; }
.icon { border: 0; background: transparent; font-size: 18px; cursor: pointer; padding: 6px; border-radius: 8px; }
.itx { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: -2px; }
.empty-name input.name { border-color: var(--warn); }

.charges .ch { display: grid; grid-template-columns: 1fr 86px 120px; gap: 6px; align-items: center; margin-bottom: 8px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 0; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.charges .ch input { text-align: right; min-height: 40px; padding: 8px; }

.sum { display: flex; justify-content: space-between; padding: 4px 0; }
.sum.total { font-weight: 800; font-size: 19px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.check { margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.check.ok { background: var(--brand-soft); color: var(--brand); }
.check.bad { background: var(--warn-soft); color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--chip); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 36px; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chip.add { background: transparent; border-style: dashed; }
.chip .x { margin-left: 6px; opacity: .6; }

.assign .a { padding: 12px 0; border-bottom: 1px solid var(--line); }
.assign .a:last-child { border-bottom: 0; }
.assign .a .t { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-weight: 600; }
.assign .a.none .t .nm::after { content: " · belum dibagi"; color: var(--warn); font-weight: 500; font-size: 13px; }

.person { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.person .amt { font-weight: 800; font-size: 18px; white-space: nowrap; }
.person details { font-size: 13px; color: var(--muted); }
.person summary { cursor: pointer; }
.person .lines div { display: flex; justify-content: space-between; gap: 8px; }
.paid { text-decoration: line-through; opacity: .55; }
.paybtn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.paybtn.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

.warn { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }
.mine { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.mine:last-child { border-bottom: 0; }
.mine input { width: 24px; height: 24px; accent-color: var(--brand); flex: none; }
.mine .who { font-size: 13px; color: var(--muted); }
.mytotal { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); z-index: 6; }
.mytotal .in2 { max-width: 640px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mytotal b { font-size: 22px; }

.recent a { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.recent a:last-child { border-bottom: 0; }

.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; font-size: 13px; color: var(--muted); margin: 16px 0 6px; }
.how div span { display: block; font-size: 26px; margin-bottom: 4px; }

.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.busybox { background: var(--card); border-radius: 18px; padding: 24px 28px; text-align: center; min-width: 240px; }
.busybox small { color: var(--muted); display: block; margin-top: 4px; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; margin: 0 auto 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#photoModal img { max-width: 100%; max-height: 85vh; border-radius: 10px; background: #fff; }
.tapclose { color: #fff; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: #18221d; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }

.sharebox { display: flex; gap: 8px; }
.sharebox input { flex: 1; min-width: 0; }

@media (max-width: 420px) {
  .items .it { grid-template-columns: 64px 1fr 36px; gap: 6px; }
  .items .it .name { grid-column: 1 / -1; }
  .items .head { display: none; }
  .items .it .qty::before { content: ''; }
  .charges .ch { grid-template-columns: 1fr 76px 104px; }
  h1 { font-size: 23px; }
}
