body {
  margin: 0;
  padding: 0;
  font-family: "Open Sans", sans-serif;
  height: 100vh;
  display: flex;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

button, a, #history-list li {
  -webkit-tap-highlight-color: transparent;
}

.layout {
  flex-grow: 1;
  display: flex;
  width: 100%;
}

#sidebar {
  width: 280px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: visible;
  transition: transform 0.3s ease;
  z-index: 2200;
  box-sizing: border-box;
}

.sidebar-hidden #sidebar {
  transform: translateX(-100%);
}

#home-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  margin-top: auto;
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

#home-button:hover {
  background-color: rgba(255, 255, 255, 0.10);
}

#home-button .icon {
  font-size: 1.2rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header .sidebar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  background-color: var(--input-bg);
  padding: 4px;
}

.sidebar-header .sidebar-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-color);
}

#new-chat {
  padding: 12px 14px;
  margin-bottom: 15px;
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
  transition: background-color 0.2s ease;
}

#new-chat::before {
  content: "＋";
  display: inline-block;
  margin-right: 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

#new-chat:hover {
  background-color: rgba(255, 255, 255, 0.10);
}

#history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
}

#history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--history-text-color);
  background-color: transparent;
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
  position: relative;
}

#history-list li.active {
  background-color: rgba(255, 255, 255, 0.12);
  color: var(--text-color);
  border-left: 3px solid var(--primary-color);
}

#history-list li:hover {
  background-color: var(--hover-bg-color);
}

.history-menu {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 1.2rem;
  color: inherit;
}

.history-actions {
  position: absolute;
  top: 100%;
  right: 8px;
  max-width: calc(100% - 16px);
  background-color: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 4px;
  padding: 4px 0;
  min-width: 160px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: none;
  overflow: hidden;
}

.history-actions button {
  width: 100%;
  background: none;
  border: none;
  padding: 6px 12px;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-color);
  cursor: pointer;
}

.history-actions button:hover {
  background-color: var(--hover-bg-color);
}

#main-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  height: 100vh;
  overflow: hidden;
}

#main-area.empty-state {
  justify-content: center;
}

#main-area.empty-state .hero {
  text-align: center;
  margin: 0 auto 16px;
  max-width: 520px;
}

#main-area.empty-state #chat-box {
  flex-grow: 0;
}

#main-area.empty-state .prompt-options {
  margin-top: 16px;
  justify-content: center;
}

.hero {
  text-align: left;
  margin-bottom: 20px;
}

.hero h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}

.hero h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 5px 0 0 0;
}

#chat-box {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 10px;
  display: flex;
  flex-direction: column;
}

.prompt-options {
  display: flex;
  gap: 10px;
  margin-top: auto;
  margin-bottom: 10px;
}

.option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px;
  background-color: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-height: 80px;
}

.option img {
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
}

.option p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--text-color);
}

.option:hover {
  background-color: var(--hover-bg-color);
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  margin-bottom: 12px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
  white-space: pre-wrap;
  width: fit-content;
}

.user.message {
  align-self: flex-end;
  background: var(--user-bubble-bg);
  color: var(--user-bubble-color);
}

.bot.message {
  align-self: flex-start;
  background: var(--bot-bubble-bg);
  color: var(--bot-bubble-color);
  border: 1px solid var(--border-color);
}

.bot.message a {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bot.message code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 0.15em 0.35em;
  border-radius: 6px;
}

.bot.message pre {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
}

.bot.message pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.bot.message blockquote {
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(138, 180, 255, 0.75);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.bot.message table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.bot.message th,
.bot.message td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 10px;
}

.bot.message th {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
}

#input-form {
  display: flex;
  align-items: center;
  margin-top: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--input-bg);
}

#input-form input {
  flex-grow: 1;
  border: none;
  padding: 12px;
  font-size: 1rem;
  color: var(--text-color);
  background-color: transparent;
}

#input-form input:focus {
  outline: none;
}

#input-form button {
  border: none;
  background-color: transparent;
  padding: 12px;
  font-size: 1.4rem;
  color: var(--text-color);
  cursor: pointer;
}

.loading {
  color: #888;
  font-size: 0.9rem;
  margin: 8px 0;
}

.loading i {
  font-style: normal;
}

.hidden {
  display: none !important;
}

:root {
  --bg-color: #0b0d12;
  --text-color: #e9edf7;
  --sidebar-bg: #0f131a;
  --border-color: rgba(255, 255, 255, 0.10);
  --hover-bg-color: rgba(255, 255, 255, 0.08);
  --primary-color: #4f6fe6;
  --secondary-color: #e65a6a;
  --user-bubble-bg: linear-gradient(135deg, rgba(79, 111, 230, 0.50) 0%, rgba(230, 90, 106, 0.42) 100%);
  --user-bubble-color: #ffffff;
  --bot-bubble-bg: rgba(255, 255, 255, 0.06);
  --bot-bubble-color: #f2f5ff;
  --link-color: #8ab4ff;
  --input-bg: rgba(255, 255, 255, 0.05);
  --history-text-color: #e0e0e0;
}

body[data-theme="light"] {
  --bg-color: #f7f7f7;
  --text-color: #333333;
  --sidebar-bg: #ffffff;
  --border-color: #e0e0e0;
  --hover-bg-color: #f0f0f0;
  --bot-bubble-bg: #f0f0f0;
  --bot-bubble-color: #333333;
  --input-bg: #ffffff;
  --history-text-color: #333333;
  --link-color: #1d4ed8;
}

body[data-model="kakangku"] {
  --primary-color: #4f6fe6;
  --secondary-color: #e65a6a;
  --user-bubble-bg: linear-gradient(135deg, rgba(79, 111, 230, 0.52) 0%, rgba(230, 90, 106, 0.44) 100%);
  --user-bubble-color: #ffffff;
}

body[data-model="buzz"] {
  --primary-color: #e65a6a;
  --secondary-color: #4f6fe6;
  --user-bubble-bg: linear-gradient(135deg, rgba(230, 90, 106, 0.52) 0%, rgba(79, 111, 230, 0.44) 100%);
  --user-bubble-color: #ffffff;
}

.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 3000;
  background-color: rgba(255, 255, 255, 0.10);
  color: var(--text-color);
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
}

.layout.sidebar-visible .sidebar-toggle {
  left: calc(min(82vw, 340px) + 12px);
  background-color: rgba(255, 255, 255, 0.14);
}

@media (max-width: 1024px) {
  .sidebar-toggle {
    display: block;
  }
}

@media (max-width: 480px) {
  .message {
    max-width: 92%;
    font-size: 1rem;
    padding: 12px 14px;
  }
  .prompt-options {
    flex-direction: column;
  }
  .option {
    min-height: 70px;
  }
}

@media (max-width: 1024px) {
  #sidebar {
    width: min(82vw, 340px);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
    transform: translateX(-100%);
    border-right: 1px solid var(--border-color);
  }

  #main-area {
    padding: 18px;
    padding-top: 56px;
  }

  .layout.sidebar-visible #sidebar {
    transform: translateX(0);
  }

  .layout.sidebar-visible::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1500;
  }
}
