:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #3f3f3f;
  --panel-deep: #202020;
  --panel-soft: #2a2a2a;
  --text: #f4f4f4;
  --muted: #9b9b9b;
  --green: #69d64f;
  --blue: #064ef5;
  --red: #ef4455;
  --line: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 52% 34%, rgba(49, 116, 255, 0.12), transparent 18rem),
    radial-gradient(circle at 38% 58%, rgba(105, 214, 79, 0.08), transparent 16rem),
    #000;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.peepo-app {
  width: min(1440px, 100% - 40px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(420px, 1fr) minmax(220px, 280px);
  gap: 28px;
  align-items: center;
  padding: 42px 0;
}

.plans-panel,
.status-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.plans-panel {
  min-height: 560px;
  padding: 28px;
}

.file-tab {
  margin-bottom: 34px;
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  font-weight: 800;
}

.plan-list {
  display: grid;
  gap: 10px;
}

.plan {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 10px;
  background: rgba(0, 0, 0, 0.14);
  color: #d7d7d7;
  text-align: left;
  cursor: pointer;
}

.plan span {
  color: var(--green);
}

.plan.active {
  border-color: rgba(105, 214, 79, 0.55);
  background: rgba(105, 214, 79, 0.12);
  color: #fff;
}

.plan-output {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: #dcdcdc;
  line-height: 1.55;
}

.plan-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 18px;
}

.plan-actions button,
.prompt-row button,
.contribution-form button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #161616;
  color: #fff;
  cursor: pointer;
}

.plan-actions button {
  min-height: 42px;
  padding: 0 12px;
}

.stage {
  min-height: 760px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 10px 0 34px;
}

.topbar {
  width: min(880px, 100%);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  color: var(--muted);
}

.topbar p {
  margin: 0 0 4px;
}

.topbar strong,
.topbar span {
  color: #fff;
}

.pet-wrap {
  position: relative;
  width: min(640px, 100%);
  min-height: 430px;
  display: grid;
  place-items: center;
  padding-top: 26px;
}

h1 {
  position: absolute;
  top: 0;
  margin: 0;
  font-size: clamp(3rem, 5vw, 5.2rem);
  line-height: 1;
  font-weight: 850;
}

.pet-shadow {
  position: absolute;
  bottom: 86px;
  width: 220px;
  height: 34px;
  border-radius: 50%;
  background: rgba(6, 78, 245, 0.22);
  filter: blur(10px);
  animation: shadow-pulse 1.2s steps(2, end) infinite;
}

.codex-pet-sprite,
.peepo-fallback {
  position: relative;
  z-index: 2;
  margin-top: 70px;
  filter: drop-shadow(0 0 22px rgba(105, 214, 79, 0.15));
}

.codex-pet-sprite {
  display: none;
  width: min(44vw, 248px);
  aspect-ratio: 192 / 208;
  background-image: url("assets/pet/spritesheet.webp");
  background-repeat: no-repeat;
  background-size: 800% 900%;
  image-rendering: pixelated;
  animation: hop 2.8s ease-in-out infinite;
}

.has-codex-sprite .codex-pet-sprite {
  display: block;
}

.has-codex-sprite .peepo-fallback {
  display: none;
}

.peepo-fallback {
  width: min(42vw, 220px);
  image-rendering: pixelated;
  animation: fallback-hop 2.8s ease-in-out infinite;
}

.bubble {
  position: absolute;
  right: 16px;
  bottom: 116px;
  z-index: 3;
  max-width: 250px;
  border: 1px solid rgba(105, 214, 79, 0.45);
  border-radius: 4px;
  padding: 12px 14px;
  background: rgba(17, 17, 17, 0.86);
  color: #f7f7f7;
  line-height: 1.35;
}

.chat-shell {
  width: min(920px, 100%);
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.prompt-row button {
  min-height: 34px;
  padding: 0 12px;
  color: #d9d9d9;
}

.prompt-row button:hover,
.plan-actions button:hover,
.contribution-form button:hover {
  border-color: rgba(105, 214, 79, 0.6);
}

.messages {
  max-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  margin-bottom: 12px;
  padding: 0 4px;
}

.message {
  max-width: 78%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #151515;
  line-height: 1.4;
}

.message span {
  display: block;
  margin-bottom: 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
}

.message p {
  margin: 0;
}

.user-message {
  align-self: flex-end;
  background: #1d263a;
}

.user-message span {
  color: #77a3ff;
}

.ask-bar {
  display: grid;
  grid-template-columns: 1fr 50px;
  gap: 10px;
  min-height: 86px;
  border-radius: 24px;
  padding: 12px;
  background: #1f1f1f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ask-bar input {
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 8px;
  background: transparent;
  color: #fff;
}

.ask-bar input::placeholder {
  color: #9c9c9c;
  opacity: 1;
}

.ask-bar button {
  align-self: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #4a4a4a;
  color: #dcdcdc;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}

.ai-status {
  margin: 10px 8px 0;
  color: #777;
  font-size: 0.82rem;
}

.status-panel {
  align-self: end;
  padding: 20px;
  background: #111;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.stat span {
  color: var(--muted);
}

.stat strong {
  text-align: right;
  color: #fff;
}

.fine-print {
  margin: 18px 0 0;
  color: #8d8d8d;
  line-height: 1.45;
}

.contribution-form {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.contribution-form label {
  color: var(--green);
  font-weight: 800;
}

.contribution-form div {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
}

.contribution-form input {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
  background: #050505;
  color: #fff;
  outline: 0;
}

.contribution-form button {
  font-size: 1.2rem;
}

.community-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.community-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  background: #070707;
  color: #d7d7d7;
  line-height: 1.35;
}

.community-item button {
  border: 0;
  border-radius: 4px;
  padding: 6px 8px;
  background: rgba(105, 214, 79, 0.16);
  color: var(--green);
  cursor: pointer;
}

@keyframes hop {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-10px) scale(1.02);
  }
}

@keyframes fallback-hop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes shadow-pulse {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.65;
  }
  50% {
    transform: scaleX(0.82);
    opacity: 0.35;
  }
}

@media (max-width: 1100px) {
  .peepo-app {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .plans-panel {
    min-height: auto;
    order: 2;
  }

  .stage {
    min-height: 700px;
    order: 1;
  }

  .status-panel {
    order: 3;
  }
}

@media (max-width: 620px) {
  .peepo-app {
    width: min(100% - 20px, 560px);
    padding: 20px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .pet-wrap {
    min-height: 360px;
  }

  .bubble {
    right: 0;
    bottom: 70px;
    max-width: 210px;
  }

  .ask-bar {
    grid-template-columns: 1fr 44px;
    min-height: 72px;
    border-radius: 18px;
  }
}
