:root {
  --bg: #f8f9fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --brand: #111827;
  --brand-strong: #0b1220;
  --danger: #d7263d;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  position: relative;
}

.bg-shape {
  display: none;
}

.bg-shape-1 {
  width: 280px;
  height: 280px;
  background: #cde0ff;
  top: -90px;
  left: -80px;
}

.bg-shape-2 {
  width: 260px;
  height: 260px;
  background: #ccf6e8;
  bottom: -80px;
  right: -70px;
}

.view {
  width: 100%;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 24px rgba(16, 24, 40, 0.06);
}

.login-card {
  width: 100%;
  max-width: 430px;
  padding: 28px;
  animation: riseIn 300ms ease-out;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h1 {
  margin: 16px 0 8px;
  font-size: 30px;
  line-height: 1.1;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
}

.stack-md {
  display: grid;
  gap: 12px;
}

label {
  font-size: 14px;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: #c7ccd4;
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.08);
}

button {
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

button:hover {
  background: var(--brand-strong);
}

button:active {
  transform: translateY(1px);
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.app-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  font-family: "IBM Plex Mono", monospace;
  color: #4b5563;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  font-size: 12px;
  padding: 6px 10px;
}

.ghost-btn {
  background: #f3f4f6;
  color: #111827;
}

.ghost-btn:hover {
  background: #e5e7eb;
}

.ghost-btn.danger {
  color: #9b1f2e;
  background: #ffeef1;
}

.ghost-btn.danger:hover {
  background: #ffdbe2;
}

.chat-container {
  overflow-y: auto;
  padding: 26px 16px 12px;
}

.messages-list {
  max-width: 780px;
  margin: 0 auto;
  display: grid;
  gap: 8px;
}

.msg {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: none;
  animation: riseIn 180ms ease-out;
}

.msg .author {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #6b7280;
  margin-bottom: 6px;
}

.msg.user {
  background: #f9fafb;
  border-color: #eceff3;
}

.msg.assistant {
  background: #ffffff;
}

.msg .content {
  white-space: pre-wrap;
  line-height: 1.5;
}

.composer-wrap {
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 12px 16px 16px;
}

.composer {
  max-width: 780px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

#user-input {
  min-height: 48px;
  max-height: 220px;
  resize: none;
  border-radius: 14px;
}

#send-btn {
  align-self: end;
  height: 48px;
  min-width: 86px;
}

#error-toast {
  max-width: 780px;
  margin: 8px auto 0;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .composer button {
    width: 100%;
  }
}
