/* ===== Chat page layout fixes ===== */
/* Some global styles (style.css) center pages vertically via flex; for /chat we want top-aligned. */
body {
  display: block !important;
  min-height: auto !important;
  margin: 0;
  color: rgba(255,255,255,.92);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Give the page a proper “hero” background so the top area doesn’t feel like empty white space. */
.page {
  position: relative;
}

/* Aurora animatable variables (so the blobs actually move) */
@property --a1x { syntax: '<percentage>'; inherits: false; initial-value: 20%; }
@property --a1y { syntax: '<percentage>'; inherits: false; initial-value: 10%; }
@property --a2x { syntax: '<percentage>'; inherits: false; initial-value: 80%; }
@property --a2y { syntax: '<percentage>'; inherits: false; initial-value: 15%; }
@property --a3x { syntax: '<percentage>'; inherits: false; initial-value: 50%; }
@property --a3y { syntax: '<percentage>'; inherits: false; initial-value: 100%; }

.page{
  --a1x: 20%; --a1y: 10%;
  --a2x: 80%; --a2y: 15%;
  --a3x: 50%; --a3y: 100%;
}

.page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 800px at var(--a1x) var(--a1y), rgba(120, 170, 255, 0.14), transparent 58%),
    radial-gradient(900px 700px at var(--a2x) var(--a2y), rgba(0, 255, 220, 0.12), transparent 60%),
    radial-gradient(1100px 900px at var(--a3x) var(--a3y), rgba(255, 255, 255, 0.08), transparent 62%),
    linear-gradient(180deg, rgba(10, 12, 27, 1) 0%, rgba(7, 9, 20, 1) 60%, rgba(6, 8, 18, 1) 100%);
}

.page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,.55) 0, transparent 55%),
    radial-gradient(1px 1px at 35% 55%, rgba(255,255,255,.35) 0, transparent 55%),
    radial-gradient(1px 1px at 62% 32%, rgba(255,255,255,.45) 0, transparent 55%),
    radial-gradient(1px 1px at 78% 70%, rgba(255,255,255,.30) 0, transparent 55%),
    radial-gradient(1px 1px at 88% 18%, rgba(255,255,255,.40) 0, transparent 55%);
  background-size: 100% 100%;
}

/* Subtle vignette to pull focus toward the center (pairs well with the border glow) */
.page::after{
  /* keep existing star speckles; add vignette via background layers */
  background-image:
    radial-gradient(1200px 800px at 50% 45%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.22) 55%, rgba(0,0,0,0.55) 100%),
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,.55) 0, transparent 55%),
    radial-gradient(1px 1px at 35% 55%, rgba(255,255,255,.35) 0, transparent 55%),
    radial-gradient(1px 1px at 62% 32%, rgba(255,255,255,.45) 0, transparent 55%),
    radial-gradient(1px 1px at 78% 70%, rgba(255,255,255,.30) 0, transparent 55%),
    radial-gradient(1px 1px at 88% 18%, rgba(255,255,255,.40) 0, transparent 55%);
  background-size: 100% 100%;
  opacity: 0.52;
}

/* Tighten the top spacing so the module starts higher on the viewport. */
.page { padding: 18px 18px 60px; }
.page-header { margin-bottom: 14px; }

  /* ===== Chat page polish (local only) ===== */
  .page { max-width: 980px; margin: 0 auto; }
  .page-header { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:18px; }
  .page-title { font-size: 28px; font-weight: 700; letter-spacing: .2px; color: rgba(255,255,255,.94); }
  .page-subtitle { color: rgba(255,255,255,.70); margin-top:4px; }
  .page-actions { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

  .chat-panel details { border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(0,0,0,.20); overflow:hidden; }
  .chat-summary { cursor:pointer; padding: 12px 14px; display:flex; gap:10px; align-items:center; justify-content:space-between; }
  .chat-summary-hint { opacity:.75; font-size: 12px; color: rgba(255,255,255,.62); }

  .chat-controls { padding: 14px; display:flex; flex-direction:column; gap:12px; }
  .chat-row { display:flex; gap:10px; align-items:center; }
  .chat-input {
    width:100%; min-height: 140px; resize: vertical;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.25);
    color: rgba(255,255,255,.92);
    caret-color: rgba(255,255,255,.92);
    outline: none;
  }

  /* actions */
  .chat-actions { justify-content:flex-end; }
  #chat-send { min-width: 110px; }
  #chat-clear { min-width: 92px; }

  .chat-status { margin-left:auto; opacity:.8; font-size: 12px; }

  /* advanced */
  .adv { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; margin-top: 2px; }
  .adv details { border: none; background: transparent; }
  .adv summary { list-style:none; cursor:pointer; opacity:.9; font-size: 13px; }
  .adv summary::-webkit-details-marker { display:none; }
  .adv-grid {
    margin-top:10px;
    display:grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap:10px;
  }
  .chat-label { display:flex; flex-direction:column; gap:6px; font-size: 12px; opacity:.9; color: rgba(255,255,255,.82); }
  .chat-number, .chat-text {
    width:100%;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.22);
    color: rgba(255,255,255,.92);
    caret-color: rgba(255,255,255,.92);
    outline: none;
  }

  /* output */
  .chat-output { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); display:flex; flex-direction:column; gap:12px; }
  .chat-answer, .chat-citations {
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    background: rgba(0,0,0,.18);
    padding: 12px;
  }
  .chat-answer-title, .chat-citations-title { font-weight: 700; margin-bottom: 8px; }
  .chat-answer-text { white-space: pre-wrap; word-break: break-word; margin:0; }

  .chat-citations-list { display:flex; flex-wrap:wrap; gap:8px; }
  .chat-citation-item {
    display:inline-flex; align-items:center; gap:6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.20);
    font-size: 12px;
    opacity: .95;
  }
  .chat-citation-item a { color: inherit; text-decoration: none; }
  .chat-citation-item a:hover { text-decoration: underline; }

  /* responsive */
  @media (max-width: 840px) {
    .adv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }


/* ===== Border Glow (mesh, edge-focused) ===== */
.border-glow-card {
  --edge-proximity: 0;
  --cursor-angle: 45deg;
  --edge-sensitivity: 18;
  --color-sensitivity: calc(var(--edge-sensitivity) + 18);
  --border-radius: 28px;
  --glow-padding: 22px;
  --cone-spread: 30;
  --fill-opacity: 0.14;

  /* palette (your ChatGPT purple/pink/blue) */
  --gradient-one: radial-gradient(at 80% 55%, rgba(192,132,252,1) 0px, transparent 52%);
  --gradient-two: radial-gradient(at 69% 34%, rgba(244,114,182,1) 0px, transparent 52%);
  --gradient-three: radial-gradient(at 41% 38%, rgba(56,189,248,1) 0px, transparent 52%);
  --gradient-base: linear-gradient(#c299ff 0 100%);

  /* glow colors for edge-light::before */
  --glow-color: rgba(255,255,255,.92);
  --glow-color-60: rgba(255,255,255,.60);
  --glow-color-40: rgba(255,255,255,.40);
  --glow-color-25: rgba(255,255,255,.25);
  --glow-color-12: rgba(255,255,255,.12);

  position: relative;
  border-radius: var(--border-radius);
  isolation: isolate;
  transform: translate3d(0, 0, 0.01px);
  display: grid;

  border: 1px solid rgba(255,255,255,.16);
  background: var(--card-bg, #060010);
  overflow: visible;

  /* crisp but present depth */
  box-shadow:
    rgba(0, 0, 0, 0.18) 0px 1px 2px,
    rgba(0, 0, 0, 0.16) 0px 2px 6px,
    rgba(0, 0, 0, 0.14) 0px 8px 18px,
    rgba(0, 0, 0, 0.12) 0px 22px 48px;
}

.border-glow-card::before,
.border-glow-card::after,
.border-glow-card > .edge-light {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transition: opacity 0.25s ease-out;
  z-index: -1;
}

/* idle: keep a visible thin bright ring (you asked “always brighter”) */
.border-glow-card:not(:hover):not(.sweep-active)::before,
.border-glow-card:not(:hover):not(.sweep-active)::after,
.border-glow-card:not(:hover):not(.sweep-active) > .edge-light {
  opacity: 0.55;
  transition: opacity 0.75s ease-in-out;
}

/* colored mesh-gradient border (thin but punchy) */
.border-glow-card::before {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--card-bg, #060010) 0 100%) padding-box,
    linear-gradient(rgba(255,255,255,0) 0% 100%) border-box,
    var(--gradient-one) border-box,
    var(--gradient-two) border-box,
    var(--gradient-three) border-box,
    var(--gradient-base) border-box;

  /* make it pop even before reaching strict edge threshold */
  opacity: clamp(0.65, (var(--edge-proximity) - var(--color-sensitivity)) / (100 - var(--color-sensitivity)), 1);

  mask-image:
    conic-gradient(
      from var(--cursor-angle) at center,
      black calc(var(--cone-spread) * 1%),
      transparent calc((var(--cone-spread) + 14) * 1%),
      transparent calc((100 - var(--cone-spread) - 14) * 1%),
      black calc((100 - var(--cone-spread)) * 1%)
    );
  -webkit-mask-image:
    conic-gradient(
      from var(--cursor-angle) at center,
      black calc(var(--cone-spread) * 1%),
      transparent calc((var(--cone-spread) + 14) * 1%),
      transparent calc((100 - var(--cone-spread) - 14) * 1%),
      black calc((100 - var(--cone-spread)) * 1%)
    );
}

/* subtle edge fill (keep it subtle so it won't look like a “block glow”) */
.border-glow-card::after {
  border: 1px solid transparent;
  background:
    var(--gradient-one) padding-box,
    var(--gradient-two) padding-box,
    var(--gradient-three) padding-box,
    var(--gradient-base) padding-box;

  /* masks: keep color near edges + follow cursor angle */
  mask-image:
    linear-gradient(to bottom, black, black),
    radial-gradient(ellipse at 50% 50%, black 40%, transparent 66%),
    conic-gradient(from var(--cursor-angle) at center, transparent 6%, black 16%, black 84%, transparent 94%);
  -webkit-mask-image:
    linear-gradient(to bottom, black, black),
    radial-gradient(ellipse at 50% 50%, black 40%, transparent 66%),
    conic-gradient(from var(--cursor-angle) at center, transparent 6%, black 16%, black 84%, transparent 94%);

  mask-composite: subtract, add;
  /* Safari */
  -webkit-mask-composite: xor, source-over;

  opacity: clamp(0.10, var(--fill-opacity) * (var(--edge-proximity) - var(--color-sensitivity)) / (100 - var(--color-sensitivity)), 0.55);
  mix-blend-mode: soft-light;
}

/* outer glow layer */
.border-glow-card > .edge-light {
  inset: calc(var(--glow-padding) * -1);
  pointer-events: none;
  z-index: 1;

  mask-image:
    conic-gradient(from var(--cursor-angle) at center, black 2.5%, transparent 10%, transparent 90%, black 97.5%);
  -webkit-mask-image:
    conic-gradient(from var(--cursor-angle) at center, black 2.5%, transparent 10%, transparent 90%, black 97.5%);

  opacity: clamp(0.70, (var(--edge-proximity) - var(--edge-sensitivity)) / (100 - var(--edge-sensitivity)), 1);
  mix-blend-mode: plus-lighter;
}

.border-glow-card > .edge-light::before {
  content: "";
  position: absolute;
  inset: var(--glow-padding);
  border-radius: inherit;

  /* this is the “thin but very bright” punch */
  box-shadow:
    inset 0 0 0 1px var(--glow-color),
    inset 0 0 1px 0 var(--glow-color-60),
    inset 0 0 4px 0 rgba(56,189,248,.55),
    inset 0 0 10px 0 rgba(192,132,252,.45),
    inset 0 0 22px 2px rgba(255,255,255,.18),

    0 0 1px 0 var(--glow-color-60),
    0 0 5px 0 rgba(56,189,248,.55),
    0 0 12px 0 rgba(192,132,252,.45),
    0 0 26px 2px rgba(255,255,255,.16),
    0 0 48px 6px rgba(56,189,248,.10),
    0 0 18px 2px rgba(244,114,182,.18),
    0 0 32px 6px rgba(192,132,252,.14);
}

.border-glow-inner {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: auto;
  z-index: 1;
}


/* Aurora drift (subtle) */
@keyframes auroraShift {
  0% {
    --a1x: 18%; --a1y: 8%;
    --a2x: 82%; --a2y: 14%;
    --a3x: 52%; --a3y: 100%;
    filter: saturate(1.05);
  }
  100% {
    --a1x: 26%; --a1y: 14%;
    --a2x: 74%; --a2y: 10%;
    --a3x: 48%; --a3y: 96%;
    filter: saturate(1.18);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .page::before {
    animation: auroraShift 22s ease-in-out infinite alternate;
    will-change: filter;
  }
}


.particles-container{
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.particles-container > #stars{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: .85;
}

.particles-container > .page{
  position: relative;
  z-index: 1;
}