* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #000;
  color: #eee;
  font-family: Inter, system-ui, sans-serif;
}
body { overflow: hidden; }
body.scroll-page {
  overflow: auto;
  height: auto;
  min-height: 100%;
}

.world-bg {
  position: fixed; inset: 0; z-index: 0;
  background: url("/images/world.jpg") center / cover no-repeat;
  pointer-events: none;
}
#rain {
  position: fixed; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  pointer-events: none;
  background: transparent;
}
.scanlines, .vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
}
.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0, transparent 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
  opacity: 0.35;
}
.vignette {
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.55) 100%),
    linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 38%);
}

.home-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  gap: 8px;
}
.brand {
  font-weight: 600;
  letter-spacing: 0.28em;
  color: #00ff41;
  text-decoration: none;
  text-shadow: 0 0 14px #00ff41;
  font-size: 0.92rem;
  flex-shrink: 0;
}
.profile-link {
  color: rgba(200, 255, 200, 0.72);
  text-decoration: none;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}
.profile-link:hover { color: #00ff41; }
.account-chip { display: flex; align-items: center; gap: 14px; }

.hamburger {
  display: none;
  width: 42px; height: 42px;
  margin-left: auto;
  background: transparent;
  border: 1px solid #00ff41;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger span {
  display: block; width: 20px; height: 2px; background: #00ff41;
}

.home-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-left: auto;
}
.home-nav a {
  color: rgba(200, 255, 200, 0.72);
  text-decoration: none;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  white-space: nowrap;
}
.home-nav a:hover, .home-nav a.on { color: #00ff41; }

@media (max-width: 768px) {
  .hamburger { display: inline-flex !important; }
  .home-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    margin-left: 0;
    background: rgba(0, 10, 0, 0.96);
    border-bottom: 1px solid #145214;
    padding: 8px 0 12px;
    z-index: 30;
  }
  .home-nav.open { display: flex; }
  .home-nav a {
    padding: 14px 18px;
    border-bottom: 1px solid #0b3d0b;
  }
}

@media (min-width: 769px) {
  .hamburger { display: none !important; }
  .home-nav {
    display: flex !important;
    position: static;
    flex-direction: row;
    background: transparent;
    border: 0;
    padding: 0;
  }
  .home-nav a { border-bottom: 0; }
}

.chat-shell {
  position: relative; z-index: 5;
  height: 100%;
  padding: 72px 16px 24px;
  display: flex;
  flex-direction: column;
}
body.has-chat .chat-shell { padding-bottom: 110px; }
.chat-log {
  flex: 1;
  overflow: auto;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 4px 24px;
  font-family: "Share Tech Mono", monospace;
  scrollbar-width: thin;
  scrollbar-color: #00ff41 transparent;
}
.msg {
  margin: 12px 0;
  max-width: 92%;
  line-height: 1.55;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px 12px;
  border-radius: 0;
  font-family: "Share Tech Mono", monospace;
}
.msg.user {
  margin-left: auto;
  background: rgba(0, 20, 0, 0.72);
  border: 1px solid #00ff41;
  color: #b6ffb6;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.18);
}
.msg.user::before {
  content: "> USER // ";
  display: block;
  color: #00ff41;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  margin-bottom: 6px;
}
.msg.aloy {
  margin-right: auto;
  color: #00ff41;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.45);
  background: rgba(0, 8, 0, 0.7);
  border: 1px solid #145214;
  border-left: 3px solid #00ff41;
}
.msg.aloy::before {
  content: "ALOY // ";
  display: block;
  color: #00ff41;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  margin-bottom: 6px;
  text-shadow: 0 0 8px #00ff41;
}
.msg.aloy.pending { opacity: 1; }
.msg.error { color: #ff8a8a; border-color: #5a1a1a; }
.msg img, .msg video, .msg audio { max-width: 100%; margin-top: 8px; border-radius: 0; display: block; border: 1px solid #145214; }
.msg audio { height: 40px; background: #031403; }
.msg .file-tag { display: inline-block; margin-top: 6px; font-size: 0.8rem; color: #9dffb0; }
.msg a.file-tag {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  border: 1px solid #00ff41;
  background: rgba(0, 255, 65, 0.12);
  color: #00ff41;
  text-decoration: none;
  letter-spacing: 0.04em;
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.25);
}
.msg a.file-tag:hover { background: rgba(0, 255, 65, 0.22); }

.gen-load {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 2px;
  position: relative;
}
.gen-rain {
  display: block;
  width: 100%;
  height: 64px;
  background: #000;
  border: 1px solid #00ff41;
  box-shadow: 0 0 14px rgba(0, 255, 65, 0.28), inset 0 0 18px rgba(0, 255, 65, 0.08);
}
.gen-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gen-spin {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 2px solid #145214;
  border-top-color: #00ff41;
  border-right-color: #9dffb0;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.35);
  animation: gen-spin 0.7s linear infinite;
}
.gen-copy { min-width: 0; flex: 1; }
.gen-title {
  color: #00ff41;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.45);
}
.gen-stage {
  color: rgba(157, 255, 176, 0.82);
  font-size: 0.78rem;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.gen-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.gen-dots i {
  display: block;
  width: 4px;
  height: 4px;
  background: #00ff41;
  box-shadow: 0 0 6px #00ff41;
  animation: gen-blink 1s ease-in-out infinite;
}
.gen-dots i:nth-child(2) { animation-delay: 0.18s; }
.gen-dots i:nth-child(3) { animation-delay: 0.36s; }
.gen-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gen-barwrap {
  flex: 1;
  height: 8px;
  background: #041204;
  border: 1px solid #145214;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0, 255, 65, 0.12);
}
.gen-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #007a20 0%, #00ff41 70%, #b6ffb6 100%);
  box-shadow: 0 0 10px #00ff41;
  transition: width 0.18s linear;
}
.gen-barwrap::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(182, 255, 182, 0.35), transparent);
  animation: gen-shimmer 1.4s linear infinite;
}
.gen-pct {
  min-width: 3.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: #9dffb0;
  text-shadow: 0 0 8px #00ff41;
}
@keyframes gen-spin {
  to { transform: rotate(360deg); }
}
@keyframes gen-shimmer {
  from { transform: translateX(-120%); }
  to { transform: translateX(320%); }
}
@keyframes gen-blink {
  0%, 80%, 100% { opacity: 0.15; }
  40% { opacity: 1; }
}

.ask-bar {
  position: fixed; z-index: 21;
  left: 50%;
  top: 48%;
  bottom: auto;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 28px));
  min-height: 56px;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 6px 6px 6px 8px;
  background: rgba(0, 12, 0, 0.82);
  border: 1px solid #00ff41;
  border-radius: 0;
  box-shadow: 0 0 18px rgba(0, 255, 65, 0.22), inset 0 0 24px rgba(0, 255, 65, 0.06);
}
.ask-row {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 44px;
}
.ask-bar textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 160px;
  height: 44px;
  border: 0;
  outline: none;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: #00ff41;
  font: 400 1.02rem "Share Tech Mono", monospace;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.35);
  line-height: 1.4;
  padding: 10px 4px;
  caret-color: #00ff41;
}
.ask-bar textarea::placeholder { color: #1f7a32; }
.attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 8px 0 44px;
}
.attach-row[hidden] { display: none !important; }
.attach-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 30, 0, 0.7);
  border: 1px solid #145214;
  border-radius: 0;
  padding: 4px 8px 4px 4px;
  color: #b6ffb6;
  font-size: 0.78rem;
  font-family: "Share Tech Mono", monospace;
  max-width: 220px;
}
.attach-chip img {
  width: 36px; height: 36px; object-fit: cover; border-radius: 0;
}
.attach-chip span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-chip button {
  border: 0; background: none; color: #aaa; cursor: pointer; font-size: 16px; line-height: 1;
}
.icon-btn {
  width: 40px; height: 40px;
  border: 0; background: transparent;
  color: #00ff41;
  display: grid; place-items: center;
  cursor: pointer;
  border-radius: 0;
  flex: 0 0 auto;
}
.icon-btn:hover { color: #b6ffb6; background: rgba(0, 255, 65, 0.12); }
.icon-btn.on, .icon-btn[aria-pressed="true"] { color: #00ff41; }
.go-btn {
  width: 44px; height: 44px;
  border: 1px solid #00ff41;
  border-radius: 0;
  background: #00ff41;
  color: #001400;
  display: grid; place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  margin-left: 4px;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.35);
}
.go-btn .arrow { display: none; }
.go-btn.has-text .wave { display: none; }
.go-btn.has-text .arrow { display: block; transform: rotate(-90deg); }
.go-btn:hover { background: #b6ffb6; }
.go-btn:disabled { opacity: 0.5; cursor: default; }

body.has-chat .ask-bar {
  top: auto;
  bottom: 22px;
  transform: translateX(-50%);
}

.crawl-only {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important; border: 0 !important;
}

@media (max-width: 640px) {
  .ask-bar {
    min-height: 54px;
    width: calc(100% - 24px);
    top: 46%;
    bottom: auto;
    transform: translateX(-50%);
  }
  body.has-chat .ask-bar {
    top: auto;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
  }
  .attach-row { padding-left: 8px; }
  .chat-shell { padding: 60px 12px 24px; }
  body.has-chat .chat-shell { padding-bottom: 120px; }
  .msg { max-width: 94%; font-size: 0.95rem; }
}
