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

:root {
  --bg: #e9e9e9;
  --bg-hover: #a4a4a4;
  --surface: #e9e9e9;
  --border: #a1a1a1;
  --border-hi: #333;
  --text: #090909;
  --muted: #6b6560;
  --accent: #6973cb;
  --accent-lo: #e9e9e9;
  --green: #14833d;
  --red: #b62323;
  --font-head: sans-serif;
  --font-body: "DM Sans", sans-serif;
  --font-mono: monospace;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 3rem 1.25rem 5rem;
}

/* ── Layout ─────────────────────────────────────────── */
.wrap {
  max-width: 760px;
  margin: 0 auto;
}

/* ── Step rail ──────────────────────────────────────── */
.step-rail {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2.5rem;
}

.step-node {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  opacity: 0.35;
}

.step-node.active {
  opacity: 1;
}
.step-node.done {
  opacity: 0.6;
}

.step-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
}

.step-node.active .step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}

.step-node.done .step-circle {
  background: transparent;
  border-color: var(--green);
  color: var(--green);
}

.step-label {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  white-space: nowrap;
  color: var(--text);
}

.step-track {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 0.75rem;
  min-width: 24px;
}

/* ── Card ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  animation: fadeIn 0.25s ease;
}

.card-heading {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.375rem;
}

.card-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

/* ── Form ───────────────────────────────────────────── */
.field {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

input[type="text"],
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  padding: 0.7rem 0.9rem;
  outline: none;
  appearance: none;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-lo);
}

textarea {
  resize: vertical;
  min-height: 108px;
  line-height: 1.55;
}

::placeholder {
  color: var(--muted);
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: 1.5px solid transparent;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--accent);
  color: var(--text);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-hi);
  color: var(--muted);
}
.btn-ghost:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.btn-logout {
  padding: 2rem;
}

/* ── Alert ───────────────────────────────────────────── */
.alert {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  padding: 0.65rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.alert-error {
  background: var(--surface);
  border-color: var(--red);
  color: var(--red);
}

/* ── Loading ─────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 3rem 1rem;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 2.5px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.loading-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Results list ────────────────────────────────────── */
.results-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.sel-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  border: 1px solid var(--border-hi);
  color: var(--muted);
}

.sel-badge.has-sel {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-lo);
}

.result-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.625rem;
  cursor: pointer;
  user-select: none;
}

.result-item:hover {
  border-color: var(--border-hi);
  background: var(--bg-hover);
}

.result-item.selected {
  border-color: var(--accent);
  background: var(--accent-lo);
}

/* custom checkbox */
.check-wrap {
  flex-shrink: 0;
  margin-top: 2px;
}

.check-box {
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--border-hi);
  border-radius: 4px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-item.selected .check-box {
  background: var(--accent);
  border-color: var(--accent);
}

.check-mark {
  width: 9px;
  height: 9px;
  opacity: 0;
}

.result-item.selected .check-mark {
  opacity: 1;
}

.result-body {
  flex: 1;
  min-width: 0;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.result-pos {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.ai-tag {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 500;
  background: var(--accent-lo);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.result-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-url {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--green);
  margin-bottom: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.8;
}

.result-snippet {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ── Brief output ────────────────────────────────────── */
.brief-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 560px;
  overflow-y: auto;
}

/* scrollbar */
.brief-wrap::-webkit-scrollbar {
  width: 6px;
}
.brief-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.brief-wrap::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 3px;
}

.brief-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

/* ── Scraped articles summary ────────────────────────── */
.scrape-list {
  margin-top: 1.75rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.scrape-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.875rem;
}

.scrape-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}

.scrape-row:last-child {
  border-bottom: none;
}

.scrape-status {
  flex-shrink: 0;
  font-size: 0.85rem;
}

.scrape-url {
  flex: 1;
  font-family: var(--font-mono);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scrape-words {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

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

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}
