:root {
  color-scheme: dark;
  --bg-0: #07110d;
  --bg-1: #0d1a14;
  --panel: rgba(8, 15, 12, 0.9);
  --line: rgba(83, 183, 123, 0.18);
  --line-strong: rgba(83, 183, 123, 0.42);
  --text: #d9f7df;
  --muted: #79a884;
  --accent: #5aff9a;
  --accent-dim: #2a6d45;
  --user: rgba(16, 53, 34, 0.82);
  --assistant: rgba(11, 29, 20, 0.92);
  --system: rgba(58, 28, 24, 0.88);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Courier New", Courier, monospace;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(90, 255, 154, 0.1), transparent 28%),
    radial-gradient(circle at bottom right, rgba(34, 93, 61, 0.3), transparent 24%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 4px
    );
  opacity: 0.24;
}

.app {
  width: min(1080px, calc(100% - 32px));
  margin: 24px auto;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel__header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  padding: 28px 28px 0;
}

.eyebrow,
.status,
.composer__label {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1 {
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.95;
  font-weight: 700;
  text-transform: uppercase;
}

.status-grid {
  display: grid;
  gap: 8px;
}

.messages {
  display: grid;
  gap: 14px;
  height: min(68vh, 780px);
  overflow-y: auto;
  padding: 28px;
}

.message {
  max-width: min(90%, 820px);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.message__role {
  margin-bottom: 8px;
  color: var(--muted);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.message__content {
  white-space: pre-wrap;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message--typing .message__content::after {
  content: "▋";
  margin-left: 2px;
  color: var(--accent);
  animation: blink 0.9s steps(1, end) infinite;
}

.message--assistant {
  justify-self: start;
  background: var(--assistant);
}

.message--user {
  justify-self: end;
  background: var(--user);
}

.message--system {
  justify-self: center;
  background: var(--system);
}

.composer {
  border-top: 1px solid var(--line);
  padding: 20px 28px 28px;
}

textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 16px 18px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(10, 19, 14, 0.92);
  color: var(--text);
  font: inherit;
}

textarea:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(90, 255, 154, 0.08);
}

.composer__actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(90, 255, 154, 0.18), rgba(29, 87, 54, 0.55));
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.button--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.button:disabled,
textarea:disabled {
  opacity: 0.72;
  cursor: wait;
}

code {
  color: var(--accent);
  font-size: 0.98em;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@media (max-width: 720px) {
  .app {
    width: calc(100% - 16px);
    margin: 8px auto;
  }

  .panel__header,
  .messages,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .panel__header {
    display: block;
    padding-top: 20px;
  }

  .status-grid {
    margin-top: 14px;
  }

  .composer__actions {
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }
}
