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

html, body {
  height: auto;
  min-height: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: #f0f0f0;
  background-image: url('/bg.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: #1a1a1a;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.form-header {
  margin-bottom: 32px;
}

.form-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #111;
  margin-bottom: 8px;
}

.hint {
  font-size: 15px;
  color: #6b7280;
  line-height: 1.5;
}

.progress-wrap {
  margin-bottom: 28px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  color: #9ca3af;
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #7B1D31;
  border-radius: 999px;
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.28), transparent);
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
  from { left: -60%; }
  to   { left: 160%; }
}

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  overflow: visible;
  animation: cardIn 500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.page {
  display: none;
}

.page.active {
  display: block;
}

.page.active.from-right {
  animation: slideInRight 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.page.active.from-left {
  animation: slideInLeft 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}

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

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: #111;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f3f4f6;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  color: #1a1a1a;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  appearance: none;
  -webkit-appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239CA3AF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.field textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.5;
}

.field label {
  transition: color 200ms ease;
}

.field:focus-within label {
  color: #7B1D31;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: #fff;
  border-color: #7B1D31;
  box-shadow: 0 0 0 3px rgba(123, 29, 49, 0.12);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #9ca3af;
}

.help {
  display: block;
  font-size: 13px;
  color: #9ca3af;
  margin-top: 6px;
  line-height: 1.4;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid #f3f4f6;
  position: static !important;
  float: none !important;
  width: 100%;
  box-sizing: border-box;
}

.nav-spacer {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 150ms ease;
  line-height: 1;
  position: static !important;
  float: none !important;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #7B1D31;
  color: #fff;
}

.btn-primary:hover {
  background: #621527;
  box-shadow: 0 4px 14px rgba(123, 29, 49, 0.35);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #d1d5db;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
  background: #f9fafb;
  color: #374151;
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary:disabled:hover {
  background: transparent;
  color: #6b7280;
}

.chat-thread {
  margin-top: 28px;
}

.chat-message {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  align-items: flex-start;
  animation: fadeIn 400ms ease;
}

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

.chat-message-user .chat-content {
  align-items: flex-end;
}

.chat-message-user .chat-name {
  text-align: right;
}

.chat-bubble-user {
  background: #7B1D31 !important;
  color: #fff !important;
  border-radius: 14px 0 14px 14px !important;
  border-color: #7B1D31 !important;
}

.chat-bubble-error {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #991b1b !important;
}

.chat-avatar-error {
  background: #dc2626 !important;
}

.reply-box {
  margin-top: 12px;
  animation: fadeIn 400ms ease;
}

.reply-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.reply-input-wrap textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a1a;
  background: transparent;
  padding: 4px 0;
}

.reply-input-wrap textarea::placeholder {
  color: #9ca3af;
}

.reply-input-wrap .btn {
  flex-shrink: 0;
  padding: 8px 12px;
}

.chat-response {
  display: flex;
  gap: 14px;
  margin-top: 28px;
  align-items: flex-start;
  animation: fadeIn 400ms ease;
}

.chat-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-content {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.chat-bubble {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0 14px 14px 14px;
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.7;
  color: #1a1a1a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-bubble h1,
.chat-bubble h2,
.chat-bubble h3 {
  font-weight: 600;
  color: #111;
  margin-top: 16px;
  margin-bottom: 8px;
}

.chat-bubble h1 { font-size: 18px; }
.chat-bubble h2 { font-size: 16px; }
.chat-bubble h3 { font-size: 15px; }

.chat-bubble h1:first-child,
.chat-bubble h2:first-child,
.chat-bubble h3:first-child {
  margin-top: 0;
}

.chat-bubble p {
  margin-bottom: 10px;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble strong {
  font-weight: 600;
  color: #111;
}

.chat-bubble em {
  font-style: italic;
}

.chat-bubble code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SFMono-Regular', Consolas, monospace;
}

.chat-bubble ul,
.chat-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.chat-bubble li {
  margin-bottom: 4px;
}

.chat-bubble li:last-child {
  margin-bottom: 0;
}

.chat-bubble a {
  color: #2563eb;
  text-decoration: underline;
  word-break: break-word;
}

.chat-bubble a:hover {
  color: #1d4ed8;
}

.chat-response.error .chat-bubble {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.chat-response.error .chat-avatar {
  background: #dc2626;
}

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

@media (max-width: 640px) {
  .wrapper {
    padding: 28px 16px 60px;
  }

  .form-header h1 {
    font-size: 22px;
  }

  .card {
    padding: 24px 20px 20px;
    border-radius: 12px;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
}

.form-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.96);
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 10;
  text-align: center;
  padding: 40px 32px;
}

.form-overlay-dots {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-overlay-dots div {
  width: 13px;
  height: 13px;
  background: #7B1D31;
  border-radius: 50%;
  animation: dotBounce 0.9s ease-in-out infinite;
}

.form-overlay-dots div:nth-child(2) { animation-delay: 0.18s; }
.form-overlay-dots div:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.4; }
  40%            { transform: scale(1.25); opacity: 1; }
}

.form-overlay-title {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0;
}

.form-overlay-sub {
  font-size: 15px;
  color: #6b7280;
  line-height: 1.6;
  margin: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chat-thread.card {
  padding: 28px 32px;
}

#chatView {
  animation: fadeIn 300ms ease;
}