:root {
  --neu-bg: #e0e5ec;
  --neu-shadow-dark: #bebebe;
  --neu-shadow-light: #ffffff;
  --neu-text: #2e2e2e;
  --neu-accent: #91eac9;
  --neu-radius: 1.5em;
  --neu-border: #d3dae6;
}

body {
  margin: 0;
  background: var(--neu-bg);
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  color: var(--neu-text);
  height: 100vh;
}

#theme-bar {
  position: fixed;
  top: 12px; left: 18px; z-index: 9;
  display: flex; align-items: center; gap: 10px;
  background: var(--neu-bg);
  padding: 5px 14px 5px 10px;
  border-radius: 2em;
  box-shadow: 2px 2px 8px var(--neu-shadow-dark),
              -2px -2px 8px var(--neu-shadow-light);
}
#theme-bar label { font-size: 1.4em; cursor: pointer; }
#theme-picker { width: 28px; height: 28px; border: none; border-radius: 8px; background: var(--neu-accent); cursor: pointer;}
#install-btn { margin-left: 10px; padding: 2px 14px;}
#install-btn:not(.hidden) { display: inline-block !important; }

.logo {
  width: 72px;
  display: block;
  margin: 32px auto 12px auto;
  box-shadow: 4px 4px 12px var(--neu-shadow-dark),
              -4px -4px 16px var(--neu-shadow-light);
  border-radius: 50%;
  background: var(--neu-bg);
}

#app {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card {
  background: var(--neu-bg);
  padding: 36px 32px 24px 32px;
  border-radius: 2.2em;
  box-shadow: 8px 8px 18px var(--neu-shadow-dark),
              -8px -8px 24px var(--neu-shadow-light);
  max-width: 370px;
  width: 100%;
  text-align: center;
  margin: 0 auto;
}

#login-form input {
  width: 95%;
  margin: 10px 0;
  padding: 14px;
  border-radius: 1em;
  border: none;
  background: var(--neu-bg);
  color: var(--neu-text);
  font-size: 1.08em;
  box-shadow: inset 2px 2px 6px var(--neu-shadow-dark),
              inset -2px -2px 6px var(--neu-shadow-light);
  outline: none;
  transition: box-shadow 0.2s;
}
#login-form input:focus {
  box-shadow: 0 0 0 2px var(--neu-accent),
    inset 2px 2px 6px var(--neu-shadow-dark),
    inset -2px -2px 6px var(--neu-shadow-light);
}

.neon-btn, .neon-btn:focus {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 46px;
  padding: 0 18px;
  margin-top: 8px;
  border: none;
  border-radius: 1em;
  font-size: 1.1em;
  font-weight: 700;
  background: var(--neu-bg);
  color: var(--neu-text);
  cursor: pointer;
  box-shadow: 2px 2px 8px var(--neu-shadow-dark),
              -2px -2px 8px var(--neu-shadow-light);
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}
.neon-btn:hover, .neon-btn:active {
  background: #f0f3f9;
  color: #2ec48e;
  box-shadow: inset 2px 2px 7px var(--neu-shadow-dark),
              inset -2px -2px 7px var(--neu-shadow-light);
}

.neon-text {
  color: #22a887;
  text-shadow: 0 1px 0 var(--neu-shadow-light);
  font-weight: bold;
}

.error {
  color: #f34536;
  margin-top: 10px;
  font-size: 1em;
  min-height: 1.3em;
}

.hidden { display: none !important; }

#chat-container {
  width: 100vw;
  max-width: 430px;
  min-height: 100vh;
  background: var(--neu-bg);
  border-radius: 2.2em;
  box-shadow: 8px 8px 18px var(--neu-shadow-dark),
              -8px -8px 24px var(--neu-shadow-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  background: var(--neu-bg);
  padding: 26px 22px 14px 22px;
  border-radius: 2em 2em 0 0;
  box-shadow: 3px 3px 10px var(--neu-shadow-dark),
              -3px -3px 12px var(--neu-shadow-light);
  gap: 12px;
}
.avatar, .user-avatar, .bot-avatar {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 2em;
  background: var(--neu-bg);
  box-shadow: 4px 4px 10px var(--neu-shadow-dark),
              -4px -4px 14px var(--neu-shadow-light);
  border: none;
  margin: 0;
  object-fit: cover;
}
.user-avatar {
  background: linear-gradient(135deg, #c1f3e3 10%, #e0e5ec 90%);
  border: 2px solid #fff;
}
.bot-avatar {
  background: var(--neu-bg);
  border: none;
}
.chat-title {
  font-size: 1.3em;
  flex: 1;
  font-weight: 600;
  letter-spacing: 1px;
}
#logout-btn {
  background: none;
  border: none;
  color: #22a887;
  font-size: 1.4em;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 50%;
  transition: background 0.18s;
}
#logout-btn:hover {
  background: #d5e2ec;
}

#chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 28px 18px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--neu-bg);
  scroll-behavior: smooth;
}

.bubble-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bubble, .bubble.user, .bubble.bot {
  border-radius: 1.6em !important;
  box-shadow: 3px 3px 10px var(--neu-shadow-dark),
              -3px -3px 10px var(--neu-shadow-light);
  background: var(--neu-bg);
  color: var(--neu-text);
  max-width: 76%;
  padding: 16px 20px;
  font-size: 1.07em;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: box-shadow 0.15s;
  word-break: break-word;
}
.bubble.user {
  align-self: flex-end;
}
.bubble.bot {
  align-self: flex-start;
}

.bubble code, .bubble pre {
  background: #f3f8fa;
  color: #14b57d;
  border-radius: 6px;
  padding: 2px 6px;
  font-family: "Fira Mono", "Consolas", monospace;
}
.bubble pre {
  display: block;
  padding: 14px;
  white-space: pre-wrap;
  margin: 12px 0 6px 0;
  font-size: 0.98em;
}

.timestamp {
  font-size: 0.83em;
  color: #aaa;
  margin-top: 8px;
  align-self: flex-end;
}

#message-form {
  display: flex;
  padding: 20px 16px 18px 16px;
  background: var(--neu-bg);
  border-radius: 0 0 2em 2em;
  box-shadow: 2px 2px 7px var(--neu-shadow-dark),
              -2px -2px 7px var(--neu-shadow-light);
  gap: 10px;
  flex-wrap: wrap;
}

#message-input {
  flex: 1;
  border: none;
  border-radius: 1em;
  padding: 14px 18px;
  font-size: 1.09em;
  background: var(--neu-bg);
  color: var(--neu-text);
  box-shadow: inset 2px 2px 6px var(--neu-shadow-dark),
              inset -2px -2px 6px var(--neu-shadow-light);
  outline: none;
  transition: box-shadow 0.2s;
}
#message-input:focus {
  box-shadow: 0 0 0 2px var(--neu-accent),
    inset 2px 2px 6px var(--neu-shadow-dark),
    inset -2px -2px 6px var(--neu-shadow-light);
}

#message-form button, #message-form input[type="file"] {
  width: auto;
  min-width: 46px;
  margin-left: 2px;
  margin-top: 4px;
}

footer {
  padding: 0 16px 16px 16px;
  text-align: center;
  color: #44bca3;
  font-size: 0.93em;
  background: var(--neu-bg);
}

.typing-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 24px 10px 24px;
  min-height: 32px;
}
.typing-indicator img.pulse { animation: pulse 1.2s infinite alternate;}
@keyframes pulse { 0% {filter: brightness(1) drop-shadow(0 0 0 #d0f9f5);} 100% {filter: brightness(2) drop-shadow(0 0 14px #acefdc);} }
.typing-indicator span {
  width: 10px;
  height: 10px;
  background: #14b57d;
  opacity: 0.7;
  border-radius: 50%;
  display: inline-block;
  animation: blink 1.2s infinite both;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s;}
.typing-indicator span:nth-child(3) { animation-delay: 0.4s;}
@keyframes blink { 0% { opacity: .8;} 20% { opacity: .2;} 100% { opacity: .8;} }

kbd {
  background: #f6fbfa;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.98em;
  border: 1px solid var(--neu-border);
}

:focus {
  outline: 2px solid var(--neu-accent);
  outline-offset: 2px;
}
@media (max-width: 600px) {
  #chat-container { border-radius: 0; box-shadow: none; max-width: 100vw; }
  #theme-bar { left: 2vw; top: 4vw; }
}