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

:root {
  --bg-primary: #111b21;
  --bg-secondary: #1f2c34;
  --bg-header: #202c33;
  --bg-input: #2a3942;
  --bg-bubble-user: #005c4b;
  --bg-bubble-ai: #1f2c34;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --accent: #00a884;
  --accent-hover: #06cf9c;
  --recording: #ef4444;
  --border: #2a3942;
  --progress-ring: #00a884;
  --progress-bg: #2a3942;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-container {
  width: 100%;
  max-width: 500px;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
}

/* Header */
.app-header {
  background: var(--bg-header);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.header-info {
  flex: 1;
  min-width: 0;
}

.header-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-status {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cost display */
.cost-display {
  background: var(--bg-input);
  padding: 4px 10px;
  border-radius: 12px;
  flex-shrink: 0;
}

.cost-display span {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Progress ring */
.progress-ring-container {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--progress-bg);
  stroke-width: 3;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--progress-ring);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Section bar */
.section-bar {
  background: var(--bg-secondary);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--progress-bg);
  flex-shrink: 0;
  transition: all 0.3s;
}

.section-dot.completed {
  background: var(--accent);
}

.section-dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 4px;
}

.section-connector {
  width: 12px;
  height: 2px;
  background: var(--progress-bg);
  flex-shrink: 0;
}

.section-connector.completed {
  background: var(--accent);
}

.section-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 8px;
  white-space: nowrap;
}

/* Welcome screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.welcome-screen.hidden { display: none; }

.welcome-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.welcome-icon svg {
  width: 40px;
  height: 40px;
  fill: #fff;
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.welcome-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 32px;
  max-width: 320px;
}

.start-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 40px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.start-btn:hover {
  background: var(--accent-hover);
}

.start-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Chat area */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-container.hidden { display: none; }

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

/* Chat bubbles */
.message {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 2px;
}

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

.message-wrapper.assistant {
  align-items: flex-start;
}

.message.user {
  background: var(--bg-bubble-user);
  border-top-right-radius: 2px;
}

.message.assistant {
  background: var(--bg-bubble-ai);
  border-top-left-radius: 2px;
}

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 4px;
}

.message .audio-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.message .audio-indicator svg {
  width: 14px;
  height: 14px;
  fill: var(--accent);
}

/* Processing states */
.processing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-bubble-ai);
  border-radius: 8px;
  align-self: flex-start;
  max-width: 85%;
}

.processing-dots {
  display: flex;
  gap: 4px;
}

.processing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: dotPulse 1.4s infinite ease-in-out;
}

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

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.processing-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Input bar */
.input-bar {
  background: var(--bg-header);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.mode-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

.mode-toggle:hover {
  color: var(--text-primary);
}

.mode-toggle svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Text input */
.text-input-container {
  flex: 1;
  display: none;
}

.text-input-container.active {
  display: flex;
}

.text-input {
  flex: 1;
  background: var(--bg-input);
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}

.text-input::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Record button */
.record-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.record-container.hidden {
  display: none;
}

.record-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.record-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.record-btn.recording {
  background: var(--recording);
  animation: recordPulse 1.5s infinite;
}

@keyframes recordPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.record-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 12px;
}

.recording-timer {
  font-size: 14px;
  color: var(--recording);
  font-weight: 600;
  margin-left: 12px;
  font-variant-numeric: tabular-nums;
}

/* CV Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.cv-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cv-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #ddd;
}

.cv-modal-header h3 {
  font-size: 18px;
  color: #2c3e50;
}

.cv-modal-actions {
  display: flex;
  gap: 8px;
}

.cv-modal-actions button {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-download {
  background: #2980b9;
  color: #fff;
}

.btn-download:hover {
  background: #2471a3;
}

.btn-close-modal {
  background: #e9ecef;
  color: #333;
}

.btn-close-modal:hover {
  background: #dee2e6;
}

.cv-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.cv-modal-body iframe {
  width: 100%;
  height: 600px;
  border: none;
}

/* Error toast */
.error-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc3545;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  animation: toastIn 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.error-toast.hidden { display: none; }

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

@media (max-width: 500px) {
  .app-container {
    max-width: 100%;
  }
}
