/* ============ OF Link Scraper — dark utility UI ============ */

:root, [data-theme="dark"] {
  --bg: #0c1014;
  --surface: #12171d;
  --surface-2: #171d24;
  --surface-offset: #1b232c;
  --border: #232c36;
  --border-strong: #2e3a46;
  --text: #e4eaef;
  --text-muted: #97a4b0;
  --text-faint: #74828f;
  --accent: #00aff0;
  --accent-strong: #38d5ff;
  --accent-dim: rgba(0, 175, 240, 0.14);
  --success: #3fb950;
  --success-dim: rgba(63, 185, 80, 0.14);
  --error: #f85149;
  --error-dim: rgba(248, 81, 73, 0.13);
  --warning: #d29922;
  --warning-dim: rgba(210, 153, 34, 0.14);
  --font-body: 'General Sans', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.83rem + 0.25vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.35rem);
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
}

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

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(0, 175, 240, 0.07), transparent 60%),
    var(--bg);
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }

a { color: var(--accent-strong); text-decoration: none; transition: color 140ms ease; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-10);
}

/* ============ header ============ */

.header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap;
  padding-bottom: var(--space-5); margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: var(--space-3); }

.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--accent-dim); color: var(--accent-strong);
  border: 1px solid rgba(0, 175, 240, 0.35);
}

h1 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.tagline { font-size: var(--text-xs); color: var(--text-muted); }

.header-status {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); color: var(--text-muted);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
}

.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-idle { background: var(--text-faint); }
.dot-run { background: var(--accent); box-shadow: 0 0 8px rgba(0, 175, 240, 0.8); animation: pulse 1.2s ease infinite; }
.dot-done { background: var(--success); }
.dot-err { background: var(--error); }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ============ layout ============ */

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
}

.form-panel {
  position: sticky; top: var(--space-4);
  max-height: calc(100dvh - var(--space-8));
  overflow-y: auto;
  scrollbar-width: thin;
}
@media (max-width: 960px) { .form-panel { position: static; } }

h2 { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--space-4); }

/* ============ form ============ */

.field-label {
  display: block;
  font-size: var(--text-xs); font-weight: 500; color: var(--text-muted);
  margin-bottom: var(--space-2);
}

textarea, input[type="text"], input[type="number"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  color: var(--text);
  font-size: var(--text-sm);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
textarea {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  resize: vertical;
  min-height: 140px;
}
textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 175, 240, 0.15);
}
textarea::placeholder, input::placeholder { color: var(--text-faint); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-4); }

.advanced {
  margin-top: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}
.advanced summary {
  font-size: var(--text-xs); font-weight: 500; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.advanced summary:hover { color: var(--text); }
.advanced[open] summary { margin-bottom: var(--space-3); }
.advanced input { font-family: var(--font-mono); font-size: var(--text-xs); }

.hint { font-size: var(--text-xs); color: var(--text-faint); margin-top: var(--space-2); line-height: 1.5; }

.actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); }

.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); font-weight: 600;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-5);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 100ms ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent); color: #06222e;
  flex: 1; justify-content: center;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border-strong);
  padding: var(--space-2) var(--space-4);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }

.hidden { display: none !important; }

/* ============ results ============ */

.results { min-width: 0; }

.results-bar {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.progress-wrap { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 180px; }

.progress {
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--surface-offset); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}
.progress-label { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }

.results-stats { display: flex; gap: var(--space-4); font-size: var(--text-xs); color: var(--text-muted); }
.results-stats b { color: var(--text); font-weight: 600; }
.results-export { display: flex; gap: var(--space-2); }

.empty-state {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  gap: var(--space-3);
  min-height: 340px;
  padding: var(--space-10) var(--space-6);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(18, 23, 29, 0.5);
}
.empty-icon { display: flex; justify-content: center; margin-bottom: var(--space-6); color: var(--text-faint); }
.empty-state p { margin: 0 auto; }

/* ============ cards ============ */

.cards { display: flex; flex-direction: column; gap: var(--space-4); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  transition: border-color 140ms ease;
}
.card:hover { border-color: var(--border-strong); }
.card-error { border-color: rgba(248, 81, 73, 0.35); }

.card-head {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--surface-offset);
}
.avatar-fallback {
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; color: var(--accent-strong);
  font-size: var(--text-lg);
}

.card-id { min-width: 0; flex: 1; }
.card-username {
  font-family: var(--font-mono); font-size: var(--text-base); font-weight: 600;
}
.card-name { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.chip {
  font-size: var(--text-xs); font-weight: 500;
  padding: 2px var(--space-2); border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-muted);
  white-space: nowrap;
}
.chip-free { color: var(--success); border-color: rgba(63, 185, 80, 0.4); background: var(--success-dim); }
.chip-price { color: var(--text); }
.chip-verified { color: var(--accent-strong); border-color: rgba(0, 175, 240, 0.4); background: var(--accent-dim); }
.chip-posts-text { color: var(--warning); border-color: rgba(210, 153, 34, 0.4); background: var(--warning-dim); }

.card-meta {
  display: flex; gap: var(--space-2) var(--space-4); flex-wrap: wrap;
  font-size: var(--text-xs); color: var(--text-muted);
  padding-bottom: var(--space-4); margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.meta-loc {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-muted);
}
.meta-loc svg { flex-shrink: 0; opacity: 0.7; }
.card-meta b { color: var(--text); font-weight: 600; }

.link-section { margin-top: var(--space-4); }
.link-section:first-of-type { margin-top: 0; }
.link-title {
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint);
  margin-bottom: var(--space-2);
}
.link-list { display: flex; flex-direction: column; gap: var(--space-1); }
.link-row {
  display: flex; align-items: baseline; gap: var(--space-2) var(--space-3);
  flex-wrap: wrap;
  font-family: var(--font-mono); font-size: var(--text-xs);
  min-width: 0;
  row-gap: 2px;
}
.link-domain { color: var(--text-faint); flex-shrink: 0; }
.link-row a {
  overflow-wrap: anywhere;
  min-width: 0;
}
.link-sub { color: var(--text-faint); font-size: var(--text-xs); }

.empty-links { font-size: var(--text-xs); color: var(--text-muted); font-style: normal; }

.card-error-msg {
  color: var(--error); font-size: var(--text-sm);
  background: var(--error-dim); border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius-sm); padding: var(--space-3);
}

.card-scanning {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--text-muted); font-size: var(--text-sm);
  padding: var(--space-2) 0;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer {
  margin-top: var(--space-10);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--text-muted);
  display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
}

@media (max-width: 560px) {
  .shell { padding: var(--space-4) var(--space-3) var(--space-16); }
  .form-panel { position: static; max-height: none; overflow: visible; }
  .card-meta > span + span::before { margin-right: var(--space-3); }
}

/* ============ mode switch ============ */

.mode-switch {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1);
  margin-bottom: var(--space-4);
}

.mode-btn {
  font-size: var(--text-sm); font-weight: 500;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: 5px;
  transition: background 140ms ease, color 140ms ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--accent-dim);
  color: var(--accent-strong);
}

/* ============ dropzone ============ */

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  text-align: center;
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
  outline: none;
}
.dropzone p { margin: 0; font-size: var(--text-sm); }
.dropzone b { color: var(--text); font-weight: 600; }

/* ============ parse result ============ */

.parse-result {
  margin-top: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: var(--space-3);
}

.parse-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.parse-count {
  font-size: var(--text-xs); font-weight: 600; color: var(--success);
}
.parse-count.err { color: var(--error); }

.parse-col {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); color: var(--text-muted);
}
.parse-col select {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-offset);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--text);
  max-width: 180px;
}

.parse-preview {
  display: flex; flex-wrap: wrap; gap: var(--space-1);
  font-family: var(--font-mono); font-size: var(--text-xs);
}
.parse-preview span {
  color: var(--accent-strong);
  background: var(--accent-dim);
  border-radius: 999px;
  padding: 1px var(--space-2);
}
.parse-preview span.more { color: var(--text-muted); background: none; }

.table-val {
  color: var(--text);
  overflow-wrap: anywhere;
  min-width: 0;
}

.chip-metric {
  color: var(--warning);
  border-color: rgba(210, 153, 34, 0.4);
  background: var(--warning-dim);
  font-family: var(--font-mono);
}
