:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --panel: #15151f;
  --panel-hover: #1c1c2b;
  --fg: #e8e6f0;
  --dim: #9b98ad;
  --line: #262633;
  --acc: #7c6cff;
  --acc2: #39d0ff;
  --warm: #ffb454;
  --danger: #ff5f57;
  --success: #7cffc4;
  --grad: linear-gradient(120deg, #7c6cff, #39d0ff 55%, #7cffc4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  color: var(--fg);
  background: var(--bg);
  font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", sans-serif;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

::selection {
  color: #fff;
  background: var(--acc);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: #2c2c3d;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--acc);
}

/* Header */
.play-header {
  position: relative;
  z-index: 100;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgb(10 10 15 / 85%);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  color: var(--fg);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-decoration: none;
}

.logo em {
  color: transparent;
  font-style: normal;
  background: var(--grad);
  background-clip: text;
  -webkit-background-clip: text;
}

.badge {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #7c6cff66;
  color: var(--acc2);
  background: #7c6cff15;
}

.badge-session {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.65rem;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 5px;
}
.badge-session::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--panel-hover);
  border-color: var(--acc);
}

.icon-btn.primary {
  background: #7c6cff22;
  border-color: #7c6cff88;
  color: var(--acc2);
}

.icon-btn.primary:hover {
  background: #7c6cff44;
  border-color: var(--acc2);
}

.icon-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Chat Main Layout */
.chat-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

.messages-pane {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Welcome state */
.welcome-screen {
  margin: auto;
  text-align: center;
  max-width: 520px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.welcome-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--acc);
  box-shadow: 0 0 24px #7c6cff66;
  object-fit: cover;
  margin-bottom: 16px;
}

.welcome-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.welcome-desc {
  font-size: 0.85rem;
  color: var(--dim);
  line-height: 1.6;
  margin-bottom: 24px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.prompt-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.prompt-chip:hover {
  background: #7c6cff22;
  border-color: var(--acc);
  color: var(--acc2);
  transform: translateY(-2px);
}

/* Messages */
.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
  animation: messageIn 0.25s ease-out;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-avatar.user-avatar {
  background: linear-gradient(135deg, #7c6cff, #39d0ff);
  color: #0a0a0f;
  font-weight: 700;
  font-size: 0.8rem;
  font-family: "JetBrains Mono", monospace;
}

.message-bubble {
  max-width: min(650px, 82%);
  padding: 12px 18px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.7;
  position: relative;
  word-break: break-word;
}

.message-row.assistant .message-bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  color: var(--fg);
}

.message-row.user .message-bubble {
  background: #252244;
  border: 1px solid #7c6cff55;
  border-top-right-radius: 4px;
  color: #fff;
}

.message-bubble pre {
  background: #09090e;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}

.message-bubble code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--warm);
}

.message-bubble pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

/* Typing cursor & loader */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--acc2);
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  vertical-align: -2px;
  background: var(--acc2);
  margin-left: 3px;
  animation: blink 0.8s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Alert Banner */
.error-banner {
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(255, 95, 87, 0.12);
  border: 1px solid rgba(255, 95, 87, 0.4);
  color: #ff9d99;
  font-size: 0.82rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 20px 10px;
}

.error-banner a {
  color: var(--acc2);
  text-decoration: underline;
}

/* Input Area */
.input-pane {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: rgb(17 17 24 / 90%);
  backdrop-filter: blur(14px);
  padding: 14px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-box-wrapper {
  display: flex;
  align-items: flex-end;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 10px 6px 16px;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box-wrapper:focus-within {
  border-color: var(--acc);
  box-shadow: 0 0 16px rgba(124, 108, 255, 0.25);
}

.chat-input {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
  min-height: 26px;
  padding: 6px 0;
}

.chat-input:focus {
  outline: none;
}

.chat-input::placeholder {
  color: #555566;
}

.send-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--grad);
  color: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.send-btn:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(124, 108, 255, 0.4);
  transform: translateY(-1px);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(1);
}

.send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.stop-btn {
  background: var(--danger) !important;
  color: #fff !important;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--dim);
  padding: 0 4px;
}

.input-hints {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-hints kbd {
  font-family: "JetBrains Mono", monospace;
  background: #26263388;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--acc2);
}

/* Responsive */
@media (max-width: 640px) {
  .play-header {
    padding: 10px 14px;
  }
  .badge-session {
    display: none;
  }
  .messages-pane {
    padding: 16px 12px;
  }
  .input-pane {
    padding: 10px 12px 14px;
  }
  .input-hints {
    display: none;
  }
}
