/* OURS — Design System (dari referensi visual 2026-10-12)
   Dark cozy · pixel-art indie · charcoal + sage + beige */

:root {
  --charcoal: #1E1E1E;
  --surface: #2A2A2A;
  --surface-2: #333333;
  --surface-3: #3D3D3D;
  --sage: #8ADAB7;
  --sage-deep: #5FA98A;
  --sage-soft: rgba(138, 218, 183, 0.14);
  --beige: #D7C8B8;
  --beige-soft: rgba(215, 200, 184, 0.14);
  --soft-green: #B7C9A7;
  --error: #E07A7A;
  --error-soft: rgba(224, 122, 122, 0.14);
  --text: #F5F1E8;
  --text-dim: #A8A094;
  --text-faint: #6E6A62;
  --line: rgba(245, 241, 232, 0.10);
  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 16px;
  --radius-pill: 999px;
  --font-head: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--charcoal); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: var(--sage); }
img { max-width: 100%; }
button { font-family: inherit; }

/* ---------- App frame ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.view {
  flex: 1; width: 100%; max-width: 560px; margin: 0 auto;
  padding: calc(12px + var(--safe-t)) 20px calc(var(--nav-h) + 28px + var(--safe-b));
  animation: viewIn 0.22s ease;
}
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view.no-nav { padding-bottom: calc(28px + var(--safe-b)); }

/* Desktop: jangan paksa layout mobile melebar */
@media (min-width: 900px) {
  .view { max-width: 640px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* ---------- Splash ---------- */
.splash {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; text-align: center;
  padding: 48px 28px calc(40px + var(--safe-b));
  background: var(--charcoal) url("../img/splash-bg.png") center/cover no-repeat;
  position: relative;
}
.splash::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(30,30,30,0.92) 30%, rgba(30,30,30,0.15) 70%);
  pointer-events: none;
}
.splash > * { position: relative; z-index: 1; }
.splash h1 { font-size: 44px; letter-spacing: 0.08em; font-weight: 800; }
.splash .tagline { color: var(--text-dim); margin: 8px 0 28px; font-size: 15px; }
.splash .btn { width: 100%; max-width: 340px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; font-weight: 600; font-size: 15px;
  border-radius: var(--radius-pill); padding: 14px 24px;
  transition: transform 0.08s ease, opacity 0.15s ease;
  min-height: 48px; text-decoration: none; color: var(--charcoal);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--sage); color: #143327; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-beige { background: var(--beige); color: #3A2F24; }
.btn-ghost { background: transparent; color: var(--sage); border: 1px solid var(--line); }
.btn-danger { background: var(--error-soft); color: var(--error); }
.btn-sm { padding: 9px 18px; min-height: 38px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-l); padding: 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row .grow { flex: 1; min-width: 0; }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* ---------- Pills / segmented ---------- */
.pills { display: flex; gap: 8px; margin: 12px 0; overflow-x: auto; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-dim); border-radius: var(--radius-pill);
  padding: 9px 18px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.pill.active { background: var(--beige); border-color: var(--beige); color: #3A2F24; }
.pill.sage.active { background: var(--sage); border-color: var(--sage); color: #143327; }

/* Segmented control (Your Room / Visit Partner) */
.segmented {
  display: flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-pill); padding: 4px; margin: 12px 0;
}
.segmented button {
  flex: 1; border: 0; background: transparent; color: var(--text-dim);
  border-radius: var(--radius-pill); padding: 10px; font-weight: 600; font-size: 14px;
  cursor: pointer;
}
.segmented button.active { background: var(--beige); color: #3A2F24; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.input, .textarea, select.input {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); color: var(--text);
  padding: 13px 16px; font-size: 15px; font-family: inherit; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--sage-deep); }
.textarea { min-height: 88px; resize: vertical; }
.input::placeholder { color: var(--text-faint); }
.form-error { color: var(--error); font-size: 13px; margin-top: 6px; min-height: 18px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(30, 30, 30, 0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.bottom-nav .tabs {
  display: flex; max-width: 560px; margin: 0 auto; height: var(--nav-h);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: 0; color: var(--text-faint);
  font-size: 10.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 44px;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--sage); }

/* ---------- Header ---------- */
.topbar { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.topbar .grow { flex: 1; }
.topbar h1 { font-size: 24px; }
.topbar .sub { color: var(--text-dim); font-size: 13.5px; margin-top: 2px; }
.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- Mood selector ---------- */
.moods { display: flex; gap: 6px; justify-content: space-between; margin: 12px 0 4px; }
.mood {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 0; cursor: pointer; padding: 6px 2px; border-radius: var(--radius-m);
}
.mood .face {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mood .face svg { width: 30px; height: 30px; image-rendering: pixelated; }
.mood span { font-size: 11px; color: var(--text-dim); font-weight: 600; }
.mood.selected .face { border-color: var(--sage); background: var(--sage-soft); }
.mood.selected span { color: var(--text); }

/* ---------- XP bar ---------- */
.xpbar { height: 8px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.xpbar > i { display: block; height: 100%; background: var(--sage); border-radius: var(--radius-pill); transition: width 0.4s ease; }
.xp-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-top: 5px; font-family: var(--font-mono); }

/* ---------- Quest cards ---------- */
.quest-art {
  width: 100%; aspect-ratio: 16/8.2; object-fit: cover;
  border-radius: var(--radius-m); background: var(--surface-2);
  image-rendering: pixelated;
}
.quest-badges { display: flex; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; font-family: var(--font-mono);
  background: var(--beige-soft); color: var(--beige);
  border-radius: var(--radius-pill); padding: 4px 10px;
}
.badge.sage { background: var(--sage-soft); color: var(--sage); }
.badge svg { width: 13px; height: 13px; }
.quest-item { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 10px; cursor: pointer; }
.quest-item .thumb { width: 52px; height: 52px; border-radius: var(--radius-s); background: var(--surface-2); flex: none; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.quest-item .thumb svg { width: 26px; height: 26px; color: var(--sage); }
.quest-item > svg { width: 20px; height: 20px; flex: none; color: var(--text-faint); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-proposed { background: var(--beige); }
.status-accepted, .status-active { background: var(--sage); }
.status-completed { background: var(--text-faint); }

/* ---------- Timeline (Our Story) ---------- */
.timeline { position: relative; margin: 8px 0 0 8px; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-item { position: relative; margin-bottom: 20px; }
.tl-item::before {
  content: ""; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--sage); border: 3px solid var(--charcoal);
  box-shadow: 0 0 0 2px var(--sage-deep);
}
.tl-date { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); }
.tl-title { font-weight: 700; margin: 2px 0; }
.tl-body { color: var(--text-dim); font-size: 13.5px; }
.polaroid {
  background: #EFE9DC; border-radius: 4px; padding: 8px 8px 22px; margin-top: 10px;
  width: 150px; transform: rotate(-2deg); box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 2px; image-rendering: pixelated; background: var(--surface-2); }
.tl-item:nth-child(even) .polaroid { transform: rotate(2deg); }

/* ---------- Stats ---------- */
.stats { display: flex; text-align: center; margin: 14px 0; }
.stats .stat { flex: 1; }
.stats .num { font-size: 20px; font-weight: 800; font-family: var(--font-head); }
.stats .lbl { font-size: 12px; color: var(--text-dim); }
.stats .stat + .stat { border-left: 1px solid var(--line); }

/* ---------- Menu list (settings) ---------- */
.menu { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; margin-bottom: 12px; }
.menu button, .menu a {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: none; border: 0; color: var(--text); font-size: 15px; cursor: pointer;
  text-decoration: none; text-align: left;
}
.menu button + button, .menu a + a, .menu button + a { border-top: 1px solid var(--line); }
.menu svg { width: 20px; height: 20px; color: var(--text-dim); flex: none; }
.menu .chev { margin-left: auto; color: var(--text-faint); }
.menu .danger { color: var(--error); }
.menu .danger svg { color: var(--error); }

/* ---------- Avatar ---------- */
.avatar {
  width: 84px; height: 84px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--surface-2); background: var(--surface-2);
  image-rendering: pixelated;
}
.avatar.sm { width: 44px; height: 44px; border-width: 2px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 16px + var(--safe-b)); z-index: 100; display: flex; justify-content: center; pointer-events: none; padding: 0 20px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #111; border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-pill); padding: 12px 20px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: toastIn 0.25s ease; max-width: 480px;
}
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok svg { color: var(--sage); }
.toast.err svg { color: var(--error); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transition: opacity 0.3s ease; }

/* ---------- Modal ---------- */
#modal-root { position: fixed; inset: 0; z-index: 90; display: none; }
#modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }
.modal {
  position: absolute; left: 16px; right: 16px; bottom: calc(16px + var(--safe-b));
  max-width: 480px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 20px; animation: viewIn 0.22s ease; max-height: 80dvh; overflow-y: auto;
}
.modal h3 { margin-bottom: 6px; }

/* ---------- Loading / empty / error ---------- */
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 20px; color: var(--text-dim); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--surface-2); border-top-color: var(--sage);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.state-err { text-align: center; padding: 40px 20px; }
.state-err .msg { color: var(--error); margin: 8px 0 16px; font-size: 14px; }

/* ---------- Invite code ---------- */
.invite-code {
  font-family: var(--font-mono); font-size: 30px; font-weight: 700; letter-spacing: 0.18em;
  text-align: center; background: var(--charcoal); border: 1px dashed var(--sage-deep);
  border-radius: var(--radius-m); padding: 18px 12px; margin: 14px 0; color: var(--sage);
  user-select: all;
}

/* ---------- Pixel placeholder (aset belum ada) ---------- */
.pixel-ph {
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 0 0 / 24px 24px;
  border-radius: var(--radius-m); display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-family: var(--font-mono); font-size: 11px; min-height: 120px;
  border: 1px solid var(--line); text-align: center; padding: 12px;
}

/* ---------- Steps checklist ---------- */
.step { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 8px; }
.step .check {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  border: 2px solid var(--text-faint); display: flex; align-items: center; justify-content: center;
}
.step.done .check { background: var(--sage); border-color: var(--sage); color: #143327; }
.step.done .check svg { width: 14px; height: 14px; }
.step .check svg { display: none; }
.step.done .check svg { display: block; }

/* ---------- Companion ---------- */
.companion-hero { text-align: center; padding: 8px 0 4px; }
.companion-hero img { width: 150px; height: 150px; object-fit: contain; image-rendering: pixelated; }
.room-art { width: 100%; border-radius: var(--radius-l); border: 1px solid var(--line); image-rendering: pixelated; display: block; }

/* ---------- Util ---------- */
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.center { text-align: center; }
.hidden { display: none !important; }
.linklike { background: none; border: 0; color: var(--sage); font-weight: 600; cursor: pointer; font-size: 14px; padding: 8px; }
.caption { font-size: 12.5px; color: var(--text-faint); }

/* Companion dengan aksesori + animasi idle */
.companion-stage {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}
.companion-base {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: pet-bob 3s ease-in-out infinite;
}
.companion-acc {
  position: absolute;
  pointer-events: none;
  animation: pet-bob 3s ease-in-out infinite;
}
.companion-acc.acc-hat {
  top: -8%;
  left: 50%;
  transform: translateX(-50%);
  width: 75%;
}
.companion-acc.acc-glasses {
  top: 32%;
  left: 50%;
  transform: translateX(-50%);
  width: 62%;
}
.companion-acc.acc-scarf {
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  width: 68%;
}
@keyframes pet-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}
.companion-stage:active .companion-base {
  animation: pet-happy 0.6s ease;
}
@keyframes pet-happy {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.08) rotate(-2deg); }
  60% { transform: scale(1.05) rotate(2deg); }
}
