:root {
  --bg: #0f1216;
  --panel: #171c22;
  --panel-2: #1e2530;
  --accent: #e0a458;
  --accent-2: #c97b3c;
  --text: #ecebe6;
  --text-dim: #a8a49a;
  --user-bubble: #2a3340;
  --bot-bubble: #21262f;
  --border: #2a2f38;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Georgia", "Iowan Old Style", serif;
  background: radial-gradient(circle at top, #1a1310 0%, #0f1216 55%);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.side-figure {
  display: none;
  position: fixed;
  bottom: 0;
  height: 88vh;
  height: 88dvh;
  width: auto;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

.side-figure-left {
  left: 0;
  bottom: 20vh;
  bottom: 20dvh;
  height: 50vh;
  height: 50dvh;
  transform: translateX(-2%) scaleX(-1);
}

.side-figure-right {
  right: 0;
  transform: translateX(8%) scaleX(-1);
}

@media (min-width: 1100px) {
  .side-figure {
    display: block;
  }
}

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px clamp(16px, 4vw, 64px);
}

.app-inner {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px 20px;
  border-bottom: 1px solid var(--border);
}

.om {
  font-size: 36px;
  color: var(--accent);
  line-height: 1;
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.app-header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.chat-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
}

.sanskrit-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.sanskrit-glyph {
  position: absolute;
  bottom: -60px;
  color: var(--accent);
  font-family: "Noto Sans Devanagari", "Georgia", serif;
  opacity: 0;
  user-select: none;
  animation-name: sanskrit-float;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform, opacity;
}

@keyframes sanskrit-float {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: var(--glyph-opacity, 0.14);
  }
  85% {
    opacity: var(--glyph-opacity, 0.14);
  }
  100% {
    transform: translateY(-720px) rotate(var(--glyph-rotate, 20deg));
    opacity: 0;
  }
}

.chat {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  overflow-y: auto;
  padding: 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border-bottom-right-radius: 2px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  border-left: 3px solid var(--accent);
  border-bottom-left-radius: 2px;
}

.msg.bot.loading {
  color: var(--text-dim);
  font-style: italic;
}

.msg.error {
  align-self: flex-start;
  background: #3a1e1e;
  border-left: 3px solid #c96b6b;
  color: #f0c9c9;
}

.msg p {
  margin: 0 0 10px;
}
.msg p:last-child {
  margin-bottom: 0;
}

.msg strong {
  color: var(--accent);
}

.msg em {
  color: #d8cdb8;
}

.msg blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent-2);
  background: rgba(224, 164, 88, 0.08);
  color: #e8d9b8;
  font-style: italic;
}
.msg blockquote:first-child {
  margin-top: 0;
}
.msg blockquote:last-child {
  margin-bottom: 0;
}

.msg ul,
.msg ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}
.msg li {
  margin-bottom: 6px;
}
.msg li:last-child {
  margin-bottom: 0;
}

.msg hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.msg code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 0.9em;
}

.msg h1, .msg h2, .msg h3, .msg h4 {
  margin: 4px 0 8px;
  color: var(--accent);
}

.composer {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

#input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

#input:focus {
  outline: none;
  border-color: var(--accent);
}

#send {
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #201509;
  font-weight: bold;
  cursor: pointer;
  font-size: 15px;
}

#send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat::-webkit-scrollbar {
  width: 8px;
}
.chat::-webkit-scrollbar-thumb {
  background: var(--panel-2);
  border-radius: 4px;
}
