:root {
  --bg: #fdf6ec;
  --panel: #ffffff;
  --ink: #2b2119;
  --muted: #7a6a58;
  --accent: #c94f4f;
  --accent-2: #d97b3f;
  --al-bubble: #fff3e2;
  --user-bubble: #e6f0ea;
  --border: #e7dcc9;
  --green: #3f7a4f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background-image:
    repeating-linear-gradient(45deg, rgba(201,79,79,0.035) 0, rgba(201,79,79,0.035) 12px, transparent 12px, transparent 24px);
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* ---------- header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.avatar {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.avatar svg { width: 100%; height: 100%; }

.brand-text h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.1;
}
.al-name { color: var(--accent); }

.tagline {
  margin: 2px 0 0;
  font-style: italic;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
}

.disclaimer {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: .85rem;
}

.tip-btn {
  background: var(--accent-2);
  color: #fff;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.tip-btn:hover { filter: brightness(1.05); }

/* ---------- ad slots ---------- */
.ad-slot {
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  margin: 14px 0;
  background: rgba(0,0,0,.02);
}

/* ---------- chat ---------- */
.chat-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.05);
}

.chat-window {
  min-height: 340px;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: .97rem;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.msg.al {
  align-self: flex-start;
  background: var(--al-bubble);
  border-bottom-left-radius: 4px;
}

.msg.al .msg-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 3px;
  letter-spacing: .04em;
}

.msg.loading {
  color: var(--muted);
  font-style: italic;
}

.msg-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.msg-actions button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .75rem;
  cursor: pointer;
  padding: 0;
}
.msg-actions button:hover { color: var(--accent); text-decoration: underline; }

.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

#chat-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: #fffdf9;
}
#chat-input:focus { outline: 2px solid var(--accent-2); }

#send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 20px;
  font-weight: 700;
  cursor: pointer;
}
#send-btn:hover { filter: brightness(1.05); }
#send-btn:disabled { opacity: .5; cursor: not-allowed; }

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: .8rem;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--green);
  cursor: pointer;
  font-size: .8rem;
  text-decoration: underline;
  padding: 0;
}

/* ---------- footer ---------- */
.site-footer {
  margin-top: 24px;
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
}
.footer-links a { color: var(--muted); }

@media (max-width: 480px) {
  .brand-text h1 { font-size: 1.4rem; }
  .tip-btn { font-size: .8rem; padding: 8px 12px; }
}
