/* ============================================================
   Nexus — clean & minimal, mobile-first
   Display: Fraunces (countdown + headings) · UI: Inter
   ============================================================ */

:root {
  --bg: #FBFAF7;
  --surface: #FFFFFF;
  --ink: #1A1714;
  --muted: #8A817A;
  --faint: #B7AFA7;
  --line: #ECE7E0;
  --line-strong: #DED7CD;

  --accent: #9B2C4A;        /* garnet rose */
  --accent-soft: #FBEEF1;
  --green: #2F6B4F;         /* ready / paid */
  --green-soft: #E8F1EC;
  --amber: #B45309;         /* unpaid / pending */
  --amber-soft: #FBF0E2;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26,23,20,.04), 0 8px 24px rgba(26,23,20,.05);
  --tab-h: 64px;
  --maxw: 480px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

.serif { font-family: "Fraunces", Georgia, serif; }

/* ---------- shell ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
}
.topbar .brand {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.topbar .brand span { color: var(--accent); }

.view { padding: 4px 20px 28px; display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-title {
  font-family: "Fraunces", serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 8px 0 2px;
}
.view-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

/* ---------- bottom tabs ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--maxw);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 50;
}
.tabbar button {
  flex: 1;
  background: none;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.tabbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tabbar button.active { color: var(--accent); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

/* ---------- countdown (signature) ---------- */
.countdowns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.cd {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.cd::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent);
}
.cd.k::before { background: var(--green); }
.cd .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.cd .num { font-family: "Fraunces", serif; font-size: 46px; font-weight: 600; line-height: 1; margin: 8px 0 2px; letter-spacing: -0.03em; }
.cd .unit { font-size: 12px; color: var(--muted); }
.cd .date { font-size: 12px; color: var(--ink); margin-top: 8px; font-weight: 500; }
.cd .past { color: var(--green); font-weight: 600; font-size: 13px; }

/* ---------- progress ---------- */
.prog-row { margin-bottom: 16px; }
.prog-row:last-child { margin-bottom: 0; }
.prog-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.prog-top .name { font-weight: 600; font-size: 13.5px; }
.prog-top .val { font-size: 12px; color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s ease; }
.bar.g > i { background: var(--green); }

/* ---------- list rows ---------- */
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.row .main { flex: 1; min-width: 0; }
.row .ttl { font-weight: 500; font-size: 14px; }
.row.done .ttl { text-decoration: line-through; color: var(--faint); }
.row .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.check {
  width: 22px; height: 22px; border-radius: 7px;
  border: 1.8px solid var(--line-strong);
  background: var(--surface);
  flex-shrink: 0; cursor: pointer;
  display: grid; place-items: center;
}
.check.on { background: var(--green); border-color: var(--green); }
.check svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; }
.check.on svg { opacity: 1; }

/* ---------- pills ---------- */
.pill { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; letter-spacing: .02em; white-space: nowrap; }
.pill.tunang { background: var(--accent-soft); color: var(--accent); }
.pill.kahwin { background: var(--green-soft); color: var(--green); }
.pill.both { background: #F0ECE6; color: var(--muted); }
.pill.paid { background: var(--green-soft); color: var(--green); }
.pill.unpaid { background: var(--amber-soft); color: var(--amber); }
.pill.cat { background: #F4F1EC; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  border: 0; border-radius: var(--radius-sm); padding: 11px 16px;
  cursor: pointer; color: #fff; background: var(--ink);
}
.btn.accent { background: var(--accent); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:active { transform: scale(.985); }

.icon-btn { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }

.add-fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 0;
  font-size: 28px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 18px rgba(155,44,74,.35);
  z-index: 40;
  display: grid; place-items: center;
}
.app:has(.view:not(.active)) .add-fab { display: grid; }

.row-actions { display: flex; gap: 4px; }
.row-actions button { font-size: 16px; }

/* ---------- forms / modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,23,20,.42);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; animation: fade .2s ease;
}
.modal {
  background: var(--surface);
  width: 100%; max-width: var(--maxw);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: slideup .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-family: "Fraunces", serif; font-size: 20px; font-weight: 600; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 11px 12px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- budget ---------- */
.budget-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; }
.stat .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .v { font-family: "Fraunces", serif; font-size: 19px; font-weight: 600; margin-top: 4px; letter-spacing: -0.02em; }
.stat .v.spent { color: var(--accent); }
.stat .v.left { color: var(--green); }
.stat .v.over { color: var(--amber); }

.bcat { margin-bottom: 16px; }
.bcat .btop { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.bcat .bname { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.bcat .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.bcat .bval { font-size: 12px; color: var(--muted); }
.bcat .bval b { color: var(--ink); font-weight: 600; }
.bbar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bbar > i { display: block; height: 100%; border-radius: 99px; transition: width .5s ease; }
.bbar > i.over { background: var(--amber) !important; }

/* ---------- media grid ---------- */
.media-cat { margin-bottom: 22px; }
.media-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.media-grid .cell {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--line); cursor: pointer;
}
.media-grid .cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid .cell .doc { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 11px; padding: 8px; text-align: center; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 200; display: grid; place-items: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox .x { position: absolute; top: 16px; right: 18px; color: #fff; font-size: 30px; background: none; border: 0; cursor: pointer; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; color: var(--muted); padding: 36px 16px; font-size: 14px; }
.empty .big { font-family: "Fraunces", serif; font-size: 17px; color: var(--ink); margin-bottom: 4px; }
.loading { text-align: center; color: var(--faint); padding: 30px; font-size: 13px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 500;
  padding: 11px 18px; border-radius: 99px; z-index: 300; transition: all .25s ease;
  max-width: 86%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--accent); }

/* ============================================================
   Login (index.html)
   ============================================================ */
.login-wrap { max-width: 380px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; }
.login-brand { font-family: "Fraunces", serif; font-size: 40px; font-weight: 600; letter-spacing: -0.03em; text-align: center; }
.login-brand span { color: var(--accent); }
.login-tag { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 32px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.login-err { color: var(--accent); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.login-foot { text-align: center; color: var(--faint); font-size: 11.5px; margin-top: 22px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
