* { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', system-ui, sans-serif; color: #fff; background: #000000;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

button, a, [role="button"] { touch-action: manipulation; }

/* ===== HERO ===== */
.hero {
  min-height: 100vh;
  min-height: calc(var(--app-vh, 1vh) * 100);
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 56px 20px;
  padding-top: calc(56px + env(safe-area-inset-top));
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
  background: #000000;
  font-family: 'DM Sans', system-ui, sans-serif;
  transition: align-items .2s ease;
}
.hero.keyboard-open { align-items: flex-start; }

.wrapper {
  position: relative;
  width: 100%; max-width: 550px;
  margin: 0 auto;
}

/* ===== NEBULA ===== */
.nebula {
  position: absolute;
  left: 0; right: 0;
  top: 50%; translate: 0 -50%;
  height: 62px; min-height: 62px; border-radius: 100px;
  background: conic-gradient(from var(--angle), #4285f4, #b100cd, #ff3d00, #ffd000, #4285f4);
  filter: blur(18px); opacity: .6; z-index: 1; pointer-events: none;
  animation: flowFade 3s ease-out forwards;
  transition: height .12s ease, border-radius .12s ease;
}
.nebula.active { animation: flowLoop 3s linear infinite; opacity: 0.6; }
.nebula.multiline { border-radius: 24px; }

/* ===== SEARCH BAR ===== */
.search-bar-container {
  position: relative;
  width: 100%;
  min-height: 62px;
}
.search-bar {
  position: relative; min-height: 62px; border-radius: 100px;
  background: #111111;
  display: flex; align-items: center;
  padding: 11px 14px 11px 18px;
  z-index: 2; gap: 10px;
  cursor: text;
  transition: border-radius .12s ease, background .2s ease;
  border: 1px solid rgba(255,255,255,.07);
}
.search-bar:hover { background: #161616; }
.search-bar.multiline { border-radius: 24px; align-items: flex-end; }
.search-bar::before {
  content: "";
  position: absolute; inset: -1.5px; border-radius: 100px; padding: 1.5px;
  background: conic-gradient(from var(--angle), #4285f4 0%, #b100cd 25%, #ff3d00 50%, #ffd000 75%, #4285f4 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out; mask-composite: exclude;
  animation: none;
  opacity: 0;
  pointer-events: none;
}
.search-bar.flash-border::before { animation: flowFade 3s ease-out forwards; }
.search-bar.searching::before {
  animation: flowLoop 3s linear infinite;
  opacity: 1;
}

/* ===== PLUS / UPLOAD BUTTON ===== */
.plus-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%; border: none;
  background: rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  animation: fadeUp .4s ease .3s both;
  pointer-events: all;
  cursor: pointer;
  transition: background .2s, transform .15s;
  position: relative;
}
.plus-btn:hover { background: rgba(138,180,248,.18); }
.plus-btn:active { transform: scale(.88); }
.plus-btn.has-file { background: rgba(0,205,147,.15); }
.plus-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: #fff;
  stroke-width: 2.2; stroke-linecap: round;
  transition: opacity .15s;
}
.plus-btn::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: rgba(20,20,20,.92);
  color: #fff;
  font-size: 11px;
  letter-spacing: .3px;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
  font-family: 'DM Sans', system-ui, sans-serif;
}
.plus-btn:hover::after { opacity: 1; }

.file-badge-remove {
  flex-shrink: 0;
  cursor: pointer;
  opacity: .6;
  transition: opacity .15s;
  background: none; border: none; color: #80ffe1;
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.file-badge-remove:hover { opacity: 1; }

/* ===== INPUT ROW ===== */
.input-row {
  flex: 1;
  display: flex; align-items: stretch;
  overflow: hidden;
  min-width: 0;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}
.typed-text {
  font-size: clamp(1rem, 4vw, 1.1rem);
  line-height: 1.4;
  font-weight: 400;
  color: #fff;
  font-family: 'DM Sans', system-ui, sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  overflow-x: hidden;
  resize: none;
  width: 100%;
  max-height: 160px;
  text-align: left;
  background: transparent;
  border: none;
  outline: none;
  caret-color: #8ab4f8;
  padding: 0;
  margin: 0;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  scrollbar-width: thin;
}
.typed-text::placeholder { color: rgba(255,255,255,.38); font-weight: 400; }

/* ===== SEND BUTTON ===== */
.send-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%; border: none;
  background: rgba(138,180,248,.12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s, transform .15s;
  z-index: 3;
}
.send-btn:hover { background: rgba(138,180,248,.22); transform: scale(1.06); }
.send-btn:active { transform: scale(.92); }
.send-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: #8ab4f8;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.send-btn.loading { background: rgba(255,255,255,.06); }
.send-btn.loading svg { animation: spin 1s linear infinite; }

/* ===== MIC BUTTON ===== */
.mic-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%; border: none;
  background: rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s, transform .15s;
  position: relative;
  z-index: 3;
}
.mic-btn:hover { background: rgba(138,180,248,.14); }
.mic-btn:active { transform: scale(.9); }
.mic-btn svg {
  width: 17px; height: 17px;
  fill: none; stroke: rgba(255,255,255,.75);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke .2s;
}
.mic-btn.listening { background: rgba(255,61,0,.18); animation: micPulse 1.4s ease-in-out infinite; }
.mic-btn.listening svg { stroke: #ff6a4d; }
.mic-btn::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: rgba(20,20,20,.92);
  color: #fff;
  font-size: 11px;
  letter-spacing: .3px;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
  font-family: 'DM Sans', system-ui, sans-serif;
}
.mic-btn:hover::after { opacity: 1; }

/* ===== AI BADGE ===== */
.ai-badge {
  display: none;
  margin-bottom: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: clamp(1.7rem, 5vw, 3.2rem);
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -.5px;
  text-align: center;
  justify-content: center;
  animation: fadeUp .45s ease both;
  transition: opacity .3s ease, transform .3s ease;
}
.ai-badge.hidden { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.ai-badge-logo { display: none; }

/* ===== FILE PREVIEW ===== */
.file-preview-image {
  display: none;
  position: relative;
  width: 64px; height: 64px;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,.14);
  animation: fadeUp .25s ease both;
}
.file-preview-image.visible { display: inline-block; }
.file-preview-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-preview-image .file-badge-remove {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 11px;
  opacity: 1;
  padding: 0;
}
.file-preview-image .file-badge-remove:hover { background: rgba(0,0,0,.85); }

/* ===== MOBILE RESPONSIVE (layout / input) ===== */
@media (max-width: 759px) {
  .hero {
    height: 100vh;
    height: calc(var(--app-vh, 1vh) * 100);
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 16px 20px 20px;
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    align-items: stretch;
  }
  .hero-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    width: 100%;
    min-height: 0;
  }
  .wrapper {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-height: 0;
  }
  .ai-badge { margin-bottom: 14px; flex: 0 0 auto; }

  .plus-btn { width: 40px; height: 40px; }
  .mic-btn { width: 42px; height: 42px; }
  .send-btn { width: 42px; height: 42px; }
  .file-badge-remove { padding: 6px; font-size: 13px; }
  .typed-text { font-size: 16px; }

  .plus-btn::after, .mic-btn::after { display: none; }

  .input-dock {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, #000 65%, rgba(0,0,0,0));
  }
  .input-dock .wrapper-inner { max-width: 550px; margin: 0 auto; }
  .hero { padding-bottom: var(--dock-h, calc(140px + env(safe-area-inset-bottom))); }
  .hero.keyboard-open { align-items: stretch; }
}

@media (min-width: 760px) {
  body.chat-active {
    overflow: hidden; height: 100%;
  }
  body.chat-active .hero {
    height: 100vh; height: calc(var(--app-vh, 1vh) * 100); height: 100dvh;
    min-height: 0; overflow: hidden; align-items: stretch;
  }
  body.chat-active .hero-content {
    display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0;
  }
  body.chat-active .ai-badge { display: none !important; }
  body.chat-active .wrapper {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; justify-content: flex-end;
  }
  body.chat-active .input-dock { flex: 0 0 auto; }
}
