:root {
  --bg: #050505;
  --bg-soft: rgba(255, 255, 255, 0.04);
  --bg-soft-2: rgba(255, 255, 255, 0.07);
  --panel: rgba(12, 12, 12, 0.78);
  --panel-strong: rgba(18, 18, 18, 0.9);
  --border: rgba(255, 170, 220, 0.18);
  --border-strong: rgba(255, 170, 220, 0.32);
  --text: #f7eaf1;
  --text-soft: #cba5ba;
  --text-dim: #9d7f90;
  --accent: #ff4fa3;
  --accent-soft: #ff8fc5;
  --accent-glow: rgba(255, 79, 163, 0.28);
  --green: #78f5a1;
  --red: #ff8f98;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--text);
  background:
      radial-gradient(circle at top center, rgba(255, 79, 163, 0.12), transparent 32%),
      radial-gradient(circle at bottom right, rgba(255, 79, 163, 0.08), transparent 22%),
      #000;
  overflow-x: hidden;
}

body.drawer-open {
  overflow: hidden;
}

a {
  color: var(--accent-soft);
  text-decoration: none;
}

a:hover {
  color: #ffd2e8;
}

button,
textarea,
input {
  font: inherit;
}

/* Top controls */
.top-icon-button,
.top-action-button {
  position: fixed;
  z-index: 5000;
  border: 1px solid var(--border);
  background: rgba(20, 20, 20, 0.72);
  color: var(--text);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.top-icon-button {
  top: 18px;
  left: 18px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#hamburgerIcon {
  width: 24px;
  height: 24px;
  display: block;
}

.top-actions {
  position: fixed;
  top: 35px;
  right: 20px;
  z-index: 5000;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.top-action-button {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.top-action-button:hover,
.top-icon-button:hover {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px var(--accent-glow), 0 10px 32px rgba(0, 0, 0, 0.35);
}

.top-action-button.hidden {
  display: none !important;
}

#newConversationButton {
  margin-right: 80px;
}

/* Shared backdrop */
#drawerBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
  z-index: 3999;
}

#drawerBackdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Drawers */
.drawer {
  position: fixed;
  top: 0;
  width: min(360px, 88vw);
  height: 100vh;
  z-index: 4000;
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 84px 18px 18px;
  overflow-y: auto;
  transition: transform 0.28s ease;
}

.drawer-left {
  left: 0;
  border-right: 1px solid var(--border);
  border-left: none;
  border-top: none;
  border-bottom: none;
  border-radius: 0 24px 24px 0;
  transform: translateX(-104%);
}

.drawer-right {
  right: 0;
  border-left: 1px solid var(--border);
  border-right: none;
  border-top: none;
  border-bottom: none;
  border-radius: 24px 0 0 24px;
  transform: translateX(100%);
}

.drawer.active {
  transform: translateX(0);
}

.drawer.active {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffd2e8;
  letter-spacing: 0.02em;
}

.drawer-user {
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent-soft);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.drawer-link-block {
  margin-bottom: 16px;
}

.drawer-link-block a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.drawer-link-block a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.drawer-link-block img,
.sidebar-menu img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.sidebar-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-menu li {
  margin: 0;
  padding: 0;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.18s ease;
}

.sidebar-menu a:hover {
  background: rgba(255, 79, 163, 0.12);
  border-color: rgba(255, 79, 163, 0.22);
}

/* History drawer */
.history-search-wrap {
  margin-bottom: 16px;
}

#conversationSearch {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
}

#conversationSearch:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px rgba(255, 79, 163, 0.18);
}

#conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#conversation-list li {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.18s ease, border-color 0.18s ease;
}

#conversation-list li:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 79, 163, 0.14);
}

.conversation-label {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-label.active {
  color: #ff76e8;
  font-weight: 700;
}

.menu-button {
  margin: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  flex: 0 0 auto;
}

.menu-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.popup-menu {
  display: none;
  position: absolute;
  top: 48px;
  right: 8px;
  min-width: 130px;
  z-index: 20;
  padding: 8px;
  border-radius: 14px;
  background: rgba(14, 14, 14, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.popup-menu.visible {
  display: block;
}

.popup-option {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
}

.popup-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* App shell */
.app-shell {
  height: calc(100vh - 56px); /* reserve space for P&E / copyright */
  padding: 0 18px 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  position: relative;
}

.wrapper {
  width: min(1100px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.header {
  min-height: 88px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.04),
      rgba(255, 255, 255, 0.015)
  );
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(255, 79, 163, 0.2));
}

.brand-stack h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
  color: #ffe6f2;
}

.brand-subtitle {
  display: inline-block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 79, 163, 0.22);
  background: rgba(255, 79, 163, 0.08);
  color: #ffd2e8;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Chat area */
.container {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  background:
      radial-gradient(circle at top center, rgba(255, 79, 163, 0.06), transparent 28%),
      rgba(0, 0, 0, 0.42);
  scroll-behavior: smooth;
}

#character-image {
  display: block;
  width: min(380px, 72vw);
  max-width: 100%;
  height: auto;
  margin: 48px auto 18px;
  opacity: 0.96;
  filter: drop-shadow(0 8px 32px rgba(0, 0, 0, 0.5));
}

#welcome-message {
  width: min(620px, 100%);
  margin: 0 auto 12px;
  padding: 18px 22px;
  text-align: center;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 79, 163, 0.18);
  color: #ffe6f2;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.22);
}

#disclaimer {
  width: min(620px, 100%);
  margin: 0 auto 28px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Messages */
.message-block {
  margin-bottom: 18px;
}

.message {
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

.user-message {
  margin-left: auto;
  max-width: min(780px, 92%);
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff4fa;
}

.user-message .message-header {
  color: #ffb8d9;
}

.bot-message {
  max-width: min(860px, 96%);
  padding: 16px 18px;
  background: rgba(255, 79, 163, 0.08);
  color: #ffd6e8;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
  color: #fff4fa;
}

.message-text {
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.bot-response {
  color: #ffe3ef;
}

.message-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Composer */
.footer {
  padding: 18px;
  background: linear-gradient(
      to top,
      rgba(255, 255, 255, 0.04),
      rgba(255, 255, 255, 0.015)
  );
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#message {
  width: 100%;
  height: 24px;
  min-height: 24px;
  max-height: 108px;
  border: none;
  outline: none;
  resize: none;
  overflow-y: hidden;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

#message::placeholder {
  color: var(--text-dim);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}


.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#charCounter {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.composer-submit-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.composer-icon-button {
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 79, 163, 0.22);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: #ffd6e8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.composer-icon-button img {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
}

.composer-icon-button:hover {
  border-color: rgba(255, 79, 163, 0.36);
  background: rgba(255, 79, 163, 0.10);
  box-shadow: 0 0 0 1px rgba(255, 79, 163, 0.14), 0 8px 20px rgba(255, 79, 163, 0.10);
}

.composer-icon-button.active {
  border-color: rgba(255, 79, 163, 0.5);
  background: linear-gradient(180deg, rgba(255, 79, 163, 0.22), rgba(255, 79, 163, 0.14));
  box-shadow: 0 0 0 1px rgba(255, 79, 163, 0.18), 0 8px 20px rgba(255, 79, 163, 0.14);
}

.composer-icon-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.composer-icon-button:disabled:hover {
  box-shadow: none;
}

.composer-icon-button[aria-pressed="true"] img {
  filter: brightness(1.15);
}

#sendButton {
  margin: 0;
  min-width: 120px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(255, 79, 163, 0.28);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 79, 163, 0.22), rgba(255, 79, 163, 0.14));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

#sendButton:hover {
  box-shadow: 0 0 0 1px rgba(255, 79, 163, 0.18), 0 8px 20px rgba(255, 79, 163, 0.14);
}

#sendButton.disabled,
#sendButton:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* Footer bar */


#privacyEthicsLink {
  height: 56px;
  padding: 10px 18px 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}

#privacyEthicsLink a {
  color: var(--text-soft);
}

#privacyEthicsLink span {
  display: inline-block;
  margin-left: 10px;
}

/* Scroll button */
#scrollToBottomBtn {
  position: fixed;
  left: 50%;
  top: 65%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  z-index: 99999;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 79, 163, 0.45);
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.98);
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.28s ease,
    visibility 0.28s ease;
  /*display: inline-flex !important;*/
}

#scrollToBottomBtn:hover {
  transform: translate(-50%, -50%);
}

#scrollToBottomBtn.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.drawer-open #scrollToBottomBtn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

/* Code blocks */
.runa-code-block {
  margin: 8px 0;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
}

.runa-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.runa-code-lang {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

.runa-copy-code-btn {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
}

.runa-copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.runa-code-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.runa-code-scroll pre {
  margin: 0;
  padding: 14px;
  font-family: "Courier New", Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre;
  color: #f0f0f0;
}

/* Audio / feedback / sources controls */
.runa-speak-btn,
.runa-feedback-btn {
  width: 32px;
  height: 32px;
  margin: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #ffd7e9;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.runa-speak-btn:hover,
.runa-feedback-btn:hover {
  background: rgba(255, 255, 255, 0.07);
}

.runa-speak-btn[disabled],
.runa-feedback-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.runa-speak-btn svg,
.runa-feedback-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.runa-feedback-up.active svg {
  color: var(--green);
}

.runa-feedback-down.active svg {
  color: var(--red);
}

.runa-sources-btn {
  margin: 0;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 79, 163, 0.2);
  background: rgba(255, 79, 163, 0.08);
  color: #ffd6e8;
  cursor: pointer;
}

.runa-sources-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.runa-search-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
  font-size: 0.84rem;
}

.spin {
  animation: runa-spin 1s linear infinite !important;
  transform-origin: 50% 50%;
}

@keyframes runa-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.runa-think-spinner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  color: var(--text-soft);
}

.runa-think-spinner-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(1.3) contrast(1.1);
}

.runa-think-spinner-label {
  font-size: 0.92rem;
}

/* Sources modal */
.runa-sources-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.runa-sources-modal {
  width: min(720px, 92vw);
  max-height: min(70vh, 600px);
  overflow: auto;
  background: rgba(12, 12, 12, 0.94);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 16px 16px 12px;
  color: var(--text);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.runa-sources-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.runa-sources-modal-title {
  font-weight: 700;
  color: #ffd6e8;
}

.runa-sources-close {
  width: 36px;
  height: 36px;
  margin: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.runa-sources-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.runa-sources-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
}

.runa-sources-list li {
  margin: 8px 0;
}

.runa-source-meta {
  color: var(--text-dim);
}



/* Mobile */
@media (max-width: 768px) {
  .app-shell {
    height: calc(100vh - 56px);
    padding: 84px 10px 0;
  }

  .wrapper {
    height: 100%;
    min-height: 0;
    border-radius: 22px;
  }

  .header {
      padding: 16px 18px;
      min-height: 78px;
  }

  .logo {
      width: 48px;
      height: 48px;
  }

  .brand-stack h1 {
      font-size: 1.25rem;
  }

  .container {
      padding: 16px;
  }

  #character-image {
      width: min(300px, 84vw);
      margin-top: 26px;
  }

  #welcome-message,
  #disclaimer {
      width: 100%;
  }

  .user-message,
  .bot-message {
      max-width: 100%;
  }


  .runa-avatar {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex: 0 0 32px;
    vertical-align: middle;
  }

  .composer {
      padding: 12px;
      border-radius: 18px;
  }

  #message {
    max-height: 88px;
  }

  #scrollToBottomBtn {
    left: 90%;
    top: 70%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    font-size: 22px;
  }

  .composer-submit-group {
    gap: 8px;
  }

  .composer-icon-button {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }

  .composer-icon-button img {
    width: 20px;
    height: 20px;
  }

  #sendButton {
    min-width: 108px;
  }

  .top-actions {
    top: 35px;
    right: 10px;
    gap: 8px;
  }

  .top-action-button {
      min-height: 46px;
      padding: 0 14px;
      border-radius: 14px;
  }

  .top-icon-button {
      top: 10px;
      left: 10px;
      width: 46px;
      height: 46px;
      border-radius: 14px;
  }

  .drawer {
    width: min(340px, 92vw);
    padding: 72px 14px 14px;
  }

  .drawer-left {
      border-radius: 0 20px 20px 0;
  }

  .drawer-right {
      border-radius: 20px 0 0 20px;
  }
}