/* =========================
   THEME + GLOBAL LOCKDOWN
   ========================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');

:root{
    /* Dark charcoal base */
  --bg: #0f0f14;           /* app background */
  --text: #f2f2f5;         /* main text */
  --muted: rgba(242,242,245,0.70);

  /* Topbar */
  --header: rgba(15,15,20,0.86);
  --headerText: #f5f5f7;

  /* Borders / surfaces */
  --border: rgba(255,255,255,0.10);

  /* Chat bubbles */
  --bubble: rgba(255,90,120,0.14);  /* user bubble */
  --bubbleText: #fff;


  --topbar-h: 60px;
  --app-max: 820px;

  --composer-safe: env(safe-area-inset-bottom, 0px);
  --composer-reserve: 110px;

  /* Send button sizing (thread vs home) */
  --send-size: 46px;
  --send-radius: 14px; 

  /* HOME: move composer a bit LOWER so title is visible */
  --home-composer-top: 240px;
}

html, body{
  height: 100%;
  margin: 0;
  overflow: hidden;
}


*{ box-sizing: border-box; }
body{ overflow-x: hidden; }

body{
font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
 color: var(--text);
  background: radial-gradient(1200px 700px at 50% 30%,
      rgba(255, 90, 120, 0.10),
      rgba(15, 15, 20, 0.92) 55%,
      #0f0f14 100%),
    #0f0f14;
}


.hidden{ display: none !important; }

/* =========================
   Fixed header
   ========================= */
#topbar{
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--header);
  color: var(--headerText);
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 10002;

  will-change: transform;
  transform: translate3d(0,0,0);
  backface-visibility: hidden;
}

.topbar-left{
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Bigger logo (you said too small) */
#logo{
  height: clamp(72px, 4.2vw, 98px);
  width: auto;
}

#logoText{
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar-right{
  margin-left: auto;
  position: relative;
}

#menuBtn{
  height: 38px;
  width: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: white;
  font-size: 18px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

.menu{
  position: absolute;
  right: 0;
  top: 50px;

  background: rgba(20,20,28,0.96);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 180px;

  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
}

.menu a{
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.menu a:hover{
  background: rgba(255,255,255,0.06);
}

/* =========================
   App container
   ========================= */

#app{
  max-width: var(--app-max);
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 12px) 12px 12px;
  height: 100vh;
  height: 100dvh;
  
  overflow: hidden;
  display: flex;
  flex-direction: column;
}


/* =========================
   HOME VIEW
   ========================= */
#homeView{
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  /* Move the head UP (less blank space above it) */
  padding-top: 8px;

  overflow: hidden;
}

#homeCenter{
  text-align: center;
  width: 100%;
  max-width: 520px;
  padding: 0 12px;
margin-top: -10px;  
}

/* wrapper for glow */
#homeMascotWrap{
  position: relative;
  display: inline-block;
  isolation: isolate;
}

/* ===== HOME Spiral mascot (IMAGE base + CSS spark) ===== */
#homeMascotWrap{
  display:flex;
  justify-content:center;
  align-items:center;
  margin: 0 auto 12px;
}

/* ===== HOME Spiral mascot (PNG base + spark overlay) ===== */
/* ===== HOME Spiral mascot (PNG base + SVG motion spark) ===== */
#spiralStage{
  position: relative;
  width: 190px;
  height: 190px;
  margin: 0 auto 10px;

  border-radius: 999px;
  overflow: hidden;            /* removes square edges */
  isolation: isolate;

  background: transparent;

  animation: spiralBreath 3.2s ease-in-out infinite;
}

#spiralStage::before{
  content:"";
  position:absolute;
  inset:-12%;
  border-radius:999px;
  pointer-events:none;
  background: radial-gradient(circle at 50% 50%,
    rgba(255,170,190,0.16) 0%,
    rgba(255,90,120,0.10) 32%,
    rgba(0,0,0,0) 68%);
  mix-blend-mode: screen;
  opacity: 0.95;
}

/* subtle center-core glow (leaf-shaped center area) */
#spiralStage::after{
  content:"";
  position:absolute;
  left:50%;
  top:50%;
  width: 64px;
  height: 64px;
  transform: translate(-50%,-50%);
  border-radius: 999px;
  pointer-events:none;
  z-index: 2;
  /* warm subtle glow */
  background: radial-gradient(circle,
    rgba(255,235,210,0.35) 0%,
    rgba(255,214,90,0.18) 28%,
    rgba(255,140,170,0.10) 52%,
    rgba(0,0,0,0) 72%);

  mix-blend-mode: screen;
  opacity: 0.70;

  filter:
    blur(0.2px)
    drop-shadow(0 0 10px rgba(255,214,90,0.25))
    drop-shadow(0 0 18px rgba(255,140,170,0.18));

  animation: coreGlow 2.8s ease-in-out infinite;
}

@keyframes coreGlow{
  0%,100% { opacity: 0.38; transform: translate(-50%,-50%) scale(0.96); }
  50%     { opacity: 0.62; transform: translate(-50%,-50%) scale(1.04); }
}


#spiralImg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
  z-index: 1;
  
  -webkit-mask-image: radial-gradient(circle at 50% 50%,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 58%,
    rgba(0,0,0,0) 78%);
  mask-image: radial-gradient(circle at 50% 50%,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 58%,
    rgba(0,0,0,0) 78%);

  filter:
    brightness(1.22)
    contrast(1.10)
    saturate(1.25)
    drop-shadow(0 0 18px rgba(255,160,190,0.22))
    drop-shadow(0 0 44px rgba(255,90,120,0.14));
}

#spiralMotion{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
  z-index: 3;

  -webkit-mask-image: radial-gradient(circle at 50% 50%,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 65%,
    rgba(0,0,0,0) 84%);
  mask-image: radial-gradient(circle at 50% 50%,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 65%,
    rgba(0,0,0,0) 84%);
}

/* ===== Spiral spark group (SVG) ===== */
#spiralMotion .sparkGroup{
  /* stronger glow than the SVG filter alone */
  filter:
    drop-shadow(0 0 8px rgba(255,255,255,0.90))
    drop-shadow(0 0 18px rgba(255,214,90,0.85))
    drop-shadow(0 0 34px rgba(255,140,170,0.55));
  transform-origin: 100px 100px;
}



#spiralStage .sp, #spiralStage .tw{
  position:absolute;
  border-radius:999px;
  pointer-events:none;
  mix-blend-mode: screen;
}

#spiralStage .sp{
  width:2px;height:2px;
  background: rgba(255,210,190,0.45);
  filter: drop-shadow(0 0 8px rgba(255,170,140,0.35));
  opacity:0.75;
}

/* Tiny glowing dust (the 3 pulsing dots) */
#spiralStage .tw{
  width: 2px; height: 2px;           /* smaller */
  border-radius: 999px;

  background: rgba(255,245,230,0.95);
  opacity: 0.55;

  /* soft yellow-white dust glow */
  filter:
    drop-shadow(0 0 4px rgba(255,255,255,0.55))
    drop-shadow(0 0 9px rgba(255,214,90,0.45))
    drop-shadow(0 0 16px rgba(255,140,170,0.18));

  animation: dustPulse 1.8s ease-in-out infinite;
}

@keyframes dustPulse{
  0%,100% { transform: scale(0.85); opacity: 0.20; }
  50%     { transform: scale(1.30); opacity: 0.75; }
}



#spiralStage .s1{ left: 30px; top: 58px; }
#spiralStage .s2{ left: 126px; top: 46px; }
#spiralStage .s3{ left: 156px; top: 98px; }
#spiralStage .s4{ left: 54px; top: 138px; }
#spiralStage .s5{ left: 102px; top: 156px; }
#spiralStage .s6{ left: 44px; top: 96px; }
#spiralStage .s7{ left: 92px; top: 36px; }
#spiralStage .s8{ left: 146px; top: 138px; }

#spiralStage .t1{ left: 70px; top: 76px; animation-delay:.15s; }
#spiralStage .t2{ left: 134px; top: 122px; animation-delay:.55s; }
#spiralStage .t3{ left: 92px; top: 44px; animation-delay:1.05s; }
#spiralStage .t4{ left: 58px; top: 112px; animation-delay:.85s; }

@keyframes spiralBreath{
  0%{ transform:scale(1); }
  50%{ transform:scale(1.018); }
  100%{ transform:scale(1); }
}

@keyframes twGlow{
  0%,100% { filter: drop-shadow(0 0 8px rgba(255,255,255,0.55)) drop-shadow(0 0 18px rgba(255,160,190,0.40)) drop-shadow(0 0 34px rgba(255,90,120,0.22)); }
  50%     { filter: drop-shadow(0 0 14px rgba(255,255,255,0.95)) drop-shadow(0 0 30px rgba(255,160,190,0.70)) drop-shadow(0 0 60px rgba(255,90,120,0.40)); }
}


/* Title smaller so it stays visible above the composer */
#homeTitle{
  font-size: clamp(28px, 9vw, 44px);
  line-height: 1.05;
  font-weight: 800;
  margin: 0;
  margin-top: 5px;   /* title slightly higher */
  white-space: nowrap;     /* FORCE single line */
  max-width: 100%;
}

/* =========================
   Composer (base)
   ========================= */
#composerBar{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(15,15,20,0.86);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  padding: 10px 12px calc(12px + var(--composer-safe));
  z-index: 60;
}

#composerWrap{
  max-width: var(--app-max);
  margin: 0 auto;
}

#composerForm{
  display: flex;
  gap: 10px;
  align-items: center;
}

#composerInput{
  flex: 1;
  resize: none;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px 12px;
  font-size: 16px;
  line-height: 20px;
  outline: none;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  min-height: 46px;

  overflow-y: hidden;
  max-height: 160px;
}

#composerInput::placeholder{
  color: rgba(242,242,245,0.55);
}

#newTopicBtn{
  margin-top: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  min-height: 44px;
}

#newTopicBtn:hover{
  background: rgba(255,255,255,0.10);
}


/* Desktop width */
@media (min-width: 900px){
  #composerWrap{ max-width: 720px; }
}

/* HOME MODE: composer floats near center (not at bottom) */
body.home-mode #composerBar{
  position: fixed;
  left: 0; right: 0;
  top: calc(var(--topbar-h) + var(--home-composer-top));
  bottom: auto;
  background: transparent;
  border-top: none;
  padding: 0 12px;
  z-index: 9999;
}


body.home-mode #composerWrap{
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

body.home-mode #composerInput{
  min-height: 64px;
  padding: 16px 14px;
  font-size: 18px;
  line-height: 24px;
  border-radius: 18px;
}

body.home-mode{
  --send-size: 54px;
  --send-radius: 18px;
}

body.home-mode #sendBtn{
  font-size: 20px;
}

body.home-mode #newTopicBtn{
  display: none !important;
}

/* =========================
   THREAD VIEW
   ========================= */
#threadView{
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Messages is the ONLY scroll container */
#messages{
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  display: flex;
  flex-direction: column;
  gap: 14px;

  padding: 16px;

  overflow-wrap: anywhere;
  word-break: break-word;

  /* IMPORTANT: keep this so messages never go under the fixed composer */
  padding-bottom: calc(var(--composer-reserve) + var(--composer-safe) + var(--kb, 0px));
}

/* =========================
   THREAD MODE OVERRIDES
   ========================= */
body.thread-mode #composerBar{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: auto;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(12px + var(--composer-safe));
  z-index: 60;
}

body.thread-mode #composerWrap{
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

/* =========================
   Messages
   ========================= */
.msg{
  max-width: 92%;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.msg-user{
  align-self: flex-end;
  background: var(--bubble);
  color: var(--bubbleText);
  padding: 12px 14px;
  border-radius: 16px;
}

.msg-ai{
  align-self: flex-start;
  color: var(--text);
  padding: 2px 2px;
}

/* =========================
   Composer thinking state
   ========================= */
#composerBar.thinking{
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#composerBar{
  transition: opacity 0.25s ease;
}

/* =========================
   Thinking row
   ========================= */
.thinking-row{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 6px 0;
  opacity: 1;
  transition: opacity 240ms ease, transform 240ms ease;
}

.thinking-row.fade-out{
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
}

.thinking-avatar{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  position: relative;
  display: inline-block;
  overflow: hidden;
}

.thinking-avatar img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.thinking-avatar::after{
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 35%,
    rgba(255, 214, 90, 0.95),
    rgba(255, 214, 90, 0.25) 40%,
    rgba(255, 214, 90, 0.00) 72%
  );
  opacity: 0.22;
  animation: thinkGlow 1.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes thinkGlow{
  0%{ opacity: 0.10; transform: scale(0.97); }
  50%{ opacity: 0.70; transform: scale(1.06); filter: drop-shadow(0 0 18px rgba(255,214,90,0.85)); }
  100%{ opacity: 0.10; transform: scale(0.97); }
}

.thinking-text{
  font-size: 17px;
  font-weight: 650;
  opacity: 0.85;
}

@media (prefers-reduced-motion: reduce){
  /* Keep glow, but if you want to disable, uncomment:
  .thinking-avatar::after{ animation: none; }
  */
}


/* =========================
   Send button (final black style)
   ========================= */
#sendBtn{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: var(--send-size);
  height: var(--send-size);

  border-radius: var(--send-radius);
  border: 1px solid rgba(255,255,255,0.10);

  background: rgba(255,255,255,0.08);
  color: #fff;

  box-shadow:
    0 6px 16px rgba(0,0,0,0.18),
    inset 0 0 0 1px rgba(255,255,255,0.06);

  cursor: pointer;
  min-height: var(--send-size);
  min-width: var(--send-size);

  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    opacity 120ms ease;
}

#sendBtn svg{
  width: 30px;
  height: 30px;
  fill: currentColor;
  display: block;
} 


#sendBtn:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.40),
    0 0 18px rgba(255, 90, 120, 0.18);
}

#sendBtn:active{
  transform: translateY(0);
  opacity: 0.88;
}

#sendBtn:disabled{
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== AI answer typography (single source of truth) ===== */
.msg-ai{
  align-self: flex-start;
  color: var(--text);
  padding: 2px 2px;

  max-width: 720px;
  font-size: 17px;
  line-height: 1.55;
}

/* Each normal line your renderer outputs is a top-level <div> */
.msg-ai > div{
  margin: 0 0 6px 0;
}

/* Lists */
.msg-ai ol,
.msg-ai ul{
  margin: 6px 0 10px 22px;
  padding: 0;
}
.msg-ai li{
  margin: 4px 0;
}

/* Your renderer inserts <br> for blank lines — control that gap here */
.msg-ai br{
  display: block;
  content: "";
  margin: 6px 0;
}

@media (min-width: 900px){
  :root{
    --home-composer-top: 300px;
  }
}

/* ===== Mobile spacing tuning ===== */
@media (max-width: 600px){

  .msg-ai{
    font-size: 16px;        /* slightly smaller text */
    line-height: 1.45;      /* tighter vertical rhythm */
  }

  .msg-ai > div{
    margin-bottom: 4px;     /* reduce paragraph gap */
  }

  .msg-ai br{
    margin: 3px 0;          /* reduce blank-line gap */
  }

  .msg-ai ol,
  .msg-ai ul{
    margin: 4px 0 8px 20px; /* tighter list spacing */
  }

  .msg-ai li{
    margin: 3px 0;
  }
}
@media (max-width: 600px){
  :root{
    --home-composer-top: 270px; /* try 260–290 */
  }
}
