:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --soft: #f7f9fc;
  --text: #1b2433;
  --muted: #66758f;
  --accent: #2f6fed;
  --danger: #d9534f;
  --success: #2f9e68;
  --border: rgba(27, 36, 51, 0.10);
  --shadow: 0 18px 50px rgba(18, 30, 50, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #f4f6fa 0%, #e9eef4 100%);
  color: var(--text);
  line-height: 1.5;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* Base form controls */
input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  opacity: 0.96;
}

button:active {
  transform: translateY(1px);
}

button.ghost-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

/* Layout */
.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 24px 40px;
}

.chat-card {
  width: 100%;
  max-width: 1080px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
}

/* Top area */
.chat-topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 28px 24px 18px;
  text-align: center;
}

.brand-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
}

.site-logo {
  max-width: 420px;
  width: 100%;
  height: auto;
}

.brand-text {
  max-width: 860px;
}

.brand-text h1 {
  margin: 42px 0 12px;
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #162033;
  text-wrap: balance;
}

.brand-text p {
  margin: 8px auto 0;
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.6;
  color: var(--muted);
  max-width: 680px;
}

.top-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
  width: 100%;
}

.top-actions select,
.top-actions button {
  min-height: 50px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 16px;
}

.top-actions select {
  min-width: 220px;
}

.top-actions button {
  white-space: nowrap;
}

.top-actions button:hover,
.top-actions select:hover {
  border-color: rgba(47, 111, 237, 0.28);
  box-shadow: 0 4px 14px rgba(47, 111, 237, 0.08);
}

/* Messages */
.messages {
  min-height: 320px;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.message {
  display: flex;
  margin-bottom: 14px;
}

.message:last-child {
  margin-bottom: 0;
}

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

.bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.message-actions button {
  font-size: 12px;
  padding: 6px 10px;
}

/* Chat form */
.chat-form {
  margin-top: 16px;
}

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

.provider-chip {
  color: var(--muted);
  font-size: 13px;
}

.chat-form-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.free-questions-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.free-questions-chip.is-registered {
  background: rgba(47, 158, 104, 0.12);
  color: #1e6f49;
}

.free-questions-chip.is-limit-reached {
  background: rgba(217, 83, 79, 0.12);
  color: #a23330;
}

/* Guest notice */
.guest-notice {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid rgba(47, 111, 237, 0.14);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(47, 111, 237, 0.06), rgba(47, 111, 237, 0.03));
  color: var(--muted);
  line-height: 1.6;
}

.guest-notice strong {
  color: var(--text);
}

.guest-notice a {
  color: var(--accent);
  font-weight: 700;
}

/* Alerts */
.flash,
.alert {
  max-width: 1000px;
  margin: 16px auto 0;
  padding: 12px 14px;
  border-radius: 12px;
}

.flash-success,
.alert.success {
  background: rgba(47, 158, 104, 0.12);
  color: #1e6f49;
}

.flash-error,
.alert.error {
  background: rgba(217, 83, 79, 0.10);
  color: #a23330;
}

/* Mini header */
.site-mini-header {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(27, 36, 51, 0.08);
}

.site-mini-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-mini-home {
  font-weight: 700;
}

.site-mini-auth {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-mini-auth-text {
  color: var(--muted);
  font-size: 14px;
}

.site-mini-auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
}

.site-mini-auth-link.is-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}


/* Turnstile */
.turnstile-wrap,
.turnstile-chat-wrap {
  margin: 6px 0 2px;
}

.turnstile-chat-wrap {
  display: flex;
  justify-content: flex-start;
}

.turnstile-wrap .cf-turnstile,
.turnstile-chat-wrap .cf-turnstile {
  max-width: 100%;
}

/* Honeypot */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: block;
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner-inner {
  max-width: 980px;
  margin: 0 auto;
  background: #152238;
  color: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(10, 18, 30, 0.28);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.cookie-banner-text {
  flex: 1 1 auto;
  min-width: 0;
}

.cookie-banner-text strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
  color: #fff;
}

.cookie-banner-text p {
  margin: 0;
  line-height: 1.6;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.74);
}

.cookie-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cookie-btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}

.cookie-btn-primary {
  background: #2f6fed;
  color: #fff;
}

.cookie-btn-primary:hover {
  background: #245fe0;
}

.cookie-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.cookie-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.cookie-btn-light {
  background: #fff;
  color: #152238;
}

.cookie-btn-light:hover {
  background: #f2f5fa;
}

/* Footer */
.site-footer {
  margin-top: 40px;
  background: #152238;
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
}

.footer-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 38px 24px 28px;
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.footer-brand {
  min-width: 0;
}

.footer-logo {
  width: 100%;
  max-width: 200px;
  filter: brightness(0) invert(1);
  opacity: 0.9;
  margin-bottom: 14px;
}

.footer-tagline {
  margin: 0;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.62);
  max-width: 360px;
  font-size: 15px;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.footer-col {
  min-width: 0;
}

.footer-col h4 {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 700;
}

.footer-col a {
  display: block;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.6;
}

.footer-col a:last-child {
  margin-bottom: 0;
}

.footer-col a:hover {
  color: #fff;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 24px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 18px;
  flex-wrap: wrap;
}

.footer-bottom p {
  margin: 0;
  color: rgba(255, 255, 255, 0.48);
  line-height: 1.6;
}

.footer-luka-credit a {
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.6;
}

.footer-luka-credit a:hover {
  color: #fff;
}

.footer-luka-credit strong {
  color: rgba(255, 255, 255, 0.9);
}

/* Responsive */
@media (max-width: 900px) {
  .bubble {
    max-width: 90%;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 20px;
  }
}

@media (max-width: 768px) {
  .site-logo {
    max-width: 360px;
  }

  .brand-text h1 {
    margin-top: 26px;
    font-size: 42px;
  }

  .brand-text p {
    font-size: 18px;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .top-actions select,
  .top-actions button {
    width: 100%;
    max-width: 320px;
  }

  .cookie-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .cookie-banner-inner {
    padding: 16px;
    border-radius: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .cookie-banner-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .cookie-btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 14px;
    align-items: flex-start;
  }

  .chat-card {
    padding: 18px;
    border-radius: 18px;
  }

  .chat-topbar {
    gap: 14px;
    margin-bottom: 14px;
    padding: 18px 12px 14px;
  }

  .site-logo {
    max-width: 320px;
  }

  .messages {
    min-height: 260px;
    max-height: 54vh;
    padding: 12px;
  }

  .bubble {
    max-width: 96%;
    font-size: 15px;
    padding: 11px 12px;
  }

  textarea {
    min-height: 110px;
    font-size: 16px;
  }

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

  .chat-form-actions button {
    width: 100%;
  }

  .chat-form-meta {
    width: 100%;
    justify-content: center;
  }

  .provider-chip {
    text-align: center;
  }

  .site-mini-header-inner {
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
  }

  .guest-notice {
    margin-bottom: 14px;
    padding: 12px 14px;
  }

  .site-footer {
    margin-top: 32px;
  }

  .footer-inner {
    padding: 28px 18px 22px;
    gap: 24px;
  }

  .footer-logo {
    max-width: 170px;
    margin-bottom: 12px;
  }

  .footer-tagline {
    max-width: 100%;
    font-size: 15px;
  }

  .footer-links {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .footer-col h4 {
    margin-bottom: 8px;
  }

  .footer-col a {
    margin-bottom: 8px;
    font-size: 15px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px 18px 18px;
  }

  .footer-bottom p,
  .footer-luka-credit a {
    font-size: 14px;
  }
}