:root {
  --bg: #0a0f17;
  --surface: rgba(15, 22, 34, 0.9);
  --surface-strong: #131b28;
  --surface-soft: #1a2638;
  --ink: #e8edf7;
  --muted: #9caac0;
  --accent: #17c79a;
  --accent-2: #4aa3ff;
  --accent-3: #ff9f40;
  --line: rgba(118, 152, 200, 0.2);
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(70vw 45vh at 12% 10%, rgba(74, 163, 255, 0.2), transparent 58%),
    radial-gradient(55vw 42vh at 94% 4%, rgba(23, 199, 154, 0.18), transparent 56%),
    radial-gradient(65vw 45vh at 50% 98%, rgba(255, 159, 64, 0.14), transparent 62%),
    linear-gradient(180deg, #05080f 0%, var(--bg) 100%);
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(4px);
}

.bg-shape-a {
  width: 310px;
  height: 310px;
  left: -85px;
  bottom: 8vh;
  background: rgba(74, 163, 255, 0.2);
}

.bg-shape-b {
  width: 350px;
  height: 350px;
  right: -110px;
  top: 14vh;
  background: rgba(23, 199, 154, 0.15);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 18px auto;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.app-header,
.chat-panel {
  backdrop-filter: blur(6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.app-header {
  display: grid;
  gap: 14px;
  grid-template-columns: 1.4fr 1fr;
  align-items: end;
  animation: reveal-up 0.55s ease;
}

.eyebrow {
  margin: 0;
  color: #7db5ff;
  font-weight: 700;
  font-size: 0.9rem;
}

h1 {
  margin: 6px 0 0;
  font-size: clamp(1.5rem, 2.8vw, 2.3rem);
}

.source-form {
  display: grid;
  gap: 8px;
}

.source-form label {
  font-weight: 700;
}

.source-row {
  display: flex;
  gap: 8px;
}

.source-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: #0e1623;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.source-row input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(74, 163, 255, 0.2);
}

button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.source-row button {
  background: linear-gradient(120deg, #119d8e, #2d7ce3);
  color: #f4f8ff;
  min-width: 96px;
  padding: 0 14px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.chat-panel {
  min-height: min(72vh, 860px);
  display: grid;
  grid-template-rows: auto 1fr;
  animation: reveal-up 0.5s ease;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-window {
  border: 1px solid rgba(123, 156, 201, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(15, 24, 37, 0.9) 0%, rgba(8, 14, 23, 0.92) 100%);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.chat-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: rise-in 0.32s ease;
}

.msg {
  max-width: min(84%, 640px);
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.8;
  border: 1px solid rgba(145, 170, 209, 0.2);
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(145deg, rgba(37, 84, 148, 0.95), rgba(20, 128, 120, 0.95));
  color: #f7fbff;
  box-shadow: 0 10px 24px rgba(23, 65, 110, 0.35);
}

.msg.bot {
  align-self: flex-start;
  background: var(--surface-soft);
  color: #deebff;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.item-chip {
  border: 1px solid rgba(23, 199, 154, 0.35);
  background: rgba(12, 35, 31, 0.95);
  color: #95f5dc;
  padding: 10px 14px;
  border-radius: 11px;
  width: min(100%, 480px);
  text-align: right;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.item-chip:hover {
  transform: translateY(-1px);
  background: rgba(14, 58, 50, 0.95);
  border-color: rgba(76, 222, 192, 0.52);
}

.ghost-btn {
  border: 1px solid var(--line);
  color: #a7c9ff;
  background: #101926;
  padding: 8px 12px;
}

.status {
  min-height: 1.4em;
  margin: 0 2px;
  color: var(--muted);
  font-size: 0.93rem;
}

.status.error {
  color: #ff8a8a;
  font-weight: 700;
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .app-shell {
    margin: 10px auto;
    padding: 12px;
  }

  .app-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .source-row {
    flex-direction: column;
  }

  .source-row button {
    min-height: 44px;
  }

  .chat-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-panel {
    min-height: 76vh;
  }

  .msg {
    max-width: 100%;
  }

  .item-chip {
    width: 100%;
  }
}
