/* DataRail Harvest. Tokens follow datarail.org: dark by default, light on request or system preference. */

:root {
  --bg: #05070b;
  --bg-soft: #0b0e16;
  --bg-raised: #10141f;
  --fg: #f5f5f7;
  --muted: #9ca3af;
  --dim: #7c8694;
  --accent: #42f5ff;
  --accent-strong: #42ffb3;
  --accent-warm: #ffd94a;
  --ink-cyan: #42f5ff;
  --ink-mint: #42ffb3;
  --ink-warm: #ffd94a;
  --on-accent: #05070b;
  --danger: #ff7a7a;
  --border-soft: #1f2933;
  --border-glow: rgba(66, 245, 255, 0.14);
  --shade: rgba(255, 255, 255, 0.04);
  --header-bg: rgba(5, 7, 11, 0.82);
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --shell: 1180px;
  --fast: 160ms ease-out;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f2f4f7;
  --bg-soft: #ffffff;
  --bg-raised: #ffffff;
  --fg: #0b0e16;
  --muted: #4b5563;
  --dim: #646c78;
  --ink-cyan: #06697a;
  --ink-mint: #0b6e4a;
  --ink-warm: #7a5a00;
  --on-accent: #ffffff;
  --danger: #b42318;
  --border-soft: #d5dce4;
  --border-glow: rgba(6, 105, 122, 0.18);
  --shade: rgba(5, 7, 11, 0.03);
  --header-bg: rgba(242, 244, 247, 0.88);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f4f7;
    --bg-soft: #ffffff;
    --bg-raised: #ffffff;
    --fg: #0b0e16;
    --muted: #4b5563;
    --dim: #646c78;
    --ink-cyan: #06697a;
    --ink-mint: #0b6e4a;
    --ink-warm: #7a5a00;
    --on-accent: #ffffff;
    --danger: #b42318;
    --border-soft: #d5dce4;
    --border-glow: rgba(6, 105, 122, 0.18);
    --shade: rgba(5, 7, 11, 0.03);
    --header-bg: rgba(242, 244, 247, 0.88);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--font-main);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

[hidden] { display: none !important; }

a { color: var(--ink-cyan); }
code { font-family: var(--font-mono); font-size: 0.88em; background: var(--shade); padding: 0.1em 0.35em; border-radius: 5px; }

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.nav { display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--accent);
  box-shadow: 0 0 10px rgba(66, 245, 255, 0.7), 0 0 30px rgba(66, 245, 255, 0.35);
  position: relative;
  overflow: hidden;
}
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: conic-gradient(from 180deg, rgba(66, 245, 255, 0.05), rgba(66, 255, 179, 0.5),
    rgba(255, 217, 74, 0.5), rgba(66, 245, 255, 0.05));
  mix-blend-mode: screen;
  animation: spin 8s linear infinite;
}
:root[data-theme="light"] .brand-mark::before { mix-blend-mode: normal; opacity: 0.95; }
.brand-mark.big { width: 44px; height: 44px; margin-bottom: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand-text { font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.8rem; color: var(--ink-cyan); }
.brand-sub { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }
.brand-sub::before { content: "/ "; color: var(--dim); }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: color var(--fast), background var(--fast);
}
.tabs a:hover { color: var(--fg); background: var(--shade); }
.tabs a[aria-selected="true"] { color: var(--fg); background: var(--shade); box-shadow: inset 0 0 0 1px var(--border-glow); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------- controls ---------- */

.btn {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: border-color var(--fast), background var(--fast), opacity var(--fast);
}
.btn:hover:not(:disabled) { border-color: var(--ink-cyan); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #05070b; border-color: transparent; }
:root[data-theme="light"] .btn-primary { background: var(--ink-cyan); color: #fff; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .btn-primary { background: var(--ink-cyan); color: #fff; } }
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 18px rgba(66, 245, 255, 0.35); }
.btn-primary .dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; opacity: 0.7; }
.btn-primary.busy .dot { animation: pulse 1s ease-in-out infinite; }
.btn-ghost { background: transparent; }
.icon-btn {
  font: inherit;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--fg); border-color: var(--ink-cyan); }

:focus-visible { outline: 2px solid var(--ink-cyan); outline-offset: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--dim); }
.pill.ok::before { background: var(--accent-strong); box-shadow: 0 0 8px var(--accent-strong); }
.pill.warn::before { background: var(--accent-warm); }
.pill.bad::before { background: var(--danger); }
.pill.busy::before { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.filters { padding: 22px 0 6px; display: grid; gap: 14px; }
.filter-line { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit;
  font-size: 0.84rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all var(--fast);
}
.chip:hover { color: var(--fg); }
.chip[aria-pressed="true"] { color: var(--fg); border-color: var(--ink-cyan); background: var(--shade); box-shadow: inset 0 0 0 1px var(--border-glow); }
.chip .n { font-family: var(--font-mono); font-size: 0.75rem; color: var(--dim); margin-left: 6px; }

.segmented { display: inline-flex; border: 1px solid var(--border-soft); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented button {
  font: inherit;
  font-size: 0.84rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: #05070b; }
:root[data-theme="light"] .segmented button[aria-pressed="true"] { background: var(--ink-cyan); color: #fff; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .segmented button[aria-pressed="true"] { background: var(--ink-cyan); color: #fff; } }

.field { display: inline-flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--muted); }
select, .search, input[type="password"] {
  font: inherit;
  font-size: 0.88rem;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 6px 10px;
}
.search { flex: 1 1 240px; min-width: 0; border-radius: 999px; padding: 7px 14px; }

.hint { color: var(--muted); font-size: 0.86rem; margin: 18px 0; }
.summary { color: var(--dim); font-size: 0.82rem; font-family: var(--font-mono); margin: 10px 0 14px; }

/* ---------- feed ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }

.card {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  transition: border-color var(--fast);
}
.card:hover { border-color: var(--border-glow); }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.76rem; }
.card-top time { margin-left: auto; color: var(--dim); font-family: var(--font-mono); }

.badge { font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.68rem; padding: 2px 7px; border-radius: 5px; border: 1px solid currentColor; }
.p-youtube { color: var(--ink-warm); }
.p-instagram { color: var(--ink-mint); }
.p-hackernoon { color: var(--ink-cyan); }
.p-other { color: var(--muted); }
.tag { color: var(--muted); background: var(--shade); padding: 2px 7px; border-radius: 5px; }

.hook { margin: 0; font-size: 1rem; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hook a { color: var(--fg); text-decoration: none; }
.hook a:hover { color: var(--ink-cyan); }
.body { margin: 0; color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.metrics { display: flex; gap: 16px; margin: 2px 0 0; font-size: 0.8rem; }
.metrics div { display: flex; gap: 5px; align-items: baseline; }
.metrics dt { color: var(--dim); }
.metrics dd { margin: 0; font-family: var(--font-mono); font-weight: 600; }

.notes { display: flex; flex-wrap: wrap; gap: 5px; }
.note { font-size: 0.74rem; font-family: var(--font-mono); color: var(--muted); border: 1px dashed var(--border-soft); border-radius: 5px; padding: 1px 6px; overflow-wrap: anywhere; }
.note.cue { color: var(--ink-cyan); border-style: solid; border-color: var(--border-glow); }

.hashtags { font-size: 0.78rem; color: var(--dim); overflow-wrap: anywhere; }
.hashtags button { font: inherit; background: none; border: 0; padding: 0 6px 0 0; color: inherit; cursor: pointer; }
.hashtags button:hover { color: var(--ink-cyan); }

.more { display: flex; justify-content: center; padding: 22px 0 48px; }

.empty { grid-column: 1 / -1; text-align: center; padding: 48px 16px; color: var(--muted); border: 1px dashed var(--border-soft); border-radius: var(--radius); }
.empty .btn { margin-top: 12px; }

/* ---------- insights ---------- */

.panels { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; padding-bottom: 48px; }
.panel { background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.panel header { display: flex; align-items: baseline; gap: 10px; }
.panel h2 { margin: 0; font-size: 1.02rem; }
.panel .count { margin-left: auto; color: var(--dim); font-family: var(--font-mono); font-size: 0.8rem; }
.panel h3 { margin: 0 0 6px; font-size: 0.72rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

.stack { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--shade); gap: 2px; }
.stack span { display: block; height: 100%; }
.stack .p-youtube, .legend .p-youtube::before { background: var(--accent-warm); }
.stack .p-instagram, .legend .p-instagram::before { background: var(--accent-strong); }
.stack .p-hackernoon, .legend .p-hackernoon::before { background: var(--accent); }
.stack .p-other, .legend .p-other::before { background: var(--dim); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.78rem; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 8px; height: 8px; border-radius: 2px; }

.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 130px 1fr 34px; gap: 10px; align-items: center; font-size: 0.82rem; }
.bar .track { height: 6px; border-radius: 99px; background: var(--shade); overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar .v { font-family: var(--font-mono); color: var(--dim); text-align: right; font-size: 0.76rem; }

.cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.cloud button { font: inherit; font-size: 0.78rem; color: var(--muted); background: var(--shade); border: 0; border-radius: 5px; padding: 2px 7px; cursor: pointer; }
.cloud button:hover { color: var(--ink-cyan); }
.cloud .n { color: var(--dim); font-family: var(--font-mono); margin-left: 4px; }

.toplist { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 0.84rem; }
.toplist li { display: flex; gap: 8px; min-width: 0; }
.toplist a { color: var(--fg); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toplist a:hover { color: var(--ink-cyan); }
.panel .muted { color: var(--muted); font-size: 0.86rem; margin: 0; }

/* ---------- sources ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; padding-bottom: 48px; }
.source { background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.source header { display: flex; align-items: center; gap: 10px; }
.source h2 { margin: 0; font-size: 1.05rem; }
.source header .pill { margin-left: auto; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 0.85rem; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; }
.log { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); background: var(--shade); border-radius: 6px; padding: 8px 10px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9.5em; overflow: auto; }
.fix { font-size: 0.84rem; color: var(--ink-warm); margin: 0; }

/* ---------- niches ---------- */

.table-wrap { overflow-x: auto; padding-bottom: 48px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; white-space: nowrap; }
td:first-child { font-weight: 600; white-space: nowrap; }
td .q { display: inline-block; font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted); background: var(--shade); border-radius: 5px; padding: 1px 6px; margin: 0 4px 4px 0; }
td .none { color: var(--dim); }

/* ---------- overlay, toast ---------- */

.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 30%, rgba(66, 245, 255, 0.08), transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: 14px; padding: 28px; display: grid; gap: 10px; justify-items: start; }
.login-card h1 { margin: 0; font-size: 1.3rem; }
.login-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.login-card label { font-size: 0.8rem; color: var(--dim); margin-top: 8px; }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 6px; }
.login-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.token-box { width: 100%; margin-top: 4px; }
.token-box summary { cursor: pointer; color: var(--dim); font-size: 0.82rem; }
.token-box form { display: grid; gap: 8px; justify-items: start; margin-top: 8px; }
.token-box.solo summary { display: none; }
.who { font-size: 0.78rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.error { color: var(--danger) !important; min-height: 1.2em; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 30; max-width: min(560px, calc(100% - 32px)); background: var(--bg-raised); color: var(--fg); border: 1px solid var(--border-glow); border-radius: 10px; padding: 10px 14px; font-size: 0.86rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }

.fatal { color: var(--danger); padding: 24px 0; }

@media (max-width: 720px) {
  .shell { padding: 0 16px; }
  .nav { gap: 10px; padding: 8px 0; }
  .tabs { order: 3; width: 100%; }
  .grid, .panels, .cards { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 100px 1fr 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
