:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --text: #1e2033;
  --muted: #6b6f80;
  --brand: #4338ca;
  --brand-2: #7c3aed;
  --accent: #6366f1;
  --wa: #25d366;
  --wa-dark: #128c7e;
  --danger: #e11d48;
  --border: #e6e7f0;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(30, 32, 51, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #fff;
  background: rgba(255,255,255,.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.brand-txt h1 { font-size: 18px; letter-spacing: .2px; }
.brand-txt p { font-size: 12px; opacity: .85; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0;
  font-size: 26px; line-height: 1; color: #fff;
  background: rgba(255,255,255,.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
  cursor: pointer; flex: none;
}
.icon-btn.small { width: 34px; height: 34px; font-size: 22px; }

/* Cari / arahan */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 18px 8px;
  padding: 4px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.search-icon { color: var(--muted); font-size: 18px; }
.search-bar input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 16px; padding: 12px 0; color: var(--text);
}
.search-bar input::placeholder { color: #9aa0b4; }
.clear-btn {
  border: 0; background: #eceef6; color: var(--muted);
  width: 26px; height: 26px; border-radius: 50%; font-size: 18px; cursor: pointer;
}

.hint {
  margin: 4px 18px 6px; padding: 8px 12px;
  font-size: 13px; color: var(--brand);
  background: rgba(99,102,241,.1);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}

/* Content */
.content { padding: 4px 18px 90px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 12px; }
.section-head h2 { font-size: 15px; color: var(--muted); font-weight: 600; }
.count { font-size: 12px; color: #9aa0b4; }

.cards { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 12px 12px 14px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .06s ease;
}
.card:active { transform: scale(.99); }
.card-thumb {
  width: 48px; height: 48px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-size: 20px; color: #fff;
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb.type-text { background: linear-gradient(135deg, var(--accent), var(--brand-2)); }
.card-thumb.type-image { background: linear-gradient(135deg, #ec4899, #f97316); }
.card-body { flex: 1; min-width: 0; }
.card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-preview {
  font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-cmd {
  font-size: 12px; color: var(--accent); font-weight: 700;
  background: rgba(99,102,241,.1);
  padding: 3px 8px; border-radius: 999px; flex: none;
}
.card-chevron { color: #c2c6d6; font-size: 18px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .small { margin-top: 6px; }

/* Modals */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(20, 21, 33, .5);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: 20px;
  padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.3);
  animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-card h3 { font-size: 18px; margin-bottom: 14px; }

.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  font-size: 15px; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; background: #fafbff;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; font-family: inherit; }

.seg { display: flex; gap: 8px; margin-top: 6px; }
.seg-btn {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: #fafbff; color: var(--muted); font-size: 14px; cursor: pointer;
}
.seg-btn.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

.preview { margin-top: 8px; }
.preview img { width: 100%; max-height: 200px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }

.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.flex-sp { flex: 1; }
.btn {
  border: 0; border-radius: 10px; padding: 11px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: #eceef6; color: var(--text); }
.btn.danger { background: #ffe4e6; color: var(--danger); }
.btn.whatsapp { background: var(--wa); color: #fff; }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#vBody { margin-top: 6px; }
#vBody .v-text {
  font-size: 16px; white-space: pre-wrap; word-break: break-word;
  background: #f6f7fb; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
}
#vBody img { width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; background: #f6f7fb; }

.small { font-size: 12px; color: var(--muted); }
.center { text-align: center; margin-top: 10px; }

code { background: #eceef6; padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1e2033; color: #fff; font-size: 14px;
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 100; max-width: 90%;
}
.toast[hidden] { display: none; }

@media (max-width: 360px) {
  .brand-txt h1 { font-size: 16px; }
  .modal-card { padding: 16px; }
}
