:root {
  --bg-a: #0b1520;
  --bg-b: #112b2f;
  --card: rgba(8, 14, 20, 0.72);
  --card-border: rgba(136, 186, 176, 0.28);
  --text: #ecf6f3;
  --muted: #a5c5bf;
  --accent: #1ec8a3;
  --accent-strong: #0ca07f;
  --warn: #ff7d66;
  --user-bubble: #1f4f4b;
  --assistant-bubble: #1a2230;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(47, 180, 153, 0.35), transparent 50%),
    radial-gradient(circle at 100% 20%, rgba(248, 155, 83, 0.22), transparent 45%),
    linear-gradient(165deg, var(--bg-a), var(--bg-b));
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, black, transparent 75%);
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.panel {
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: var(--card);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(4, 10, 20, 0.45);
}

.hidden {
  display: none !important;
}

.login-panel {
  margin: 8vh auto 0;
  width: min(420px, 100%);
  padding: 28px;
}

.brand {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-size: 0.76rem;
  margin-bottom: 10px;
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 2rem;
}

.login-panel p {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-panel form {
  display: grid;
  gap: 10px;
}

.login-panel label {
  font-size: 0.9rem;
  color: var(--muted);
}

input,
textarea,
button {
  font: inherit;
}

.login-panel input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(176, 215, 206, 0.35);
  background: rgba(14, 22, 34, 0.72);
  color: var(--text);
  padding: 12px 14px;
}

.login-panel button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  color: #06261f;
  font-weight: 700;
  background: linear-gradient(120deg, #34ddb8, #1ea37b);
  cursor: pointer;
}

.error {
  min-height: 20px;
  color: var(--warn);
  margin-top: 12px;
  font-size: 0.92rem;
}

.chat-panel {
  height: calc(100vh - 48px);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  border-bottom: 1px solid rgba(137, 182, 176, 0.25);
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.chat-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.chat-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.robot-picker {
  display: flex;
  gap: 8px;
  align-items: center;
}

.robot-picker input {
  width: 180px;
  border-radius: 10px;
  border: 1px solid rgba(166, 204, 193, 0.4);
  background: rgba(8, 15, 22, 0.5);
  color: var(--text);
  padding: 8px 10px;
}

.robot-picker input::placeholder {
  color: rgba(213, 236, 230, 0.6);
}

.ghost {
  border: 1px solid rgba(166, 204, 193, 0.4);
  border-radius: 10px;
  background: rgba(8, 15, 22, 0.5);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: min(78ch, 88%);
  border: 1px solid rgba(166, 204, 193, 0.26);
  border-radius: 16px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(165deg, rgba(35, 92, 86, 0.9), var(--user-bubble));
}

.message.assistant {
  align-self: flex-start;
  background: linear-gradient(165deg, rgba(27, 39, 59, 0.93), var(--assistant-bubble));
}

.message.system {
  align-self: center;
  background: rgba(34, 44, 54, 0.75);
  color: var(--muted);
}

.message img {
  max-width: 100%;
  border-radius: 10px;
  margin-top: 8px;
  border: 1px solid rgba(162, 202, 192, 0.32);
}

.attachment-name {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.composer {
  border-top: 1px solid rgba(137, 182, 176, 0.25);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.image-preview {
  border: 1px solid rgba(156, 204, 191, 0.3);
  border-radius: 12px;
  background: rgba(8, 16, 24, 0.66);
  padding: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.image-preview img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 8px;
}

.image-meta {
  display: grid;
  gap: 8px;
}

.image-meta span {
  color: var(--muted);
  font-size: 0.82rem;
  word-break: break-all;
}

.image-meta button {
  border: 1px solid rgba(230, 164, 150, 0.5);
  border-radius: 9px;
  color: #ffd6cd;
  background: rgba(66, 25, 19, 0.55);
  padding: 6px 10px;
  cursor: pointer;
  width: fit-content;
}

.composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: end;
}

.attach-btn {
  border: 1px dashed rgba(156, 214, 200, 0.55);
  color: var(--muted);
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  min-width: 78px;
  text-align: center;
}

#imageInput {
  display: none;
}

#chatInput {
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid rgba(155, 199, 190, 0.42);
  background: rgba(7, 14, 21, 0.84);
  color: var(--text);
  padding: 11px 12px;
}

#sendBtn {
  border: none;
  border-radius: 11px;
  color: #06261f;
  font-weight: 700;
  min-width: 88px;
  padding: 11px 14px;
  cursor: pointer;
  background: linear-gradient(120deg, #3ae3bd, #179f79);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 860px) {
  .shell {
    padding: 10px;
  }

  .chat-panel {
    height: calc(100vh - 20px);
    border-radius: 16px;
  }

  .chat-header {
    padding: 14px 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .robot-picker {
    width: 100%;
  }

  .robot-picker input {
    width: 100%;
    min-width: 0;
  }

  .messages {
    padding: 12px;
  }

  .message {
    max-width: 94%;
  }

  .composer {
    padding: 10px;
  }

  .composer-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .attach-btn,
  #sendBtn {
    width: 100%;
  }

  #chatInput {
    min-height: 88px;
  }
}
