:root{
  --bg:#0b1020;
  --card:#111833;
  --card2:#0f1630;
  --text:#e9ecff;
  --muted:#a9b2ff;
  --line:rgba(255,255,255,0.10);
  --accent:#7c5cff;
  --accent2:#2ce6c0;
  --danger:#ff5c7a;
  --shadow: 0 14px 40px rgba(0,0,0,0.55);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 700px at 15% 10%, rgba(124,92,255,0.25), transparent 55%),
              radial-gradient(900px 600px at 80% 30%, rgba(44,230,192,0.18), transparent 60%),
              var(--bg);
  color:var(--text);
}

.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 18px;
  background: linear-gradient(180deg, rgba(11,16,32,0.90), rgba(11,16,32,0.65));
  backdrop-filter: blur(12px);
  border-bottom:1px solid var(--line);
}

.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:40px; height:40px; border-radius:14px;
  display:grid; place-items:center;
  background: rgba(124,92,255,0.18);
  border:1px solid rgba(124,92,255,0.25);
  box-shadow: var(--shadow);
  font-size:18px;
}
.title{font-weight:800; letter-spacing:0.2px}
.subtitle{color:var(--muted); font-size:13px; margin-top:2px}

.controls{display:flex; gap:10px; align-items:center}
.selectWrap{display:flex; gap:8px; align-items:center; color:var(--muted); font-size:13px}
select{
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  outline:none;
}
button{
  border:1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  cursor:pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  user-select:none;
}
button:hover{background: rgba(255,255,255,0.09)}
button:active{transform: translateY(1px)}
button.primary{
  background: linear-gradient(135deg, rgba(124,92,255,0.95), rgba(44,230,192,0.70));
  border-color: rgba(255,255,255,0.16);
  font-weight:700;
}
button.ghost{background: transparent}

.layout{
  max-width: 1180px;
  margin: 18px auto;
  padding: 0 16px 26px;
  display:grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
@media (max-width: 980px){
  .layout{grid-template-columns: 1fr;}
}

.chatCard, .imageCard{
  background: linear-gradient(180deg, rgba(17,24,51,0.92), rgba(15,22,48,0.85));
  border:1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.topicRow{
  display:flex; gap:10px; flex-wrap:wrap;
  padding: 14px 14px 0;
}
.chip{
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(124,92,255,0.12);
  border-color: rgba(124,92,255,0.20);
}
.chip:hover{background: rgba(124,92,255,0.18)}
.chat{
  height: 52vh;
  min-height: 420px;
  overflow:auto;
  padding: 14px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  scroll-behavior:smooth;
}
.bubble{
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  line-height:1.35;
  white-space:pre-wrap;
  word-wrap:break-word;
}
.bubble.user{
  margin-left:auto;
  background: rgba(124,92,255,0.14);
  border-color: rgba(124,92,255,0.20);
}
.bubble.assistant{
  background: rgba(255,255,255,0.06);
}
.bubble.meta{
  background: rgba(255,92,122,0.10);
  border-color: rgba(255,92,122,0.18);
  color: rgba(255,255,255,0.9);
}

.composer{
  display:flex; gap:10px;
  padding: 12px 14px 14px;
  border-top:1px solid var(--line);
  background: rgba(0,0,0,0.08);
}
textarea{
  width:100%;
  resize:none;
  border-radius: 16px;
  border:1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 10px 12px;
  outline:none;
}
textarea:focus{border-color: rgba(124,92,255,0.35)}
.hint{
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: 12.5px;
}

.imageCard{padding: 14px}
.imageHeader{
  display:flex; justify-content:space-between; align-items:center;
  gap:12px;
}
.cardTitle{font-weight:800}
.cardSub{color:var(--muted); font-size:13px; margin-top:3px}
.imageArea{
  margin-top: 12px;
  border:1px dashed rgba(255,255,255,0.18);
  border-radius: 18px;
  padding: 12px;
  min-height: 260px;
  display:grid;
  place-items:center;
  background: rgba(0,0,0,0.10);
}
.imageStatus{color: var(--muted); font-size: 13px; text-align:center}
#genImage{
  max-width: 100%;
  border-radius: 18px;
  display:none;
  border:1px solid rgba(255,255,255,0.14);
  box-shadow: 0 18px 55px rgba(0,0,0,0.45);
}
.smallNote{margin-top: 10px; color: var(--muted); font-size: 12.5px}

.footer{
  max-width: 1180px;
  margin: 0 auto 18px;
  padding: 0 16px;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
}


.attachBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:44px;
  height:44px;
  border:1px solid var(--line);
  border-radius:12px;
  cursor:pointer;
  user-select:none;
  font-size:20px;
  background: var(--bgCard);
}

.attachBtn input{
  display:none;
}


.chatImage{
  max-width: 180px;
  max-height: 180px;
  border-radius: 16px;
  margin-bottom: 6px;
  display:block;
}


/* Loading spinner icon for chat + image generation */
.loadingSpinner{
  display:flex;
  justify-content:center;
  align-items:center;
  padding:6px 0;
}
.loadingSpinner-inner{
  width:18px;
  height:18px;
  border-radius:50%;
  border:2px solid rgba(255,255,255,0.25);
  border-top-color:#4ade80;
  border-right-color:#22d3ee;
  animation: spinnerRotate 0.8s linear infinite;
}
@keyframes spinnerRotate{
  0%{ transform: rotate(0deg); }
  100%{ transform: rotate(360deg); }
}