/* ============ Token desain ============ */
:root {
  --bg: #101216;
  --bg-side: #0c0e11;
  --surface: #171a20;
  --surface-2: #1e222a;
  --line: #272c36;
  --line-strong: #363c49;
  --text: #ebe8e1;
  --muted: #98a1af;
  --faint: #6c7584;
  --accent: #8d9bff;
  --accent-ink: #0f1225;
  --accent-soft: rgba(141, 155, 255, .14);
  --ok: #6fd3a0;
  --warn: #f0be5c;
  --bad: #f07a7a;
  --code-bg: #0b0d10;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px -18px rgba(0,0,0,.7);
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --side-w: 272px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f3ee;
  --bg-side: #efece5;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --line: #e1ddd2;
  --line-strong: #cfc9bb;
  --text: #1d1f25;
  --muted: #5d6573;
  --faint: #868d9a;
  --accent: #4452d9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(68, 82, 217, .1);
  --ok: #17874f;
  --warn: #a96a00;
  --bad: #c43d3d;
  --code-bg: #fbfaf7;
  --shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 10px 28px -20px rgba(40,35,20,.35);
  color-scheme: light;
}

/* ============ Dasar ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
svg { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Input: 16px agar iOS Safari tidak zoom saat fokus */
input, select, textarea {
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
  transition: border-color .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

/* ============ Tombol ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: .94rem; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, color .15s ease;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .86rem; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  color: var(--muted); border: 1px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ============ Badge ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 999px; font-size: .78rem; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ============ Toast ============ */
.toasts {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--text); color: var(--bg); border-radius: 12px; font-weight: 500; font-size: .92rem;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.55); pointer-events: auto;
  animation: toast-in .22s cubic-bezier(.2,.8,.2,1);
}
.toast.err { background: var(--bad); color: #1b0b0b; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ============ Loading & kosong ============ */
.skeleton { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 168px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.05) 50%, transparent 70%);
  transform: translateX(-100%); animation: shimmer 1.2s infinite;
}
:root[data-theme="light"] .skeleton::after { background: linear-gradient(100deg, transparent 30%, rgba(0,0,0,.05) 50%, transparent 70%); }
@keyframes shimmer { to { transform: translateX(100%); } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted);
}
.empty h3 { color: var(--text); font-family: var(--serif); font-weight: 500; font-size: 1.35rem; }
.empty p { max-width: 42ch; }
.empty .icon { width: 28px; height: 28px; color: var(--faint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
