:root {
  --bg: #f9fcf7;
  --bg-soft: #f2f8ef;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-strong: #ffffff;
  --panel-alt: #edf7e7;
  --line: rgba(116, 150, 110, 0.20);
  --line-strong: rgba(116, 150, 110, 0.34);
  --text: #2f4030;
  --muted: #6f8370;
  --accent: #b7ddb0;
  --accent-2: #d7c8a0;
  --accent-3: #dbeed4;
  --success: #7fb07a;
  --danger: #c78472;
  --shadow: 0 18px 42px rgba(101, 132, 95, 0.12);
  --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(183, 221, 176, 0.42), transparent 28%),
    radial-gradient(circle at top right, rgba(215, 200, 160, 0.28), transparent 22%),
    linear-gradient(180deg, #ffffff 0%, #f8fcf6 60%, #f6f4ec 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: #5a8764; }
a:hover { color: #7a6a52; }
.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: #48624b;
  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: #edf7e9;
  color: #3f6044;
}

.bestdiet-app {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}
.bestdiet-sidebar {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  height: calc(100vh - var(--header-height));
  padding: 20px;
  background: rgba(248, 252, 246, 0.94);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.bestdiet-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bestdiet-brand-mark .custom-logo,
.bestdiet-default-logo {
  max-height: 52px;
  width: auto;
  display: block;
}
.bestdiet-brand-mark .custom-logo-link {
  display: inline-flex;
  align-items: center;
}
body.bestdiet-assistant-theme .site-title,
body.bestdiet-assistant-theme .site-description,
.bestdiet-sidebar .site-title,
.bestdiet-sidebar .site-description,
.bestdiet-brand .site-title,
.bestdiet-brand .site-description,
.bestdiet-brand .custom-logo-link + .site-title,
.bestdiet-brand .custom-logo-link + .site-description,
.bestdiet-brand .custom-logo-link ~ .site-title,
.bestdiet-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;
}
.bestdiet-logo-fallback,
.bestdiet-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;
}
.bestdiet-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(114, 152, 107, 0.14);
}
.bestdiet-new-chat {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f1f8ed);
  color: var(--text);
  font-weight: 600;
  padding: 13px 16px;
  cursor: pointer;
}
.bestdiet-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.bestdiet-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: #eef5ea;
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
}
.bestdiet-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, #f8fcf6);
  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: #6d816f;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.bestdiet-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.bestdiet-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 16px;
}
.bestdiet-topbar h2,
.welcome-card h3,
.fallback-card h1 { margin: 0; color: #314436; }
.bestdiet-topbar p,
.disclaimer,
.helper-text,
.message-meta,
.chat-history-empty,
.fallback-card p {
  margin: 4px 0 0;
  color: var(--muted);
}
.status-pill {
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 12px;
  color: #516753;
  background: #ffffff;
  border: 1px solid var(--line);
}
.status-pill.is-busy { background: #edf7ea; }
.status-pill.is-error { background: #faece8; }
.status-pill.is-success { background: #eef7ef; }
.bestdiet-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, #f9fcf7);
  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: #536b56;
  background: #f1f8ed;
  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, #f7fbf5);
}
.message-row.user .message-bubble {
  border-bottom-right-radius: 10px;
  background: linear-gradient(180deg, #eaf5e4, #dcedd2);
}
.message-row.assistant .message-bubble {
  border-bottom-left-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #fcfaf6);
}
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 10px;
}
.message-role { color: #58745c; font-weight: 600; }
.message-content {
  line-height: 1.7;
  font-size: 15px;
  overflow-wrap: anywhere;
  color: #304133;
}
.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: #39533f;
}
.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: #eef4ea;
}
.message-content pre {
  padding: 14px 16px;
  border-radius: 18px;
  overflow: auto;
  background: #f4f8f1;
  border: 1px solid rgba(116, 150, 110, 0.16);
}
.message-content pre code { padding: 0; background: transparent; }
.message-content blockquote {
  padding: 12px 14px;
  border-left: 3px solid #b7ddb0;
  background: #f4f9f1;
  border-radius: 0 12px 12px 0;
  color: #536a58;
}
.message-content table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 14px;
  overflow: hidden;
}
.message-content th,
.message-content td {
  border: 1px solid rgba(116, 150, 110, 0.16);
  padding: 10px 12px;
  text-align: left;
}
.message-content th { background: #eef7ea; }
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #93be8e;
  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: #8fa18f; }
.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: #44564a;
  background: linear-gradient(135deg, #cfe8ca, #e2d2a8);
  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(199, 132, 114, 0.28);
  background: rgba(199, 132, 114, 0.1);
  color: #87584f;
  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: #597560;
  background: #f4f8f1;
  border: 1px solid rgba(116, 150, 110, 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) {
  .bestdiet-app { grid-template-columns: 1fr; }
  .bestdiet-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,
  .bestdiet-topbar,
  .composer-shell,
  .bestdiet-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; }
}
