
:root {
  --bg: #f7f7fc;
  --panel: #ffffff;
  --text: #202035;
  --muted: #77778e;
  --border: #e8e7f2;
  --purple: #8057f5;
  --pink: #e65cae;
  --blue: #4b8df8;
  --shadow: 0 12px 40px rgba(62, 45, 115, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
      radial-gradient(ellipse at 75% 0%, rgba(180, 155, 255, 0.08), transparent 45%),
      linear-gradient(135deg, #f5f1ff 0%, #faf6ff 55%, #f0f7ff 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(128, 87, 245, 0.3);
  outline-offset: 3px;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: #ded4ff;
  color: #34205f;
}

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

::-webkit-scrollbar-thumb {
  background: #d7d2e8;
  border-radius: 20px;
}

.card {
  max-width: 620px;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.app,
.app-container,
.app-layout {
  min-height: 100vh;
}

.sidebar {
  background: rgba(255, 255, 255, 0.88);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand,
.logo,
.app-logo {
  font-weight: 800;
  letter-spacing: -0.7px;
  background: linear-gradient(115deg, var(--purple), var(--pink), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

button,
.btn,
.action-button,
.new-chat-button {
  border-radius: 12px;
}

.new-chat-button,
.primary-button,
.send-button {
  border: 0;
  color: #fff;
  background: linear-gradient(115deg, var(--purple), var(--pink));
  box-shadow: 0 7px 18px rgba(128, 87, 245, 0.20);
}

.new-chat-button:hover,
.primary-button:hover,
.send-button:hover {
  box-shadow: 0 10px 24px rgba(128, 87, 245, 0.28);
}

main,
.chat-main,
.chat-container {
  min-width: 0;
}

.chat-input-area,
.input-area,
.composer {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 8px 28px rgba(45, 35, 90, 0.07);
}

input,
textarea {
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #9998ad;
}

textarea {
  resize: vertical;
}

.message,
.chat-message {
  overflow-wrap: anywhere;
  line-height: 1.7;
}

.user-message,
.message.user,
.chat-message.user {
  color: #fff;
  background: linear-gradient(120deg, #cbb8ff, #dfc5f5);
  border-radius: 18px 18px 5px 18px;
  padding: 12px 16px;
  height: auto;
  min-height: 0;
  max-height: none;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: normal;
  box-sizing: border-box;
}

.assistant-message,
.message.assistant,
.chat-message.assistant {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 5px;
}

.welcome-title,
.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -1.8px;
  line-height: 1.12;
}

.gradient-text {
  background: linear-gradient(110deg, var(--purple), var(--pink), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.suggestion-card,
.feature-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: 0 5px 18px rgba(62, 45, 115, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.suggestion-card:hover,
.feature-card:hover {
  border-color: #c7b8ff;
  box-shadow: 0 10px 28px rgba(91, 65, 170, 0.10);
  transform: translateY(-3px);
}

.muted,
.subtitle,
.description {
  color: var(--muted);
}

body.dark,
body.dark-theme,
body[data-theme="dark"] {
  --bg: #10101a;
  --panel: #191927;
  --text: #f0effa;
  --muted: #aaa8c0;
  --border: #303044;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  background:
    radial-gradient(ellipse at 75% 0%, rgba(128, 87, 245, 0.14), transparent 36%),
    var(--bg);
}

body.dark .sidebar,
body.dark-theme .sidebar,
body[data-theme="dark"] .sidebar {
  background: rgba(25, 25, 39, 0.92);
}

body.dark .suggestion-card,
body.dark .feature-card,
body.dark .assistant-message,
body.dark .message.assistant,
body.dark .chat-message.assistant,
body.dark-theme .suggestion-card,
body.dark-theme .feature-card,
body[data-theme="dark"] .suggestion-card,
body[data-theme="dark"] .feature-card {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}

body.dark .chat-input-area,
body.dark .input-area,
body.dark .composer,
body.dark-theme .chat-input-area,
body.dark-theme .composer,
body[data-theme="dark"] .chat-input-area,
body[data-theme="dark"] .composer {
  background: var(--panel);
  border-color: var(--border);
}

@media (max-width: 760px) {
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .welcome-title,
  .hero-title {
    letter-spacing: -1px;
  }

  .card {
    margin: 12px;
    padding: 14px;
  }

  .chat-input-area,
  .input-area,
  .composer {
    border-radius: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

#historyList {
  position: relative;
  z-index: 20;
  pointer-events: auto;
  flex-direction: column !important;
  gap: 8px !important;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px 0 !important;
}

#historyList button {
  position: relative;
  z-index: 21;
  pointer-events: auto !important;
  cursor: pointer !important;
  display: block !important;
  width: 100% !important;
  min-height: 42px;
  padding: 11px 14px !important;
  margin: 0 !important;
  text-align: left !important;
  line-height: 1.5 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  background: var(--panel) !important;
  color: var(--text) !important;
  box-sizing: border-box !important;
}

#historyList button:hover {
  background: rgba(128, 87, 245, 0.10) !important;
  border-color: var(--purple) !important;
  transform: none;
}

#historyList .history-item {
  flex-shrink: 0;
}

.voice-mode {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: #10101a;
  color: white;
  align-items: center;
  justify-content: center;
  font-family: Arial, sans-serif;
}

.voice-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 25px;
}

.voice-close {
  position: absolute;
  top: 24px;
  right: 25px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #292638;
  color: white;
  font-size: 28px;
  cursor: pointer;
}

.voice-orb {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8c52ff, #ff4da6, #36d1dc);
  box-shadow: 0 0 65px #8c52ff66;
  transition: transform .3s ease;
}

.voice-orb-inner {
  width: 125px;
  height: 125px;
  border-radius: 50%;
  background: #171526;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 55px;
}

.voice-orb.active {
  animation: voicePulse 1.3s infinite alternate;
}

@keyframes voicePulse {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

.voice-content h2 {
  margin-top: 35px;
  font-size: 25px;
}

#voiceModeStatus {
  color: #bbb;
  min-height: 22px;
}

#voiceTranscript {
  max-width: 500px;
  color: #ddd;
  line-height: 1.6;
}

.voice-controls {
  display: flex;
  gap: 18px;
  margin-top: 30px;
}

.voice-controls button {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #8c52ff, #ff4da6);
  color: white;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.composer {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
}

.composer #prompt {
  display: block;
  width: 100%;
  min-height: 58px;
  max-height: 160px;
  padding: 15px 14px;
  margin: 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  box-sizing: border-box;
}

.composer #prompt:focus {
  outline: none;
}

.composer-footer {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
}

.composer-footer > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#voiceModeButton {
  width: 46px !important;
  min-width: 46px !important;
  height: 46px !important;
  min-height: 46px !important;
  padding: 0 !important;
  flex-shrink: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  box-sizing: border-box !important;
}

#voiceModeButton svg {
  width: 22px;
  height: 22px;
}

.composer-note {
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .composer {
    padding: 12px;
  }

  .composer #prompt {
    min-height: 54px;
    font-size: 15px;
  }

  #voiceModeButton {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }
}

.preview-notice h1,
.preview-notice h2,
.preview-notice h3 {
  margin: 16px 0 10px;
  line-height: 1.4;
}

.preview-notice p {
  margin: 8px 0;
  line-height: 1.7;
}

.preview-notice ul,
.preview-notice ol {
  padding-left: 25px;
  margin: 10px 0;
}

.preview-notice li {
  margin: 5px 0;
}

.preview-notice strong {
  font-weight: 700;
}

.preview-notice table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  display: block;
  overflow-x: auto;
}

.preview-notice th,
.preview-notice td {
  border: 1px solid #514765;
  padding: 9px 12px;
  text-align: left;
}

.preview-notice th {
  font-weight: 700;
  background: rgba(140, 82, 255, 0.12);
}

.preview-notice pre {
  padding: 14px;
  border-radius: 10px;
  overflow-x: auto;
  background: #191827;
  margin: 12px 0;
}

.preview-notice code {
  font-family: Consolas, monospace;
  overflow-wrap: anywhere;
}

.preview-notice blockquote {
  border-left: 3px solid #8c52ff;
  padding-left: 12px;
  margin: 12px 0;
  opacity: 0.85;
}

.app {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  min-width: 270px;
  min-height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  width: 100%;
  min-height: 64px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.conversation {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 24px;
  overflow-y: auto;
}

.welcome {
  width: 100%;
  max-width: 850px;
  margin: 35px auto;
}

.messages {
  width: 100%;
  max-width: 850px;
  margin: 0 auto;
}

.composer-area {
  width: 100%;
  padding: 12px 24px 8px;
  margin-top: auto;
}

.composer {
  width: 100%;
  max-width: 850px;
  margin: 0 auto;
}

.disclaimer {
  text-align: center;
  font-size: 12px;
  margin: 10px 0 0;
}

@media (max-width: 760px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    min-height: auto;
  }

  .main {
    width: 100%;
    min-height: 70vh;
  }

  .conversation {
    padding: 14px;
  }

  .composer-area {
    padding: 10px 12px;
  }
}

.composer .send-button {
  width: 46px !important;
  min-width: 46px !important;
  height: 46px !important;
  min-height: 46px !important;
  padding: 0 !important;
  flex-shrink: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  font-size: 24px !important;
  background: linear-gradient(135deg, #8c52ff, #ff4da6) !important;
  color: white !important;
}

@media (max-width: 600px) {
  .composer .send-button {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }
}
