:root {
  --side: #07151f;
  --side-mid: #0c2230;
  --side-hover: #143042;
  --green: #3fbf3a;
  --green-2: #2f9a2c;
  --green-soft: #b7e3a8;
  --gold: #f0b429;
  --paper: #eef2ee;
  --text: #122017;
  --muted: #66756c;
  --line: #dce4dc;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(7, 21, 31, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: Outfit, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--paper);
}

body {
  display: grid;
  grid-template-columns: 76px 1fr;
  height: 100%;
  min-height: 0;
  transition: grid-template-columns .22s ease;
}

body.sidebar-open {
  grid-template-columns: 292px 1fr;
}

button, input, textarea { font-family: inherit; }
::selection { background: #c8efb6; }

.sidebar {
  position: relative;
  background:
    radial-gradient(420px 240px at 20% -10%, rgba(63, 191, 58, .18), transparent 60%),
    linear-gradient(180deg, #0a1c28 0%, var(--side) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px 10px 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid rgba(240, 180, 41, .12);
  transition: padding .22s ease;
}

body.sidebar-open .sidebar {
  padding: 22px 16px 14px;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.8'/%3E%3C/filter%3E%3Crect width='80' height='80' filter='url(%23n)'/%3E%3C/svg%3E");
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  position: relative;
  justify-content: center;
}

body.sidebar-open .brand { justify-content: flex-start; margin-bottom: 20px; }

.logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(240, 180, 41, .35), 0 8px 18px rgba(0,0,0,.25);
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-title { font-weight: 800; font-size: 22px; letter-spacing: -.04em; }
.brand-sub { font-size: 11px; color: #b7c4bc; line-height: 1.35; margin-top: 2px; }
.brand-tag { font-size: 11px; color: var(--gold); margin-top: 4px; font-weight: 600; letter-spacing: .02em; }

.btn-new {
  width: 100%;
  border: 0;
  background: linear-gradient(180deg, #4ad344 0%, var(--green) 100%);
  color: #fff;
  font-weight: 700;
  border-radius: 14px;
  padding: 12px 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 22px rgba(63, 191, 58, .28);
  position: relative;
  transition: transform .15s ease, filter .15s ease;
}

.btn-new .plus { font-size: 18px; line-height: 1; }
.btn-new:hover { filter: brightness(1.05); transform: translateY(-1px); }

.conv-label {
  margin: 22px 8px 10px;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #8a9aa3;
  font-weight: 600;
}

.brand, .btn-new, .conv-label, .sidebar-foot { flex-shrink: 0; }

.conv-list {
  list-style: none;
  margin: 0;
  padding: 0 2px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.16);
  border-radius: 8px;
}

.conv-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 11px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}

.conv-list li:hover { background: var(--side-hover); }

.conv-list li.active {
  background: linear-gradient(90deg, rgba(63, 191, 58, .18), rgba(20, 48, 66, .5));
  border-color: rgba(63, 191, 58, .28);
}

.conv-icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  opacity: .65;
  flex-shrink: 0;
}

.conv-list li.active .conv-icon { opacity: 1; color: var(--green-soft); }

.conv-list .t {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-list .d { font-size: 11px; color: #8a9aa3; margin-top: 3px; }

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.agent { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #d5e2da; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(63, 191, 58, .18);
}
.dot.off { background: #f87171; box-shadow: 0 0 0 4px rgba(248, 113, 113, .18); }

.btn-exit {
  background: transparent;
  color: #c5d0c8;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}
.btn-exit:hover { color: #fff; border-color: rgba(240, 180, 41, .5); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(720px 340px at 50% 12%, rgba(63, 191, 58, .09), transparent 58%),
    radial-gradient(520px 280px at 90% 100%, rgba(240, 180, 41, .07), transparent 50%),
    var(--paper);
}

.topbar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(220, 228, 220, .9);
}

.menu-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-right: 10px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 10px;
  cursor: pointer;
}
.menu-toggle:hover { border-color: var(--green); }

.top-left { display: flex; align-items: center; }
.top-title { font-weight: 700; font-size: 15px; letter-spacing: -.02em; }
.top-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }

.btn-new-top {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  color: var(--text);
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.btn-new-top:hover { border-color: var(--green); color: var(--green-2); }

.welcome, .thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 8% 12px;
}

.welcome[hidden], .thread[hidden] {
  display: none !important;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
}

.hero {
  position: relative;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.robot-glow {
  position: absolute;
  width: 220px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(63, 191, 58, .28), rgba(138, 92, 246, .12) 42%, transparent 70%);
  filter: blur(12px);
  z-index: 0;
  animation: glow 3.4s ease-in-out infinite;
}

.robot {
  position: relative;
  z-index: 1;
  line-height: 0;
}

.robot img {
  width: 176px;
  height: auto;
  display: block;
  object-fit: contain;
  background: transparent;
  animation: float 4.2s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { opacity: .7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.hello {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--green-2);
  font-weight: 700;
}

h1 {
  margin: 6px 0 10px;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -.045em;
  color: #0d1b14;
  line-height: 1.1;
}

.lead {
  color: var(--muted);
  max-width: 560px;
  margin: 0 0 28px;
  line-height: 1.55;
  font-size: 15.5px;
}

.chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(760px, 100%);
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(220, 228, 220, .95);
  border-radius: 16px;
  padding: 16px 16px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  transition: transform .16s ease, box-shadow .15s ease, border-color .15s ease;
}

.chip:hover {
  border-color: rgba(63, 191, 58, .45);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.chip-index {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .08em;
  margin-right: 2px;
}

.chip-arrow { color: #9aa89e; font-size: 20px; line-height: 1; }

.thread { display: flex; flex-direction: column; gap: 16px; padding-top: 22px; }

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 74%;
  animation: in .22s ease;
}

@keyframes in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-row.bot { align-self: flex-start; }

.msg-avatar {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: transparent;
  flex-shrink: 0;
}

.msg {
  padding: 13px 16px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  background: linear-gradient(180deg, #e9f8df, #dcf3d1);
  border-bottom-right-radius: 6px;
}

.msg.bot {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 10px 24px rgba(7, 21, 31, .05);
}

.msg img.chat-img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  margin-top: 8px;
}

.msg.pending {
  font-style: normal;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.wait-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wait-copy strong { font-size: 13px; }
.wait-copy span { font-size: 11px; color: var(--muted); }

.dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: bounce 1.1s infinite ease-in-out;
}

.dots i:nth-child(2) { animation-delay: .15s; background: var(--green-2); }
.dots i:nth-child(3) { animation-delay: .3s; background: var(--gold); }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.send.busy { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  margin: 0 8% 2px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 24px;
  padding: 8px 10px 8px 14px;
  box-shadow: 0 16px 40px rgba(7, 21, 31, .08);
  backdrop-filter: blur(12px);
}

.attach {
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 8px;
  border-radius: 10px;
}
.attach:hover { color: var(--green); background: #f1f8ee; }
.attach input { display: none; }

#input {
  flex: 1;
  border: 0;
  resize: none;
  outline: none;
  font: inherit;
  max-height: 140px;
  padding: 10px 4px;
  background: transparent;
}

.send {
  width: 42px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #c8ebba, var(--green-soft));
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
.send:hover { filter: brightness(1.04); }
.send:disabled { opacity: .45; cursor: wait; }

.hint {
  text-align: center;
  font-size: 11px;
  color: #8b9690;
  margin-bottom: 12px;
  flex-shrink: 0;
}

#file-hint:not(:empty) {
  color: var(--green-2);
  font-weight: 600;
}

body:not(.sidebar-open) .brand-copy,
body:not(.sidebar-open) .btn-new-text,
body:not(.sidebar-open) .conv-label,
body:not(.sidebar-open) .conv-list .t,
body:not(.sidebar-open) .conv-list .d,
body:not(.sidebar-open) #agent-label,
body:not(.sidebar-open) .btn-exit-text {
  display: none;
}

body:not(.sidebar-open) .btn-new {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  margin: 0 auto;
}

body:not(.sidebar-open) .conv-list li {
  justify-content: center;
  padding: 10px 0;
}

body:not(.sidebar-open) .sidebar-foot {
  flex-direction: column;
  align-items: center;
}

body:not(.sidebar-open) .btn-exit {
  width: 40px;
  height: 36px;
  padding: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23c5d0c8' stroke-width='1.8'%3E%3Cpath d='M9 4h5v8H9M12 8H3M6 5l-3 3 3 3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.backdrop { display: none; }

body.login-body {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  background:
    radial-gradient(900px 420px at 20% 10%, rgba(63, 191, 58, .2), transparent 50%),
    radial-gradient(700px 380px at 90% 90%, rgba(240, 180, 41, .12), transparent 46%),
    #07151f;
}

.login-stage {
  width: min(920px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 28px;
  align-items: center;
}

.login-visual {
  position: relative;
  color: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-visual .robot-glow {
  width: 280px;
  height: 180px;
}

.login-bot {
  position: relative;
  z-index: 1;
  width: 220px;
  height: auto;
  object-fit: contain;
  background: transparent;
  animation: float 4.2s ease-in-out infinite;
}

.login-wordmark {
  margin-top: 8px;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -.05em;
}

.login-visual p {
  margin: 4px 0 8px;
  color: #b7c4bc;
}

.login-tag {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: .04em;
}

.login-card {
  background: rgba(255,255,255,.96);
  border-radius: 24px;
  padding: 32px 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  box-shadow: 0 30px 70px rgba(0,0,0,.28);
}

.login-card .logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 4px;
}
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.login-card p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}
.login-card input[type="text"],
.login-card input[type="password"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  font: inherit;
  outline: none;
  background: #f7faf7;
}
.login-card input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(63, 191, 58, .16);
  background: #fff;
}
.login-card button[type="submit"] {
  margin-top: 8px;
  border: 0;
  background: linear-gradient(180deg, #4ad344, var(--green));
  color: #fff;
  font-weight: 700;
  border-radius: 12px;
  padding: 13px;
  cursor: pointer;
  font-size: 15px;
  box-shadow: 0 10px 22px rgba(63, 191, 58, .28);
}
.login-card button[type="submit"]:hover { filter: brightness(1.04); }
.login-error {
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .robot img, .login-bot, .robot-glow, .msg-row { animation: none; }
}

@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 20;
    width: min(292px, 86vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.nav-open .sidebar { transform: none; }
  .backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 21, 31, .5);
    z-index: 15;
  }
  body.nav-open .backdrop { display: block; }
  .menu-toggle { display: grid; place-items: center; }
  body, body.sidebar-open { grid-template-columns: 1fr; }
  .welcome, .thread, .composer { margin-left: 16px; margin-right: 16px; padding-left: 0; padding-right: 0; }
  h1 { font-size: 28px; }
  .chips { grid-template-columns: 1fr; }
  .msg-row { max-width: 92%; }
  .robot img { width: 140px; }
  .login-stage { grid-template-columns: 1fr; }
  .login-bot { width: 150px; }
  .login-wordmark { font-size: 32px; }
}
