:root {
  --lai-ink: #f5f7ff;
  --lai-muted: #98a1b6;
  --lai-panel: rgba(12, 16, 27, 0.92);
  --lai-line: rgba(255, 255, 255, 0.1);
  --lai-accent: #7c6cff;
  --lai-accent-2: #42d3b2;
}

.local-ai-chat-page .entry-header { display: none; }
.local-ai-chat-page .site-content > .ast-container { max-width: none; padding: 0; }
.local-ai-chat-page .content-area { width: 100%; margin: 0; }
.local-ai-chat-page .site-main > article { margin: 0; padding: 0; }
.local-ai-chat-page .entry-content { margin: 0; }

.lai-shell,
.lai-shell * { box-sizing: border-box; }

.lai-shell {
  min-height: min(780px, calc(100vh - 110px));
  padding: clamp(18px, 4vw, 48px);
  color: var(--lai-ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(124, 108, 255, 0.22), transparent 34%),
    radial-gradient(circle at 90% 100%, rgba(66, 211, 178, 0.14), transparent 32%),
    #080b13;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.lai-app {
  width: min(940px, 100%);
  min-height: min(690px, calc(100vh - 180px));
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  border: 1px solid var(--lai-line);
  border-radius: 28px;
  background: var(--lai-panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(22px);
}

.lai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--lai-line);
}

.lai-brand,
.lai-actions { display: flex; align-items: center; gap: 12px; }

.lai-mark,
.lai-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(145deg, var(--lai-accent), #4c3ed2);
  color: white;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.lai-mark { width: 44px; height: 44px; border-radius: 14px; font-size: 0.88rem; }
.lai-brand h1 { margin: 0; color: white; font-size: 1.1rem; line-height: 1.25; }
.lai-brand p { margin: 3px 0 0; color: var(--lai-muted); font-size: 0.82rem; line-height: 1.35; }

.lai-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--lai-muted);
  font-size: 0.82rem;
}

.lai-status i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--lai-accent-2);
  box-shadow: 0 0 12px rgba(66, 211, 178, 0.75);
}

.lai-status.is-active i { animation: lai-pulse 1.2s infinite; }

.lai-clear {
  padding: 9px 13px;
  border: 1px solid var(--lai-line);
  border-radius: 11px;
  color: #dfe3f1;
  background: rgba(255, 255, 255, 0.04);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.lai-clear:hover { background: rgba(255, 255, 255, 0.09); }

.lai-messages {
  min-height: 360px;
  max-height: 58vh;
  padding: 30px clamp(18px, 4vw, 44px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}

.lai-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 82%;
  margin-bottom: 22px;
  animation: lai-in .25s ease-out both;
}

.lai-message.lai-user { margin-left: auto; flex-direction: row-reverse; }
.lai-avatar { width: 34px; height: 34px; border-radius: 11px; font-size: 0.72rem; }
.lai-user .lai-avatar { background: #252b3c; color: #cbd1e1; }

.lai-bubble {
  padding: 13px 16px;
  border: 1px solid var(--lai-line);
  border-radius: 6px 17px 17px 17px;
  background: rgba(255,255,255,.045);
  color: #eef0f7;
  font-size: 1rem;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.lai-user .lai-bubble {
  border-color: rgba(124, 108, 255, .38);
  border-radius: 17px 6px 17px 17px;
  background: linear-gradient(145deg, rgba(124,108,255,.32), rgba(86,72,202,.22));
}

.lai-bubble p { margin: 0; }
.lai-bubble code { padding: .15em .4em; border-radius: 5px; background: rgba(0,0,0,.28); font-size: .9em; }
.lai-bubble pre { margin: 10px 0 2px; padding: 14px; overflow: auto; border-radius: 10px; background: #05070c; }

.lai-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 clamp(18px, 4vw, 36px);
  padding: 10px 10px 10px 18px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  background: rgba(255,255,255,.055);
  transition: border-color .2s, box-shadow .2s;
}

.lai-composer:focus-within { border-color: rgba(124,108,255,.7); box-shadow: 0 0 0 4px rgba(124,108,255,.1); }
.lai-composer textarea { width: 100%; min-height: 32px; max-height: 160px; padding: 5px 0; resize: none; border: 0; outline: 0; color: white; background: transparent; font: inherit; font-size: 1rem; line-height: 1.45; }
.lai-composer textarea::placeholder { color: #727b91; }

.lai-composer button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, #8878ff, #6252e2);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(98,82,226,.28);
}

.lai-composer button:disabled { opacity: .45; cursor: wait; }
.lai-composer svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lai-note { margin: 10px 0 16px; color: #6f788d; text-align: center; font-size: .78rem; }

.lai-dots { display: inline-flex; gap: 5px; padding: 5px 2px; }
.lai-dots i { width: 6px; height: 6px; border-radius: 50%; background: #9ca5ba; animation: lai-dot 1.1s infinite ease-in-out; }
.lai-dots i:nth-child(2) { animation-delay: .14s; }
.lai-dots i:nth-child(3) { animation-delay: .28s; }

@keyframes lai-dot { 0%, 70%, 100% { transform: translateY(0); opacity: .45; } 35% { transform: translateY(-5px); opacity: 1; } }
@keyframes lai-pulse { 50% { opacity: .35; transform: scale(.75); } }
@keyframes lai-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 640px) {
  .lai-shell { min-height: calc(100vh - 70px); padding: 0; }
  .lai-app { min-height: calc(100vh - 70px); border-radius: 0; border-left: 0; border-right: 0; }
  .lai-header { padding: 15px 16px; }
  .lai-status span { display: none; }
  .lai-messages { max-height: none; min-height: 0; padding: 22px 14px; }
  .lai-message { max-width: 94%; }
  .lai-composer { margin: 0 12px; }
  .lai-note { margin-bottom: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .lai-message, .lai-dots i, .lai-status.is-active i { animation: none; }
  .lai-messages { scroll-behavior: auto; }
}
