/* ═══════════════════════════════════════════════════════════════
   KAPSUL — tema semesta (vanilla CSS, tanpa framework)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #050510;
  --panel: rgba(16, 18, 38, 0.72);
  --panel-solid: #101226;
  --border: rgba(140, 160, 255, 0.18);
  --text: #e8ecff;
  --dim: #8b93b8;
  --faint: #565e82;
  --accent: #8ab4ff;
  --accent2: #c792ea;
  --good: #7ee8a2;
  --warn: #ffd166;

  --r-bubble: 18px;
  --font: ui-rounded, 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'JetBrains Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Langit ─────────────────────────────────────────────────── */
#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.star { position: absolute; border-radius: 50%; background: #fff; opacity: 0.7; animation: twinkle 3.5s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: 0.15; } 50% { opacity: 0.85; } }

.shooting-star {
  position: fixed; top: 12%; left: -10%; width: 130px; height: 2px; z-index: 1;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff);
  transform: rotate(18deg); opacity: 0; pointer-events: none;
}
.shooting-star.active { animation: shoot 1.1s ease-out; }
@keyframes shoot { 0% { opacity: 0; transform: translateX(0) rotate(18deg); } 12% { opacity: 1; } 100% { opacity: 0; transform: translateX(120vw) rotate(18deg); } }

/* ── Terminal ───────────────────────────────────────────────── */
.terminal {
  position: relative; z-index: 2;
  width: min(560px, 100%);
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

#header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.capsule-glyph { font-size: 22px; filter: drop-shadow(0 0 6px rgba(138,180,255,.6)); }
.brand-text h1 { margin: 0; font-size: 15px; letter-spacing: 0.35em; font-weight: 800; }
.brand-text p { margin: 1px 0 0; font-size: 9px; letter-spacing: 0.22em; color: var(--faint); font-family: var(--mono); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.stamp-chip { font-size: 11px; color: var(--dim); background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 999px; padding: 4px 9px; font-family: var(--mono); }
.icon-btn {
  border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--text);
  border-radius: 10px; font-size: 15px; padding: 6px 9px; cursor: pointer; transition: 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.icon-btn.on { box-shadow: 0 0 10px rgba(126,232,162,0.5); border-color: rgba(126,232,162,0.5); }

/* ── Chat ───────────────────────────────────────────────────── */
#chat {
  flex: 1 1 auto; overflow-y: auto; padding: 16px 14px 8px;
  display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}

.row { display: flex; flex-direction: column; max-width: 86%; animation: rise 0.28s ease both; }
.row.machine { align-self: flex-start; }
.row.user { align-self: flex-end; align-items: flex-end; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.who { font-size: 9px; letter-spacing: 0.2em; color: var(--faint); margin: 0 4px 4px; font-family: var(--mono); }
.row.user .who { color: rgba(199,146,234,0.75); }

.bubble {
  padding: 11px 14px; line-height: 1.55; font-size: 14.5px; white-space: pre-wrap; word-break: break-word;
  border-radius: var(--r-bubble);
}
.row.machine .bubble {
  background: linear-gradient(160deg, rgba(138,180,255,0.13), rgba(199,146,234,0.09));
  border: 1px solid var(--border);
  border-top-left-radius: 6px;
}
.row.user .bubble {
  background: linear-gradient(160deg, rgba(199,146,234,0.28), rgba(138,180,255,0.2));
  border: 1px solid rgba(199,146,234,0.4);
  border-top-right-radius: 6px;
}
.bubble.caret::after { content: '▋'; margin-left: 2px; color: var(--accent); animation: blink 0.85s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Stempel & kartu kecil di gelembung */
.stamp { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; padding: 3px 8px; border-radius: 6px; border: 1px dashed var(--dim); color: var(--dim); margin-top: 8px; }
.stamp.good { color: var(--good); border-color: rgba(126,232,162,0.55); }
.stamp.warn { color: var(--warn); border-color: rgba(255,209,102,0.55); }
.meta { margin-top: 6px; font-size: 11px; color: var(--dim); }

.theme-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.theme-amber { background: #ffb35c; box-shadow: 0 0 8px #ffb35c; }
.theme-aurora { background: #7ee8a2; box-shadow: 0 0 8px #7ee8a2; }
.theme-nebula { background: #c792ea; box-shadow: 0 0 8px #c792ea; }
.theme-ocean { background: #6ec3ff; box-shadow: 0 0 8px #6ec3ff; }

/* ── Chip ───────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 14px; flex: 0 0 auto; }
.chip {
  border: 1px solid var(--border); background: rgba(138,180,255,0.09); color: var(--text);
  padding: 9px 14px; border-radius: 999px; font-size: 13px; font-family: var(--font);
  cursor: pointer; transition: 0.15s; animation: rise 0.3s ease both;
}
.chip:hover { background: rgba(138,180,255,0.2); transform: translateY(-1px); }
.chip.primary { background: linear-gradient(120deg, rgba(138,180,255,0.3), rgba(199,146,234,0.3)); border-color: rgba(199,146,234,0.5); }

/* ── Composer ───────────────────────────────────────────────── */
#composer {
  display: flex; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); flex: 0 0 auto; align-items: flex-end;
}
#input {
  flex: 1; resize: none; max-height: 120px; padding: 11px 14px; font-size: 14.5px; font-family: var(--font);
  color: var(--text); background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 14px; outline: none; transition: border-color 0.15s;
}
#input:focus { border-color: rgba(138,180,255,0.55); }
#input::placeholder { color: var(--faint); }
#send {
  border: none; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; font-size: 16px;
  color: #0b0d1e; background: linear-gradient(135deg, #8ab4ff, #c792ea);
  transition: transform 0.12s, box-shadow 0.12s; flex: 0 0 auto;
}
#send:hover { transform: scale(1.06); box-shadow: 0 0 14px rgba(199,146,234,0.55); }
#composer.hidden { visibility: hidden; }

.badge-demo {
  margin: 0 14px 6px; font-size: 10px; color: var(--warn); font-family: var(--mono);
  letter-spacing: 0.08em; text-align: center; opacity: 0.85;
}

/* ── Kapsul terbang & lenyap ────────────────────────────────── */
.fly-capsule { position: fixed; z-index: 60; font-size: 34px; pointer-events: none; filter: drop-shadow(0 0 12px rgba(138,180,255,0.9)); }
.fly-capsule.fly { animation: flyaway 1.35s cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }
@keyframes flyaway {
  0% { transform: translate(0, 0) rotate(-12deg) scale(1); opacity: 1; }
  55% { transform: translate(60vw, -26vh) rotate(24deg) scale(0.8); opacity: 1; }
  100% { transform: translate(110vw, -52vh) rotate(40deg) scale(0.25); opacity: 0; }
}
.bubble.dissolve { animation: dissolve 1.2s ease forwards; }
@keyframes dissolve { to { opacity: 0; filter: blur(8px); transform: translateY(-14px) scale(0.92); } }

/* ── Drawer koleksi ─────────────────────────────────────────── */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(3, 4, 12, 0.6); backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(340px, 88vw);
  background: var(--panel-solid); border-left: 1px solid var(--border);
  transform: translateX(102%); transition: transform 0.28s ease; display: flex; flex-direction: column;
  padding: 14px; overflow-y: auto;
}
.drawer.open { transform: none; }
.drawer h2 { margin: 2px 0 10px; font-size: 12px; letter-spacing: 0.3em; color: var(--dim); font-family: var(--mono); }
.drawer .tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.drawer .tab { flex: 1; padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--dim); font-size: 12.5px; cursor: pointer; font-family: var(--font); }
.drawer .tab.active { color: var(--text); background: rgba(138,180,255,0.12); border-color: rgba(138,180,255,0.4); }
.capsule-card { border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; background: rgba(255,255,255,0.03); }
.capsule-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.capsule-card .label { font-size: 12px; color: var(--text); }
.capsule-card .snip { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.capsule-card .stamp { margin-top: 6px; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.drawer-head h2 { margin: 0; }

/* ── Profil ─────────────────────────────────────────────── */
.profile-seal { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(160deg, rgba(138,180,255,0.1), rgba(199,146,234,0.08)); margin-bottom: 12px; }
.profile-avatar { font-size: 26px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,0.06); border: 1px dashed rgba(199,146,234,0.5); }
.profile-name { font-size: 16px; font-weight: 700; letter-spacing: 0.04em; }
.profile-sub { font-size: 10px; color: var(--faint); letter-spacing: 0.2em; font-family: var(--mono); margin-top: 2px; }
.profile-row { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid rgba(140,160,255,0.1); font-size: 13px; }
.profile-row-label { color: var(--dim); }
.profile-row-value { font-family: var(--mono); font-size: 12px; }
.profile-heading { margin: 16px 4px 8px; font-size: 10px; letter-spacing: 0.25em; color: var(--faint); font-family: var(--mono); font-weight: 600; }
.profile-stats { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 4px; }
.profile-stat { display: contents; }
.profile-stat-label { color: var(--dim); font-size: 13px; }
.profile-stat-value { font-family: var(--mono); font-size: 13px; color: var(--accent); text-align: right; }
.profile-note { margin-top: 14px; font-size: 11px; color: var(--faint); line-height: 1.6; text-align: center; }
.empty-note { color: var(--faint); font-size: 12.5px; text-align: center; padding: 22px 10px; line-height: 1.6; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(140,160,255,0.2); border-radius: 8px; }

@media (min-width: 720px) { .terminal { height: min(100dvh, 900px); margin: 0; } body { padding: 0; } }
