:root {
  --bg: #0f172a; --bg2: #1e293b; --card: #1e293b; --line: #334155;
  --txt: #f1f5f9; --dim: #94a3b8; --acc: #38bdf8; --acc2: #818cf8;
  --user: #0ea5e9; --me: #1d4ed8;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", system-ui, sans-serif;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
#modelSel {
  background: #0b1220; color: var(--txt); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; font-size: 13px; max-width: 55%;
}
#chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px;
  background: var(--bg2); border-bottom: 1px solid var(--line); scrollbar-width: none;
}
#chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: #0b1220; border: 1px solid var(--line); color: var(--txt);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.chip.active { border-color: var(--acc); color: var(--acc); }
#chat { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; line-height: 2; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-start; background: var(--me); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-end; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .meta { display: flex; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--dim); }
.msg .meta button { background: none; border: none; color: var(--dim); font-size: 14px; cursor: pointer; padding: 2px 6px; }
.caret::after { content: "▍"; color: var(--acc); animation: blink 0.8s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg img.gen { max-width: 100%; border-radius: 10px; margin-top: 6px; display: block; }
#imgPanel { background: var(--bg2); border-top: 1px solid var(--line); padding: 10px 12px; }
.hidden { display: none !important; }
.img-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 8px; }
.xbtn { background: none; border: none; color: var(--dim); font-size: 16px; cursor: pointer; }
.img-row { display: flex; gap: 8px; }
.img-row input { flex: 1; }
#imgOut { margin-top: 10px; text-align: center; }
#imgOut img { max-width: 100%; border-radius: 12px; }
#imgOut a { display: inline-block; margin-top: 8px; color: var(--acc); }
#voiceBar { background: #172554; border-top: 1px solid var(--acc); padding: 12px; }
.voice-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vstatus { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: #ef4444; animation: blink 1s infinite; }
.vstop { background: #ef4444; color: #fff; border: none; border-radius: 10px; padding: 10px 14px; font-size: 14px; cursor: pointer; }
#composer {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg2); border-top: 1px solid var(--line); align-items: center;
}
#composer input, .img-row input {
  flex: 1; background: #0b1220; border: 1px solid var(--line); color: var(--txt);
  border-radius: 12px; padding: 12px; font-size: 15px; font-family: inherit; min-width: 0;
}
#composer button, #imgGo {
  border: none; border-radius: 12px; padding: 11px 13px; font-size: 17px; cursor: pointer;
  background: #0b1220; color: var(--txt); border: 1px solid var(--line); flex: 0 0 auto;
}
#btnSend { background: linear-gradient(135deg, var(--acc), var(--acc2)); border: none; font-size: 18px; }
#btnVoice.listening { background: #ef4444; border-color: #ef4444; }
#footbar { display: flex; justify-content: space-between; align-items: center; padding: 6px 14px calc(6px + env(safe-area-inset-bottom)); background: var(--bg2); font-size: 12px; color: var(--dim); }
#btnNew { background: none; border: none; color: var(--dim); font-size: 13px; cursor: pointer; }
.spin { display: inline-block; animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
