/* Janus.guru Chat UI — Light Theme */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root {
  --surface-canvas: #f5f3ee;
  --surface-muted: #faf8f4;
  --surface-base: #ffffff;
  --surface-elevated: rgba(255,255,255,0.88);
  --surface-hover: #f0ede6;
  --surface-user-message: #1a1714;
  --surface-bot-message: #ffffff;
  --color-accent-primary: #c9a84c;
  --color-accent-primary-hover: #8a7330;
  --color-accent-primary-soft: #f0e6c8;
  --color-accent-primary-subtle: #faf5e8;
  --color-status-negative: #b5453b;
  --color-text-primary: #1a1714;
  --color-text-secondary: #5a564e;
  --color-text-muted: #9a9590;
  --color-text-on-accent: #ffffff;
  --color-border-default: #e0dcd4;
  --color-border-subtle: #ece8e0;
  --shadow-panel: 0 18px 42px rgba(26,23,20,0.08);
  --shadow-message: 0 1px 3px rgba(26,23,20,0.04);
  --radius: 12px;
  --radius-sm: 10px;
  --max-w: 880px;
  --content-w: 760px;
  --header-h: 64px;
  --input-h: 108px;
  --font-display: 'IBM Plex Sans', 'Rubik', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'IBM Plex Sans', 'Rubik', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top, rgba(201,168,76,0.09), transparent 34%),
    linear-gradient(180deg, #f8f5ef 0%, #f5f3ee 48%, #f7f4ee 100%);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

.seo-chat-intro {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── Header ─────────────────────────────────── */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(255,255,255,0.82);
  border-bottom: 1px solid var(--color-border-subtle);
  backdrop-filter: blur(18px);
  box-shadow: 0 1px 0 rgba(26,23,20,0.03);
  z-index: 100;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.logo {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--color-text-primary);
  flex: 0 0 auto;
}
.logo-dot { color: var(--color-accent-primary); }
.corpus-badge {
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  display: none;
  max-width: min(48vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.corpus-badge.visible { display: inline-block; }
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.lang-btn {
  font: 600 11px/1 var(--font-display);
  letter-spacing: 0;
}
.btn-clear {
  width: 36px;
  height: 36px;
}

/* ── Chat Area ──────────────────────────────── */
main {
  position: fixed;
  top: var(--header-h);
  bottom: var(--input-h);
  left: 0;
  right: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  background: transparent;
}
#messages {
  width: min(100%, var(--content-w));
  margin: 0 auto;
  padding: 36px 20px 52px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}

/* ── Welcome ────────────────────────────────── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  width: min(100%, 560px);
  min-height: min(420px, calc(100vh - var(--header-h) - var(--input-h) - 120px));
  margin: auto;
  padding: 44px 36px;
  background: var(--surface-elevated);
  border: 1px solid rgba(201,168,76,0.24);
  border-radius: 12px;
  box-shadow: var(--shadow-panel);
}
.welcome-logo {
  width: 74px;
  height: 74px;
  margin-bottom: 24px;
  opacity: 0.68;
}
.welcome h2 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3vw, 2.4rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0;
  margin-bottom: 12px;
  color: var(--color-text-primary);
}
.welcome p {
  max-width: 34ch;
  font-size: 1rem;
  color: var(--color-text-secondary);
  line-height: 1.65;
}
.welcome.hidden { display: none; }

/* ── Messages ───────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  max-width: min(86%, 620px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.msg.user {
  align-self: flex-end;
}
.msg.bot {
  align-self: flex-start;
}
.msg-bubble {
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.68;
  font-size: 0.97rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg.user .msg-bubble {
  background: var(--surface-user-message);
  color: var(--color-text-on-accent);
  border-bottom-right-radius: 4px;
}
.msg.bot .msg-bubble {
  background: var(--surface-bot-message);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-default);
  border-bottom-left-radius: 4px;
  box-shadow: 0 10px 26px rgba(26,23,20,0.04);
}
.msg-meta {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.msg.user .msg-meta { text-align: right; }

/* ── Bot message content (Markdown) ─────────── */
.msg.bot .msg-bubble p { margin-bottom: 8px; }
.msg.bot .msg-bubble p:last-child { margin-bottom: 0; }
.msg.bot .msg-bubble strong { color: var(--color-text-primary); font-weight: 600; }
.msg.bot .msg-bubble ul,
.msg.bot .msg-bubble ol {
  margin: 6px 0 6px 20px;
}
.msg.bot .msg-bubble li { margin-bottom: 4px; }
.msg.bot .msg-bubble a { color: var(--color-accent-primary-hover); text-decoration: underline; }
.msg.bot .sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg.bot .sources-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--color-text-primary);
}
.msg.bot .source-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.msg.bot .source-link,
.msg.bot .source-text {
  display: block;
  color: inherit;
  text-decoration: none;
}
.source-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 12px;
  background: var(--surface-base);
}
.source-link .source-card:hover,
.source-link .source-card:focus-visible {
  border-color: var(--color-accent-primary);
  background: var(--color-accent-primary-subtle);
}
.source-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.source-card-kicker {
  font-size: 0.62rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--color-text-muted);
}
.source-card-title {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--color-text-primary);
}
.source-card-arrow {
  flex: 0 0 auto;
  color: var(--color-accent-primary-hover);
  font-size: 0.9rem;
  line-height: 1.2;
  padding-top: 2px;
}
.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.answer-action {
  min-height: 30px;
  padding: 6px 10px;
  font: 500 0.75rem/1 var(--font-body);
  cursor: pointer;
}
.answer-action:hover {
  border-color: var(--color-accent-primary);
}
.answer-action.is-active {
  border-color: var(--color-accent-primary);
  color: var(--color-accent-primary-hover);
}
.answer-actions-note {
  width: 100%;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--color-text-muted);
  padding: 2px 2px 0;
}

/* ── Typing indicator ───────────────────────── */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Error / Retry ──────────────────────────── */
.msg-error {
  color: var(--color-status-negative);
}
.btn-retry {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* ── Input Area ─────────────────────────────── */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(245,243,238,0.75), rgba(245,243,238,0.96));
  border-top: 1px solid var(--color-border-subtle);
  padding: 14px 20px 14px;
  backdrop-filter: blur(16px);
  z-index: 100;
}
.input-wrap {
  width: min(100%, var(--content-w));
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--color-border-default);
  border-radius: 12px;
  padding: 10px 10px 10px 18px;
  box-shadow: 0 8px 24px rgba(26,23,20,0.05);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input-wrap:focus-within {
  border-color: var(--color-accent-primary);
  box-shadow: 0 10px 30px rgba(201,168,76,0.16);
  background: rgba(255,255,255,0.98);
}
#queryInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-size: 0.97rem;
  line-height: 1.6;
  resize: none;
  min-height: 28px;
  max-height: 150px;
  font-family: var(--font-body);
}
#queryInput::placeholder { color: var(--color-text-muted); }
#btnSend {
  width: 46px;
  height: 46px;
  background: var(--color-accent-primary);
  color: var(--color-text-on-accent);
  flex-shrink: 0;
}
#btnSend:hover { background: var(--color-accent-primary-hover); }
#btnSend:disabled { opacity: 0.4; cursor: not-allowed; }
.input-hint {
  width: min(100%, var(--content-w));
  margin: 8px auto 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  letter-spacing: 0;
}

/* ── Corpus selector (multi-corpus) ─────────── */
.corpus-select {
  padding: 0 12px;
  height: 42px;
  font-size: 0.86rem;
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
  min-width: 0;
  max-width: min(52vw, 360px);
  flex: 1 1 auto;
}

/* ── Scrollbar ──────────────────────────────── */
main::-webkit-scrollbar { width: 6px; }
main::-webkit-scrollbar-track { background: transparent; }
main::-webkit-scrollbar-thumb { background: var(--color-border-default); border-radius: 3px; }
main::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 600px) {
  :root {
    --header-h: 62px;
    --input-h: 96px;
    --max-w: 100%;
  }
  header {
    padding: 8px 12px;
    gap: 8px;
    align-items: center;
  }
  .header-left {
    gap: 8px;
    min-width: 0;
  }
  .header-right {
    gap: 8px;
  }
  .logo {
    font-size: 0.92rem;
    letter-spacing: 0;
  }
  .lang-switcher {
    padding: 3px;
    gap: 2px;
  }
  .lang-btn {
    min-width: 34px;
    height: 26px;
    font-size: 10px;
  }
  .corpus-badge {
    font-size: 0.68rem;
    padding: 2px 8px;
    max-width: calc(100vw - 182px);
  }
  .corpus-select {
    font-size: 0.75rem;
    padding: 4px 8px;
    max-width: calc(100vw - 182px);
  }
  .btn-clear {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
  }
  #messages { padding: 18px 12px 36px; }
  .msg { max-width: 94%; }
  .msg-bubble { font-size: 0.92rem; padding: 12px 15px; }
  .source-card { padding: 9px 10px; }
  .welcome {
    width: 100%;
    min-height: min(360px, calc(100vh - var(--header-h) - var(--input-h) - 80px));
    padding: 32px 22px;
    border-radius: 16px;
  }
  .welcome h2 { font-size: 1.7rem; }
  .welcome p {
    max-width: 28ch;
    margin: 0 auto;
  }
  footer { padding: 10px 12px 10px; }
  .input-wrap { padding: 8px 8px 8px 14px; border-radius: 12px; }
  #queryInput {
    min-height: 24px;
    font-size: 0.9rem;
  }
  #btnSend {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
  .input-hint {
    font-size: 0.65rem;
    line-height: 1.35;
  }
}
