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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --error: #dc2626;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 10px;
  flex-wrap: nowrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.header-logo {
  height: 32px;
  max-width: 100px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.header-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

header h1 {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-ready { background: #e0f2fe; color: #0369a1; }
.status-active { background: #fef3c7; color: #92400e; animation: pulse 2s infinite; }
.status-done { background: #dcfce7; color: #166534; }
.status-error { background: #fee2e2; color: #991b1b; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* Start section */
.start-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 32px 20px 40px;
  gap: 18px;
}

.start-description {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 300px;
  margin-bottom: 4px;
}

.btn-start {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 8px;
}

.btn-start:active {
  transform: scale(0.95);
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.btn-start:disabled {
  background: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
}

/* Service selector */
.service-selector {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  max-width: 300px;
}

.service-selector label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}

.service-selector select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.service-selector select:focus {
  border-color: var(--primary);
}

/* Chat section */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: fadeIn 0.3s ease;
}

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

.chat-bubble.ai {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  background: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble.typing {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
}

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

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* Chat input */
.chat-input-area {
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-input-area textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
  border-color: var(--primary);
}

.input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:active { background: var(--bg); }
.btn-icon.recording {
  background: var(--error);
  color: white;
  border-color: var(--error);
  animation: pulse 1s infinite;
}

.btn-primary {
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-secondary {
  padding: 10px 24px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
}

/* Results section */
.results-section {
  padding: 20px;
}

.results-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.field-group {
  margin-bottom: 16px;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.field-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  background: var(--surface);
}

.field-group textarea:focus {
  border-color: var(--primary);
}

.btn-save {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 8px;
}

/* Progress bar */
.progress-bar {
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}

.progress-steps {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 6px;
}

.step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.3s;
}

.step.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.step.done {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.progress-label {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Utility */
.hidden { display: none !important; }

/* Saved toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  z-index: 100;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* === RESPONSIVE — mobile === */
@media (max-width: 480px) {
  header {
    padding: 10px 12px;
    gap: 8px;
  }

  .header-brand {
    gap: 8px;
  }

  .header-logo {
    height: 26px;
    max-width: 80px;
  }

  header h1 {
    font-size: 14px;
  }

  .header-subtitle {
    font-size: 10px;
  }

  .status-badge {
    font-size: 10px;
    padding: 3px 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .start-section {
    padding: 24px 16px 32px;
    gap: 14px;
  }

  .start-description {
    font-size: 13px;
  }

  .service-selector {
    max-width: 100%;
  }

  .service-selector select {
    padding: 8px 10px;
    font-size: 14px;
  }

  .btn-start {
    width: 110px;
    height: 110px;
    font-size: 14px;
  }

  .chat-messages {
    padding: 12px 14px;
    gap: 10px;
  }

  .chat-bubble {
    max-width: 90%;
    padding: 10px 14px;
    font-size: 14px;
  }

  .chat-input-area {
    padding: 10px 14px;
  }

  .chat-input-area textarea {
    font-size: 14px;
    padding: 8px 10px;
  }

  .results-section {
    padding: 16px;
  }

  .field-group textarea {
    font-size: 14px;
    padding: 8px 10px;
  }

  .progress-bar {
    padding: 10px 14px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  header {
    padding: 8px 10px;
  }

  .header-logo {
    height: 22px;
    max-width: 70px;
  }

  header h1 {
    font-size: 13px;
  }

  .start-section {
    padding: 20px 12px 24px;
    gap: 12px;
  }

  .btn-start {
    width: 100px;
    height: 100px;
    font-size: 13px;
  }
}
