:root {
  --bg: #fcfdff;
  --bg-soft: #f3f8fd;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --panel-alt: #eef5fb;
  --line: rgba(120, 147, 180, 0.22);
  --line-strong: rgba(120, 147, 180, 0.34);
  --text: #304155;
  --muted: #70869d;
  --accent: #a7d0ee;
  --accent-2: #d8b796;
  --accent-3: #c8e2f5;
  --success: #7fb79a;
  --danger: #d68578;
  --shadow: 0 18px 42px rgba(102, 133, 165, 0.14);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-width: 320px;
  --header-height: 72px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(167, 208, 238, 0.4), transparent 28%),
    radial-gradient(circle at top right, rgba(216, 183, 150, 0.35), transparent 22%),
    linear-gradient(180deg, #ffffff 0%, #f8fbfe 60%, #f6f2ec 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: #5c89b1; }
a:hover { color: #7a6a5a; }

.screen-reader-text {
  border: 0;
  clip: rect(1px,1px,1px,1px);
  -webkit-clip-path: inset(50%);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  margin: -1px;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

.site-shell-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.site-shell-header-inner {
  min-height: var(--header-height);
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.site-shell-nav {
  width: 100%;
}

.site-shell-menu,
.site-shell-menu ul,
.site-shell-nav .menu,
.site-shell-nav .menu ul,
.site-shell-nav .children,
.site-shell-nav .sub-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-shell-menu,
.site-shell-nav .menu {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.site-shell-menu li,
.site-shell-nav .menu > li,
.site-shell-nav .page_item {
  margin: 0;
}

.site-shell-menu a,
.site-shell-nav .menu > li > a,
.site-shell-nav .page_item > a {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: #42586c;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}

.site-shell-menu .current-menu-item > a,
.site-shell-menu a:hover,
.site-shell-nav .menu > li.current_page_item > a,
.site-shell-nav .page_item.current_page_item > a,
.site-shell-nav .page_item > a:hover {
  background: #eef6fb;
  color: #43617c;
}

.renovai-app {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

.renovai-sidebar {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  height: calc(100vh - var(--header-height));
  padding: 20px;
  background: rgba(248, 251, 254, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.renovai-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.renovai-brand-mark .custom-logo {
  max-height: 42px;
  width: auto;
}

.renovai-brand-mark .custom-logo-link {
  display: inline-flex;
  align-items: center;
}

/* Force-hide any WordPress site title / tagline text that may still render beside the logo */
body.renovai-chat-v31-theme .site-title,
body.renovai-chat-v31-theme .site-description,
.renovai-sidebar .site-title,
.renovai-sidebar .site-description,
.renovai-brand .site-title,
.renovai-brand .site-description,
.renovai-brand .custom-logo-link + .site-title,
.renovai-brand .custom-logo-link + .site-description,
.renovai-brand .custom-logo-link ~ .site-title,
.renovai-brand .custom-logo-link ~ .site-description {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}

.renovai-logo-fallback,
.renovai-new-chat,
.prompt-chip,
.send-btn,
.clear-history-btn,
.history-item {
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.renovai-new-chat:hover,
.prompt-chip:hover,
.send-btn:hover,
.clear-history-btn:hover,
.history-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(121, 152, 184, 0.14);
}

.renovai-logo-fallback {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  border-radius: 16px;
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, #9fcdea, #d8b796);
  box-shadow: var(--shadow);
}

.renovai-topbar h2,
.welcome-card h3,
.fallback-card h1 {
  margin: 0;
  color: #31445a;
}

.renovai-topbar p,
.disclaimer,
.helper-text,
.message-meta,
.chat-history-empty,
.fallback-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.renovai-new-chat {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f0f6fb);
  color: var(--text);
  font-weight: 600;
  padding: 13px 16px;
  cursor: pointer;
}

.renovai-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.renovai-panel h2,
.panel-heading-row h2 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.clear-history-btn {
  border: 0;
  border-radius: 999px;
  background: #eef4f9;
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
}

.renovai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-chip {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f6fafc);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 13px;
}

.history-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
  max-height: 44vh;
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #6f8398;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.renovai-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.renovai-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 16px;
}

.status-pill {
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 12px;
  color: #516779;
  background: #ffffff;
  border: 1px solid var(--line);
}

.status-pill.is-busy { background: #edf6fc; }
.status-pill.is-error { background: #faece8; }
.status-pill.is-success { background: #edf7f1; }

.renovai-thread-wrap {
  flex: 1;
  min-height: 0;
}

.chat-thread {
  width: min(940px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 160px;
}

.welcome-card,
.fallback-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  box-shadow: var(--shadow);
}

.welcome-card { padding: 28px; }

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #536a80;
  background: #f1f7fb;
  margin-bottom: 14px;
}

.welcome-card p,
.welcome-card ul,
.fallback-card code {
  color: var(--muted);
}

.welcome-card ul {
  margin: 18px 0 0 18px;
  padding: 0;
  line-height: 1.7;
}

.message-row {
  display: flex;
  margin: 0 0 18px;
}

.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }

.message-bubble {
  width: min(790px, 88%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, #ffffff, #f7fbfd);
}

.message-row.user .message-bubble {
  border-bottom-right-radius: 10px;
  background: linear-gradient(180deg, #e7f4fb, #d7ebf8);
}

.message-row.assistant .message-bubble {
  border-bottom-left-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #fbf7f2);
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 10px;
}

.message-role {
  color: #58758d;
  font-weight: 600;
}

.message-content {
  line-height: 1.7;
  font-size: 15px;
  overflow-wrap: anywhere;
  color: #304155;
}

.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  line-height: 1.25;
  margin: 1.1em 0 0.55em;
  color: #37506a;
}

.message-content p,
.message-content ul,
.message-content ol,
.message-content pre,
.message-content blockquote,
.message-content table {
  margin: 0 0 1em;
}

.message-content ul,
.message-content ol {
  padding-left: 1.35rem;
}

.message-content li + li {
  margin-top: 0.32rem;
}

.message-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 0.18em 0.4em;
  border-radius: 8px;
  background: #eef4f8;
}

.message-content pre {
  padding: 14px 16px;
  border-radius: 18px;
  overflow: auto;
  background: #f3f7fa;
  border: 1px solid rgba(120, 147, 180, 0.16);
}

.message-content pre code {
  padding: 0;
  background: transparent;
}

.message-content blockquote {
  padding: 12px 14px;
  border-left: 3px solid #a7d0ee;
  background: #f5f9fc;
  border-radius: 0 12px 12px 0;
  color: #53687d;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 14px;
  overflow: hidden;
}

.message-content th,
.message-content td {
  border: 1px solid rgba(120, 147, 180, 0.16);
  padding: 10px 12px;
  text-align: left;
}

.message-content th {
  background: #eef5fb;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #92bddc;
  opacity: 0.4;
  animation: typingPulse 1.1s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingPulse {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.36; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.composer-shell {
  position: sticky;
  bottom: 0;
  padding: 18px 20px 22px;
  background: linear-gradient(to top, rgba(255,255,255,0.98), rgba(255,255,255,0.88), rgba(255,255,255,0));
  backdrop-filter: blur(8px);
}

.chat-form {
  width: min(940px, calc(100% - 8px));
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255,255,255,0.96);
  box-shadow: var(--shadow);
  padding: 14px;
}

.chat-input {
  width: 100%;
  min-height: 52px;
  max-height: 220px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.6;
}

.chat-input::placeholder { color: #90a3b6; }

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

.helper-text { font-size: 12px; }

.send-btn {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  color: #4f5b67;
  background: linear-gradient(135deg, #bfe0f3, #e0c5a6);
  min-width: 92px;
}

.send-btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.disclaimer {
  width: min(940px, calc(100% - 8px));
  margin: 10px auto 0;
  text-align: center;
  font-size: 12px;
}

.error-notice {
  border: 1px solid rgba(214, 133, 120, 0.28);
  background: rgba(214, 133, 120, 0.1);
  color: #8f5a50;
  padding: 12px 14px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.source-link {
  text-decoration: none;
  color: #597694;
  background: #f4f8fb;
  border: 1px solid rgba(120, 147, 180, 0.16);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
}

.fallback-page {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  place-items: center;
  padding: 24px;
}

.fallback-card {
  width: min(840px, 100%);
  padding: 28px;
}

.fallback-content { margin-top: 20px; }

@media (max-width: 1024px) {
  :root { --sidebar-width: 290px; }
}

@media (max-width: 900px) {
  .renovai-app { grid-template-columns: 1fr; }

  .renovai-sidebar {
    position: static;
    top: auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-history { max-height: 220px; }
}

@media (max-width: 640px) {
  .site-shell-header-inner,
  .renovai-topbar,
  .composer-shell,
  .renovai-sidebar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .chat-thread {
    width: min(100%, calc(100% - 18px));
    padding-bottom: 148px;
  }

  .message-bubble { width: min(100%, 100%); }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .send-btn { width: 100%; }

  .site-shell-menu,
  .site-shell-nav .menu { gap: 4px; }

  .site-shell-menu a,
  .site-shell-nav .menu > li > a,
  .site-shell-nav .page_item > a {
    padding: 8px 10px;
    font-size: 13px;
  }
}
