:root {
  --bg: #0E0D0B;
  --bg-2: #161411;
  --card: #1A1814;
  --line: #2C2820;
  --line-2: #3A3428;
  --ink: #F3EEE3;
  --ink-2: #BDB4A2;
  --ink-3: #8F8674;
  --gold: #E2B65C;
  --gold-2: #C4913A;
  --gold-ink: #1A1408;
  --red: #FF7A66;
  --green: #8FD18A;
  --r-s: 10px;
  --r-m: 16px;
  --r-l: 26px;
  --r-pill: 999px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
  --f-head: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --f-body: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(120% 40% at 30% 0%, #2A2215 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 15px/1.45 var(--f-body);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(110px + var(--safe-b));
}

/* header */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
h1 { margin: 0; font: 800 34px/1.05 var(--f-head); letter-spacing: -.02em; }
h2 { margin: 0; font: 700 18px/1.2 var(--f-head); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.muted { color: var(--ink-3); font-size: 13px; }

/* buttons */
.btn {
  border: 0; border-radius: var(--r-m); padding: 12px 16px; font-weight: 700; font-size: 15px;
  transition: transform .2s var(--ease), filter .2s var(--ease);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-gold { background: linear-gradient(180deg, #F0CC7E, var(--gold) 45%, var(--gold-2)); color: var(--gold-ink); }
.btn-ghost { background: var(--bg-2); border: 1px solid var(--line-2); color: var(--ink); }
.btn-danger { background: transparent; border: 1px solid #5A2A22; color: var(--red); }
.btn-block { width: 100%; }
.icon-btn {
  width: 46px; height: 46px; border-radius: var(--r-m); border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--ink-2); display: grid; place-items: center;
}

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 22px; }
.stat { border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 10px; background: var(--card); min-width: 0; }
.stat span { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b { display: block; font: 800 clamp(18px, 5.4vw, 24px)/1.2 var(--f-head); letter-spacing: -.01em; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* today */
.today { margin-bottom: 22px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.today-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.today-list li { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.today-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.today-list .dot.red { background: var(--red); }
.today-list .dot.calm { background: var(--green); }
.today-list .txt { flex: 1; min-width: 0; font-size: 14px; }
.today-list .txt b { font-weight: 600; }
.today-list .go { background: none; border: 0; color: var(--gold); font-weight: 600; font-size: 14px; padding: 6px 0 6px 8px; }

/* filters */
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.search input {
  width: 100%; border: 1px solid var(--line-2); background: var(--bg-2); border-radius: var(--r-m);
  padding: 14px 16px; font-size: 16px; outline: none;
}
.search input::placeholder { color: var(--ink-3); }
.chips { display: flex; gap: 8px; }
.chip {
  border: 1px solid var(--line-2); background: transparent; color: var(--ink-2);
  padding: 8px 14px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600;
}
.chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* cards */
.cards { display: grid; gap: 14px; }
.card {
  border: 1px solid var(--line); border-radius: var(--r-l); background: var(--card); padding: 18px;
}
.cards.anim .card { animation: rise .45s var(--ease) both; }
.cards.anim .card:nth-child(2) { animation-delay: .06s; }
.cards.anim .card:nth-child(3) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card-head { display: flex; gap: 14px; align-items: flex-start; }
.thumb {
  width: 84px; height: 84px; border-radius: var(--r-m); flex: none; object-fit: cover; background: var(--bg-2);
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-3);
  font: 800 28px var(--f-head);
}
.card-title { flex: 1; min-width: 0; }
.card-title h3 {
  margin: 0 0 6px; font: 800 20px/1.15 var(--f-head); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill); background: #2E2617; color: #F0CC7E; }
.badge.red { background: #3A1C17; color: var(--red); }
.badge.green { background: #1C2C1A; color: var(--green); }
.badge.grey { background: #24211C; color: var(--ink-2); }
.card-sub { color: var(--gold); font-size: 14px; }
.card-sub.red { color: var(--red); }
.edit-btn { width: 40px; height: 40px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink-2); display: grid; place-items: center; flex: none; }
.edit-btn svg { width: 18px; height: 18px; }

.prog { margin: 16px 0 14px; }
.prog-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.prog-row b { color: var(--ink); }
.prog-row .pct { color: var(--gold); font-weight: 700; margin-left: 8px; }
.bar { height: 8px; border-radius: var(--r-pill); background: #2A261E; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-2), #F0CC7E); transition: width .6s var(--ease); }

.mini { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; margin-bottom: 14px; }
.mini div { border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 12px; min-width: 0; }
.mini span { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini b { display: block; font: 800 18px/1.3 var(--f-head); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini b.small { font: 700 14px/1.6 var(--f-body); }
.card-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }

.empty { text-align: center; padding: 36px 12px; border: 1px dashed var(--line-2); border-radius: var(--r-l); color: var(--ink-2); }
.empty h3 { margin: 0 0 6px; font: 800 20px var(--f-head); color: var(--ink); }
.empty p { margin: 0 0 16px; }

/* tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 10px max(24px, calc(50% - 250px)) calc(10px + var(--safe-b));
  background: rgba(14, 13, 11, .92); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.tab { background: none; border: 0; display: grid; justify-items: center; gap: 2px; color: var(--ink-3); font-size: 13px; font-weight: 700; padding: 6px; }
.tab.is-on { color: var(--gold); }
.fab {
  width: 64px; height: 64px; border-radius: 50%; margin-top: -30px; border: 4px solid var(--bg);
  background: linear-gradient(180deg, #F0CC7E, var(--gold) 45%, var(--gold-2)); color: var(--gold-ink);
  display: grid; place-items: center; box-shadow: 0 8px 24px rgba(226, 182, 92, .25);
  transition: transform .25s var(--bounce);
}
.fab:active { transform: scale(.92); }
.fab svg { width: 28px; height: 28px; stroke-width: 2.4; }

/* sheet */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh;
  background: var(--bg-2); color: var(--ink); border-radius: var(--r-l) var(--r-l) 0 0;
  border-top: 1px solid var(--line-2);
}
.sheet[open] { animation: sheet-in .35s var(--ease); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
.sheet::backdrop { background: rgba(0, 0, 0, .6); }
.sheet-inner { padding: 20px 16px calc(20px + var(--safe-b)); display: grid; gap: 14px; }
.sheet-inner h2 { font-size: 22px; }
.sheet-inner .lead { margin: -6px 0 0; color: var(--ink-2); font-size: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line-2); background: var(--bg); border-radius: var(--r-s);
  padding: 12px; font-size: 16px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); }
.field small { color: var(--ink-3); font-size: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; padding: 9px 14px; border-radius: var(--r-pill); border: 1px solid var(--line-2); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg input:checked + span { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 4px; }
.sheet-actions.one { grid-template-columns: 1fr; }
.photo-pick { display: flex; gap: 12px; align-items: center; }
.photo-pick .thumb { width: 64px; height: 64px; font-size: 20px; }
.err { color: var(--red); font-size: 13px; margin: 0; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list li .l { min-width: 0; overflow-wrap: anywhere; }
.list li .r { color: var(--ink-2); white-space: nowrap; }
.list .del { background: none; border: 0; color: var(--ink-3); padding: 0 0 0 8px; font-size: 13px; }
.quick { display: grid; gap: 10px; }
.quick button { text-align: left; display: flex; gap: 12px; align-items: center; padding: 16px; border-radius: var(--r-m); border: 1px solid var(--line-2); background: var(--bg); font-weight: 700; }
.quick button small { display: block; font-weight: 400; color: var(--ink-3); font-size: 13px; }

/* analisis & settings */
.panel { border: 1px solid var(--line); border-radius: var(--r-l); background: var(--card); padding: 18px; margin-bottom: 14px; }
.panel h2 { margin-bottom: 12px; }
.panel p { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; }
.big3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.locked { position: relative; overflow: hidden; }
.locked .blur { filter: blur(6px); opacity: .5; pointer-events: none; user-select: none; }
.locked .lock-cta { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 16px; }
.lock-cta b { font: 800 18px var(--f-head); }
.rank { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rank li { counter-increment: r; display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.rank li::before { content: counter(r); font: 800 16px var(--f-head); color: var(--gold); }
.rank li .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 700; text-align: right; }
.stack { display: grid; gap: 10px; }

/* banner & toast */
.banner { background: var(--gold); color: var(--gold-ink); padding: 12px 16px; font-size: 14px; font-weight: 600; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.banner button { background: var(--gold-ink); color: var(--gold); border: 0; border-radius: var(--r-pill); padding: 6px 12px; font-weight: 700; flex: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--r-pill);
  font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; z-index: 30; max-width: calc(100% - 32px);
  transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  h1 { font-size: 30px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .mini { grid-template-columns: 1fr 1fr; }
  .mini div:last-child { grid-column: span 2; }
  .thumb { width: 68px; height: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* target sentuh >= 44px (hasil review) */
.chip, .seg span { min-height: 44px; display: inline-flex; align-items: center; }
.today-list .go { min-height: 44px; min-width: 44px; }
.edit-btn { width: 44px; height: 44px; }
.banner button { min-height: 40px; padding: 8px 14px; }
.list .del { min-height: 44px; min-width: 44px; padding: 0 0 0 12px; }
.link-btn { background: none; border: 0; color: var(--gold); font-weight: 600; padding: 10px 2px; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }
.locked { min-height: 220px; }
.locked .lock-cta { top: 52px; }
