#sidebar {
  position: fixed;
  left: 0;
  top: 0;

  width: 250px;
  height: 100vh;

  padding: 20px;

  background: rgba(255, 255, 255, 0.85);

  backdrop-filter: blur(15px);

  border-right: 1px solid rgba(0, 0, 0, 0.08);

  box-shadow: 5px 0 25px rgba(0, 0, 0, 0.06);

  display: flex;
  flex-direction: column;

  gap: 15px;

  z-index: 10;
}

.sidebar-header h2 {
  font-size: 22px;
  letter-spacing: 2px;
}

#new-chat {
  width: 100%;

  padding: 12px;

  border: none;
  border-radius: 12px;

  font-size: 15px;
  font-weight: bold;

  cursor: pointer;

  background: linear-gradient(135deg, #626cff, #8b5cf6);

  color: white;

  box-shadow: 0 6px 18px rgba(98, 108, 255, 0.25);

  transition: 0.2s ease;
}

#new-chat:hover {
  transform: translateY(-2px);

  box-shadow: 0 9px 22px rgba(98, 108, 255, 0.35);
}

.history-title {
  font-size: 13px;
  font-weight: bold;

  opacity: 0.55;

  margin-top: 10px;
}


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

body {
  font-family: Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  padding-left: 270px;
  background:
    radial-gradient(circle at top left, #e8eaff, transparent 35%),
    radial-gradient(circle at bottom right, #e5f4ff, transparent 35%),
    #f4f6fb;
  color: #202124;

   animation: pageLoad 0.6s ease;
}
 

#main-content {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - 40px);

  display: flex;
  flex-direction: column;
}


/* HEADER */

.app-header {
  text-align: center;
  margin-bottom: 18px;
}

.logo {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 30px;

  animation: logoGlow 2s ease-in-out infinite;
}

h1 {
  font-size: 30px;
  letter-spacing: 4px;
}

.app-header p {
  margin-top: 5px;
  font-size: 14px;
  opacity: 0.6;
}

/* CHAT SCREEN */

#chat {
  flex: 1;

  padding: 25px;

  margin-bottom: 15px;

  overflow-y: auto;

  display: flex;
  flex-direction: column;
  gap: 14px;

  border: 1px solid rgba(255, 255, 255, 0.8);

  border-radius: 24px;

  background: rgba(255, 255, 255, 0.72);

  backdrop-filter: blur(15px);

  box-shadow:
    0 15px 40px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);

  scroll-behavior: smooth;

  animation: chatAppear 0.7s ease;
}

/* USER MESSAGE */

.user-message {
  align-self: flex-end;

  max-width: 75%;

  padding: 13px 17px;

  border-radius: 18px 18px 4px 18px;

  margin: 0;

  background: #e7e9ff;

  line-height: 1.5;

  box-shadow: 0 5px 15px rgba(80, 90, 180, 0.12);

  animation: messageAppear 0.3s ease;

  transition: transform 0.2s ease;
}

.user-message:hover {
  transform: translateY(-2px);
}

/* AI MESSAGE */

.ai-message {
  align-self: flex-start;
  
  width: fit-content;

  max-width: 75%;

  padding: 13px 17px;

  border-radius: 18px 18px 18px 4px;

  margin: 0;

  line-height: 1.6;

  background: rgba(255, 255, 255, 0.9);

  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.06);

  animation: messageAppear 0.3s ease;

  transition: transform 0.2s ease;
}

.ai-message:hover {
  transform: translateY(-2px);
}

/* INPUT AREA */

.chat-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;

  animation: controlsAppear 0.7s ease;
}

#message {
  width: 100%;

  padding: 15px 17px;

  font-size: 16px;

  border-radius: 14px;

  border: 1px solid rgba(0, 0, 0, 0.08);

  outline: none;

  background: rgba(255, 255, 255, 0.9);

  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);

  transition:
    border 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.25s ease;
}

#message:focus {
  border-color: #9aa2ff;

  box-shadow:
    0 0 0 3px rgba(100, 110, 255, 0.12),
    0 8px 25px rgba(0, 0, 0, 0.08);

  transform: translateY(-1px);
}

/* BUTTON ROW */

.button-row {
  display: flex;
margin-top: 15px;
  justify-content: space-between;

  align-items: center;
}

/* BUTTONS */

#send,
#clear {
  padding: 12px 25px;

  font-size: 16px;

  font-weight: bold;

  border: none;

  border-radius: 12px;

  cursor: pointer;

  color: white;

  background: linear-gradient(135deg, #626cff, #8b5cf6);

  box-shadow:
    0 7px 18px rgba(98, 108, 255, 0.25);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

#send:hover,
#clear:hover {
  transform: translateY(-3px);

  box-shadow:
    0 10px 25px rgba(98, 108, 255, 0.35);

  filter: brightness(1.05);
}

#send:active,
#clear:active {
  transform: translateY(1px);

  box-shadow:
    0 4px 10px rgba(98, 108, 255, 0.2);
}

/* TYPING ANIMATION */

.dots {
  display: inline-block;

  animation: typing 1.2s infinite;
}

@keyframes typing {
  0% {
    opacity: 0.2;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.2;
  }
}

/* ANIMATIONS */

@keyframes pageLoad {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes chatAppear {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

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

@keyframes controlsAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

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

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

@keyframes logoGlow {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.7;
  }
}

/* MOBILE */

@media (max-width: 600px) {

  body {
    padding: 10px;
    padding-left: 10px;
  }

  #sidebar {
    position: relative;
    width: 100%;
    height: auto;

    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);

    margin-bottom: 10px;
  }

  #main-content {
    min-height: calc(100vh - 20px);
  }

  h1 {
    font-size: 24px;
  }

  #chat {
    padding: 14px;
    border-radius: 18px;
  }

  .user-message,
  .ai-message {
    max-width: 90%;
  }

  #send,
  #clear {
    padding: 11px 18px;
  }
}
#menu-button {
  display: none;
}

@media (max-width: 600px) {

  #menu-button {
    display: block;

    width: 45px;
    height: 45px;

    border: none;
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.85);

    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);

    font-size: 24px;
    cursor: pointer;

    margin-bottom: 10px;
  }
}
@media (max-width: 600px) {

  #sidebar {
    position: fixed;

    top: 0;
    left: 0;

    width: 280px;
    height: 100vh;

    transform: translateX(-100%);
    transition: transform 0.3s ease;

    z-index: 1000;
  }

  #sidebar.open {
    transform: translateX(0);
  }

}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  padding: 20px;
  padding-left: 270px;

  display: flex;
  flex-direction: column;

  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */

#sidebar {
  position: fixed;

  left: 0;
  top: 0;

  width: 250px;
  height: 100vh;

  overflow-y: auto;

  z-index: 10;
}

/* MAIN AREA */

#main-content {
  width: 100%;
  height: calc(100vh - 40px);

  min-width: 0;
  min-height: 0;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

/* ONLY CHAT SCROLLS */

#chat {
  flex: 1;
  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;
}

/* INPUT + BUTTONS NEVER SCROLL */

.chat-controls {
  flex: 0 0 auto;

  width: 100%;

  background: transparent;
}

/* .typing-bubble {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
}

.typing-bubble span {
  width: 10px;
  height: 10px;
  background: #555;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-8px);
  }
} */

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  padding: 12px 16px;
  border-radius: 18px;

  opacity: 0;
  animation: typingAppear 0.2s ease forwards;
}

@keyframes typingAppear {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

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

.typing-bubble span {
  width: 12px;
  height: 12px;
  background: #555;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-10px);
  }
}

.ai-message p {
  margin: 0 0 10px;
}

.ai-message p:last-child {
  margin-bottom: 0;
}

.ai-message ul,
.ai-message ol {
  margin: 8px 0;
  padding-left: 22px;
}

.ai-message li {
  margin-bottom: 4px;
}

.ai-message code {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: monospace;
}

.ai-message pre {
  background: #1e1e1e;
  color: #fff;
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 10px 0;
}

.ai-message pre code {
  background: none;
  padding: 0;
}

/* .history-item {
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s ease;
}

.history-item:hover {
  background: rgba(0, 0, 0, 0.06);
} */
 .history-item {
  padding: 10px 12px;
  margin: 5px 0;
  border-radius: 10px;
  cursor: pointer;
  color: #444;
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
  /* .history-item { */
  position: relative;
  z-index: 1;


  transition:
    background 0.2s ease,
    transform 0.2s ease,
    color 0.2s ease;
}

.history-item:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  transform: translateX(3px);
}

.history-item:active {
  transform: scale(0.98);
}

.history-item.active {
  background: linear-gradient(
    90deg,
    rgba(124, 58, 237, 0.14),
    rgba(6, 182, 212, 0.08)
  );

  color: #7c3aed;
  font-weight: 600;
}

#clear-history {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.06);
  transition: background 0.2s ease;
}

#clear-history:hover {
  background: rgba(0, 0, 0, 0.12);
}

.paulix-x {
  font-size: 1.15em;
  font-weight: 900;
  display: inline-block;
  position: relative;

  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;

  animation: paulixGlitch 5s infinite;
}

@keyframes paulixGlitch {

  0%, 72%, 100% {
    opacity: 1;
    transform: translate(0);
    filter: none;
  }

  74% {
    opacity: 0.9;
    transform: translate(-1px, 0);
    filter: drop-shadow(2px 0 #06b6d4);
  }

  75% {
    opacity: 0.5;
    transform: translate(2px, -1px);
    filter: drop-shadow(-3px 0 #7c3aed);
  }

  76% {
    opacity: 0.15;
    transform: translate(-1px, 1px) skewX(-8deg);
    filter: drop-shadow(3px 0 #06b6d4);
  }

  77% {
    opacity: 0.8;
    transform: translate(2px, 0) skewX(5deg);
    filter: drop-shadow(-2px 0 #7c3aed);
  }

  78% {
    opacity: 0.25;
    transform: translate(-2px, 0);
    filter: drop-shadow(3px 0 #06b6d4);
  }

  79% {
    opacity: 1;
    transform: translate(0);
    filter: none;
  }

  80% {
    opacity: 0.7;
    transform: translate(1px, 0);
    filter: drop-shadow(-2px 0 #7c3aed);
  }

  81% {
    opacity: 1;
    transform: translate(0);
    filter: none;
  }
}
/* PAULIX Send Button */
#send {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: white;

  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);

  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

#send:hover {
  transform: translateY(-2px);

  box-shadow:
    0 6px 18px rgba(124, 58, 237, 0.35),
    0 0 10px rgba(6, 182, 212, 0.2);

  filter: brightness(1.08);
}

#send:active {
  transform: scale(0.95);

  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

#main-content {
  position: relative;
}

@media (max-width: 700px) {

  body {
    padding: 10px;
    padding-left: 10px;
  }

  #sidebar {
    width: 250px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main-content {
    width: 100%;
    height: calc(100vh - 20px);
  }

  #menu-button {
    display: block;
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 5;
  }

  .app-header {
    padding-left: 45px;
  }

  #chat {
    padding: 10px 5px;
  }

  .user-message,
  .ai-message {
    max-width: 85%;
  }

  .chat-controls {
    padding: 8px 0;
  }

  .button-row {
    gap: 8px;
  }

 #send,
#stop,
#clear {
  flex: 1;
}
}
#welcome-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  text-align: center;

  opacity: 0.9;
}

.welcome-logo {
  font-size: 34px;
  margin-bottom: 8px;

  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#welcome-screen h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 1px;
}

/* .welcome-x {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
} */

.welcome-x {
  font-size: 36px !important;
  font-weight: 900;
  display: inline-block;
  line-height: 1;

  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;

  animation: paulixGlitch 5s infinite;
}

#welcome-screen p {
  margin: 6px 0 18px;
  opacity: 0.6;
}

#welcome-screen span:last-child {
  font-size: 14px;
  opacity: 0.45;
}

/* PAULIX Chat Bubbles */

.user-message,
.ai-message {
  max-width: 75%;
  padding: 12px 16px;
  margin: 10px 0;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;

  transition: transform 0.2s ease;
}

/* User messages */
.user-message {
  margin-left: auto;

  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: white;

  border-bottom-right-radius: 5px;

  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

/* PAULIX messages */
.ai-message {
  margin-right: auto;

  background: rgba(255, 255, 255, 0.8);
  color: #222;

  border-bottom-left-radius: 5px;

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Small hover effect */
.user-message:hover,
.ai-message:hover {
  transform: translateY(-1px);
}
.ai-message p {
  margin: 0 0 8px;
}

.ai-message p:last-child {
  margin-bottom: 0;
}

.ai-message ul,
.ai-message ol {
  margin: 8px 0;
  padding-left: 22px;
}

.ai-message li {
  margin-bottom: 4px;
}

.ai-message strong {
  font-weight: 700;
}

.ai-message code {
  background: rgba(124, 58, 237, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: monospace;
}

.ai-message pre {
  background: #1e1e1e;
  color: white;
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 10px 0;
}

.ai-message pre code {
  background: none;
  padding: 0;
}
/* PAULIX Message Animation */

.ai-message {
  animation: messageAppear 0.25s ease-out;
}

.user-message {
  animation: messageAppear 0.2s ease-out;
}

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

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

/* PAULIX Chat Input */

#message {
  width: 100%;
  box-sizing: border-box;

  padding: 13px 16px;

  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 14px;

  background: rgba(255, 255, 255, 0.85);

  outline: none;

  font-size: 15px;
  color: #222;

  transition:
    border 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

#message::placeholder {
  color: #999;
}

#message:focus {
  border-color: rgba(124, 58, 237, 0.5);

  background: white;

  box-shadow:
    0 0 0 3px rgba(124, 58, 237, 0.08);
}
/* PAULIX Clear Button */

#clear {
  background: rgba(0, 0, 0, 0.04);
  color: #555;

  border: 1px solid rgba(0, 0, 0, 0.08);

  transition:
    transform 0.15s ease,
    background 0.2s ease,
    color 0.2s ease;
}

#clear:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;

  transform: translateY(-2px);
}

#clear:active {
  transform: scale(0.95);
}

/* PAULIX Sidebar Polish */

#sidebar {
  background: rgba(255, 255, 255, 0.92);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  border-right: 1px solid rgba(124, 58, 237, 0.08);
}

.sidebar-header h2 {
  letter-spacing: 1px;
}

#new-chat {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: white;

  border: none;
  border-radius: 12px;

 transition:
  opacity 0.06s ease,
  transform 0.06s ease;
}

#new-chat:hover {
  transform: translateY(-2px);

  box-shadow:
    0 5px 15px rgba(124, 58, 237, 0.25);
}

#new-chat:active {
  transform: scale(0.97);
}

#clear-history {
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

#clear-history:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
}
/* Smooth typing → response transition */

.typing-bubble {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}

.typing-bubble.typing-hide {
  opacity: 0;
  transform: translateY(-4px);
}

.ai-message-enter {
  opacity: 0;
  transform: translateY(4px);
  animation: aiResponseEnter 0.1s ease forwards;
}

@keyframes aiResponseEnter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* History Delete Button */

.history-item {
  position: relative;
/* z-index: 1; */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.history-item:has(.chat-menu) {
  z-index: 1000;
}

.history-title-text {
  flex: 1;
  min-width: 0;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-menu {
  flex-shrink: 0;

  border: none;
  background: transparent;

  color: #999;
  font-size: 18px;
  line-height: 1;

  padding: 2px 5px;

  border-radius: 6px;
  cursor: pointer;

  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.history-menu:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
}

.chat-menu {
  position: absolute;
  right: 0;
  top: 32px;

  z-index: 1000;

  display: flex;
  flex-direction: column;

  width: 125px;
  padding: 6px;

  background: white;
  border: 1px solid rgba(124, 58, 237, 0.12);
  border-radius: 11px;

  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);

  animation: menuAppear 0.15s ease-out;
}

.chat-menu button {
  display: block;
  width: 100%;

  padding: 9px 10px;

  border: none;
  border-radius: 7px;

  background: transparent;
  color: #333 !important;

  text-align: left;
  font-size: 14px;

  cursor: pointer;
}

.chat-menu button:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed !important;
}

.chat-menu .delete-chat {
  opacity: 1;
  visibility: visible;
}

.chat-menu .delete-chat:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444 !important;
}

@keyframes menuAppear {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
  }

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

.rename-box {
  margin-top: 8px;
  padding: 8px;

  background: white;
  border: 1px solid rgba(124, 58, 237, 0.12);
  border-radius: 10px;

  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);

  animation: renameAppear 0.15s ease-out;
}

.rename-input {
  width: 100%;
  box-sizing: border-box;

  padding: 8px 9px;

  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 7px;

  outline: none;

  font-size: 13px;
  color: #333;

  background: #fafafa;
}

.rename-input:focus {
  border-color: rgba(124, 58, 237, 0.45);
  background: white;

  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.08);
}

.rename-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;

  margin-top: 7px;
}

.rename-actions button {
  padding: 6px 9px;

  border: none;
  border-radius: 6px;

  font-size: 12px;
  cursor: pointer;

  transition:
    transform 0.15s ease,
    background 0.2s ease;
}

.rename-cancel {
  background: rgba(0, 0, 0, 0.05);
  color: #555;
}

.rename-cancel:hover {
  background: rgba(0, 0, 0, 0.09);
}

.rename-save {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: white;
}

.rename-save:hover {
  transform: translateY(-1px);
}

.rename-actions button:active {
  transform: scale(0.95);
}

@keyframes renameAppear {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.theme-toggle {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 20;
}

#theme-toggle-button {
  position: relative;

  width: 68px;
  height: 36px;

  padding: 4px;

  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: 20px;

  background: rgba(255, 255, 255, 0.95);

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: space-between;

  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.15);

  transition:
    background 0.3s ease,
    border 0.3s ease,
    box-shadow 0.3s ease,
    transform 0.15s ease;
}

#theme-toggle-button span {
  width: 28px;
  height: 28px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  font-size: 16px;

  transition:
    transform 0.3s ease,
    opacity 0.3s ease,
    background 0.3s ease,
    box-shadow 0.3s ease;
}

/* Light mode */

#theme-toggle-button .sun {
  background: #ffffff;

  opacity: 1;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.18);
}

#theme-toggle-button .moon {
  opacity: 0.35;
}

/* Hover */

#theme-toggle-button:hover {
  transform: translateY(-1px);

  box-shadow:
    0 6px 18px rgba(124, 58, 237, 0.25);
}

#theme-toggle-button:active {
  transform: scale(0.94);
}

/* PAULIX DARK MODE */

body.dark-mode {
  background: #101014 !important;
  color: #eeeeee;
  transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode #main-content {
  color: #eeeeee;
}

body.dark-mode .app-header h1,
body.dark-mode .app-header p {
  color: #eeeeee;
}

body.dark-mode #sidebar {
  background: #18181d !important;
  border-right-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .sidebar-header h2 {
  color: #eeeeee;
}

body.dark-mode .history-title {
  color: #999999;
}

body.dark-mode .history-item {
  color: #dddddd;
}

body.dark-mode .history-menu {
  color: #aaaaaa;
}

body.dark-mode #chat {
  color: #eeeeee;
}

body.dark-mode .ai-message {
  background: #222228 !important;
  color: #eeeeee !important;
}

body.dark-mode #message {
  background: #222228 !important;
  color: #eeeeee !important;
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode #message::placeholder {
  color: #888888;
}

body.dark-mode #message:focus {
  background: #28282f !important;
}

body.dark-mode #clear {
  background: #24242a !important;
  color: #dddddd !important;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode #clear:hover {
  background: rgba(124, 58, 237, 0.2) !important;
  color: #b69cff !important;
}

body.dark-mode .chat-menu {
  background: #222228 !important;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .chat-menu button {
  color: #eeeeee !important;
}

body.dark-mode .chat-menu button:hover {
  background: rgba(124, 58, 237, 0.15);
}

body.dark-mode .rename-box {
  background: #222228 !important;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .rename-input {
  background: #18181d !important;
  color: #eeeeee !important;
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .rename-input:focus {
  background: #202027 !important;
}

body.dark-mode #welcome-screen {
  color: #eeeeee;
}

body.dark-mode #welcome-screen p,
body.dark-mode #welcome-screen span {
  color: #cccccc;
}

#theme-toggle-button .sun,
#theme-toggle-button .moon {
  position: relative;
  z-index: 2;
}

body.dark-mode #theme-toggle-button .moon {
  transform: translateX(0);
}

body:not(.dark-mode) #theme-toggle-button .sun {
  transform: translateX(0);
}

body.dark-mode #theme-toggle-button .sun {
  transform: translateX(0);
}

body:not(.dark-mode) #theme-toggle-button .moon {
  transform: translateX(0);
}
/* Dark mode toggle */

body.dark-mode #theme-toggle-button {
  background: #25252d !important;
  border-color: rgba(255, 255, 255, 0.2) !important;

  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.5);
}

body.dark-mode #theme-toggle-button .sun {
  opacity: 0.35;

  background: transparent !important;

  box-shadow: none !important;
}

body.dark-mode #theme-toggle-button .moon {
  opacity: 1;

  background: #44444f !important;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Smooth theme slider */

#theme-toggle-button {
  position: relative;
  overflow: hidden;
}

#theme-toggle-button .toggle-slider {
  position: absolute;

  top: 4px;
  left: 4px;

  width: 28px;
  height: 28px;

  border-radius: 50%;

  background: white;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.18);

  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.3s ease,
    box-shadow 0.3s ease;

  z-index: 1;
}

/* Light mode */

#theme-toggle-button .sun,
#theme-toggle-button .moon {
  position: relative;
  z-index: 2;
}

/* Dark mode */

body.dark-mode #theme-toggle-button .toggle-slider {
  transform: translateX(32px);

  background: #44444f;

  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Smooth theme transition */

body,
#sidebar,
#main-content,
.app-header,
#chat,
.chat-controls,
#message,
.ai-message,
#clear,
.chat-menu,
.rename-box,
.rename-input,
#theme-toggle-button {
  transition:
    background 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

/* Dark mode readability */

body.dark-mode #chat {
  background: #101014;
}

body.dark-mode .ai-message {
  background: #25252d !important;
  color: #ffffff !important;
}

body.dark-mode .ai-message p,
body.dark-mode .ai-message li,
body.dark-mode .ai-message strong {
  color: #ffffff !important;
}

body.dark-mode .ai-message code {
  color: #eeeeee;
  background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .ai-message pre {
  background: #18181d;
  color: #ffffff;
}

body.dark-mode .history-title {
  color: #aaaaaa !important;
}

body.dark-mode #clear-history {
  color: #eeeeee !important;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode #clear-history:hover {
  background: rgba(124, 58, 237, 0.2);
  color: #ffffff !important;
}

/* Final Dark Mode Polish */

/* Main header */
body.dark-mode .app-header p {
  color: #a8a8b3 !important;
}

/* Sidebar */
body.dark-mode #new-chat {
  box-shadow:
    0 4px 14px rgba(124, 58, 237, 0.25);
}

body.dark-mode #clear-history {
  background: #24242b !important;
  color: #eeeeee !important;
}

body.dark-mode #clear-history:hover {
  background: rgba(124, 58, 237, 0.2) !important;
}

/* History items */
body.dark-mode .history-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .history-item.active {
  background: rgba(124, 58, 237, 0.16);
}

/* History menu button */
body.dark-mode .history-menu:hover {
  background: rgba(124, 58, 237, 0.18);
  color: #b69cff;
}

/* Input */
body.dark-mode #message {
  background: #1c1c22 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.14);
}

body.dark-mode #message:focus {
  background: #222229 !important;
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow:
    0 0 0 3px rgba(124, 58, 237, 0.12);
}

/* Clear button */
body.dark-mode #clear {
  background: #24242b !important;
  color: #eeeeee !important;
}

body.dark-mode #clear:hover {
  background: rgba(124, 58, 237, 0.18) !important;
  color: #ffffff !important;
}

/* Welcome screen */
body.dark-mode #welcome-screen {
  opacity: 0.95;
}

body.dark-mode #welcome-screen p {
  color: #b5b5bf !important;
}

body.dark-mode #welcome-screen span:last-child {
  color: #9999a5 !important;
}

/* Typing indicator */
body.dark-mode .typing-bubble span {
  background: #bbbbc5;
}

/* Markdown */
body.dark-mode .ai-message a {
  color: #a78bfa;
}

body.dark-mode .ai-message blockquote {
  color: #cccccc;
  border-left-color: #55555f;
}

body.dark-mode .ai-message hr {
  border-color: rgba(255, 255, 255, 0.1);
}

/* Mobile menu button */
body.dark-mode #menu-button {
  color: #eeeeee;
  background: #24242b;
}

.recent-title {
  margin: 14px 8px 6px;

  font-size: 11px;
  font-weight: 700;

  letter-spacing: 1px;
  text-transform: uppercase;

  color: #888;
}

body.dark-mode .recent-title {
  color: #9999a5;
}
.older-title {
  margin: 18px 8px 6px;

  font-size: 11px;
  font-weight: 700;

  letter-spacing: 1px;
  text-transform: uppercase;

  color: #888;
}

body.dark-mode .older-title {
  color: #9999a5;
}
#view-more-recent,
#view-more-older {
  display: none;

  width: 100%;
  margin-top: 5px;
  padding: 8px;

  border: none;
  border-radius: 8px;

  background: transparent;
  color: #777;

  font-size: 12px;
  text-align: left;

  cursor: pointer;

  transition:
    background 0.2s ease,
    color 0.2s ease;
}

#view-more-recent:hover,
#view-more-older:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
}

/* Dark mode */

body.dark-mode #view-more-recent,
body.dark-mode #view-more-older {
  color: #aaa;
}

body.dark-mode #view-more-recent:hover,
body.dark-mode #view-more-older:hover {
  background: rgba(124, 58, 237, 0.15);
  color: #b69cff;
}

/* #chat {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.45) transparent;
} */

/* Chrome / Edge / Safari */

#chat::-webkit-scrollbar {
  width: 7px;
}

#chat::-webkit-scrollbar-track {
  background: transparent;
}

#chat::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    #7c3aed,
    #06b6d4
  );

  border-radius: 10px;
}

#chat::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    #6d28d9,
    #0891b2
  );
}

/* #sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.4) transparent;
} */

#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    #7c3aed,
    #06b6d4
  );

  border-radius: 10px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    #6d28d9,
    #0891b2
  );
}

/* #sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.4) transparent;
} */

#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    #7c3aed,
    #06b6d4
  );

  border-radius: 10px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    #6d28d9,
    #0891b2
  );
}

.delete-box {
  margin-top: 8px;
  padding: 10px;

  background: white;
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: 10px;

  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.08);

  animation: deleteAppear 0.15s ease-out;
}

.delete-message {
  margin: 0 0 9px;

  color: #444;
  font-size: 12px;
  line-height: 1.4;
}

.delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.delete-actions button {
  padding: 6px 9px;

  border: none;
  border-radius: 6px;

  font-size: 12px;
  cursor: pointer;

  transition:
    transform 0.15s ease,
    background 0.2s ease;
}

.delete-cancel {
  background: rgba(0, 0, 0, 0.05);
  color: #555;
}

.delete-cancel:hover {
  background: rgba(0, 0, 0, 0.09);
}

.delete-confirm {
  background: #ef4444;
  color: white;
}

.delete-confirm:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.delete-actions button:active {
  transform: scale(0.95);
}

@keyframes deleteAppear {

  from {
    opacity: 0;
    transform: translateY(-4px);
  }

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

}

/* Dark mode */

body.dark-mode .delete-box {
  background: #222228;
  border-color: rgba(239, 68, 68, 0.2);
}

body.dark-mode .delete-message {
  color: #eeeeee;
}

body.dark-mode .delete-cancel {
  background: rgba(255, 255, 255, 0.07);
  color: #ddd;
}

body.dark-mode .delete-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ai-message-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;

  width: fit-content;
  max-width: 100%;
  min-width: 0;

  margin: 10px 0;
  box-sizing: border-box;
}

.ai-message-wrapper .ai-message {
  width: fit-content;
  max-width: 100%;
  min-width: 0;

  margin: 0;
  box-sizing: border-box;

  overflow-wrap: anywhere;
  word-break: break-word;
}

.copy-message {
  margin-top: 5px;
  padding: 5px 9px;

  border: none;
  border-radius: 8px;

  background: rgba(0, 0, 0, 0.04);
  color: #777;

  font-size: 11px;
  cursor: pointer;

  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease;
}

.copy-message:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
}

.copy-message:active {
  transform: scale(0.95);
}

/* Dark mode */

body.dark-mode .copy-message {
  background: rgba(255, 255, 255, 0.06);
  color: #aaa;
}

body.dark-mode .copy-message:hover {
  background: rgba(124, 58, 237, 0.15);
  color: #c4b5fd;
}

.copy-message:disabled {
  opacity: 0.45;
  cursor: default;
}

.copy-message:disabled:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #777;
  transform: none;
}

body.dark-mode .copy-message:disabled:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #aaa;
}
.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.message-action {
  padding: 5px 9px;

  border: none;
  border-radius: 8px;

  background: rgba(0, 0, 0, 0.04);
  color: #777;

  font-size: 11px;
  cursor: pointer;

  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease;
}

.message-action:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
}

.message-action:active {
  transform: scale(0.95);
}

body.dark-mode .message-action {
  background: rgba(255, 255, 255, 0.06);
  color: #aaa;
}

body.dark-mode .message-action:hover {
  background: rgba(124, 58, 237, 0.15);
  color: #c4b5fd;
}

#send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}

.error-message {
  color: #b91c1c;
}

.error-message small {
  opacity: 0.75;
}

body.dark-mode .error-message {
  color: #fca5a5;
}

/* Stop button */
#stop {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.15);

  transition:
    transform 0.15s ease,
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

#stop:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(239, 68, 68, 0.12);
}

#stop:active:not(:disabled) {
  transform: scale(0.95);
}

#stop:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Dark mode */
body.dark-mode #stop {
  background: rgba(248, 113, 113, 0.08);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.15);
}

body.dark-mode #stop:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
}
#stop {
  min-width: 100px;
}
#stop {
  width: 80px;
  height: 42px;
  border-radius: 10px;
}

/* ========================================= */
/* PAULIX CHATGPT-STYLE COMPOSER + MESSAGES */
/* ========================================= */

/* Give the chat a little more room */
#main-content {
  height: calc(100vh - 25px);
}

/* Wider AI responses */
/* .ai-message-wrapper {
  width: fit-content;
  max-width: 82%;
}

.ai-message-wrapper .ai-message {
  width: fit-content;
  max-width: 100%;
} */

/* .ai-message {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-message-wrapper .ai-message {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
} */

/* User messages stay compact */
.user-message {
  max-width: 70%;
}

/* Tables should use the available response width */
.ai-message table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.ai-message th,
.ai-message td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.ai-message th {
  font-weight: 700;
  background: rgba(124, 58, 237, 0.06);
}

body.dark-mode .ai-message th,
body.dark-mode .ai-message td {
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .ai-message th {
  background: rgba(124, 58, 237, 0.12);
}


/* ================= */
/* CHAT COMPOSER */
/* ================= */

.chat-controls {
  position: relative;

  width: 100%;
  max-width: 900px;

  margin: 0 auto;
  padding: 8px 0 4px;

  box-sizing: border-box;

  transition:
    transform 0.2s ease,
    padding 0.2s ease;
}

/* Main input bar */
#message {
  width: 100%;
  height: 48px;

  box-sizing: border-box;

  padding: 0 112px 0 18px;

  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 26px;

  background: rgba(255, 255, 255, 0.94);

  font-size: 14px;

  outline: none;

  box-shadow:
    0 4px 18px rgba(0, 0, 0, 0.06);

  transition:
    height 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

/* Slightly bigger when using it */
.chat-controls:hover #message,
#message:focus {
  height: 56px;

  border-color: rgba(124, 58, 237, 0.35);

  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.09),
    0 0 0 3px rgba(124, 58, 237, 0.06);
}

/* Buttons live INSIDE the composer */
.button-row {
  position: absolute;

  right: 9px;
  top: 50%;

  transform: translateY(-50%);

  display: flex;
  align-items: center;

  gap: 5px;

  margin: 0;
}

/* Send / Stop / Clear */
#send,
#stop,
#clear {
  width: 34px;
  height: 34px;

  min-width: 34px;

  padding: 0;

  border-radius: 12px;

  border: none;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 14px;

  cursor: pointer;

  transition:
    transform 0.15s ease,
    background 0.2s ease,
    opacity 0.2s ease,
    box-shadow 0.2s ease;
}

/* Send */
#send {
  background: linear-gradient(
    135deg,
    #7c3aed,
    #06b6d4
  );

  color: white;

  box-shadow:
    0 3px 10px rgba(124, 58, 237, 0.22);
}

/* Stop uses the SAME shape */
/* #stop {
  background: #25252d;
  color: white;
} */

/* Clear */
#clear {
  background: rgba(0, 0, 0, 0.06);
  color: #555;
}

/* Button hover */
#send:hover,
#stop:hover,
#clear:hover {
  transform: translateY(-1px);
}

/* Button press */
#send:active,
#stop:active,
#clear:active {
  transform: scale(0.92);
}

/* Disabled Stop */
/* #stop:disabled {
  display: none;
} */


/* ================= */
/* DARK MODE */
/* ================= */

body.dark-mode #message {
  background: #1c1c22 !important;
  color: #ffffff !important;

  border-color: rgba(255, 255, 255, 0.12);

  box-shadow:
    0 4px 18px rgba(0, 0, 0, 0.25);
}

body.dark-mode .chat-controls:hover #message,
body.dark-mode #message:focus {
  background: #222229 !important;

  border-color: rgba(124, 58, 237, 0.45);

  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.3),
    0 0 0 3px rgba(124, 58, 237, 0.10);
}

body.dark-mode #clear {
  background: rgba(255, 255, 255, 0.08);
  color: #ddd;
}


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

@media (max-width: 600px) {

  #chat {
    padding: 12px 7px;
  }

  /* .ai-message-wrapper {
  width: fit-content;
  max-width: 82%;
} */

 
.ai-message {
  overflow-wrap: anywhere;
  word-break: break-word;
}

  .user-message {
    max-width: 82%;
  }
  .chat-controls {
    width: 100%;
    padding: 6px 0 2px;
  }

  #message {
    height: 46px;

    padding-left: 16px;
    padding-right: 108px;

    border-radius: 24px;
  }

  .chat-controls:hover #message,
  #message:focus {
    height: 54px;
  }

  .button-row {
    right: 7px;
  }

  #send,
  #clear {
    width: 32px;
    height: 32px;
    min-width: 32px;

    border-radius: 11px;
  }

  /* Tables get their own horizontal scroll */
  .ai-message table {
    max-width: 100%;
    overflow-x: auto;
  }
}

#chat {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.ai-message pre {
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}

.ai-message table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}

.ai-message code {
  overflow-wrap: anywhere;
}

/* =========================================
   PAULIX FIRST-TIME SETUP
========================================= */

#setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(5, 8, 18, 0.72);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  opacity: 1;
  visibility: visible;

  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

#setup-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.setup-card {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);

  box-sizing: border-box;

  /* overflow-y: auto; */
  overflow-x: hidden;
  overflow: hidden;

  padding: 30px;
  border-radius: 26px;

  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.98),
      rgba(245, 243, 252, 0.98)
    );

  border: 1px solid rgba(255, 255, 255, 0.7);

  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.25),
    0 0 40px rgba(100, 80, 255, 0.12);

  text-align: center;

  transform: translateY(0) scale(1);
  animation: setupCardIn 0.7s ease;

  scrollbar-gutter: stable;
}

body.dark-mode .setup-card {
  background:
    linear-gradient(
      145deg,
      rgba(30, 35, 55, 0.96),
      rgba(12, 16, 30, 0.98)
    );

  border: 1px solid rgba(255, 255, 255, 0.1);

  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 50px rgba(130, 90, 255, 0.12);
}

@keyframes setupCardIn {
  from {
    opacity: 0;
    transform: translateY(25px) scale(0.96);
  }

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


/* =========================================
   LIVING PAULIX ORB
========================================= */

.setup-orb {
  position: relative;

  width: 92px;
  height: 92px;

  margin: 0 auto 18px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-core {
  width: 58px;
  height: 58px;

  border-radius: 50%;

  background:
    radial-gradient(
      circle at 35% 30%,
      #ffffff,
      #bba7ff 22%,
      #735cff 52%,
      #34218f 100%
    );

  box-shadow:
    0 0 18px rgba(140, 110, 255, 0.9),
    0 0 45px rgba(110, 80, 255, 0.65),
    0 0 85px rgba(110, 80, 255, 0.35);

  animation: orbPulse 2.4s ease-in-out infinite;
}

@keyframes orbPulse {
  0%,
  100% {
    transform: scale(0.94);
    box-shadow:
      0 0 18px rgba(140, 110, 255, 0.9),
      0 0 45px rgba(110, 80, 255, 0.65),
      0 0 85px rgba(110, 80, 255, 0.35);
  }

  50% {
    transform: scale(1.08);
    box-shadow:
      0 0 25px rgba(170, 145, 255, 1),
      0 0 60px rgba(120, 90, 255, 0.8),
      0 0 105px rgba(110, 80, 255, 0.45);
  }
}

.orb-ring {
  position: absolute;

  border: 1px solid rgba(150, 125, 255, 0.4);

  border-radius: 50%;

  pointer-events: none;
}

.orb-ring-one {
  width: 76px;
  height: 76px;

  animation: orbRotate 5s linear infinite;
}

.orb-ring-two {
  width: 92px;
  height: 92px;

  border-style: dashed;
  opacity: 0.45;

  animation: orbRotateReverse 8s linear infinite;
}

@keyframes orbRotate {
  from {
    transform: rotate(0deg) scaleX(1);
  }

  to {
    transform: rotate(360deg) scaleX(1);
  }
}

@keyframes orbRotateReverse {
  from {
    transform: rotate(360deg) scaleX(0.72);
  }

  to {
    transform: rotate(0deg) scaleX(0.72);
  }
}


/* =========================================
   SETUP TEXT
========================================= */

.setup-brand {
  font-size: 13px;
  font-weight: 700;

  letter-spacing: 2px;

  opacity: 0.75;

  margin-bottom: 12px;
}

.setup-brand span {
  font-size: 17px;
}

.setup-card h2 {
  margin: 0;

  font-size: 27px;
  font-weight: 700;

  letter-spacing: -0.5px;
}

.setup-subtitle {
  margin: 9px auto 26px;

  max-width: 340px;

  font-size: 14px;
  line-height: 1.6;

  opacity: 0.65;
}


/* =========================================
   FORM
========================================= */

.setup-form {
  text-align: left;
}

.setup-form label {
  display: block;

  margin-bottom: 8px;

  font-size: 13px;
  font-weight: 600;

  opacity: 0.75;
}

#setup-name {
  width: 100%;
  height: 48px;

  padding: 0 15px;

  margin-bottom: 20px;

  box-sizing: border-box;

  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;

  outline: none;

  background: rgba(255, 255, 255, 0.055);

  color: inherit;

  font-size: 15px;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

#setup-name::placeholder {
  opacity: 0.4;
}
#setup-name:focus {
  border-color: rgba(145, 120, 255, 0.65);

  background: rgba(255, 255, 255, 0.075);

  box-shadow:
    0 0 0 3px rgba(120, 90, 255, 0.1),
    0 0 20px rgba(120, 90, 255, 0.08);
}


/* =========================================
   ADDRESS OPTIONS
========================================= */

.address-options {
  display: grid;

  grid-template-columns: repeat(3, 1fr);

  gap: 9px;

  margin-bottom: 22px;
}

.address-option {
  min-height: 67px;

  padding: 10px 5px;

  border-radius: 13px;

  border: 1px solid rgba(255, 255, 255, 0.08);

  background: rgba(255, 255, 255, 0.04);

  color: inherit;

  cursor: pointer;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 4px;

  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.address-option span {
  font-size: 18px;
}

.address-option strong {
  font-size: 12px;
}

.address-option:hover {
  transform: translateY(-2px);

  background: rgba(255, 255, 255, 0.075);

  border-color: rgba(145, 120, 255, 0.35);
}

.address-option.selected {
  border-color: rgba(145, 120, 255, 0.8);

  background: rgba(120, 90, 255, 0.15);

  box-shadow:
    0 0 18px rgba(120, 90, 255, 0.12);
}


/* =========================================
   WAKE PAULIX BUTTON
========================================= */

#finish-setup {
  width: 100%;
  height: 49px;
  margin-top: 24px;

  border: none;
  border-radius: 14px;

  background:
    linear-gradient(
      135deg,
      #755cff,
      #5a3dd5
    );

  color: white;

  font-size: 14px;
  font-weight: 700;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  box-shadow:
    0 10px 30px rgba(100, 70, 255, 0.25);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

#finish-setup span {
  font-size: 18px;

  transition: transform 0.2s ease;
}

#finish-setup:hover {
  transform: translateY(-2px);

  box-shadow:
    0 14px 35px rgba(100, 70, 255, 0.38);
}

#finish-setup:hover span {
  transform: translateX(4px);
}

#finish-setup:active {
  transform: translateY(0);
}


/* =========================================
   USER AVATAR
========================================= */

.user-avatar {
  position: absolute;

  left: 20px;
  top: 18px;

  width: 40px;
  height: 40px;

  border-radius: 50%;

  border: 1px solid rgba(255, 255, 255, 0.14);

  background:
    linear-gradient(
      135deg,
      rgba(120, 90, 255, 0.9),
      rgba(80, 60, 190, 0.9)
    );

  color: white;

  font-size: 14px;
  font-weight: 700;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow:
    0 5px 20px rgba(80, 60, 200, 0.25);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;

  z-index: 10;
}

.user-avatar:hover {
  transform: scale(1.06);

  box-shadow:
    0 7px 25px rgba(100, 75, 240, 0.4);
}


/* =========================================
   SETUP FOOTER
========================================= */

.setup-note {
  margin: 19px 0 0;

  font-size: 11px;

  opacity: 0.4;
}


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

@media (max-width: 600px) {

  .setup-card {
    padding: 30px 22px 23px;

    border-radius: 24px;
  }

  .setup-card h2 {
    font-size: 24px;
  }

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

  .setup-orb {
    transform: scale(0.9);

    margin-bottom: 10px;
  }

 .user-avatar {
  left: 68px;
  top: 19px;

  width: 36px;
  height: 36px;
}

@media (max-width: 600px) {

  #sidebar.open ~ #main-content .user-avatar {
    opacity: 0;
    pointer-events: none;
  }

}

  .address-options {
    gap: 6px;
  }

  .address-option {
    min-height: 62px;
  }
}

/* =========================================
   PAULIX USER PROFILE SETTINGS
========================================= */

#profile-overlay {
  position: fixed;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(5, 8, 20, 0.38);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;

  z-index: 2000;
}


/* OPEN STATE */

#profile-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#setup-overlay,
#profile-overlay {
  box-sizing: border-box;
  overflow: hidden;
}
/* PROFILE CARD */

#profile-card {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);

  box-sizing: border-box;

  /* overflow-y: auto; */
  overflow-x: hidden;
  overflow: hidden;

  padding: 30px;
  border-radius: 26px;

  background: rgba(255, 255, 255, 0.96);

  border: 1px solid rgba(255, 255, 255, 0.7);

  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.25),
    0 0 40px rgba(100, 80, 255, 0.12);

  transform: translateY(15px) scale(0.97);
  transition: transform 0.25s ease;

  scrollbar-gutter: stable;
}


/* CARD ANIMATION */

#profile-overlay.open #profile-card {
  transform: translateY(0) scale(1);
}


/* CLOSE BUTTON */

/* CLOSE BUTTON */

#close-profile {
  position: absolute;

  top: 24px;
  right: 24px;

  width: 34px;
  height: 34px;

  border: none;
  border-radius: 50%;

  background: rgba(0, 0, 0, 0.06);

  font-size: 21px;
  line-height: 1;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

#close-profile:hover {
  background: rgba(0, 0, 0, 0.12);

  transform: rotate(90deg);
}


/* LARGE PROFILE AVATAR */

.profile-avatar-large {
  width: 72px;
  height: 72px;

  margin: 5px auto 18px;

  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    linear-gradient(
      135deg,
      rgba(120, 90, 255, 0.95),
      rgba(80, 60, 190, 0.95)
    );

  color: white;

  font-size: 22px;
  font-weight: 700;

  box-shadow:
    0 10px 30px rgba(90, 70, 220, 0.28);
}


/* TITLE */

#profile-card h2 {
  margin: 0;

  text-align: center;

  font-size: 24px;
}

.profile-subtitle {
  margin: 8px 0 25px;

  text-align: center;

  font-size: 14px;

  opacity: 0.65;
}


/* FORM */

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-form label {
  margin-top: 8px;

  font-size: 13px;
  font-weight: 600;

  opacity: 0.75;
}


/* NAME INPUT */

#profile-name {
  width: 100%;

  padding: 13px 15px;

  border-radius: 12px;

  border: 1px solid rgba(0, 0, 0, 0.12);

  background: rgba(0, 0, 0, 0.035);

  outline: none;

  font-size: 15px;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

#profile-name:focus {
  border-color: rgba(100, 80, 240, 0.65);

  box-shadow:
    0 0 0 3px rgba(100, 80, 240, 0.10);
}


/* ADDRESS + PERSONALITY OPTIONS */

.profile-address-options,
.personality-options {
  display: grid;

  grid-template-columns: repeat(3, 1fr);

  gap: 8px;
}

.personality-options {
  grid-template-columns: repeat(2, 1fr);
}


/* OPTION BUTTONS */

.profile-address-option,
.personality-option {
  min-height: 58px;

  padding: 10px;

  border-radius: 13px;

  border: 1px solid rgba(0, 0, 0, 0.10);

  background: rgba(0, 0, 0, 0.025);

  cursor: pointer;

  font-size: 14px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 6px;

  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.profile-address-option:hover,
.personality-option:hover {
  transform: translateY(-2px);

  border-color: rgba(100, 80, 240, 0.45);
}


/* SELECTED OPTION */

.profile-address-option.selected,
.personality-option.selected {
  border-color: rgba(100, 80, 240, 0.8);

  background: rgba(100, 80, 240, 0.10);

  box-shadow:
    0 0 0 2px rgba(100, 80, 240, 0.08);
}


/* ACTION BUTTONS */

.profile-actions {
  display: flex;

  gap: 10px;

  margin-top: 20px;
}

#discard-profile,
#save-profile {
  flex: 1;

  padding: 13px 15px;

  border-radius: 12px;
  cursor: pointer;

  font-size: 14px;
  font-weight: 600;

  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

#discard-profile {
  border: 1px solid rgba(0, 0, 0, 0.12);

  background: transparent;
}

#save-profile {
  border: none;

  background:
    linear-gradient(
      135deg,
      #7564e8,
      #5746c7
    );

  color: white;

  box-shadow:
    0 7px 20px rgba(90, 70, 220, 0.25);
}

#discard-profile:hover,
#save-profile:hover {
  transform: translateY(-2px);
}

#discard-profile:active,
#save-profile:active {
  transform: translateY(0);
}


/* =========================================
   DARK MODE
========================================= */

body.dark-mode #profile-card {
  background: rgba(25, 27, 38, 0.97);

  border-color: rgba(255, 255, 255, 0.08);

  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(100, 80, 255, 0.12);
}

body.dark-mode #close-profile {
  background: rgba(255, 255, 255, 0.08);

  color: white;
}

body.dark-mode #close-profile:hover {
  background: rgba(255, 255, 255, 0.15);
}

body.dark-mode #profile-name,
body.dark-mode .profile-address-option,
body.dark-mode .personality-option {
  background: rgba(255, 255, 255, 0.045);

  border-color: rgba(255, 255, 255, 0.10);

  color: white;
}

body.dark-mode .profile-address-option.selected,
body.dark-mode .personality-option.selected {
  background: rgba(110, 90, 255, 0.15);

  border-color: rgba(130, 110, 255, 0.8);
}

body.dark-mode #discard-profile {
  color: white;

  border-color: rgba(255, 255, 255, 0.12);
}


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

@media (max-width: 600px) {

  #profile-overlay {
    padding: 12px;
  }

  #profile-card {
    width: 100%;

    max-height: calc(100vh - 24px);

    padding: 24px 18px;

    border-radius: 22px;
  }

  .profile-avatar-large {
    width: 64px;
    height: 64px;

    font-size: 20px;
  }

  #profile-card h2 {
    font-size: 22px;
  }

  .profile-address-options {
    grid-template-columns: repeat(3, 1fr);
  }

  .personality-options {
    grid-template-columns: repeat(2, 1fr);
  }
#close-profile {
  top: 20px;
  right: 20px;
}

  .profile-actions {
    margin-top: 16px;
  }

}
/* =========================================
   PAULIX CUSTOM SCROLLBAR
========================================= */

/* Chrome, Edge, Safari */

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 80, 220, 0.35);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 80, 220, 0.65);
  border: 1px solid transparent;
  background-clip: padding-box;
}


/* Firefox */

/* * {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 80, 220, 0.45) transparent;
} */


/* =========================================
   DARK MODE SCROLLBAR
========================================= */

body.dark-mode ::-webkit-scrollbar-thumb {
  background: rgba(135, 115, 255, 0.45);
  border: 2px solid transparent;
  background-clip: padding-box;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 130, 255, 0.75);
  border: 1px solid transparent;
  background-clip: padding-box;
}

body.dark-mode * {
  scrollbar-color: rgba(135, 115, 255, 0.5) transparent;
}
/* =========================================
   PAULIX FUTURISTIC SCROLLBAR SYSTEM
   ========================================= */

/* Firefox */
/* * {
  scrollbar-width: thin;
  scrollbar-color: rgba(145, 145, 255, 0.65) transparent;
} */

/* Chrome / Edge / Brave / other WebKit browsers */
*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: transparent;
  border: 0;
}

/* =========================================
   FORCE SCROLLBAR ARROWS COMPLETELY OFF
   ========================================= */

*::-webkit-scrollbar-button,
*::-webkit-scrollbar-button:single-button,
*::-webkit-scrollbar-button:vertical,
*::-webkit-scrollbar-button:horizontal,
*::-webkit-scrollbar-button:start,
*::-webkit-scrollbar-button:end,
*::-webkit-scrollbar-button:vertical:start,
*::-webkit-scrollbar-button:vertical:end,
*::-webkit-scrollbar-button:horizontal:start,
*::-webkit-scrollbar-button:horizontal:end,
*::-webkit-scrollbar-button:vertical:start:decrement,
*::-webkit-scrollbar-button:vertical:end:increment,
*::-webkit-scrollbar-button:horizontal:start:decrement,
*::-webkit-scrollbar-button:horizontal:end:increment {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 0 !important;
  max-height: 0 !important;

  background: transparent !important;
  background-image: none !important;

  border: 0 !important;
  outline: none !important;

  -webkit-appearance: none !important;
  appearance: none !important;
}

/* =========================================
   SCROLLBAR SIZE
   ========================================= */

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: transparent;
  border: none;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

/* Futuristic scrollbar thumb */
*::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    rgba(175, 175, 255, 0.85),
    rgba(105, 105, 220, 0.55)
  );

  border-radius: 999px;
  border: none;

  box-shadow:
    0 0 7px rgba(130, 130, 255, 0.45),
    inset 0 0 3px rgba(255, 255, 255, 0.15);
}

/* Hover */
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    rgba(200, 200, 255, 0.95),
    rgba(120, 120, 235, 0.75)
  );

  box-shadow:
    0 0 12px rgba(140, 140, 255, 0.65),
    inset 0 0 4px rgba(255, 255, 255, 0.18);
}


/* =========================================
   KEEP SCROLLBAR SPACE STABLE
   ========================================= */

#chat,
#setup-overlay,
.setup-card,
#profile-overlay,
#profile-card,
#history,
.chat-history,
.sidebar {
  scrollbar-gutter: stable;
}


/* =========================================
   SETUP POPUP
   ========================================= */

#setup-overlay {
  overflow: hidden;
}

.setup-card {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}


/* =========================================
   PROFILE SETTINGS
   ========================================= */

#profile-overlay {
  overflow: hidden;
}

#profile-card {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.setup-card,
#profile-card {
  max-height: 90vh;
}


/* =========================================
   CHAT
   ========================================= */

#chat {
  overflow-y: auto;
  overflow-x: hidden;
}


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

#history,
.chat-history,
.sidebar {
  overflow-y: auto;
  overflow-x: hidden;
}

/* =========================================
   SETUP CARD SCROLL CONTAINER
   ========================================= */

.setup-card {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);

  padding: 0;
  overflow: hidden;
  box-sizing: border-box;

  border-radius: 26px;
}

.setup-scroll {
  width: calc(100% - 11px);
  max-height: calc(100vh - 56px);

  margin: 8px 3px 8px 8px;
  padding: 22px 22px 30px 22px;

  box-sizing: border-box;

  overflow-y: auto;
  overflow-x: hidden;

  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* =========================================
   PROFILE CARD SCROLL CONTAINER
   ========================================= */

#profile-card {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);

  padding: 0;
  overflow: hidden;
  box-sizing: border-box;

  border-radius: 26px;
}

.profile-scroll {
  width: calc(100% - 11px);
  max-height: calc(100vh - 56px);

  margin: 8px 3px 8px 8px;
  padding: 65px 22px 30px 22px;

  box-sizing: border-box;

  overflow-y: auto;
  overflow-x: hidden;

  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}


/* =========================================
   KEEP THE CLOSE BUTTON ABOVE THE SCROLL
   ========================================= */

#close-profile {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
}


/* =========================================
   FUTURISTIC SCROLLBAR
   ========================================= */

.setup-scroll::-webkit-scrollbar,
.profile-scroll::-webkit-scrollbar,
#chat::-webkit-scrollbar {
  width: 6px;
}


/* Track stays almost invisible */

.setup-scroll::-webkit-scrollbar-track,
.profile-scroll::-webkit-scrollbar-track,
#chat::-webkit-scrollbar-track {
  background: transparent;
}


/* Faint when not hovering */

.setup-scroll::-webkit-scrollbar-thumb,
.profile-scroll::-webkit-scrollbar-thumb,
#chat::-webkit-scrollbar-thumb {
  background: rgba(140, 140, 230, 0.18);

  border-radius: 999px;
  border: none;

  box-shadow: none;

  transition:
    background 0.25s ease,
    box-shadow 0.25s ease;
}


/* Glow appears when hovering */

.setup-scroll:hover::-webkit-scrollbar-thumb,
.profile-scroll:hover::-webkit-scrollbar-thumb,
#chat:hover::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    rgba(175, 175, 255, 0.75),
    rgba(105, 105, 220, 0.55)
  );

  box-shadow:
    0 0 8px rgba(130, 130, 255, 0.45);
}


/* Stronger when directly hovering the stick */

.setup-scroll::-webkit-scrollbar-thumb:hover,
.profile-scroll::-webkit-scrollbar-thumb:hover,
#chat::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    rgba(200, 200, 255, 0.95),
    rgba(120, 120, 235, 0.75)
  );

  box-shadow:
    0 0 12px rgba(140, 140, 255, 0.65);
}


/* No arrows */

.setup-scroll::-webkit-scrollbar-button,
.profile-scroll::-webkit-scrollbar-button,
#chat::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}


/* Transparent corner */

.setup-scroll::-webkit-scrollbar-corner,
.profile-scroll::-webkit-scrollbar-corner,
#chat::-webkit-scrollbar-corner {
  background: transparent;
}


/* =========================================
   PAULIX COMPANION BUBBLE
   ========================================= */

.companion-message-wrapper {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}

.companion-message-wrapper.companion-visible {
  opacity: 1;
  transform: translateY(0);
}

.companion-message {
  width: fit-content;
  max-width: 80%;

  margin-top: 4px;

  padding: 9px 14px;

  font-size: 13px;
  line-height: 1.45;

  border-radius: 14px;

  background:
    rgba(120, 120, 220, 0.08);

  border: 1px solid
    rgba(140, 140, 255, 0.16);

  box-shadow:
    0 0 14px
    rgba(120, 120, 255, 0.08);

  backdrop-filter: blur(8px);
}

/* =========================================
   PAULIX SUMMON / COMPOSING BUBBLE
   ========================================= */

.paulix-typing-wrapper {
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
}

.paulix-typing-wrapper.paulix-typing-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* =========================================
   PAULIX STRONGER TYPING / SUMMON ANIMATION
   ========================================= */

.paulix-typing-bubble {
  width: fit-content;
  min-width: 64px;

  padding: 12px 16px;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  border-radius: 16px;

  background: rgba(105, 105, 210, 0.14);

  border: 1px solid rgba(110, 110, 220, 0.28);

  box-shadow:
    0 0 14px rgba(105, 105, 220, 0.16),
    inset 0 0 8px rgba(255, 255, 255, 0.35);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}


.paulix-typing-dot {
  width: 6px;
  height: 6px;

  border-radius: 50%;

  background: rgba(90, 90, 205, 0.9);

  box-shadow:
    0 0 6px rgba(95, 95, 220, 0.75);

  animation:
    paulixTyping 1.2s infinite ease-in-out;
}

.paulix-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.paulix-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes paulixTyping {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
/* =========================================
   PAULIX WELCOME CONTENT — SEO & READABILITY
   ========================================= */

#welcome-screen .welcome-description {
  width: min(540px, 100%);
  margin: 14px auto 20px;
  padding: 0 12px;

  font-size: 14px;
  line-height: 1.7;
  text-align: center;

  opacity: 0.82;
}

#welcome-screen .welcome-feature-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;

  width: min(540px, 100%);
  margin: 0 auto;
  padding: 0 8px;
}

#welcome-screen .welcome-feature-list span {
  display: inline-block;

  padding: 7px 11px;
  border: 1px solid rgba(130, 130, 220, 0.24);
  border-radius: 999px;

  font-size: 12px;
  line-height: 1.4;

  background: rgba(130, 130, 220, 0.07);
  opacity: 0.9;
}

@media (max-width: 480px) {

  #welcome-screen .welcome-description {
    font-size: 13px;
    line-height: 1.65;
  }

  #welcome-screen .welcome-feature-list {
    gap: 6px;
  }

  #welcome-screen .welcome-feature-list span {
    font-size: 11px;
    padding: 6px 9px;
  }

}

/* =========================================================
   PAULIX MOBILE LAYOUT FIX — ChatGPT-style responsive shell
   Keep this block LAST so it overrides older mobile rules.
   ========================================================= */

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

  body {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding-left: 0;
    overflow: hidden;
  }

  #main-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    gap: 0;
  }

  /* Keep the top bar controls in a predictable, visible position. */
  .app-header {
    position: relative;
    flex: 0 0 auto;
    min-height: 64px;
    margin: 0;
    padding: 10px 56px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 4;
  }

  .app-header .logo {
    gap: 6px;
  }

  .app-header .logo-icon {
    font-size: 23px;
  }

  .app-header h1 {
    font-size: 21px;
    letter-spacing: 3px;
    line-height: 1.2;
  }

  .app-header p {
    margin-top: 3px;
    font-size: 11px;
  }

  #menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 10px;
    left: 10px;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    z-index: 20;
  }

  .user-avatar {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    z-index: 20;
  }

  .theme-toggle {
    position: absolute;
    top: 58px;
    right: 10px;
    z-index: 6;
    transform: scale(.85);
    transform-origin: top right;
  }

  /* The conversation is the only expanding/scrolling region. */
  #chat {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    margin: 0 8px 8px;
    padding: 14px 10px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: 18px;
  }

  #welcome-screen {
    width: 100%;
    max-width: 100%;
    margin: auto 0;
    padding: 16px 8px;
    overflow-wrap: anywhere;
  }

  #welcome-screen h2 {
    font-size: clamp(25px, 7vw, 34px);
  }

  #welcome-screen .welcome-logo {
    font-size: 38px;
  }

  #welcome-screen .welcome-description {
    max-width: 100%;
    font-size: 13px;
    line-height: 1.55;
  }

  #welcome-screen .welcome-feature-list {
    gap: 7px;
    flex-wrap: wrap;
    justify-content: center;
  }

  #welcome-screen .welcome-feature-list span {
    max-width: 100%;
    font-size: 11px;
  }

  /* Composer remains visible above the mobile browser safe area. */
  .chat-controls {
    position: relative;
    z-index: 5;
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 0;
    background: rgba(244, 246, 251, 0.96);
    backdrop-filter: blur(16px);
  }

  #message {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 13px 16px;
    font-size: 16px;
    border-radius: 24px;
    line-height: 1.4;
    margin: 0;
  }

  .button-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
  }

  #send,
  #clear {
    min-width: 42px;
    min-height: 38px;
    padding: 8px 14px;
    margin: 0;
    border-radius: 18px;
  }

  /* Drawer overlays the app instead of taking space in the layout. */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 290px);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    padding: 18px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    transition: transform .25s ease;
    z-index: 1000;
    background: rgba(250, 250, 255, .98);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .user-message,
  .ai-message {
    max-width: 92%;
    overflow-wrap: anywhere;
  }

  .ai-message pre {
    max-width: 100%;
    overflow-x: auto;
  }

  #setup-overlay,
  #profile-overlay {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* Compact phones and mobile browsers with a short visible viewport. */
@media (max-width: 380px) {
  .app-header {
    padding-left: 48px;
    padding-right: 48px;
  }

  .app-header h1 {
    font-size: 19px;
    letter-spacing: 2px;
  }

  #welcome-screen .welcome-description {
    font-size: 12px;
  }

  .chat-controls {
    padding-left: 8px;
    padding-right: 8px;
  }
}


/* =========================================================
   MOBILE POLISH v2 — tighter header, single-row composer,
   and keyboard-aware viewport sizing.
   ========================================================= */
@media (max-width: 700px) {
  body {
    height: var(--paulix-viewport-height, 100dvh);
    transition: height .18s ease-out;
  }

  #main-content {
    height: var(--paulix-viewport-height, 100dvh);
    transition: height .18s ease-out;
  }

  .app-header {
    min-height: 66px;
    padding: 8px 54px 7px;
  }

  .app-header .logo {
    gap: 5px;
  }

  .app-header .logo-icon {
    font-size: 20px;
  }

  .app-header h1 {
    font-size: 20px;
    letter-spacing: 2.5px;
  }

  .app-header p {
    font-size: 10px;
    margin: 2px 0 0;
  }

  .theme-toggle {
    top: 16px;
    right: 60px;
    transform: scale(.72);
    transform-origin: top right;
  }

  #chat {
    margin: 0 8px 6px;
    padding: 10px 9px;
  }

  #welcome-screen {
    padding: 12px 7px;
  }

  #welcome-screen .welcome-logo {
    font-size: 30px;
    margin-bottom: 8px;
  }

  #welcome-screen h2 {
    font-size: 28px;
    margin: 5px 0;
  }

  #welcome-screen > p:not(.welcome-description) {
    margin: 4px 0 12px;
    font-size: 14px;
  }

  #welcome-screen > span {
    font-size: 15px;
  }

  #welcome-screen .welcome-description {
    margin: 10px auto 14px;
    font-size: 12px;
    line-height: 1.5;
  }

  #welcome-screen .welcome-feature-list {
    gap: 6px;
  }

  #welcome-screen .welcome-feature-list span {
    padding: 6px 9px;
    font-size: 10px;
  }

  .chat-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: transparent;
    backdrop-filter: none;
  }

  #message {
    flex: 1 1 auto;
    width: 0;
    min-width: 0;
    height: 48px;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 26px;
    box-sizing: border-box;
  }

  .button-row {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
  }

  #send,
  #clear {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 50%;
  }

  #chat.keyboard-active #welcome-screen {
    margin-top: 8px;
    margin-bottom: 8px;
  }

  body.paulix-keyboard-open .app-header {
    min-height: 52px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  body.paulix-keyboard-open .app-header p,
  body.paulix-keyboard-open .theme-toggle {
    display: none;
  }

  body.paulix-keyboard-open #chat {
    margin-bottom: 2px;
  }

  body.paulix-keyboard-open #welcome-screen {
    display: none;
  }

  body.paulix-keyboard-open .chat-controls {
    padding-top: 5px;
    padding-bottom: 5px;
  }
}


/* =========================================================
   MOBILE FINISHING PASS — integrated composer, full border,
   and consistently sized header controls.
   ========================================================= */
@media (max-width: 700px) {
  *, *::before, *::after {
    box-sizing: border-box;
  }

  body,
  #main-content {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  #main-content {
    padding: 0;
  }

  /* Header controls use matching 42px touch targets. */
  #menu-button {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 14px;
  }

  .theme-toggle {
    top: 10px;
    right: 60px;
    width: 42px;
    height: 42px;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #theme-toggle-button {
    position: relative;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
  }

  /* Draw a complete inset frame without clipping its right/bottom edge. */
  #chat {
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    min-width: 0;
    margin: 0 8px 6px;
    border: 1px solid rgba(190, 190, 210, 0.82);
    border-radius: 22px;
    background-clip: padding-box;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* One continuous pill: input, send and X all stay inside it. */
  .chat-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
    border: 1px solid rgba(135, 135, 180, 0.28);
    border-radius: 30px;
    background: rgba(34, 34, 43, 0.98);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.24);
    overflow: hidden;
  }

  #message {
    flex: 1 1 0;
    width: 0;
    max-width: 100%;
    min-width: 0;
    height: 46px;
    min-height: 46px;
    margin: 0;
    padding: 0 10px 0 12px;
    border: 1px solid transparent;
    border-radius: 24px;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font-size: 16px;
    line-height: normal;
    transform: none;
  }

  #message:focus {
    border-color: transparent;
    box-shadow: none;
    transform: none;
    outline: none;
  }

  .button-row {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin: 0;
    padding: 0;
  }

  #send,
  #clear {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    box-shadow: none;
  }

  #send:hover,
  #clear:hover {
    transform: none;
  }

  #clear {
    background: rgba(255, 255, 255, 0.09);
    color: #f4f4f7;
  }

  body:not(.dark-mode) .chat-controls {
    background: rgba(248, 248, 252, 0.98);
    border-color: rgba(80, 80, 120, 0.18);
  }

  body:not(.dark-mode) #clear {
    background: rgba(30, 30, 50, 0.08);
    color: #292938;
  }

  body.paulix-keyboard-open .chat-controls {
    flex-shrink: 0;
    padding-top: 5px;
    padding-bottom: 5px;
    margin-bottom: 0;
  }
}


/* Mobile follow-up: preserve the original pill-shaped theme switch,
   enlarge its tap target, and allow native pull-to-refresh. */
@media (max-width: 700px) {
  html,
  body {
    overscroll-behavior-y: auto !important;
  }

  body {
    touch-action: pan-x pan-y;
  }

  #main-content {
    overscroll-behavior-y: auto !important;
  }

  #chat {
    overscroll-behavior-y: auto !important;
    touch-action: pan-y;
  }

  .theme-toggle {
    top: 10px;
    right: 60px;
    width: auto;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: none;
  }

  #theme-toggle-button {
    /* Keep the original sun/moon toggle design, just make it easier to tap. */
    width: 68px;
    height: 42px;
    min-width: 68px;
    min-height: 42px;
    padding: 0;
    border-radius: 999px;
    overflow: visible;
  }
}


/* Slightly move the mobile theme toggle toward the right edge. */
@media (max-width: 700px) {
  .theme-toggle {
    right: 38px;
  }
}


/* Restore normal browser pull-to-refresh on mobile.
   Let the document scroll/overscroll at the page level, while the chat
   itself remains a scrollable panel for conversation history. */
@media (max-width: 700px) {
  html {
    overscroll-behavior-y: auto !important;
    touch-action: pan-y pinch-zoom !important;
  }

  body {
    overscroll-behavior-y: auto !important;
    touch-action: pan-y pinch-zoom !important;
  }

  #main-content {
    overscroll-behavior-y: auto !important;
    touch-action: pan-y pinch-zoom !important;
  }

  #chat {
    overscroll-behavior-y: auto !important;
    touch-action: pan-y pinch-zoom !important;
  }
}


/* Mobile refresh fix v2: use a real document scroll surface.
   Keep the chat app full-height, but give the browser a tiny scroll range
   so its native pull-to-refresh gesture can begin on the page itself. */
@media (max-width: 700px) {
  html {
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: auto !important;
  }

  body {
    height: auto !important;
    min-height: calc(100dvh + 2px) !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    overscroll-behavior-y: auto !important;
  }

  #main-content {
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  #chat {
    overscroll-behavior-y: contain;
  }
}


/* Persistent mobile composer + smooth message following */
@media (max-width: 700px) {
  #main-content {
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  #chat {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    scroll-behavior: smooth;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    scroll-padding-bottom: 14px;
  }

  .chat-controls {
    position: sticky !important;
    bottom: 0;
    z-index: 30;
    flex: 0 0 auto !important;
    width: 100%;
    margin-top: auto !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    transform: translateZ(0);
  }

  body.paulix-keyboard-open .chat-controls {
    position: sticky !important;
    bottom: 0;
  }
}
