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

:root {
  --bg: #06111f;

  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-200: #bae6fd;
  --sky-300: #7dd3fc;
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;
  --sky-700: #0369a1;

  --cyan: #22d3ee;
  --blue: #60a5fa;
  --ice: #dff7ff;

  --panel: rgba(7, 18, 34, 0.68);
  --panel-strong: rgba(10, 25, 45, 0.88);
  --panel-soft: rgba(255, 255, 255, 0.07);

  --border: rgba(186, 230, 253, 0.16);
  --border-strong: rgba(125, 211, 252, 0.34);

  --text: #f4fbff;
  --muted: rgba(230, 247, 255, 0.62);
  --faint: rgba(230, 247, 255, 0.34);

  --danger: #fb7185;
  --danger-2: #f43f5e;

  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  --sky-shadow: 0 18px 60px rgba(56, 189, 248, 0.22);
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(56, 189, 248, 0.34), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(34, 211, 238, 0.23), transparent 28%),
    radial-gradient(circle at 50% 90%, rgba(96, 165, 250, 0.20), transparent 36%),
    linear-gradient(135deg, #050b18 0%, #071727 48%, #082033 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black, transparent 72%);
  opacity: 0.35;
}

.hidden {
  display: none !important;
}

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-thumb {
  background: rgba(186, 230, 253, 0.22);
  border-radius: 999px;
}

/* ===== BACKGROUND ORBS ===== */

.sky-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.52;
  pointer-events: none;
  animation: floatOrb 9s ease-in-out infinite alternate;
}

.orb-one {
  width: 380px;
  height: 380px;
  background: var(--sky-400);
  top: -130px;
  left: -120px;
}

.orb-two {
  width: 420px;
  height: 420px;
  background: var(--cyan);
  right: -150px;
  bottom: -150px;
  animation-delay: 1.5s;
}

.orb-three {
  width: 300px;
  height: 300px;
  background: var(--blue);
  left: 35%;
  bottom: -170px;
  animation-delay: 0.6s;
}

@keyframes floatOrb {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }

  to {
    transform: translate3d(28px, -24px, 0) scale(1.08);
  }
}

/* ===== AUTH ===== */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 2;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.10), rgba(255,255,255,0.035)),
    rgba(7, 18, 34, 0.72);
  backdrop-filter: blur(26px);
  box-shadow: var(--shadow), var(--sky-shadow);
  animation: authIn 0.5s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes authIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 28px;
}

.auth-logo-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.80), transparent 22%),
    linear-gradient(135deg, var(--sky-300), var(--sky-500), var(--cyan));
  color: #fff;
  font-size: 24px;
  box-shadow: 0 18px 50px rgba(14, 165, 233, 0.42);
  animation: logoPulse 2.8s ease-in-out infinite;
}

@keyframes logoPulse {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 18px 50px rgba(14, 165, 233, 0.34);
  }

  50% {
    transform: translateY(-2px);
    box-shadow: 0 22px 70px rgba(56, 189, 248, 0.50);
  }
}

.auth-logo h1 {
  font-family: 'Syne', sans-serif;
  font-size: 26px;
  letter-spacing: -0.9px;
}

.auth-logo p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

#auth-form label {
  display: block;
  color: rgba(244, 251, 255, 0.78);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 9px;
}

.auth-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 13px;
  border-radius: 18px;
  background: rgba(255,255,255,0.075);
  border: 1px solid var(--border);
  transition: border-color 0.22s, background 0.22s, box-shadow 0.22s;
}

.auth-input-wrap:focus-within {
  border-color: rgba(125, 211, 252, 0.65);
  background: rgba(255,255,255,0.105);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.10);
}

#token-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: 'DM Sans', sans-serif;
  min-width: 0;
}

#token-input::placeholder {
  color: rgba(230, 247, 255, 0.28);
}

#toggle-token {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  opacity: 0.78;
}

#unlock-btn {
  width: 100%;
  margin-top: 18px;
  border: none;
  border-radius: 18px;
  padding: 14px 16px;
  background:
    linear-gradient(135deg, var(--sky-400), var(--sky-500), var(--blue));
  color: #ffffff;
  font-family: 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.18s, filter 0.18s, box-shadow 0.18s;
  box-shadow: 0 16px 46px rgba(14, 165, 233, 0.28);
}

#unlock-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.07);
  box-shadow: 0 22px 62px rgba(14, 165, 233, 0.38);
}

#unlock-btn:active {
  transform: translateY(0) scale(0.99);
}

#unlock-btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

#auth-error {
  min-height: 18px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.auth-hint {
  margin-top: 18px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.55;
}

/* ===== ERROR MODAL ===== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 23, 0.66);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.18s ease both;
}

.modal-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 365px;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid rgba(186, 230, 253, 0.18);
  background:
    linear-gradient(145deg, rgba(255,255,255,0.11), rgba(255,255,255,0.045)),
    rgba(8, 19, 35, 0.94);
  box-shadow: 0 32px 95px rgba(0,0,0,0.56), 0 20px 70px rgba(56,189,248,0.14);
  text-align: center;
  animation: modalPop 0.25s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 15px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--danger), var(--danger-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 18px 52px rgba(244, 63, 94, 0.32);
}

.modal-card h2 {
  font-family: 'Syne', sans-serif;
  font-size: 23px;
  letter-spacing: -0.7px;
  color: #fff;
  margin-bottom: 8px;
}

.modal-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 22px;
}

#modal-close-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 13px 14px;
  background: linear-gradient(135deg, var(--sky-400), var(--sky-500), var(--blue));
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s, filter 0.18s, box-shadow 0.18s;
  box-shadow: 0 16px 42px rgba(14, 165, 233, 0.26);
}

#modal-close-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

/* ===== APP LAYOUT ===== */

#app-shell {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */

#sidebar {
  width: 286px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.085), rgba(255,255,255,0.035)),
    rgba(6, 17, 31, 0.72);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 13px;
  transition: width 0.28s ease, opacity 0.28s ease, transform 0.28s ease;
  overflow: hidden;
  flex-shrink: 0;
  backdrop-filter: blur(24px);
}

#sidebar.closed {
  width: 0;
  opacity: 0;
  padding: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 22px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.72), transparent 22%),
    linear-gradient(135deg, var(--sky-300), var(--sky-500), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 12px 36px rgba(14, 165, 233, 0.28);
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.6px;
  display: block;
}

.logo-subtitle {
  color: var(--faint);
  font-size: 11px;
  margin-top: 1px;
}

#new-chat-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 20px;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

#new-chat-btn:hover {
  background: rgba(125, 211, 252, 0.13);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 14px 42px rgba(14, 165, 233, 0.14);
}

.plus-icon {
  width: 23px;
  height: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(125, 211, 252, 0.14);
  font-size: 18px;
}

.history-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 8px 8px;
}

#history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 15px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: rgba(244,251,255,0.78);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  text-align: left;
  width: 100%;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.history-item:hover {
  background: rgba(255,255,255,0.07);
  transform: translateX(2px);
}

.history-item.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(125, 211, 252, 0.25);
}

.history-item-body {
  flex: 1;
  overflow: hidden;
}

.history-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.history-time {
  font-size: 11px;
  color: rgba(230,247,255,0.36);
  margin-top: 2px;
}

.history-delete {
  opacity: 0;
  background: none;
  border: none;
  color: rgba(230,247,255,0.40);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 7px;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  color: #fff;
  background: rgba(244, 63, 94, 0.22);
}

.history-empty {
  font-size: 12px;
  color: rgba(230,247,255,0.28);
  text-align: center;
  padding: 22px 8px;
  line-height: 1.5;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 8px 4px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.user-avatar {
  width: 37px;
  height: 37px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--sky-400), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 12px 32px rgba(14, 165, 233, 0.22);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.user-plan {
  font-size: 11px;
  color: var(--faint);
}

#logout-btn {
  width: 31px;
  height: 31px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255,255,255,0.055);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

#logout-btn:hover {
  background: rgba(244, 63, 94, 0.18);
  color: #fff;
  transform: translateY(-1px);
}

/* ===== MAIN ===== */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== HEADER ===== */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.025)),
    rgba(5, 12, 24, 0.48);
  backdrop-filter: blur(20px);
}

#toggle-sidebar {
  width: 39px;
  height: 39px;
  background: rgba(255,255,255,0.065);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  flex-shrink: 0;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}

#toggle-sidebar:hover {
  background: rgba(125, 211, 252, 0.12);
  transform: translateY(-1px);
}

#toggle-sidebar span {
  display: block;
  width: 16px;
  height: 2px;
  background: rgba(244,251,255,0.70);
  border-radius: 2px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  width: 90px;
  justify-content: flex-end;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--sky-300);
  box-shadow: 0 0 16px rgba(125, 211, 252, 0.95);
}

/* ===== MODEL SELECTOR ===== */

#model-selector-wrapper {
  position: relative;
  flex: 1;
  max-width: 380px;
}

#model-selector-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#model-selector-btn:hover {
  background: rgba(255,255,255,0.10);
  border-color: var(--border-strong);
}

#model-selector-btn.open {
  border-color: rgba(125, 211, 252, 0.58);
  background: rgba(56, 189, 248, 0.11);
  box-shadow: 0 0 0 4px rgba(56,189,248,0.08);
}

.selector-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.selector-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--sky-300);
  box-shadow: 0 0 12px rgba(125,211,252,0.8);
}

.selector-dot.anthropic {
  background: #fb923c;
  box-shadow: 0 0 12px rgba(251,146,60,0.8);
}

.selector-dot.cerebras {
  background: var(--sky-300);
}

.selector-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selector-tag {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

.selector-chevron {
  font-size: 10px;
  color: var(--faint);
  flex-shrink: 0;
  transition: transform 0.2s;
}

#model-selector-btn.open .selector-chevron {
  transform: rotate(180deg);
}

#model-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035)),
    rgba(7, 18, 34, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow), var(--sky-shadow);
  z-index: 50;
  display: none;
  backdrop-filter: blur(22px);
  animation: dropdownIn 0.16s ease both;
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#model-dropdown.open {
  display: block;
}

.dropdown-group-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--faint);
  padding: 12px 12px 5px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 8px;
}

.dropdown-item:hover {
  background: rgba(125, 211, 252, 0.10);
}

.dropdown-item.active {
  background: rgba(56, 189, 248, 0.15);
}

.dropdown-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.dropdown-item-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item-tag {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

.dropdown-check {
  font-size: 12px;
  color: var(--sky-300);
  flex-shrink: 0;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.dropdown-loading {
  padding: 16px 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ===== MESSAGES ===== */

#messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
}

#empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding-bottom: 60px;
  animation: fadeUp 0.45s ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty-orb {
  width: 82px;
  height: 82px;
  border-radius: 30px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.85), transparent 20%),
    linear-gradient(135deg, var(--sky-300), var(--sky-500), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: 0 26px 90px rgba(14, 165, 233, 0.38);
  animation: emptyFloat 3.5s ease-in-out infinite;
}

@keyframes emptyFloat {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-5px) rotate(1.5deg);
  }
}

.empty-title {
  font-family: 'Syne', sans-serif;
  font-size: 31px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -1px;
}

.empty-subtitle {
  font-size: 14px;
  color: var(--muted);
  max-width: 470px;
}

#suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
  max-width: 650px;
  margin-top: 4px;
}

.suggestion-btn {
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.065);
  color: rgba(244,251,255,0.80);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.suggestion-btn:hover {
  background: rgba(125, 211, 252, 0.12);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(14, 165, 233, 0.12);
}

#message-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 850px;
  margin: 0 auto;
  width: 100%;
}

.message-wrap {
  animation: messageIn 0.24s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.message-row.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
}

.avatar.bot {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.72), transparent 22%),
    linear-gradient(135deg, var(--sky-300), var(--sky-500), var(--cyan));
}

.avatar.user {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.55), transparent 22%),
    linear-gradient(135deg, #60a5fa, #2563eb);
}

.bubble {
  max-width: 78%;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.68;
  color: var(--text);
  overflow-wrap: anywhere;
}

.bubble.bot {
  background:
    linear-gradient(145deg, rgba(255,255,255,0.10), rgba(255,255,255,0.045));
  border: 1px solid var(--border);
  border-radius: 6px 22px 22px 22px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.15);
}

.bubble.user {
  background:
    linear-gradient(135deg, var(--sky-400), var(--sky-500), #2563eb);
  border-radius: 22px 6px 22px 22px;
  box-shadow: 0 16px 48px rgba(14, 165, 233, 0.26);
  color: #fff;
}

.bubble strong {
  font-weight: 800;
}

.bubble em {
  color: rgba(255,255,255,0.88);
}

.bubble ul,
.bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.bubble li {
  margin: 4px 0;
}

.bubble code.inline-code {
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(0,0,0,0.30);
  border: 1px solid rgba(255,255,255,0.10);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.bubble-meta {
  font-size: 10px;
  color: var(--faint);
  margin-top: 6px;
  padding-left: 50px;
}

.code-block {
  margin: 11px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(186,230,253,0.14);
  background: rgba(2, 8, 23, 0.48);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  background: rgba(255,255,255,0.065);
  color: var(--muted);
  font-size: 11px;
}

.copy-code-btn {
  border: 1px solid rgba(186,230,253,0.16);
  background: rgba(255,255,255,0.075);
  color: rgba(244,251,255,0.76);
  border-radius: 9px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.copy-code-btn:hover {
  background: rgba(125,211,252,0.15);
  color: #fff;
}

.code-block pre {
  padding: 14px;
  overflow-x: auto;
}

.code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre;
}

.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 20px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sky-300);
  animation: blink 1.2s infinite;
  box-shadow: 0 0 10px rgba(125,211,252,0.8);
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.38;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== INPUT ===== */

#input-wrapper {
  padding: 16px 20px 20px;
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
}

#input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.10), rgba(255,255,255,0.045));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 11px 12px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  box-shadow: 0 22px 70px rgba(0,0,0,0.20);
  backdrop-filter: blur(18px);
}

#input-box:focus-within {
  border-color: rgba(125, 211, 252, 0.62);
  background: rgba(255,255,255,0.10);
  box-shadow: 0 0 0 4px rgba(56,189,248,0.09), 0 24px 80px rgba(0,0,0,0.24);
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  resize: none;
  line-height: 1.58;
  max-height: 160px;
  overflow-y: auto;
  padding: 7px 2px;
}

#user-input::placeholder {
  color: rgba(230,247,255,0.30);
}

#send-btn {
  width: 39px;
  height: 39px;
  border-radius: 15px;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s, opacity 0.18s, background 0.18s, box-shadow 0.18s;
  flex-shrink: 0;
  opacity: 0.45;
}

#send-btn.active {
  background: linear-gradient(135deg, var(--sky-400), var(--sky-500), #2563eb);
  opacity: 1;
  box-shadow: 0 12px 34px rgba(14,165,233,0.28);
}

#send-btn.active:hover {
  transform: scale(1.06) translateY(-1px);
}

#send-btn.loading {
  pointer-events: none;
  opacity: 0.75;
}

#disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  margin-top: 10px;
}

/* ===== MOBILE ===== */

@media (max-width: 768px) {
  #app-shell {
    position: relative;
  }

  #sidebar {
    position: fixed;
    z-index: 80;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    width: 286px;
    box-shadow: 32px 0 90px rgba(0,0,0,0.46);
  }

  #sidebar.closed {
    width: 286px;
    padding: 20px 13px;
    opacity: 1;
    transform: translateX(-105%);
  }

  #header {
    padding: 11px 12px;
  }

  .header-status {
    display: none;
  }

  #model-selector-wrapper {
    max-width: none;
  }

  .selector-tag {
    display: none;
  }

  #messages-area {
    padding: 20px 12px;
  }

  #message-list {
    gap: 19px;
  }

  .bubble {
    max-width: 85%;
    font-size: 14px;
  }

  .avatar {
    width: 33px;
    height: 33px;
    border-radius: 13px;
  }

  #input-wrapper {
    padding: 12px 12px 16px;
  }

  .empty-title {
    font-size: 26px;
  }

  .empty-subtitle {
    font-size: 13px;
  }

  .suggestion-btn {
    font-size: 12px;
    padding: 10px 13px;
  }
}

@media (max-width: 420px) {
  .bubble {
    max-width: 89%;
  }

  .auth-card {
    padding: 23px;
    border-radius: 26px;
  }

  .auth-logo h1 {
    font-size: 23px;
  }

  .modal-card {
    padding: 24px;
  }
}

/* =========================================================
   MOBILE POLISH PATCH — Nova Chat Sky UI
   Tempel di PALING BAWAH style.css
========================================================= */

/* Biar tinggi mobile browser lebih stabil */
html,
body {
  min-height: 100%;
  min-height: 100svh;
}

/* Header harus selalu di atas chat */
#header {
  position: relative;
  z-index: 120;
}

/* Dropdown harus benar-benar di atas bubble */
#model-selector-wrapper {
  z-index: 130;
}

#model-dropdown {
  z-index: 9999;
  background:
    linear-gradient(145deg, rgba(18, 35, 56, 0.98), rgba(7, 18, 34, 0.98)),
    rgba(7, 18, 34, 0.98);
  border-color: rgba(125, 211, 252, 0.32);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(125, 211, 252, 0.10),
    0 20px 80px rgba(56, 189, 248, 0.16);
}

/* Biar bubble/chat nggak kelihatan terlalu “di depan” dropdown */
.message-wrap,
.message-row,
.bubble,
.avatar {
  position: relative;
  z-index: 1;
}

/* Model dropdown item lebih rapi */
.dropdown-item {
  min-height: 54px;
}

.dropdown-item-name {
  max-width: 170px;
}

.dropdown-item-tag {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Area chat lebih lega dan nggak ketabrak input */
#messages-area {
  padding-bottom: 24px;
}

/* Input lebih clean */
#input-wrapper {
  position: relative;
  z-index: 50;
}

#input-box {
  min-height: 62px;
}

/* =========================================================
   MOBILE ONLY
========================================================= */

@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  #app-shell {
    height: 100svh;
  }

  /* Header compact */
  #header {
    padding: 10px 14px;
    gap: 10px;
    min-height: 86px;
    align-items: center;
  }

  #toggle-sidebar {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    padding: 13px;
    background: rgba(255, 255, 255, 0.075);
  }

  #toggle-sidebar span {
    width: 20px;
    height: 2.5px;
  }

  #model-selector-wrapper {
    max-width: none;
    min-width: 0;
  }

  #model-selector-btn {
    height: 56px;
    border-radius: 20px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.075);
  }

  .selector-name {
    font-size: 15px;
    max-width: 185px;
  }

  .selector-tag {
    display: none;
  }

  .selector-chevron {
    font-size: 11px;
    opacity: 0.65;
  }

  /* Dropdown mobile jadi lebih solid dan tidak transparan */
  #model-dropdown {
    top: calc(100% + 10px);
    border-radius: 22px;
    max-height: 310px;
    overflow-y: auto;
    backdrop-filter: blur(30px);
  }

  .dropdown-group-label {
    padding: 14px 18px 7px;
    font-size: 11px;
  }

  .dropdown-item {
    padding: 13px 18px;
    min-height: 58px;
  }

  .dropdown-item-left {
    min-width: 0;
  }

  .dropdown-item-name {
    font-size: 15px;
    max-width: 180px;
  }

  .dropdown-item-tag {
    font-size: 12px;
    max-width: 78px;
    opacity: 0.58;
  }

  .dropdown-check {
    font-size: 15px;
  }

  /* Sidebar mobile lebih enak */
  #sidebar {
    width: min(78vw, 330px);
    padding: 24px 18px;
    background:
      linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.035)),
      rgba(10, 26, 43, 0.94);
    backdrop-filter: blur(30px);
    box-shadow:
      28px 0 90px rgba(0,0,0,0.56),
      1px 0 0 rgba(125, 211, 252, 0.14);
  }

  #sidebar.closed {
    width: min(78vw, 330px);
    padding: 24px 18px;
    opacity: 1;
    transform: translateX(-110%);
  }

  .logo {
    padding: 8px 0 28px;
  }

  .logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    font-size: 22px;
  }

  .logo-text {
    font-size: 23px;
  }

  .logo-subtitle {
    font-size: 13px;
  }

  #new-chat-btn {
    height: 64px;
    border-radius: 22px;
    padding: 0 20px;
    font-size: 17px;
  }

  .plus-icon {
    width: 34px;
    height: 34px;
    border-radius: 14px;
    font-size: 24px;
  }

  .history-label {
    font-size: 12px;
    padding: 10px 0 12px;
  }

  .history-item {
    padding: 14px 14px;
    border-radius: 20px;
  }

  .history-title {
    font-size: 15px;
  }

  .history-time {
    font-size: 12px;
  }

  .user-section {
    padding: 18px 0 2px;
  }

  /* Chat area */
  #messages-area {
    padding: 22px 20px 18px;
  }

  #message-list {
    gap: 22px;
  }

  .message-row {
    gap: 10px;
  }

  .avatar {
    width: 34px;
    height: 34px;
    border-radius: 14px;
    font-size: 12px;
  }

  .bubble {
    font-size: 15px;
    line-height: 1.62;
    padding: 14px 16px;
    max-width: calc(100% - 56px);
  }

  .bubble.user {
    max-width: 64%;
    border-radius: 22px 8px 22px 22px;
  }

  .bubble.bot {
    max-width: calc(100% - 52px);
    border-radius: 8px 24px 24px 24px;
    background:
      linear-gradient(145deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
  }

  .bubble-meta {
    padding-left: 46px;
    font-size: 11px;
  }

  /* Input bawah lebih rapi */
  #input-wrapper {
    padding: 12px 20px 18px;
  }

  #input-box {
    min-height: 60px;
    border-radius: 24px;
    padding: 10px 12px 10px 18px;
    background:
      linear-gradient(145deg, rgba(255,255,255,0.12), rgba(255,255,255,0.055)),
      rgba(8, 22, 38, 0.82);
  }

  #user-input {
    font-size: 15px;
    padding: 9px 0;
  }

  #send-btn {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    font-size: 18px;
  }

  #disclaimer {
    display: none;
  }

  /* Empty state mobile */
  #empty-state {
    padding-inline: 10px;
    padding-bottom: 30px;
  }

  .empty-orb {
    width: 76px;
    height: 76px;
    border-radius: 28px;
  }

  .empty-title {
    font-size: 27px;
  }

  .empty-subtitle {
    max-width: 310px;
    font-size: 14px;
  }

  #suggestions {
    max-width: 340px;
  }

  .suggestion-btn {
    font-size: 13px;
    padding: 11px 14px;
  }
}

/* HP kecil banget */
@media (max-width: 420px) {
  #header {
    padding: 10px 12px;
  }

  #toggle-sidebar {
    width: 46px;
    height: 46px;
  }

  #model-selector-btn {
    height: 54px;
    padding: 0 14px;
  }

  .selector-name {
    max-width: 145px;
    font-size: 14px;
  }

  .dropdown-item-name {
    max-width: 145px;
  }

  .dropdown-item-tag {
    max-width: 62px;
  }

  #messages-area {
    padding: 20px 20px 14px;
  }

  .bubble {
    font-size: 14.5px;
  }

  .bubble.user {
    max-width: 62%;
  }

  #input-wrapper {
    padding: 10px 20px 16px;
  }

  #sidebar {
    width: 78vw;
  }

  #sidebar.closed {
    width: 78vw;
  }
}

/* =========================================================
   FLEXIBLE MOBILE LAYOUT FIX
   Fix sidebar/input/chat kepotong di mobile browser
========================================================= */

@media (max-width: 768px) {
  html,
  body {
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
  }

  #app-shell {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  /* MAIN LAYOUT FLEXIBLE */
  #main {
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #header {
    flex: 0 0 auto;
    min-height: 78px;
    padding: 10px 14px;
  }

  #messages-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 20px 18px !important;
  }

  #message-list {
    min-height: unset !important;
    justify-content: flex-start !important;
    padding-top: 20px !important;
    padding-bottom: 24px !important;
  }

  #input-wrapper {
    flex: 0 0 auto;
    padding: 10px 20px calc(12px + env(safe-area-inset-bottom)) !important;
  }

  #input-box {
    min-height: 58px;
  }

  /* SIDEBAR FLEXIBLE */
  #sidebar {
    height: 100dvh;
    max-height: 100dvh;
    width: min(78vw, 330px);
    padding: 22px 18px calc(16px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #sidebar.closed {
    width: min(78vw, 330px);
    padding: 22px 18px calc(16px + env(safe-area-inset-bottom));
    opacity: 1;
    transform: translateX(-110%);
  }

  .logo {
    flex: 0 0 auto;
    padding: 6px 0 22px;
  }

  #new-chat-btn {
    flex: 0 0 auto;
    height: 58px;
    margin-bottom: 18px;
  }

  .history-label {
    flex: 0 0 auto;
    padding: 6px 0 10px;
  }

  #history-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 14px;
  }

  .user-section {
    flex: 0 0 auto;
    margin-top: 10px;
    padding: 14px 0 0;
  }

  /* Biar chat di belakang sidebar nggak bikin scroll aneh */
  body:has(#sidebar:not(.closed)) #messages-area {
    overflow-y: auto;
  }
}

@media (max-width: 420px) {
  #header {
    min-height: 76px;
    padding: 10px 12px;
  }

  #messages-area {
    padding: 24px 18px 14px !important;
  }

  #message-list {
    padding-top: 18px !important;
    padding-bottom: 22px !important;
  }

  #input-wrapper {
    padding: 10px 18px calc(12px + env(safe-area-inset-bottom)) !important;
  }

  #sidebar {
    width: 78vw;
    padding: 22px 18px calc(16px + env(safe-area-inset-bottom));
  }

  #sidebar.closed {
    width: 78vw;
    padding: 22px 18px calc(16px + env(safe-area-inset-bottom));
  }
}

/* =========================================================
   MESSAGE ACTION BUTTONS
========================================================= */

.message-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-left: 50px;
  opacity: 0.72;
}

.message-action-btn {
  border: 1px solid rgba(186, 230, 253, 0.14);
  background: rgba(255, 255, 255, 0.055);
  color: rgba(244, 251, 255, 0.68);
  border-radius: 999px;
  padding: 5px 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.18s;
}

.message-action-btn:hover {
  background: rgba(125, 211, 252, 0.13);
  border-color: rgba(125, 211, 252, 0.30);
  color: #fff;
  transform: translateY(-1px);
}

.message-action-btn.copied {
  background: rgba(34, 211, 238, 0.16);
  color: #dff7ff;
}

@media (max-width: 768px) {
  .message-actions {
    padding-left: 46px;
    margin-top: 7px;
    gap: 7px;
  }

  .message-action-btn {
    font-size: 11px;
    padding: 5px 9px;
  }
}

/* =========================================================
   SIDEBAR COMPACT MOBILE PATCH
========================================================= */

@media (max-width: 768px) {
  #sidebar {
    width: min(74vw, 300px) !important;
    padding: 20px 16px calc(14px + env(safe-area-inset-bottom)) !important;
  }

  #sidebar.closed {
    width: min(74vw, 300px) !important;
    padding: 20px 16px calc(14px + env(safe-area-inset-bottom)) !important;
  }

  .logo {
    padding: 4px 0 20px !important;
    gap: 11px;
  }

  .logo-icon {
    width: 42px !important;
    height: 42px !important;
    border-radius: 16px !important;
    font-size: 20px !important;
  }

  .logo-text {
    font-size: 21px !important;
  }

  .logo-subtitle {
    font-size: 12px !important;
  }

  #new-chat-btn {
    height: 54px !important;
    border-radius: 18px !important;
    padding: 0 16px !important;
    font-size: 15px !important;
    margin-bottom: 18px !important;
  }

  .plus-icon {
    width: 30px !important;
    height: 30px !important;
    border-radius: 12px !important;
    font-size: 21px !important;
  }

  .history-label {
    font-size: 11px !important;
    padding: 6px 0 10px !important;
  }

  .history-item {
    padding: 12px 14px !important;
    border-radius: 17px !important;
    min-height: 66px;
  }

  .history-title {
    font-size: 14px !important;
  }

  .history-time {
    font-size: 11px !important;
  }

  .user-section {
    padding: 12px 0 0 !important;
    gap: 10px !important;
  }

  .user-avatar {
    width: 42px !important;
    height: 42px !important;
    border-radius: 16px !important;
  }

  .user-name {
    font-size: 14px !important;
  }

  .user-plan {
    font-size: 12px !important;
  }

  #logout-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
  }
}

@media (max-width: 420px) {
  #sidebar {
    width: 74vw !important;
  }

  #sidebar.closed {
    width: 74vw !important;
  }

  #new-chat-btn {
    height: 52px !important;
  }

  .history-item {
    min-height: 62px;
  }
}

/* =========================================================
   SIDEBAR EXTRA COMPACT MOBILE PATCH
========================================================= */

@media (max-width: 768px) {
  #sidebar {
    width: min(70vw, 280px) !important;
    padding: 18px 14px calc(12px + env(safe-area-inset-bottom)) !important;
  }

  #sidebar.closed {
    width: min(70vw, 280px) !important;
    padding: 18px 14px calc(12px + env(safe-area-inset-bottom)) !important;
  }

  .logo {
    padding: 2px 0 18px !important;
    gap: 10px !important;
  }

  .logo-icon {
    width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
    font-size: 18px !important;
  }

  .logo-text {
    font-size: 19px !important;
  }

  .logo-subtitle {
    font-size: 11px !important;
  }

  #new-chat-btn {
    height: 48px !important;
    border-radius: 16px !important;
    padding: 0 14px !important;
    font-size: 14px !important;
    margin-bottom: 16px !important;
  }

  .plus-icon {
    width: 27px !important;
    height: 27px !important;
    border-radius: 11px !important;
    font-size: 19px !important;
  }

  .history-label {
    font-size: 10px !important;
    padding: 4px 0 8px !important;
    letter-spacing: 1.2px !important;
  }

  #history-list {
    gap: 2px !important;
  }

  .history-item {
    padding: 10px 12px !important;
    border-radius: 15px !important;
    min-height: 56px !important;
  }

  .history-title {
    font-size: 13px !important;
  }

  .history-time {
    font-size: 10.5px !important;
    margin-top: 2px !important;
  }

  .user-section {
    padding: 10px 0 0 !important;
    gap: 9px !important;
  }

  .user-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
    font-size: 13px !important;
  }

  .user-name {
    font-size: 13px !important;
  }

  .user-plan {
    font-size: 11px !important;
  }

  #logout-btn {
    width: 34px !important;
    height: 34px !important;
    border-radius: 12px !important;
  }
}

@media (max-width: 420px) {
  #sidebar {
    width: 70vw !important;
  }

  #sidebar.closed {
    width: 70vw !important;
  }
}

/* =========================================================
   ULTRA COMPACT SIDEBAR + HISTORY SPACING FIX
========================================================= */

@media (max-width: 768px) {
  /* Sidebar / navbar kiri lebih kecil */
  #sidebar {
    width: min(62vw, 245px) !important;
    padding: 14px 12px calc(10px + env(safe-area-inset-bottom)) !important;
  }

  #sidebar.closed {
    width: min(62vw, 245px) !important;
    padding: 14px 12px calc(10px + env(safe-area-inset-bottom)) !important;
  }

  /* Logo lebih kecil */
  .logo {
    padding: 2px 0 14px !important;
    gap: 9px !important;
  }

  .logo-icon {
    width: 34px !important;
    height: 34px !important;
    border-radius: 12px !important;
    font-size: 16px !important;
  }

  .logo-text {
    font-size: 17px !important;
  }

  .logo-subtitle {
    font-size: 10px !important;
  }

  /* New Chat lebih kecil */
  #new-chat-btn {
    height: 42px !important;
    min-height: 42px !important;
    border-radius: 14px !important;
    padding: 0 12px !important;
    font-size: 13px !important;
    margin-bottom: 12px !important;
    gap: 8px !important;
  }

  .plus-icon {
    width: 24px !important;
    height: 24px !important;
    border-radius: 9px !important;
    font-size: 17px !important;
  }

  /* Label riwayat */
  .history-label {
    font-size: 9.5px !important;
    padding: 2px 0 6px !important;
    letter-spacing: 1px !important;
  }

  /* Ini yang bikin spacing riwayat tadi gede */
  #history-list {
    gap: 0 !important;
    padding-right: 2px !important;
    padding-bottom: 8px !important;
  }

  .history-item {
    min-height: 0 !important;
    height: auto !important;
    padding: 7px 10px !important;
    margin: 0 0 3px !important;
    border-radius: 12px !important;
    gap: 6px !important;
  }

  .history-title {
    font-size: 12.5px !important;
    line-height: 1.25 !important;
  }

  .history-time {
    font-size: 10px !important;
    line-height: 1.2 !important;
    margin-top: 2px !important;
  }

  .history-delete {
    font-size: 12px !important;
    padding: 1px 4px !important;
  }

  /* User bawah lebih kecil */
  .user-section {
    padding: 9px 0 0 !important;
    gap: 8px !important;
  }

  .user-avatar {
    width: 34px !important;
    height: 34px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
  }

  .user-name {
    font-size: 12.5px !important;
    line-height: 1.2 !important;
  }

  .user-plan {
    font-size: 10.5px !important;
    line-height: 1.2 !important;
  }

  #logout-btn {
    width: 30px !important;
    height: 30px !important;
    border-radius: 10px !important;
    font-size: 12px !important;
  }
}

@media (max-width: 420px) {
  #sidebar {
    width: 62vw !important;
  }

  #sidebar.closed {
    width: 62vw !important;
  }

  .history-item {
    padding: 7px 9px !important;
  }
}

/* =========================================================
   FINAL MOBILE SIDEBAR / NAVBAR FIX
========================================================= */

@media (max-width: 768px) {
  /* Sidebar mulai di bawah header, bukan dari paling atas */
  #sidebar {
    top: 74px !important;
    height: calc(100dvh - 74px) !important;
    max-height: calc(100dvh - 74px) !important;

    width: min(58vw, 230px) !important;
    padding: 12px 10px calc(10px + env(safe-area-inset-bottom)) !important;

    border-top: 1px solid rgba(186, 230, 253, 0.12);
    border-top-right-radius: 0;
  }

  #sidebar.closed {
    width: min(58vw, 230px) !important;
    padding: 12px 10px calc(10px + env(safe-area-inset-bottom)) !important;
    transform: translateX(-110%) !important;
  }

  /* Logo disembunyikan di mobile biar nggak boros tempat */
  #sidebar .logo {
    display: none !important;
  }

  /* New chat jadi compact dan nggak kepotong */
  #new-chat-btn {
    width: 100% !important;
    height: 40px !important;
    min-height: 40px !important;
    border-radius: 13px !important;
    padding: 0 10px !important;
    margin: 0 0 14px !important;

    font-size: 12.5px !important;
    gap: 7px !important;
  }

  .plus-icon {
    width: 22px !important;
    height: 22px !important;
    border-radius: 8px !important;
    font-size: 16px !important;
  }

  .history-label {
    font-size: 9px !important;
    padding: 0 0 7px !important;
    letter-spacing: 1.1px !important;
  }

  #history-list {
    gap: 1px !important;
    padding-right: 2px !important;
  }

  .history-item {
    padding: 7px 8px !important;
    margin-bottom: 2px !important;
    border-radius: 11px !important;
    min-height: 0 !important;
  }

  .history-title {
    font-size: 11.5px !important;
    line-height: 1.22 !important;
  }

  .history-time {
    font-size: 9.5px !important;
    line-height: 1.15 !important;
    margin-top: 2px !important;
  }

  .user-section {
    padding: 8px 0 0 !important;
    gap: 7px !important;
  }

  .user-avatar {
    width: 30px !important;
    height: 30px !important;
    border-radius: 10px !important;
    font-size: 11px !important;
  }

  .user-name {
    font-size: 11.5px !important;
  }

  .user-plan {
    font-size: 9.5px !important;
  }

  #logout-btn {
    width: 28px !important;
    height: 28px !important;
    border-radius: 9px !important;
    font-size: 11px !important;
  }
}

@media (max-width: 420px) {
  #sidebar {
    width: 58vw !important;
  }

  #sidebar.closed {
    width: 58vw !important;
  }
}

/* =========================================================
   SUPER COMPACT TOP NAVBAR MOBILE
========================================================= */

@media (max-width: 768px) {
  #header {
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    padding: 6px 10px !important;
    gap: 8px !important;
    align-items: center !important;
  }

  #toggle-sidebar {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 13px !important;
    padding: 9px !important;
  }

  #toggle-sidebar span {
    width: 17px !important;
    height: 2px !important;
  }

  #model-selector-wrapper {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  #model-selector-btn {
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 12px !important;
    border-radius: 14px !important;
  }

  .selector-left {
    gap: 7px !important;
    min-width: 0 !important;
  }

  .selector-dot {
    width: 7px !important;
    height: 7px !important;
  }

  .selector-name {
    font-size: 12.5px !important;
    line-height: 1 !important;
    max-width: 180px !important;
  }

  .selector-chevron {
    font-size: 9px !important;
  }

  .header-status {
    display: none !important;
  }

  #model-dropdown {
    top: calc(100% + 7px) !important;
  }

  /* Sidebar ikut header baru */
  #sidebar {
    top: 52px !important;
    height: calc(100dvh - 52px) !important;
    max-height: calc(100dvh - 52px) !important;
  }

  #sidebar.closed {
    top: 52px !important;
    height: calc(100dvh - 52px) !important;
    max-height: calc(100dvh - 52px) !important;
  }

  /* Chat area naik mengikuti navbar compact */
  #messages-area {
    padding-top: 18px !important;
  }
}

@media (max-width: 420px) {
  #header {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    padding: 5px 9px !important;
    gap: 7px !important;
  }

  #toggle-sidebar {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 12px !important;
    padding: 8px !important;
  }

  #toggle-sidebar span {
    width: 16px !important;
  }

  #model-selector-btn {
    height: 36px !important;
    min-height: 36px !important;
    border-radius: 13px !important;
    padding: 0 11px !important;
  }

  .selector-name {
    font-size: 12px !important;
    max-width: 150px !important;
  }

  #sidebar {
    top: 48px !important;
    height: calc(100dvh - 48px) !important;
    max-height: calc(100dvh - 48px) !important;
  }

  #sidebar.closed {
    top: 48px !important;
    height: calc(100dvh - 48px) !important;
    max-height: calc(100dvh - 48px) !important;
  }
}

/* =========================================================
   SIDEBAR CLOSE X BUTTON
========================================================= */

@media (max-width: 768px) {
  #toggle-sidebar {
    position: relative;
  }

  #toggle-sidebar.sidebar-open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  #toggle-sidebar.sidebar-open span:nth-child(2) {
    opacity: 0;
  }

  #toggle-sidebar.sidebar-open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  #toggle-sidebar span {
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
}

/* =========================================================
   PROMPT INPUT COMPACT MOBILE FIX
========================================================= */

@media (max-width: 768px) {
  #input-wrapper {
    padding: 8px 18px calc(10px + env(safe-area-inset-bottom)) !important;
  }

  #input-box {
    min-height: 46px !important;
    border-radius: 18px !important;
    padding: 7px 8px 7px 14px !important;
  }

  #user-input {
    font-size: 13px !important;
    line-height: 1.35 !important;
    padding: 6px 0 !important;
    max-height: 110px !important;
  }

  #send-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 14px !important;
    font-size: 15px !important;
  }
}

@media (max-width: 420px) {
  #input-wrapper {
    padding: 7px 16px calc(9px + env(safe-area-inset-bottom)) !important;
  }

  #input-box {
    min-height: 44px !important;
    border-radius: 17px !important;
    padding: 6px 7px 6px 13px !important;
  }

  #user-input {
    font-size: 12.5px !important;
    padding: 5px 0 !important;
  }

  #send-btn {
    width: 34px !important;
    height: 34px !important;
    border-radius: 13px !important;
  }
}

/* =========================================================
   PROMPT INPUT POSITION FIX
   Naikin input prompt biar nggak terlalu nempel bawah
========================================================= */

@media (max-width: 768px) {
  #input-wrapper {
    padding: 7px 18px calc(34px + env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 420px) {
  #input-wrapper {
    padding: 7px 16px calc(36px + env(safe-area-inset-bottom)) !important;
  }
}

/* =========================================================
   PROMPT INPUT TEXT VERTICAL ALIGN FIX
========================================================= */

@media (max-width: 768px) {
  #input-box {
    min-height: 46px !important;
    height: 46px !important;
    align-items: center !important;
    padding: 5px 7px 5px 14px !important;
  }

  #user-input {
    height: 24px !important;
    min-height: 24px !important;
    max-height: 90px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 24px !important;
    display: block !important;
    overflow-y: hidden !important;
  }

  #send-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 14px !important;
  }
}

@media (max-width: 420px) {
  #input-box {
    min-height: 44px !important;
    height: 44px !important;
    padding: 5px 7px 5px 13px !important;
  }

  #user-input {
    height: 22px !important;
    min-height: 22px !important;
    line-height: 22px !important;
  }

  #send-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
  }
}

/* =========================================================
   CHATGPT-LIKE SIMPLE CHAT BUBBLES
========================================================= */

.message-row {
  gap: 11px !important;
}

.avatar {
  box-shadow: none !important;
}

.avatar.bot {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(186, 230, 253, 0.16) !important;
  color: #dff7ff !important;
}

.avatar.user {
  background: rgba(56, 189, 248, 0.16) !important;
  border: 1px solid rgba(125, 211, 252, 0.26) !important;
  color: #ffffff !important;
}

/* Bot: lebih kayak ChatGPT, tanpa bubble tebal */
.bubble.bot {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 4px 0 !important;
  border-radius: 0 !important;
  max-width: calc(100% - 54px) !important;
}

/* User: bubble tetap ada, tapi kalem */
.bubble.user {
  background: rgba(56, 189, 248, 0.16) !important;
  border: 1px solid rgba(125, 211, 252, 0.22) !important;
  box-shadow: none !important;
  color: #f4fbff !important;
  border-radius: 18px !important;
  padding: 10px 14px !important;
  max-width: 72% !important;
}

/* Meta model lebih subtle */
.bubble-meta {
  opacity: 0.45 !important;
  padding-left: 49px !important;
  margin-top: 4px !important;
}

/* Action buttons lebih minimal */
.message-actions {
  padding-left: 49px !important;
  margin-top: 6px !important;
  opacity: 0.55 !important;
}

.message-action-btn {
  background: transparent !important;
  border: none !important;
  padding: 3px 6px !important;
  color: rgba(244, 251, 255, 0.58) !important;
}

.message-action-btn:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #fff !important;
}

/* Mobile tuning */
@media (max-width: 768px) {
  .message-row {
    gap: 10px !important;
  }

  .bubble {
    font-size: 14.5px !important;
    line-height: 1.62 !important;
  }

  .bubble.bot {
    max-width: calc(100% - 48px) !important;
    padding-top: 2px !important;
  }

  .bubble.user {
    max-width: 68% !important;
    padding: 9px 13px !important;
    border-radius: 17px !important;
  }

  .bubble-meta,
  .message-actions {
    padding-left: 44px !important;
  }
}

/* =========================================================
   PROFESSIONAL MARKDOWN STYLE
========================================================= */

.bubble.bot p {
  margin: 0 0 14px;
}

.bubble.bot p:last-child {
  margin-bottom: 0;
}

.bubble.bot h1,
.bubble.bot h2,
.bubble.bot h3 {
  font-family: 'DM Sans', sans-serif;
  color: #f4fbff;
  line-height: 1.25;
  margin: 22px 0 10px;
  letter-spacing: -0.3px;
}

.bubble.bot h1:first-child,
.bubble.bot h2:first-child,
.bubble.bot h3:first-child {
  margin-top: 0;
}

.bubble.bot h1 {
  font-size: 22px;
  font-weight: 800;
}

.bubble.bot h2 {
  font-size: 19px;
  font-weight: 800;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(186, 230, 253, 0.13);
}

.bubble.bot h3 {
  font-size: 16px;
  font-weight: 800;
  color: #dff7ff;
}

.bubble.bot strong {
  font-weight: 800;
  color: #ffffff;
}

.bubble.bot em {
  color: rgba(223, 247, 255, 0.86);
}

.bubble.bot a {
  color: var(--sky-300);
  text-decoration: none;
  border-bottom: 1px solid rgba(125, 211, 252, 0.35);
}

.bubble.bot a:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
}

.bubble.bot blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--sky-400);
  background: rgba(125, 211, 252, 0.07);
  border-radius: 0 12px 12px 0;
  color: rgba(244, 251, 255, 0.78);
}

.bubble.bot .md-list {
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble.bot .md-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
}

.bubble.bot .md-list li > span {
  flex: 0 0 auto;
  min-width: 20px;
  color: var(--sky-300);
  font-weight: 800;
}

.bubble.bot .md-list li > div {
  flex: 1;
  min-width: 0;
}

.bubble.bot code.inline-code {
  padding: 2px 7px;
  border-radius: 7px;
  background: rgba(125, 211, 252, 0.10);
  border: 1px solid rgba(125, 211, 252, 0.16);
  color: #dff7ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.code-block {
  margin: 14px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(186, 230, 253, 0.15);
  background: rgba(2, 8, 23, 0.72);
}

.code-header {
  background: rgba(125, 211, 252, 0.08);
  border-bottom: 1px solid rgba(186, 230, 253, 0.10);
}

.code-block pre {
  margin: 0;
  padding: 14px;
}

.code-block code {
  color: #e8f8ff;
}

/* Bot avatar bintang */
.avatar.bot {
  font-size: 17px !important;
  font-weight: 800 !important;
}

/* Mobile markdown tuning */
@media (max-width: 768px) {
  .bubble.bot h1 {
    font-size: 20px;
  }

  .bubble.bot h2 {
    font-size: 17px;
  }

  .bubble.bot h3 {
    font-size: 15px;
  }

  .bubble.bot p {
    margin-bottom: 13px;
  }

  .bubble.bot .md-list {
    gap: 7px;
  }
}

/* =========================================================
   MODEL DROPDOWN COMPACT FIX
========================================================= */

@media (max-width: 768px) {
  #model-dropdown {
    top: calc(100% + 6px) !important;
    border-radius: 16px !important;
    max-height: 245px !important;
    overflow-y: auto !important;
  }

  .dropdown-group-label {
    padding: 9px 14px 5px !important;
    font-size: 9.5px !important;
    letter-spacing: 1.2px !important;
  }

  .dropdown-item {
    min-height: 44px !important;
    height: 44px !important;
    padding: 8px 14px !important;
    gap: 7px !important;
  }

  .dropdown-item-left {
    gap: 8px !important;
    min-width: 0 !important;
  }

  .dropdown-item-name {
    font-size: 13px !important;
    line-height: 1.1 !important;
    max-width: 160px !important;
  }

  .dropdown-item-tag {
    font-size: 10.5px !important;
    max-width: 68px !important;
    opacity: 0.55 !important;
  }

  .dropdown-check {
    font-size: 13px !important;
  }

  .dropdown-divider {
    margin: 2px 0 !important;
  }
}

@media (max-width: 420px) {
  #model-dropdown {
    max-height: 220px !important;
  }

  .dropdown-item {
    min-height: 40px !important;
    height: 40px !important;
    padding: 7px 13px !important;
  }

  .dropdown-item-name {
    font-size: 12.5px !important;
    max-width: 145px !important;
  }

  .dropdown-item-tag {
    font-size: 10px !important;
    max-width: 56px !important;
  }
}

/* =========================================================
   MARKDOWN HEADING FIX H4-H6
========================================================= */

.bubble.bot .md-h4,
.bubble.bot .md-h5,
.bubble.bot .md-h6 {
  color: #f4fbff;
  font-weight: 850;
  line-height: 1.3;
  letter-spacing: -0.25px;
  margin: 18px 0 8px;
}

.bubble.bot .md-h4 {
  font-size: 15.5px;
}

.bubble.bot .md-h5 {
  font-size: 14.5px;
  color: #dff7ff;
}

.bubble.bot .md-h6 {
  font-size: 13.5px;
  color: rgba(223, 247, 255, 0.82);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.message-appear {
  animation: messageAppear 0.22s ease both;
}

@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .bubble.bot .md-h4 {
    font-size: 15px;
  }

  .bubble.bot .md-h5 {
    font-size: 14px;
  }

  .bubble.bot .md-h6 {
    font-size: 12.5px;
  }
}

/* =========================================================
   MARKDOWN HEADING FIX H4-H6
========================================================= */

.bubble.bot .md-h4,
.bubble.bot .md-h5,
.bubble.bot .md-h6 {
  color: #f4fbff;
  font-weight: 850;
  line-height: 1.3;
  letter-spacing: -0.25px;
  margin: 18px 0 8px;
}

.bubble.bot .md-h4 {
  font-size: 15.5px;
}

.bubble.bot .md-h5 {
  font-size: 14.5px;
  color: #dff7ff;
}

.bubble.bot .md-h6 {
  font-size: 13.5px;
  color: rgba(223, 247, 255, 0.82);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* =========================================================
   BOT RESPONSE BLUR FADE ANIMATION
========================================================= */

.message-fade-in {
  animation: messageBlurFadeIn 0.42s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes messageBlurFadeIn {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  .bubble.bot .md-h4 {
    font-size: 15px;
  }

  .bubble.bot .md-h5 {
    font-size: 14px;
  }

  .bubble.bot .md-h6 {
    font-size: 12.5px;
  }
}

/* =========================================================
   RESPONSE FADE DOWN + JUMP TO BOTTOM BUTTON
========================================================= */

.message-fade-down {
  animation: messageFadeDown 0.42s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes messageFadeDown {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(-16px) scale(0.985);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

#jump-to-bottom-btn {
  position: fixed;
  right: 24px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 120;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(186, 230, 253, 0.18);
  background: rgba(14, 35, 57, 0.78);
  color: #dff7ff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(18px);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.28),
    0 0 22px rgba(56, 189, 248, 0.16);
  animation: jumpButtonIn 0.2s ease both;
}

#jump-to-bottom-btn:hover {
  background: rgba(56, 189, 248, 0.18);
}

#jump-to-bottom-btn.hidden {
  display: none !important;
}

@keyframes jumpButtonIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  #jump-to-bottom-btn {
    right: 18px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
}

/* =========================================================
   CLEAN SVG ICONS
========================================================= */

.history-pin svg,
.history-delete svg,
.history-pin-mark svg,
#jump-to-bottom-btn svg {
  display: block;
}

.history-pin svg,
.history-delete svg,
.history-pin-mark svg {
  width: 14px;
  height: 14px;
}

.history-pin-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 5px;
  color: #7dd3fc;
  vertical-align: -2px;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.history-item:hover .history-actions,
.history-item.active .history-actions {
  opacity: 1;
  transform: translateX(0);
}

.history-pin,
.history-delete {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(186, 230, 253, 0.12);
  border-radius: 9px;
  background: rgba(255,255,255,0.055);
  color: rgba(230,247,255,0.58);
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.history-pin:hover {
  color: #dff7ff;
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(125, 211, 252, 0.28);
  transform: translateY(-1px);
}

.history-delete:hover {
  color: #fb7185;
  background: rgba(244, 63, 94, 0.20);
  border-color: rgba(244, 63, 94, 0.26);
  transform: translateY(-1px);
}

.history-item.pinned {
  background: rgba(56, 189, 248, 0.10);
}

.history-item.pinned .history-pin {
  color: #7dd3fc;
}

#jump-to-bottom-btn {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 120;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(186, 230, 253, 0.18);
  background: rgba(14, 35, 57, 0.78);
  color: #dff7ff;
  cursor: pointer;
  backdrop-filter: blur(18px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.28),
    0 0 22px rgba(56, 189, 248, 0.16);
  animation: jumpButtonInCenter 0.2s ease both;
}

#jump-to-bottom-btn:hover {
  background: rgba(56, 189, 248, 0.18);
}

#jump-to-bottom-btn.hidden {
  display: none !important;
}

@keyframes jumpButtonInCenter {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px) scale(0.92);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  .history-actions {
    opacity: 1;
    transform: none;
  }

  .history-pin,
  .history-delete {
    width: 24px;
    height: 24px;
  }

  #jump-to-bottom-btn {
    left: 50%;
    right: auto;
    bottom: calc(82px + env(safe-area-inset-bottom));
    width: 34px;
    height: 34px;
  }
}

/* =========================================================
   HISTORY ITEM CLEAN FIX
========================================================= */

.history-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 9px 9px 9px 12px;
  border-radius: 15px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(244, 251, 255, 0.78);
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.history-item:hover {
  background: rgba(255,255,255,0.07);
  transform: translateX(2px);
}

.history-item.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(125, 211, 252, 0.25);
}

.history-item.pinned {
  background: rgba(56, 189, 248, 0.10);
}

.history-item-body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.25;
  color: rgba(244, 251, 255, 0.86);
}

.history-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.1;
  color: rgba(230,247,255,0.36);
}

.history-pin-mark {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #7dd3fc;
  flex-shrink: 0;
  margin: 0;
  vertical-align: 0;
}

.history-pin-mark svg {
  width: 13px;
  height: 13px;
  display: block;
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(5px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.history-item:hover .history-actions,
.history-item.active .history-actions,
.history-item.pinned .history-actions {
  opacity: 1;
  transform: translateX(0);
}

.history-pin,
.history-delete {
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid rgba(186, 230, 253, 0.12);
  border-radius: 9px;
  background: rgba(255,255,255,0.055);
  color: rgba(230,247,255,0.58);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.history-pin svg,
.history-delete svg {
  width: 13px;
  height: 13px;
  display: block;
  pointer-events: none;
}

.history-pin:hover {
  color: #dff7ff;
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(125, 211, 252, 0.28);
  transform: translateY(-1px);
}

.history-delete:hover {
  color: #fb7185;
  background: rgba(244, 63, 94, 0.20);
  border-color: rgba(244, 63, 94, 0.26);
  transform: translateY(-1px);
}

.history-item.pinned .history-pin {
  color: #7dd3fc;
}

@media (max-width: 768px) {
  .history-actions {
    opacity: 1;
    transform: none;
  }

  .history-item {
    min-height: 52px;
    padding: 8px 8px 8px 12px;
  }

  .history-pin,
  .history-delete {
    width: 24px;
    height: 24px;
  }
}

/* =========================================================
   BOT AVATAR MOVE TO FOOTER — CLAUDE STYLE
========================================================= */

.message-row.bot {
  align-items: flex-start;
  gap: 0;
}

.message-row.bot .avatar.bot {
  display: none !important;
}

.bot-message-wrap {
  width: 100%;
}

.bot-message-wrap .bubble.bot {
  max-width: 100%;
  width: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}

.bot-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
  padding-left: 0;
  color: rgba(230, 247, 255, 0.42);
  font-size: 11.5px;
  line-height: 1;
}

.bot-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(223, 247, 255, 0.52);
  font-weight: 700;
}

.bot-footer-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(125, 211, 252, 0.10);
  border: 1px solid rgba(186, 230, 253, 0.13);
  color: #bdeeff;
  font-size: 12px;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.10);
}

.bot-footer-icon.loading {
  animation: novaSpin 1.1s linear infinite;
}

@keyframes novaSpin {
  to {
    transform: rotate(360deg);
  }
}

.bot-footer-meta {
  color: rgba(230, 247, 255, 0.34);
  font-size: 11.5px;
}

.bot-footer-actions {
  margin: 0 !important;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bot-footer-actions .message-action-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  color: rgba(230, 247, 255, 0.48);
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(186, 230, 253, 0.10);
}

.bot-footer-actions .message-action-btn:hover {
  color: #dff7ff;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(125, 211, 252, 0.22);
}

.typing-wrap .bubble.bot {
  opacity: 0.78;
}

.typing-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(244, 251, 255, 0.62);
  font-size: 14px;
}

.bot-footer-loading {
  margin-top: 9px;
}

@media (max-width: 768px) {
  .bot-footer {
    gap: 7px;
    margin-top: 10px;
    font-size: 11px;
  }

  .bot-footer-icon {
    width: 17px;
    height: 17px;
    font-size: 11px;
  }

  .bot-footer-actions .message-action-btn {
    height: 24px;
    padding: 0 9px;
    font-size: 11px;
  }
}

/* =========================================================
   FULL BOT RESPONSE VISIBILITY FIX
   Biar response panjang tidak terasa kepotong input bawah
========================================================= */

#messages-area {
  height: auto !important;
  min-height: 0 !important;
  padding-bottom: 180px !important;
  scroll-padding-bottom: 180px !important;
}

#message-list {
  padding-bottom: 40px !important;
}

.message-wrap,
.message-row,
.bubble {
  overflow: visible !important;
}

.bubble.bot {
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

.bot-message-wrap {
  min-height: auto !important;
  overflow: visible !important;
}

.code-block {
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

.code-block pre {
  max-height: none !important;
  height: auto !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
}

/* input tetap floating, tapi konten punya ruang aman di bawah */
#input-wrapper {
  z-index: 80;
}

@media (max-width: 768px) {
  #messages-area {
    padding-bottom: 190px !important;
    scroll-padding-bottom: 190px !important;
  }

  #message-list {
    padding-bottom: 50px !important;
  }
}

/* =========================================================
   CHATGPT/CLAUDE STYLE FULL WIDTH FIX
   Biar response tidak kepotong kanan
========================================================= */

#message-list {
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
  box-sizing: border-box !important;
}

.message-wrap,
.bot-message-wrap,
.message-row,
.message-row.bot {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.bubble.bot {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

.bubble.bot .md-p,
.bubble.bot .md-heading,
.bubble.bot .md-list,
.bubble.bot .md-quote,
.bubble.bot .md-table-wrap,
.bubble.bot .code-block {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Code block tetap full di dalam layar, scroll horizontal di dalam block */
.code-block {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.code-block pre {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  white-space: pre !important;
}

.code-block code {
  display: block !important;
  min-width: max-content !important;
  white-space: pre !important;
}

/* User bubble jangan ikut full */
.message-row.user .bubble.user {
  width: auto !important;
  max-width: min(78%, 520px) !important;
}

/* Mobile lebih rapat */
@media (max-width: 768px) {
  #message-list {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .code-block {
    border-radius: 16px !important;
  }
}

/* =========================================================
   NUCLEAR FIX — FULL RESPONSE WIDTH LIKE CHATGPT/CLAUDE
========================================================= */

#messages-area {
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

#message-list {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding-left: 28px !important;
  padding-right: 28px !important;
  box-sizing: border-box !important;
}

.message-wrap,
.message-wrap.bot-message-wrap {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.message-row.bot {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  display: block !important;
  box-sizing: border-box !important;
}

.message-row.bot .bubble.bot,
.bot-message-wrap .bubble.bot,
.bubble.bot {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  padding-right: 0 !important;
}

.bubble.bot > * {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.code-block {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.code-block pre {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
}

.code-block code {
  display: block !important;
  width: max-content !important;
  min-width: 100% !important;
  white-space: pre !important;
}

/* User bubble tetap compact */
.message-row.user {
  width: 100% !important;
}

.message-row.user .bubble.user {
  width: auto !important;
  max-width: min(78%, 520px) !important;
}

/* Mobile */
@media (max-width: 768px) {
  #message-list {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  .code-block {
    border-radius: 16px !important;
  }
}

/* =========================================================
   FINAL FIX — BOT RESPONSE TRUE FULL WIDTH MOBILE
   Hilangin sisa space avatar bot + code block full layar
========================================================= */

@media (max-width: 768px) {
  #messages-area {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  #message-list {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }

  .message-wrap.bot-message-wrap,
  .bot-message-wrap,
  .message-row.bot,
  .message-row.bot .bubble.bot,
  .bot-message-wrap .bubble.bot {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .message-row.bot {
    display: block !important;
    grid-template-columns: none !important;
  }

  .message-row.bot .avatar.bot {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .bubble.bot {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .bubble.bot .md-p,
  .bubble.bot .md-heading,
  .bubble.bot .md-list,
  .bubble.bot .md-quote,
  .bubble.bot .md-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
  }

  .code-block {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .code-block pre {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    box-sizing: border-box !important;
    -webkit-overflow-scrolling: touch;
  }

  .code-block code {
    display: block !important;
    width: max-content !important;
    min-width: 100% !important;
    white-space: pre !important;
  }

  .bot-footer {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
  }
}

/* =========================================================
   REAL FIX — STOP 100VW OVERFLOW
   Biar response/code block pas di dalam layar
========================================================= */

#messages-area {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

#message-list {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding-left: 16px !important;
  padding-right: 16px !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

.message-wrap,
.message-wrap.bot-message-wrap,
.bot-message-wrap,
.message-row,
.message-row.bot {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

.message-row.bot {
  display: block !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.message-row.bot .avatar.bot {
  display: none !important;
}

.bubble.bot,
.bot-message-wrap .bubble.bot,
.message-row.bot .bubble.bot {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  overflow-wrap: break-word !important;
  word-break: normal !important;
  overflow-x: visible !important;
}

.bubble.bot > * {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Code block pas di layar, isi panjang scroll horizontal */
.code-block {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.code-block pre {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch;
}

.code-block code {
  display: block !important;
  width: max-content !important;
  min-width: 100% !important;
  white-space: pre !important;
}

/* User bubble tetap di kanan dan tidak nyeret layout */
.message-row.user {
  width: 100% !important;
  max-width: 100% !important;
  display: flex !important;
  justify-content: flex-end !important;
  align-items: flex-start !important;
  gap: 10px !important;
  box-sizing: border-box !important;
}

.message-row.user .bubble.user {
  width: auto !important;
  max-width: min(78%, 520px) !important;
  box-sizing: border-box !important;
}

.message-row.user .avatar.user {
  flex-shrink: 0 !important;
}

/* Mobile safe spacing */
@media (max-width: 768px) {
  #message-list {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .code-block {
    border-radius: 16px !important;
  }
}

/* =========================================================
   FINAL CHAT LAYOUT RESET — CHATGPT / CLAUDE STYLE
   Tempel paling bawah style.css
========================================================= */

/* Shell wajib flex dan tidak bikin konten kepotong */
#app-shell,
#main {
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

#main {
  display: flex !important;
  flex-direction: column !important;
}

/* Header jangan makan layout aneh */
#header {
  flex-shrink: 0 !important;
}

/* Area scroll utama */
#messages-area {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-top: 22px !important;
  padding-bottom: calc(150px + env(safe-area-inset-bottom)) !important;
  scroll-padding-bottom: calc(150px + env(safe-area-inset-bottom)) !important;
  box-sizing: border-box !important;
}

/* List chat aman di dalam layar */
#message-list {
  width: 100% !important;
  max-width: 760px !important;
  margin: 0 auto !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
  padding-bottom: 40px !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

/* Wrapper pesan */
.message-wrap,
.message-row,
.bot-message-wrap,
.message-wrap.bot-message-wrap {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

/* Bot response full width di dalam container, bukan 100vw */
.message-row.bot {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

.message-row.bot .avatar.bot {
  display: none !important;
}

.bubble.bot,
.bot-message-wrap .bubble.bot,
.message-row.bot .bubble.bot {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  overflow-wrap: break-word !important;
  word-break: normal !important;
}

/* Isi markdown jangan keluar container */
.bubble.bot > *,
.bubble.bot .md-p,
.bubble.bot .md-heading,
.bubble.bot .md-list,
.bubble.bot .md-quote,
.bubble.bot .md-table-wrap {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Code block aman: box tidak keluar layar, isi kode scroll horizontal */
.code-block {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.code-block pre {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch;
}

.code-block code {
  display: block !important;
  min-width: max-content !important;
  white-space: pre !important;
}

/* User bubble tetap seperti chat */
.message-row.user {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: flex-start !important;
  gap: 10px !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.message-row.user .bubble.user {
  width: auto !important;
  max-width: min(78%, 520px) !important;
  box-sizing: border-box !important;
}

.message-row.user .avatar.user {
  flex-shrink: 0 !important;
}

/* Footer bot */
.bot-footer {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  padding-left: 0 !important;
  box-sizing: border-box !important;
}

/* Input jangan nutup konten terakhir */
#input-wrapper {
  z-index: 90 !important;
}

/* Mobile */
@media (max-width: 768px) {
  #messages-area {
    padding-top: 20px !important;
    padding-bottom: calc(165px + env(safe-area-inset-bottom)) !important;
    scroll-padding-bottom: calc(165px + env(safe-area-inset-bottom)) !important;
  }

  #message-list {
    max-width: 100% !important;
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  .code-block {
    border-radius: 16px !important;
  }
}

@media (max-width: 768px) {
  #message-list {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  .code-block {
    max-width: calc(100% - 0px) !important;
  }

  .message-row.user {
    padding-right: 4px !important;
  }

  #messages-area {
    padding-bottom: calc(180px + env(safe-area-inset-bottom)) !important;
  }
}

/* =========================================================
   PROVIDER MODEL SELECTOR — GROQ FREE / CEREBRAS HEAVY
========================================================= */

.dropdown-group-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 8px;
  color: rgba(223, 247, 255, 0.46);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.dropdown-group-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.7);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.dropdown-item {
  min-height: 52px;
  padding: 11px 14px;
  border-radius: 14px;
}

.dropdown-item-left {
  min-width: 0;
}

.dropdown-item-name {
  display: block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-item-tag {
  flex-shrink: 0;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(186, 230, 253, 0.11);
  background: rgba(255,255,255,0.045);
  color: rgba(230,247,255,0.42);
  font-size: 10.5px;
  font-weight: 750;
  white-space: nowrap;
}

/* Groq = Free / Daily */
.selector-dot.groq {
  background: #22d3ee;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.55);
}

.dropdown-item[data-provider="groq"] .dropdown-item-tag {
  color: #bdf5ff;
  background: rgba(34, 211, 238, 0.10);
  border-color: rgba(34, 211, 238, 0.22);
}

.dropdown-item[data-provider="groq"].active {
  background: rgba(34, 211, 238, 0.13);
}

/* Cerebras = Heavy */
.selector-dot.cerebras {
  background: #60a5fa;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.55);
}

.dropdown-item[data-provider="cerebras"] .dropdown-item-tag {
  color: #d7e7ff;
  background: rgba(96, 165, 250, 0.10);
  border-color: rgba(96, 165, 250, 0.22);
}

.dropdown-item[data-provider="cerebras"].active {
  background: rgba(96, 165, 250, 0.13);
}

/* OpenRouter fallback kalau nanti dipakai */
.selector-dot.openrouter {
  background: #a78bfa;
  box-shadow: 0 0 16px rgba(167, 139, 250, 0.55);
}

/* Dropdown biar compact di mobile */
@media (max-width: 768px) {
  #model-dropdown {
    max-height: min(430px, 62vh);
    overflow-y: auto;
  }

  .dropdown-item {
    min-height: 48px;
    padding: 10px 12px;
  }

  .dropdown-item-name {
    max-width: 155px;
    font-size: 13.5px;
  }

  .dropdown-item-tag {
    font-size: 10px;
    padding: 4px 7px;
  }

  .dropdown-group-label {
    padding: 9px 12px 7px;
    font-size: 10.5px;
  }
}

/* =========================================================
   USER MESSAGE CLEAN — NO AVATAR, RIGHT ALIGNED
========================================================= */

.message-row.user .avatar.user {
  display: none !important;
}

.message-row.user {
  justify-content: flex-end !important;
  padding-right: 0 !important;
}

.message-row.user .bubble.user {
  margin-left: auto !important;
  margin-right: 0 !important;
  max-width: min(82%, 560px) !important;
}

@media (max-width: 768px) {
  .message-row.user .bubble.user {
    max-width: 82% !important;
  }
}

/* =========================================================
   SETTINGS PANEL
========================================================= */

.sidebar-settings-btn {
  width: 31px;
  height: 31px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.055);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.sidebar-settings-btn:hover {
  background: rgba(56, 189, 248, 0.14);
  color: #fff;
  transform: translateY(-1px);
}

.settings-icon,
.settings-icon svg {
  display: block;
}

.settings-btn-text {
  display: none;
}

.settings-panel.hidden {
  display: none !important;
}

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 10, 20, 0.48);
  backdrop-filter: blur(8px);
  animation: settingsFadeIn 0.18s ease both;
}

.settings-sheet {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(92vw, 430px);
  border-radius: 28px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035)),
    rgba(15, 35, 52, 0.94);
  border: 1px solid rgba(186, 230, 253, 0.16);
  box-shadow: 0 24px 90px rgba(0,0,0,0.45);
  animation: settingsSheetUp 0.22s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes settingsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes settingsSheetUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.settings-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.settings-title {
  font-size: 18px;
  font-weight: 900;
  color: #f4fbff;
}

.settings-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(230,247,255,0.45);
}

.settings-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(186, 230, 253, 0.13);
  background: rgba(255,255,255,0.045);
  color: rgba(230,247,255,0.7);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.settings-section {
  margin-bottom: 14px;
}

.settings-label {
  display: block;
  margin-bottom: 8px;
  color: rgba(244,251,255,0.82);
  font-size: 13px;
  font-weight: 800;
}

.settings-select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 15px;
  border: 1px solid rgba(186, 230, 253, 0.13);
  background: rgba(5, 18, 31, 0.72);
  color: #effbff;
  outline: none;
}

.settings-row {
  min-height: 58px;
  margin: 8px 0 14px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(186, 230, 253, 0.10);
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-help {
  color: rgba(230,247,255,0.42);
  font-size: 11.5px;
  line-height: 1.35;
}

.settings-switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.settings-switch input {
  display: none;
}

.settings-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(186, 230, 253, 0.13);
}

.settings-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(230,247,255,0.72);
  transition: 0.18s ease;
}

.settings-switch input:checked + span {
  background: rgba(34, 211, 238, 0.22);
  border-color: rgba(34, 211, 238, 0.35);
}

.settings-switch input:checked + span::after {
  left: 23px;
  background: #bdf5ff;
}

.settings-danger-btn {
  width: 100%;
  height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(248, 113, 113, 0.22);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
  font-weight: 850;
  cursor: pointer;
}

.settings-danger-btn:hover {
  background: rgba(248, 113, 113, 0.14);
}

@media (max-width: 768px) {
  .settings-sheet {
    bottom: 12px;
    width: min(94vw, 430px);
    border-radius: 24px;
  }
}

/* =========================================================
   FIX SIDEBAR CLICK + INPUT BLEED THROUGH
========================================================= */

@media (max-width: 768px) {
  #sidebar {
    z-index: 300 !important;
  }

  #toggle-sidebar {
    z-index: 360 !important;
  }

  #input-wrapper,
  .input-wrapper,
  #composer,
  .composer {
    z-index: 90 !important;
  }

  /* Saat sidebar kebuka, input jangan tembus / nutup tombol sidebar */
  body:has(#sidebar:not(.closed)) #input-wrapper,
  body:has(#sidebar:not(.closed)) .input-wrapper,
  body:has(#sidebar:not(.closed)) #composer,
  body:has(#sidebar:not(.closed)) .composer {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(18px) !important;
  }

  /* Fallback kalau browser kurang cocok sama :has */
  #sidebar:not(.closed) ~ * #input-wrapper,
  #sidebar:not(.closed) ~ * .input-wrapper,
  #sidebar:not(.closed) ~ * #composer,
  #sidebar:not(.closed) ~ * .composer {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .sidebar-settings-btn,
  #settings-btn,
  #logout-btn {
    position: relative !important;
    z-index: 380 !important;
    pointer-events: auto !important;
  }

  .user-section,
  .sidebar-footer,
  .sidebar-user,
  .profile-section {
    position: relative !important;
    z-index: 370 !important;
  }
}

/* Settings modal harus paling atas */
#settings-panel,
.settings-panel {
  z-index: 9999 !important;
}

.settings-sheet {
  z-index: 10000 !important;
}

.settings-backdrop {
  z-index: 9999 !important;
}


/* =========================================================
   FIX SIDEBAR CLICK + INPUT BLEED THROUGH
========================================================= */

@media (max-width: 768px) {
  #sidebar {
    z-index: 300 !important;
  }

  #toggle-sidebar {
    z-index: 360 !important;
  }

  #input-wrapper,
  .input-wrapper,
  #composer,
  .composer {
    z-index: 90 !important;
  }

  /* Saat sidebar kebuka, input jangan tembus / nutup tombol sidebar */
  body:has(#sidebar:not(.closed)) #input-wrapper,
  body:has(#sidebar:not(.closed)) .input-wrapper,
  body:has(#sidebar:not(.closed)) #composer,
  body:has(#sidebar:not(.closed)) .composer {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(18px) !important;
  }

  /* Fallback kalau browser kurang cocok sama :has */
  #sidebar:not(.closed) ~ * #input-wrapper,
  #sidebar:not(.closed) ~ * .input-wrapper,
  #sidebar:not(.closed) ~ * #composer,
  #sidebar:not(.closed) ~ * .composer {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .sidebar-settings-btn,
  #settings-btn,
  #logout-btn {
    position: relative !important;
    z-index: 380 !important;
    pointer-events: auto !important;
  }

  .user-section,
  .sidebar-footer,
  .sidebar-user,
  .profile-section {
    position: relative !important;
    z-index: 370 !important;
  }
}

/* Settings modal harus paling atas */
#settings-panel,
.settings-panel {
  z-index: 9999 !important;
}

.settings-sheet {
  z-index: 10000 !important;
}

.settings-backdrop {
  z-index: 9999 !important;
}



/* =========================================================
   STOP GENERATING BUTTON
========================================================= */

#send-btn.stop-generating,
.send-btn.stop-generating {
  opacity: 1 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  background: rgba(248, 113, 113, 0.16) !important;
  border-color: rgba(248, 113, 113, 0.24) !important;
  color: #fecaca !important;
}

#send-btn.stop-generating:hover,
.send-btn.stop-generating:hover {
  background: rgba(248, 113, 113, 0.24) !important;
}

#send-btn.stop-generating.loading,
.send-btn.stop-generating.loading {
  animation: stopPulse 1.2s ease-in-out infinite;
}

@keyframes stopPulse {
  0%, 100% {
    box-shadow: 0 0 0 rgba(248, 113, 113, 0);
  }
  50% {
    box-shadow: 0 0 18px rgba(248, 113, 113, 0.22);
  }
}


/* =========================================================
   FORCE STOP BUTTON CLICKABLE
========================================================= */

#send-btn.stop-generating {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
  background: rgba(248, 113, 113, 0.18) !important;
  border-color: rgba(248, 113, 113, 0.32) !important;
  color: #fecaca !important;
  z-index: 999 !important;
}

#send-btn.stop-generating:disabled {
  pointer-events: auto !important;
  opacity: 1 !important;
}

#input-wrapper,
.input-wrapper,
#composer,
.composer {
  pointer-events: auto !important;
}

#send-btn.stop-generating::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: inherit;
}


/* =========================================================
   HARD FIX STOP BUTTON TAP
========================================================= */

#send-btn {
  position: relative !important;
}

#send-btn.stop-generating,
#send-btn.stop-generating.active,
#send-btn.stop-generating.loading {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  z-index: 99999 !important;
  background: rgba(248, 113, 113, 0.2) !important;
  border-color: rgba(248, 113, 113, 0.38) !important;
  color: #fecaca !important;
}

#send-btn.stop-generating:disabled {
  pointer-events: auto !important;
  opacity: 1 !important;
}
