body.page-template-page-ai-chat {
  background: #121212;
}

html.gls-ai-chat-active,
html.gls-ai-chat-active body.page-template-page-ai-chat {
  height: 100%;
  overflow: hidden;
}

body.page-template-page-ai-chat #masthead,
body.page-template-page-ai-chat .site-header,
body.page-template-page-ai-chat .primary-navigation,
body.page-template-page-ai-chat #colophon,
body.page-template-page-ai-chat .site-footer,
body.page-template-page-ai-chat #site-bottom,
body.page-template-page-ai-chat .gls-site-bottom {
  display: none !important;
}

body.page-template-page-ai-chat #page,
body.page-template-page-ai-chat #content,
body.page-template-page-ai-chat .site-content,
body.page-template-page-ai-chat .site-content > .clear {
  width: 100%;
  height: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.page-template-page-ai-chat #content,
body.page-template-page-ai-chat .site-content {
  padding-bottom: 0;
}

.gls-ai-chat-page {
  --gls-ai-bg: #151515;
  --gls-ai-panel: #1d1d1d;
  --gls-ai-panel-strong: #242424;
  --gls-ai-border: rgba(255, 255, 255, 0.09);
  --gls-ai-text: rgba(255, 255, 255, 0.9);
  --gls-ai-muted: rgba(255, 255, 255, 0.52);
  --gls-ai-dim: rgba(255, 255, 255, 0.34);
  --gls-ai-accent: #e23d3d;
  --gls-ai-accent-soft: rgba(226, 61, 61, 0.18);
  --gls-ai-warm: #f0c26a;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 150px),
    var(--gls-ai-bg);
}

.gls-ai-chat-shell {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.gls-ai-chat-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--gls-ai-panel);
}

.gls-ai-chat-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px 10px;
  padding-top: calc(11px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--gls-ai-border);
  background: rgba(29, 29, 29, 0.96);
  backdrop-filter: blur(14px);
}

.gls-ai-chat-title {
  min-width: 0;
  flex: 1 1 auto;
}

.gls-ai-chat-kicker {
  margin: 0 0 2px;
  color: var(--gls-ai-warm);
  font-size: 11px;
  line-height: 1.2;
}

.gls-ai-chat-header h1 {
  margin: 0;
  color: var(--gls-ai-text);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.gls-ai-chat-menu,
.gls-ai-chat-clear,
.gls-ai-chat-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--gls-ai-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}

.gls-ai-chat-menu {
  flex: 0 0 auto;
  width: 40px;
  padding: 0;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.76);
  font-size: 16px;
}

.gls-ai-chat-clear {
  flex: 0 0 auto;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.76);
}

.gls-ai-chat-menu:active,
.gls-ai-chat-clear:active,
.gls-ai-chat-form button:active {
  transform: scale(0.98);
}

.gls-ai-chat-status {
  position: relative;
  z-index: 1;
  overflow: hidden;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  background: rgba(18, 18, 18, 0.72);
  color: var(--gls-ai-dim);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gls-ai-chat-messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 10px 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.gls-ai-message {
  width: fit-content;
  max-width: min(88%, 720px);
  margin: 0 0 10px;
}

.gls-ai-message__meta {
  margin: 0 2px 4px;
  color: var(--gls-ai-dim);
  font-size: 11px;
  line-height: 1.2;
}

.gls-ai-message__body {
  padding: 9px 11px;
  border: 1px solid var(--gls-ai-border);
  border-radius: 8px;
  color: var(--gls-ai-text);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.gls-ai-message--assistant .gls-ai-message__body {
  background: rgba(255, 255, 255, 0.045);
}

.gls-ai-message__body--thinking {
  min-width: 132px;
  color: rgba(255, 255, 255, 0.62);
}

.gls-ai-thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.gls-ai-thinking__icon {
  width: 28px;
  height: 16px;
  color: var(--gls-ai-warm);
  flex: 0 0 auto;
}

.gls-ai-thinking__dot {
  fill: currentColor;
  opacity: 0.28;
  animation: gls-ai-thinking-pulse 1.05s ease-in-out infinite;
}

.gls-ai-thinking__dot--2 {
  animation-delay: 0.14s;
}

.gls-ai-thinking__dot--3 {
  animation-delay: 0.28s;
}

.gls-ai-thinking__text {
  font-size: 14px;
}

@keyframes gls-ai-thinking-pulse {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }

  40% {
    opacity: 0.9;
    transform: translateY(-2px);
  }
}

.gls-ai-message__body a {
  color: #f0c26a;
  text-decoration: underline;
  text-decoration-color: rgba(240, 194, 106, 0.42);
  text-underline-offset: 3px;
}

.gls-ai-message__body a:active {
  color: #ffd885;
}

.gls-ai-message--user {
  margin-left: auto;
}

.gls-ai-message--user .gls-ai-message__meta {
  text-align: right;
}

.gls-ai-message--user .gls-ai-message__body {
  border-color: rgba(226, 61, 61, 0.26);
  background: var(--gls-ai-accent-soft);
}

.gls-ai-sources {
  margin-top: 6px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.gls-ai-sources__title {
  margin: 0 0 5px;
  color: rgba(240, 194, 106, 0.82);
  font-size: 11px;
  line-height: 1.35;
}

.gls-ai-sources__terms,
.gls-ai-sources__empty {
  margin: 0 0 5px;
  color: var(--gls-ai-dim);
  font-size: 11px;
  line-height: 1.35;
}

.gls-ai-source {
  display: grid;
  gap: 2px;
  padding: 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
}

.gls-ai-source:active {
  color: #fff;
}

.gls-ai-source__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.gls-ai-source__meta {
  color: var(--gls-ai-dim);
  font-size: 11px;
  line-height: 1.3;
}

.gls-ai-chat-form {
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--gls-ai-border);
  background: rgba(24, 24, 24, 0.97);
  backdrop-filter: blur(16px);
}

.gls-ai-chat-form textarea {
  width: 100%;
  min-height: 44px;
  max-height: 118px;
  resize: none;
  border: 1px solid rgba(255, 255, 255, 0.115);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--gls-ai-text);
  font-size: 16px;
  line-height: 1.42;
  padding: 10px 11px;
}

.gls-ai-chat-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.32);
}

.gls-ai-chat-form textarea:focus {
  border-color: rgba(226, 61, 61, 0.58);
  outline: none;
}

.gls-ai-chat-form button {
  min-width: 64px;
  background: var(--gls-ai-accent);
  border-color: var(--gls-ai-accent);
  color: #fff;
  font-weight: 700;
}

.gls-ai-chat-form button:disabled {
  cursor: wait;
  opacity: 0.66;
}

@media (hover: hover) {
  .gls-ai-chat-menu:hover,
  .gls-ai-chat-clear:hover,
  .gls-ai-chat-form button:hover {
    border-color: rgba(255, 115, 115, 0.6);
  }

  .gls-ai-source:hover {
    color: #fff;
  }
}

@media (min-width: 760px) {
  .gls-ai-chat-page {
    height: 100dvh;
    padding: 16px;
  }

  .gls-ai-chat-shell {
    width: min(920px, 100%);
  }

  .gls-ai-chat-panel {
    height: calc(100dvh - 32px);
    min-height: 0;
    border: 1px solid var(--gls-ai-border);
    border-radius: 8px;
    box-shadow: 0 22px 72px rgba(0, 0, 0, 0.34);
  }

  .gls-ai-chat-header {
    padding: 16px 18px 13px;
  }

  .gls-ai-chat-header h1 {
    font-size: 23px;
  }

  .gls-ai-chat-status {
    padding: 8px 18px;
    font-size: 12px;
  }

  .gls-ai-chat-messages {
    padding: 18px;
  }

  .gls-ai-message {
    max-width: 76%;
    margin-bottom: 13px;
  }

  .gls-ai-chat-form {
    grid-template-columns: minmax(0, 1fr) 86px;
    gap: 10px;
    padding: 13px;
  }

  .gls-ai-chat-form textarea {
    min-height: 48px;
    max-height: 150px;
  }
}

body.admin-bar.page-template-page-ai-chat .gls-ai-chat-page {
  height: calc(100dvh - 46px);
}

@media (min-width: 783px) {
  body.admin-bar.page-template-page-ai-chat .gls-ai-chat-page {
    height: calc(100dvh - 32px);
  }

  body.admin-bar.page-template-page-ai-chat .gls-ai-chat-panel {
    height: calc(100dvh - 64px);
  }
}
