:root {
  --bg: #06110d;
  --panel: #0b1c16;
  --line: rgba(224,255,241,.11);
  --text: #f2fff9;
  --muted: #8fa79c;
  --mint: #73f2b6;
  --mint2: #b9ffdb;
  --blue: #8bb8ff;
  --warn: #ffd36b;
  --danger: #ff8f8f;
  --shadow: 0 28px 90px rgba(0,0,0,.38);
  --side: 286px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(900px 600px at 5% -10%, rgba(42,146,105,.22), transparent 62%),
    radial-gradient(900px 650px at 100% 0, rgba(59,103,184,.15), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans Malayalam", sans-serif;
}

body { overflow: hidden; }

button, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--side) minmax(0,1fr);
}

aside {
  height: 100vh;
  padding: 18px 15px;
  border-right: 1px solid var(--line);
  background: rgba(3,13,10,.78);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 3px 8px 18px;
}

.brand img {
  width: 80px;
  height: 42px;
  object-fit: contain;
  object-position: center;
}

.brand b { font-size: 17px; }

.brand small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
}

.new, .connect {
  width: 100%;
  padding: 11px 13px;
  border-radius: 14px;
  border: 1px solid rgba(115,242,182,.2);
  background: rgba(115,242,182,.065);
  cursor: pointer;
  font-weight: 760;
}

.connect {
  margin-top: 7px;
  background: rgba(139,184,255,.065);
  border-color: rgba(139,184,255,.18);
}

.connect.connected {
  color: var(--mint2);
  border-color: rgba(115,242,182,.3);
}

.side-section {
  margin-top: 20px;
  min-height: 0;
}

.section-title {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #668077;
  padding: 0 9px 8px;
}

.history {
  display: grid;
  gap: 3px;
  overflow: auto;
  max-height: 44vh;
}

.chat-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  color: #a9bdb4;
  padding: 10px;
  border-radius: 11px;
  cursor: pointer;
}

.chat-item:hover {
  background: rgba(255,255,255,.035);
  color: #fff;
}

.chat-item.active {
  background: rgba(115,242,182,.065);
  border-color: rgba(115,242,182,.12);
  color: #e8fff4;
}

.chat-title {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  font-size: 9px;
  color: #60756d;
  margin-top: 4px;
  display: flex;
  gap: 7px;
}

.side-bottom { margin-top: auto; }

.status {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  border-radius: 17px;
  padding: 10px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  margin: 7px 0;
  font-size: 10px;
  color: #9fb4aa;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #596b63;
  margin-right: 6px;
}

.dot.ok {
  background: var(--mint);
  box-shadow: 0 0 12px rgba(115,242,182,.7);
}

.dot.warn { background: var(--warn); }
.dot.err { background: var(--danger); }

main {
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  height: 66px;
  flex: 0 0 66px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(7,19,15,.58);
  backdrop-filter: blur(18px);
  z-index: 5;
}

.title {
  font-weight: 760;
  font-size: 14px;
}

.title span {
  color: var(--muted);
  font-weight: 500;
}

.top-actions {
  display: flex;
  gap: 7px;
}

.pill {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  border-radius: 11px;
  padding: 7px 10px;
  font-size: 10px;
  cursor: pointer;
}

.pill.active, .pill.connected {
  border-color: rgba(115,242,182,.32);
  background: rgba(115,242,182,.075);
  color: var(--mint2);
}

.chat {
  flex: 1;
  overflow: auto;
  padding: 26px max(18px,calc((100vw - 1000px)/2));
  scroll-behavior: smooth;
}

.hero {
  max-width: 900px;
  margin: 6vh auto 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  padding: 7px 10px;
  border-radius: 99px;
  color: #b8cbc2;
  font-size: 10px;
}

.badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 14px rgba(115,242,182,.65);
}

h1 {
  font-size: clamp(43px,6.5vw,76px);
  line-height: .98;
  letter-spacing: -.065em;
  margin: 19px 0 14px;
}

.gradient {
  background: linear-gradient(90deg,#fff 25%,var(--mint2) 65%,#b7d8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  max-width: 680px;
  color: var(--muted);
  line-height: 1.75;
  font-size: 15px;
  margin: 0;
}

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.quick button, .mode-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  color: #c4d4cd;
  font-size: 11px;
}

.quick button:hover, .mode-btn:hover {
  border-color: rgba(115,242,182,.3);
}

.messages {
  max-width: 900px;
  margin: 26px auto 20px;
  display: grid;
  gap: 17px;
}

.msg {
  display: flex;
  gap: 10px;
  animation: up .2s ease;
}

.msg.user { justify-content: flex-end; }

.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: #10251c;
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
}

.user .avatar {
  background: linear-gradient(145deg,#2d6659,#31567c);
}

.bubble {
  max-width: min(760px,88%);
  line-height: 1.72;
  font-size: 14px;
}

.user .bubble {
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
  border-radius: 18px 18px 5px 18px;
}

.assistant-text { color: #dcebe4; }
.assistant-text strong { color: #fff; }

.assistant-text code {
  padding: 2px 5px;
  background: #091a13;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.assistant-text ul { padding-left: 20px; }

.message-tools {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.mini {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  color: #91aaa0;
  border-radius: 9px;
  padding: 5px 8px;
  font-size: 10px;
  cursor: pointer;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(190px,1fr));
  gap: 9px;
  margin-top: 13px;
}

.card {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
}

.card img {
  width: 100%;
  height: 108px;
  object-fit: cover;
  display: block;
}

.card-body { padding: 11px; }
.card h3 { font-size: 14px; margin: 0 0 4px; }
.card p { font-size: 11px; color: var(--muted); margin: 0; }

.composer-wrap {
  padding: 10px 18px 18px;
  background: linear-gradient(transparent,var(--bg) 25%);
  position: sticky;
  bottom: 0;
}

.modebar {
  max-width: 900px;
  margin: 0 auto 8px;
  display: flex;
  gap: 7px;
  overflow: auto;
  scrollbar-width: none;
}

.modebar::-webkit-scrollbar { display: none; }

.mode-btn {
  white-space: nowrap;
  padding: 7px 10px;
  font-size: 10px;
}

.mode-btn.active {
  color: var(--mint2);
  border-color: rgba(115,242,182,.32);
  background: rgba(115,242,182,.075);
}

.composer {
  max-width: 900px;
  margin: auto;
  border: 1px solid rgba(224,255,241,.16);
  background: rgba(12,29,22,.94);
  box-shadow: var(--shadow);
  border-radius: 22px;
  padding: 8px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

textarea {
  flex: 1;
  min-height: 44px;
  max-height: 150px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  padding: 10px 8px;
  line-height: 1.55;
}

textarea::placeholder { color: #61776e; }

.icon {
  width: 43px;
  height: 43px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.mic.listening {
  border-color: rgba(115,242,182,.6);
  background: rgba(115,242,182,.1);
}

.send {
  width: 45px;
  height: 45px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(145deg,var(--mint),#7dc5ff);
  color: #061a12;
  font-weight: 950;
  cursor: pointer;
}

.send:disabled { opacity: .45; }

.note {
  max-width: 900px;
  margin: 7px auto 0;
  text-align: center;
  color: #587067;
  font-size: 9px;
}

.panel {
  position: fixed;
  right: 18px;
  top: 76px;
  width: min(390px,calc(100vw - 36px));
  border: 1px solid rgba(115,242,182,.22);
  background: rgba(8,24,17,.96);
  backdrop-filter: blur(25px);
  box-shadow: var(--shadow);
  border-radius: 20px;
  padding: 17px;
  z-index: 30;
  display: none;
}

.panel.show { display: block; }

.panel-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 13px;
}

.close {
  border: 0;
  background: transparent;
  color: #7e978d;
  cursor: pointer;
  font-size: 18px;
}

.field { margin: 11px 0; }

.field label {
  display: block;
  font-size: 10px;
  color: #789087;
  margin-bottom: 6px;
}

.select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0a1c15;
  color: #eafff4;
  outline: 0;
}

.privacy {
  font-size: 10px;
  line-height: 1.6;
  color: #789087;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  padding: 10px;
  border-radius: 11px;
}

.panel-actions {
  display: flex;
  gap: 7px;
  margin-top: 12px;
}

.panel-actions button {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  cursor: pointer;
  font-size: 10px;
}

.primary {
  border-color: rgba(115,242,182,.3) !important;
  background: rgba(115,242,182,.08) !important;
  color: var(--mint2);
}

.location-status {
  font-size: 10px;
  color: #9db2a9;
  padding: 9px;
  border-radius: 10px;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--line);
}

.location-status.ok { color: var(--mint2); }
.location-status.warn { color: var(--warn); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 380px;
  background: #122a20;
  border: 1px solid var(--line);
  padding: 11px 13px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  display: none;
  z-index: 50;
}

.toast.show { display: block; }

.ai-stream {
  position: relative;
  overflow: hidden;
  min-height: 32px;
  padding: 3px 0 5px;
}

.octopus-track {
  position: absolute;
  left: -15%;
  right: -15%;
  top: 7px;
  height: 30px;
  overflow: hidden;
  pointer-events: none;
}

.octopus-runner {
  position: absolute;
  left: -45px;
  top: 0;
  font-size: 21px;
  opacity: .28;
  filter: drop-shadow(0 0 8px rgba(115,242,182,.55));
  animation: octopusRun 7s linear infinite;
}

.octopus-runner:after {
  content: "🐙";
  position: absolute;
  left: -85px;
  top: 5px;
  opacity: .22;
  transform: scale(.65);
}

@keyframes octopusRun {
  0% { transform: translateX(-60px); }
  25% { transform: translateX(25vw) translateY(-3px); }
  50% { transform: translateX(50vw) translateY(3px); }
  75% { transform: translateX(75vw) translateY(-3px); }
  100% { transform: translateX(115vw); }
}

.stream-text {
  position: relative;
  z-index: 2;
  color: #dcebe4;
  white-space: pre-wrap;
}

.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 17px;
  margin-left: 3px;
  background: var(--mint);
  animation: cursorBlink .75s steps(1) infinite;
}

@keyframes cursorBlink {
  0%,45% { opacity: 1; }
  46%,100% { opacity: 0; }
}

@keyframes up {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.mobile { display: none; }

/* Voice listening sheet */
.voice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.52);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 70;
}

.voice-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.voice-sheet {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%,24px) scale(.97);
  width: min(430px,calc(100vw - 28px));
  padding: 25px 22px 20px;
  text-align: center;
  border: 1px solid rgba(115,242,182,.22);
  border-radius: 26px;
  background: linear-gradient(160deg,rgba(10,31,22,.98),rgba(5,20,15,.98));
  box-shadow: 0 30px 100px rgba(0,0,0,.55),0 0 70px rgba(45,190,130,.10);
  opacity: 0;
  pointer-events: none;
  transition: transform .24s cubic-bezier(.2,.8,.2,1),opacity .2s ease;
  z-index: 80;
  overflow: hidden;
}

.voice-sheet.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%,0) scale(1);
}

.voice-sheet:before {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg,transparent,var(--mint),transparent);
  opacity: .8;
}

.voice-orb-wrap {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 2px auto 14px;
}

.voice-orb {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 28%,#eafff6 0 5%,#73f2b6 18%,#23745a 52%,#0b251b 76%);
  border: 1px solid rgba(181,255,217,.35);
  box-shadow: 0 0 0 8px rgba(115,242,182,.05),0 0 40px rgba(115,242,182,.22);
  animation: voicePulse 1.35s ease-in-out infinite;
}

.voice-orb span {
  font-size: 25px;
  filter: drop-shadow(0 2px 7px rgba(0,0,0,.25));
}

.voice-ring {
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(115,242,182,.22);
  border-radius: 50%;
  animation: voiceRing 2.1s ease-out infinite;
}

.voice-ring.ring-b {
  inset: 0;
  animation-delay: 1.05s;
}

@keyframes voicePulse {
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 12px rgba(115,242,182,.06),0 0 58px rgba(115,242,182,.34);
  }
}

@keyframes voiceRing {
  0% { transform: scale(.68); opacity: .75; }
  100% { transform: scale(1.08); opacity: 0; }
}

.voice-title {
  font-size: 16px;
  font-weight: 800;
  color: #f2fff9;
}

.voice-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.voice-live {
  height: 27px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin: 12px auto 8px;
}

.voice-live i {
  width: 4px;
  height: 8px;
  border-radius: 99px;
  background: var(--mint);
  animation: voiceBars .8s ease-in-out infinite;
}

.voice-live i:nth-child(2) { animation-delay: .1s; }
.voice-live i:nth-child(3) { animation-delay: .2s; }
.voice-live i:nth-child(4) { animation-delay: .3s; }
.voice-live i:nth-child(5) { animation-delay: .4s; }

@keyframes voiceBars {
  50% { height: 24px; opacity: .55; }
}

.voice-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 9px;
}

.voice-actions button {
  min-height: 40px;
  padding: 9px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: #dcebe4;
  cursor: pointer;
  font-size: 11px;
}

.voice-actions .voice-stop {
  border-color: rgba(115,242,182,.3);
  background: rgba(115,242,182,.09);
  color: var(--mint2);
}

@media(max-width:800px) {
  .app { grid-template-columns: 1fr; }

  aside { display: none; }

  .mobile { display: inline; }

  .top {
    padding: 0 13px;
    height: 58px;
    flex-basis: 58px;
  }

  .title { font-size: 12px; }

  .top-actions {
    gap: 5px;
    overflow: hidden;
  }

  .top-actions .pill {
    padding: 7px 8px;
    font-size: 9px;
  }

  .chat { padding: 20px 14px; }

  .hero { margin-top: 6vh; }

  h1 { font-size: 47px; }

  .hero p { font-size: 13px; }

  .quick {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .quick::-webkit-scrollbar { display: none; }

  .quick button { flex: 0 0 auto; }

  .messages { margin-top: 24px; }

  .bubble { max-width: 92%; }

  .composer-wrap {
    padding: 8px 10px calc(14px + env(safe-area-inset-bottom));
  }

  .composer {
    border-radius: 19px;
    padding: 7px;
  }

  textarea {
    min-width: 0;
    font-size: 14px;
  }

  .icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
  }

  .send {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .modebar {
    margin-bottom: 7px;
  }

  .mode-btn {
    flex: 0 0 auto;
  }

  .panel {
    right: 10px;
    left: 10px;
    top: 64px;
    width: auto;
  }

  .voice-sheet {
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: calc(100vw - 18px);
    border-radius: 24px;
    padding: 22px 17px 16px;
  }

  .voice-orb-wrap {
    width: 92px;
    height: 92px;
  }

  .voice-orb { inset: 16px; }

  .voice-title { font-size: 15px; }
}
