:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #16181d;
  --text-muted: #5b6270;
  --accent: #3454d1;
  --accent-contrast: #ffffff;
  --success: #1a7f4e;
  --danger: #b3261e;
  --warning: #9a6700;
  --pending: #c7cbd3;
  --radius: 10px;
  --focus-ring: #3454d1;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  margin-bottom: 2rem;
}

.app-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-muted);
  margin: 0;
  font-size: 1rem;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Form --- */

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.input-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

input[type="text"] {
  flex: 1 1 260px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
}

input[type="text"]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  background: var(--surface);
}

.btn {
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1.2rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: #2b46b3;
}

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

.btn-secondary:hover {
  background: #eceef2;
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0;
  text-decoration: underline;
  font-weight: 500;
  margin-top: 1rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
}

/* --- Progress section --- */

#progress-heading {
  font-size: 1.15rem;
  margin: 0 0 1.25rem;
  word-break: break-word;
}

.stage-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.stage-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0;
  font-size: 0.97rem;
  color: var(--text-muted);
}

.stage-list li.is-completed {
  color: var(--text);
}

.stage-list li.is-running {
  color: var(--text);
  font-weight: 600;
}

.stage-list li.is-failed {
  color: var(--danger);
  font-weight: 600;
}

.stage-icon {
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border: 2px solid var(--pending);
  color: var(--pending);
}

.is-completed .stage-icon {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.is-running .stage-icon {
  border-color: var(--accent);
  color: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.is-failed .stage-icon {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 84, 209, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(52, 84, 209, 0); }
}

.stage-label {
  flex: 1 1 auto;
}

.stage-meta {
  flex: 0 0 auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.activity-panel {
  background: var(--bg);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.5rem;
}

#activity-text {
  margin: 0 0 0.6rem;
  font-weight: 600;
}

.progress-bar-wrap {
  background: var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s ease;
}

.current-url-line {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
}

.current-url-line .label {
  font-weight: 600;
  color: var(--text);
}

/* --- Error section --- */

#error-heading {
  color: var(--danger);
  margin-top: 0;
}

.error-detail {
  margin: 0 0 1.25rem;
}

.error-detail dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.error-detail dd {
  margin: 0.15rem 0 0;
  font-size: 1rem;
}

/* --- Result section --- */

#result-heading {
  color: var(--success);
  margin-top: 0;
}

#result-person-name {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
}

.bio {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 1.25rem;
}

.stat-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.rating-block {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.rating-label {
  font-weight: 600;
}

.rating-badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid var(--pending);
}

.rating-badge[data-rating="Strong"] {
  background: #e6f4ec;
  color: var(--success);
  border-color: var(--success);
}

.rating-badge[data-rating="Moderate"] {
  background: #fdf3e0;
  color: var(--warning);
  border-color: var(--warning);
}

.rating-badge[data-rating="Weak"] {
  background: #fbeae9;
  color: var(--danger);
  border-color: var(--danger);
}

.rating-reason {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

.result-detail {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.result-detail h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.6rem;
}

.result-detail h3:first-child {
  margin-top: 0;
}

.project-list, .writing-list, .contact-list, .notes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.notes-list {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.project-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
}

.project-item h4 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.project-item a {
  color: var(--accent);
}

.factor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.factor-chip {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.writing-list a, .contact-list a {
  color: var(--accent);
}

.empty-note {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2.5rem;
}

@media (max-width: 480px) {
  .page {
    padding: 1.5rem 0.85rem 2rem;
  }

  .card {
    padding: 1.25rem;
  }

  .input-row {
    flex-direction: column;
  }

  .btn-primary {
    width: 100%;
  }

  .stat-row {
    gap: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-running .stage-icon {
    animation: none;
  }
  .progress-bar {
    transition: none;
  }
}
