:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --miwa: #dc2626;
  --miwa-soft: #fef2f2;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  overflow-x: hidden;
}

body.is-chatting {
  height: 100dvh;
  overflow: hidden;
}

.app-shell {
  flex: 1;
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

body.is-chatting .app-shell {
  height: 100dvh;
}

/* ==========================================
   SIDEBAR KIRI (DOCKED DI DESKTOP, TANPA BAYANGAN ABU)
   ========================================== */
.sidebar-backdrop {
  display: none;
}

.left-sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0.85rem;
  height: 100dvh;
  position: sticky;
  top: 0;
  margin-left: -256px;
  transition: margin-left 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 40;
}

body.sidebar-open .left-sidebar {
  margin-left: 0;
}

.mobile-only-btn {
  display: none;
}

@media (max-width: 767px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.25);
    z-index: 65;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  .left-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    margin-left: 0;
    max-width: 82vw;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  }

  body.sidebar-open .left-sidebar {
    transform: translateX(0);
  }

  .mobile-only-btn {
    display: inline-flex;
  }
}

.left-sidebar-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.new-chat-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.new-chat-btn svg {
  width: 16px;
  height: 16px;
}

.new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.left-sidebar-body {
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-title {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.35rem;
}

.history-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.4rem 0.35rem;
  line-height: 1.45;
}

.left-sidebar-bottom {
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.fake-login-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
}

.fake-login-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-circle svg {
  width: 16px;
  height: 16px;
}

.login-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.login-meta strong {
  font-size: 0.84rem;
}

.login-meta small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================
   HEADER & HAMBURGER GARIS 3
   ========================================== */
.top-header {
  height: 60px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 30;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text-main);
  border-color: var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.02rem;
}

.cat-logo {
  width: 32px;
  height: 32px;
  transition: transform 0.25s ease;
}

.brand:hover .cat-logo {
  transform: rotate(-6deg) scale(1.06);
}

.hamburger-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4.5px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
  transition: opacity 0.28s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, background 0.2s ease;
}

body.is-chatting .hamburger-btn {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.hamburger-btn:hover {
  border-color: #93c5fd;
  background: var(--accent-soft);
}

.hamburger-btn.caught-bounce {
  animation: btnCatchJelly 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes btnCatchJelly {
  0% { transform: scale(1, 1); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.35); }
  30% { transform: scale(1.28, 0.76); border-color: #60a5fa; background: var(--accent-soft); box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  58% { transform: scale(0.88, 1.16); }
  80% { transform: scale(1.06, 0.95); }
  100% { transform: scale(1, 1); }
}

.hamburger-btn span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--text-main);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.hamburger-btn.active span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.active span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ==========================================
   MAIN STAGE & HERO
   ========================================== */
.main-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 0 0 1.15rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.center-spacer {
  flex: 1;
}

body.is-chatting .center-spacer {
  display: none;
}

.hero-block,
.composer-wrap,
.landing-footer {
  width: calc(100% - 2.5rem);
  max-width: 680px;
}

.hero-block {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.5rem;
  animation: fadeSlideIn 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

body.is-chatting .hero-block {
  display: none;
}

.cats-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(1rem, 5vw, 2.75rem);
  padding-top: 32px;
  margin-bottom: 1.25rem;
  overflow: visible;
}

.cat-interactive {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.cat-interactive:active {
  cursor: grabbing;
}

.cat-visual {
  position: relative;
  transform-origin: 50% 100%;
  will-change: transform;
}

.cat-visual img {
  display: block;
  height: clamp(120px, 21vw, 165px);
  width: auto;
  max-width: 36vw;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(15, 23, 42, 0.1));
}

.cat-shadow {
  position: absolute;
  bottom: -4px;
  width: 72%;
  height: 11px;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.14) 0%, rgba(15, 23, 42, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  transform-origin: 50% 50%;
  will-change: transform;
}

.protected-zone,
.protected-zone img {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.photo-shield {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: transparent;
}

.hero-block h1 {
  font-size: clamp(1.55rem, 4.5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.45rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: clamp(0.88rem, 2.2vw, 0.98rem);
  max-width: 470px;
}

/* ==========================================
   CHAT THREAD (MAWI = BIRU, MIWA = MERAH)
   ========================================== */
.chat-thread {
  display: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1.25rem 1.15rem;
  flex-direction: column;
  align-items: center;
}

body.is-chatting .chat-thread {
  display: flex;
}

.chat-messages {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: auto;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadeSlideIn 0.25s ease;
}

.msg-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.model {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.22rem;
  padding: 0 0.3rem;
}

.msg-row.persona-miwa .msg-sender {
  color: var(--miwa);
}

.msg-bubble {
  padding: 0.65rem 0.95rem;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Bubble Default (mawi = Biru) */
.msg-row.user .msg-bubble {
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 5px;
  box-shadow: inset 0 0 0 1.5px rgba(191, 219, 254, 0.45);
}

.msg-row.model .msg-bubble {
  background: #f8fbff;
  color: var(--text-main);
  border: 1px solid #bfdbfe;
  border-bottom-left-radius: 5px;
  box-shadow: inset 0 0 0 1.5px rgba(219, 234, 254, 0.65);
}

/* Bubble Gaul (miwa = Merah) */
.msg-row.user.persona-miwa .msg-bubble {
  background: var(--miwa);
  box-shadow: inset 0 0 0 1.5px rgba(254, 202, 202, 0.45);
}

.msg-row.model.persona-miwa .msg-bubble {
  background: var(--miwa-soft);
  color: var(--text-main);
  border: 1px solid #fecaca;
  box-shadow: inset 0 0 0 1.5px rgba(254, 202, 202, 0.7);
}

.msg-bubble.typing {
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================
   INPUT BUBBLE & PEMILIH KARAKTER
   ========================================== */
.composer-wrap {
  flex-shrink: 0;
  will-change: transform;
}

.composer-bubble {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: 24px;
  padding: 0.9rem 1rem 0.7rem 1.2rem;
  box-shadow:
    inset 0 0 0 2px rgba(219, 234, 254, 0.55),
    0 8px 28px rgba(37, 99, 235, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.composer-bubble:focus-within {
  border-color: #60a5fa;
  box-shadow:
    inset 0 0 0 2px rgba(147, 197, 253, 0.75),
    0 10px 30px rgba(37, 99, 235, 0.11);
}

/* Tema Input saat memilih miwa (Merah) */
body.theme-miwa .composer-bubble {
  background: linear-gradient(180deg, #ffffff 0%, #fff8f8 100%);
  border-color: #fecaca;
  box-shadow:
    inset 0 0 0 2px rgba(254, 202, 202, 0.55),
    0 8px 28px rgba(220, 38, 38, 0.06);
}

body.theme-miwa .composer-bubble:focus-within {
  border-color: #f87171;
  box-shadow:
    inset 0 0 0 2px rgba(252, 165, 165, 0.75),
    0 10px 30px rgba(220, 38, 38, 0.11);
}

.composer-bubble textarea {
  width: 100%;
  min-height: 54px;
  max-height: 104px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.96rem;
  color: var(--text-main);
  line-height: 1.5;
  overflow-y: hidden;
}

.composer-bubble textarea::placeholder {
  color: #94a3b8;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.persona-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.persona-pill {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.22rem 0.72rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.persona-pill:hover {
  color: var(--text-main);
}

.persona-pill[data-persona="mawi"].active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.persona-pill[data-persona="miwa"].active {
  background: var(--miwa-soft);
  color: var(--miwa);
  box-shadow: inset 0 0 0 1px #fecaca;
}

.send-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}

body.theme-miwa .send-circle {
  background: var(--miwa);
}

.send-circle:hover:not(:disabled) {
  transform: scale(1.06);
}

.send-circle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.send-circle svg {
  width: 17px;
  height: 17px;
}

/* ==========================================
   ANIMASI ZOOM & MEMUDAR KUCING SAAT MENJAWAB
   ========================================== */
.cat-reply-zoom {
  position: fixed;
  top: 50%;
  left: 50%;
  width: clamp(180px, 34vw, 270px);
  height: auto;
  pointer-events: none;
  z-index: 95;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 18px 36px rgba(15, 23, 42, 0.18));
}

/* ==========================================
   CONTACT INFO, INVENTORY LACI, & TOAST
   ========================================== */
.landing-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding-top: 1.25rem;
  animation: fadeSlideIn 0.35s ease;
}

body.is-chatting .landing-footer {
  display: none;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.48rem 0.85rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.social-btn.icon-only {
  padding: 0.48rem 0.65rem;
}

.social-btn svg {
  width: 16px;
  height: 16px;
}

.social-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

.license-line {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.license-line a {
  color: var(--text-main);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inventory-drawer {
  position: fixed;
  top: 60px;
  right: 16px;
  width: min(320px, calc(100vw - 32px));
  background: var(--bg);
  border: 1.5px solid #dbeafe;
  border-radius: 22px;
  box-shadow:
    inset 0 0 0 1.5px rgba(219, 234, 254, 0.5),
    0 20px 50px rgba(15, 23, 42, 0.14);
  padding: 1rem 1.05rem 1.1rem;
  z-index: 60;
  transform-origin: top right;
  display: none;
  overflow: visible;
}

.inventory-drawer.open {
  display: block;
  animation: jellyOpen 0.52s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.inventory-drawer.closing {
  display: block;
  pointer-events: none;
  animation: jellyClose 0.3s ease-in forwards;
}

.drawer-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.drawer-header span {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.drawer-header small {
  font-size: 0.72rem;
  color: #94a3b8;
}

.drawer-cats {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1.25rem;
  padding: 26px 0.5rem 0.6rem;
  overflow: visible;
}

.drawer-cat-slot.tilt-left { transform: rotate(-5deg) translateY(3px); }
.drawer-cat-slot.tilt-right { transform: rotate(4deg) translateY(-4px); }
.drawer-cats .cat-visual img { height: 92px; max-width: 110px; }

.inventory-drawer.open .drawer-cat-slot {
  animation: catJellyWobble 0.62s ease;
}

.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 0.65rem 0 0.85rem;
}

.social-links.compact {
  gap: 0.42rem;
  margin-bottom: 0.7rem;
}

.social-links.compact .social-btn {
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 9px;
}

.social-links.compact .social-btn.icon-only {
  padding: 0.4rem 0.55rem;
}

.drawer-license {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

@keyframes jellyOpen {
  0% { opacity: 0; transform: scale(0.35, 0.2) skewX(8deg); }
  42% { opacity: 1; transform: scale(1.06, 0.91) skewX(-3deg); }
  66% { transform: scale(0.96, 1.05) skewX(1.5deg); }
  84% { transform: scale(1.02, 0.98) skewX(-0.5deg); }
  100% { opacity: 1; transform: scale(1, 1) skewX(0); }
}

@keyframes jellyClose {
  0% { opacity: 1; transform: scale(1, 1) skewX(0); }
  30% { opacity: 1; transform: scale(1.07, 0.88) skewX(-4deg); }
  100% { opacity: 0; transform: scale(0.28, 0.18) skewX(10deg); }
}

@keyframes catJellyWobble {
  0% { transform: scale(0.8, 1.2); }
  40% { transform: scale(1.12, 0.86); }
  70% { transform: scale(0.96, 1.05); }
  100% { transform: scale(1, 1); }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-warning {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translate(-50%, 18px);
  background: var(--text-main);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
  opacity: 0;
  pointer-events: none;
  z-index: 99;
  transition: all 0.22s ease;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast-warning.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Penanda halus di chat saat berganti karakter */
.switch-divider {
  align-self: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #dbeafe;
  padding: 0.16rem 0.7rem;
  border-radius: 999px;
  margin: 0.25rem 0;
}

.switch-divider.persona-miwa {
  color: var(--miwa);
  background: var(--miwa-soft);
  border-color: #fecaca;
}