/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

:root {
  --primary: #1a1a2e;
  --bg: #fafaf8;
  --surface: #ffffff;
  --muted: #5c5c5c;
  --border: #e0e0e0;
  --accent-bg: #f0f4ff;
  --accent-border: #c8d6f0;
  --warning-bg: #fffbe6;
  --warning-border: #f0e6b0;
  --warning-text: #8a7a2a;
  --error: #dc3545;
  --chip-selected-bg: #1a1a2e;
  --chip-selected-text: #fff;
  --chip-border: #d0d0d0;
  --radius: 10px;
  --radius-sm: 6px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Typography === */
h1, h2, h3 {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
}

code, .mono {
  font-family: 'DM Mono', 'Menlo', monospace;
}

/* === Brand === */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 4px;
}

.brand-name {
  font-family: 'DM Mono', monospace;
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -1px;
  color: var(--primary);
}

.brand-name--small {
  font-size: 1.25rem;
}

.beta-badge {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--primary);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  position: relative;
  top: -2px;
}

.tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

/* === Login Page === */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
}

/* === Form Elements === */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--primary);
}

.required {
  color: var(--error);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  transition: border-color 0.15s;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
}

textarea {
  resize: vertical;
  min-height: 44px;
}

.helper-text {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.char-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  text-align: right;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.85;
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
}

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: var(--primary);
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 4px;
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* === Error & Messages === */
.error-message {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 12px;
  padding: 10px 14px;
  background: #fdf2f2;
  border: 1px solid #f5c6cb;
  border-radius: var(--radius-sm);
}

/* === OTP State === */
.otp-sent-text {
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 20px;
}

#otpInput {
  font-family: 'DM Mono', monospace;
  font-size: 1.5rem;
  letter-spacing: 8px;
  text-align: center;
  padding: 12px;
}

.otp-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.separator {
  color: var(--border);
  font-size: 0.85rem;
}

/* === App Header === */
.app-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.user-email {
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
}

/* === Progress Bar === */
.progress-container {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.progress-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 24px;
}

.progress-steps {
  display: flex;
  align-items: center;
  gap: 0;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.step-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  transition: color 0.2s;
}

.progress-step.active .step-dot {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.progress-step.active .step-label {
  color: var(--primary);
}

.progress-step.completed .step-dot {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.progress-step.completed .step-label {
  color: var(--primary);
}

.progress-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  transition: background 0.2s;
  min-width: 12px;
}

.progress-line.completed {
  background: var(--primary);
}

/* === Main Content === */
.main-content {
  padding: 32px 24px 64px;
}

.content-inner {
  max-width: 640px;
  margin: 0 auto;
}

.step-title {
  font-size: 1.6rem;
  margin-bottom: 28px;
  color: var(--primary);
}

/* === Chip Select === */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  padding: 7px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--chip-border);
  border-radius: 100px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--primary);
}

.chip.selected {
  background: var(--chip-selected-bg);
  color: var(--chip-selected-text);
  border-color: var(--chip-selected-bg);
}

.chip-group--multi .chip.selected {
  position: relative;
}

.other-input-wrap {
  margin-top: 10px;
}

/* === Step Actions === */
.step-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* === Review Card === */
.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.review-item {
  margin-bottom: 16px;
}

.review-item:last-child {
  margin-bottom: 0;
}

.review-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 2px;
  font-family: 'DM Mono', monospace;
}

.review-value {
  font-size: 0.95rem;
  color: var(--primary);
  line-height: 1.5;
}

/* === Disclaimer Box === */
.disclaimer-box {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.85rem;
  color: var(--warning-text);
  line-height: 1.5;
  margin-bottom: 24px;
}

.disclaimer-box strong {
  font-weight: 600;
}

/* === Loading State === */
.loading-state {
  text-align: center;
  padding: 80px 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

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

.loading-text {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.loading-timer {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

/* === Error State === */
.error-state {
  text-align: center;
  padding: 60px 0;
}

.error-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fdf2f2;
  color: var(--error);
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.error-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.error-state .error-message {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  text-align: center;
}

/* === Results === */
.result-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  line-height: 1.7;
}

.result-content h1 {
  font-size: 1.5rem;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.result-content h1:first-child {
  margin-top: 0;
}

.result-content h2 {
  font-size: 1.25rem;
  margin: 28px 0 12px;
}

.result-content h3 {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 8px;
}

.result-content p {
  margin-bottom: 12px;
}

.result-content ul,
.result-content ol {
  margin-bottom: 12px;
  padding-left: 24px;
}

.result-content li {
  margin-bottom: 4px;
}

.result-content li > ul,
.result-content li > ol {
  margin-top: 4px;
  margin-bottom: 4px;
}

.result-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.result-content strong {
  font-weight: 600;
}

.result-content .tam-highlight {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent-border);
  padding: 8px 14px;
  margin: 8px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-weight: 500;
}

/* === Footer === */
.footer {
  padding: 32px 24px 24px;
  text-align: center;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-feedback {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 16px;
  max-width: 420px;
  text-align: center;
  line-height: 1.5;
}

.footer-feedback a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-text {
  font-size: 0.75rem;
  color: var(--muted);
}

.footer-logo-link {
  display: flex;
  align-items: center;
  transition: opacity 0.2s;
}

.footer-logo-link:hover {
  opacity: 0.7;
}

.footer-logo {
  height: 28px;
  width: auto;
  display: block;
}

/* === Responsive === */
@media (max-width: 600px) {
  .login-card {
    padding: 32px 20px;
  }

  .header-inner {
    padding: 10px 16px;
  }

  .user-email {
    display: none;
  }

  .progress-inner {
    padding: 12px 16px;
    overflow-x: auto;
  }

  .step-label {
    font-size: 0.7rem;
  }

  .progress-line {
    min-width: 8px;
    margin: 0 4px;
  }

  .main-content {
    padding: 24px 16px 48px;
  }

  .step-title {
    font-size: 1.35rem;
  }

  .chip {
    font-size: 0.8rem;
    padding: 6px 14px;
  }

  .result-content {
    padding: 20px;
  }

  .step-actions {
    gap: 12px;
  }

  .btn {
    padding: 10px 18px;
    font-size: 0.85rem;
  }
}

@media (max-width: 380px) {
  .progress-step .step-label {
    display: none;
  }

  .progress-line {
    margin: 0 6px;
  }
}
