/* AI Intel Hub — light/dark, LTR/RTL, phone to desktop. Logical properties keep Arabic layouts mirrored. */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #121826;
  --muted: #5d667a;
  --line: #e3e7f0;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --accent: #06b6d4;
  --brand-soft: #eef0ff;
  --ok: #15803d;
  --err: #c2410c;
  --warn-bg: #fff7e6;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 6%);
  --radius: 14px;
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", "Segoe UI Arabic", Tahoma, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f19;
    --surface: #131a2a;
    --surface-2: #1a2236;
    --text: #e8ecf5;
    --muted: #9aa4ba;
    --line: #253049;
    --brand: #818cf8;
    --brand-2: #a78bfa;
    --brand-soft: #1e2347;
    --ok: #4ade80;
    --err: #fb923c;
    --warn-bg: #2a2412;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
:lang(ar) body, body:lang(ar) { font-size: 16px; line-height: 1.7; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.err { color: var(--err); }
.break { word-break: break-all; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
[hidden] { display: none !important; }

/* controls */
button, .button {
  font: inherit; font-weight: 600; font-size: .92rem; padding: .6em 1.1em; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: .4em; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--brand); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
.primary, .button.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: transparent; }
.danger { color: var(--err); }
button.small, .ghost.small { padding: .35em .7em; font-size: .8rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .65em .85em; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 1px; border-color: var(--brand); }
label { display: grid; gap: .35em; font-weight: 600; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: .6em; font-weight: 500; }
label.check input { width: auto; }

/* shell */
#shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-inline-end: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; color: var(--text); padding: 0 8px; }
.brand:hover { text-decoration: none; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a, .tabbar a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.sidebar nav a.on { background: var(--brand-soft); color: var(--brand); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.agent-slot.side { margin-top: auto; font-size: .8rem; }
.agent-slot.side .agent-bar { flex-direction: column; align-items: stretch; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 640px; }
.search input { border-radius: 999px; padding-inline-start: 1.1em; background: var(--surface); }
.view { padding: 28px; max-width: 1180px; }
.view[aria-busy="true"] { opacity: .6; transition: opacity .2s .15s; }
.tabbar, .mobile-only { display: none; }

/* sections */
section { margin-bottom: 28px; }
.page-head, .section-head, .panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 small, .page-head small { color: var(--muted); font-weight: 500; font-size: .95rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel > header h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-col .panel { margin: 0; }
.sub { margin-top: 18px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--text); }
.notice.err { color: var(--err); }

/* hero + capture */
.hero { padding: 28px; border-radius: 20px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, #22d3ee55 0%, transparent 45%), linear-gradient(135deg, #3730a3, #6d28d9 60%, #a21caf); box-shadow: var(--shadow); }
.hero h1 { font-size: 1.9rem; }
.hero .muted { color: #e0e7ff; margin: 0 0 18px; }
.capture { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.capture input[name="url"], .capture input[name="input"] { flex: 3 1 320px; }
.capture input[name="note"] { flex: 2 1 200px; }
.hero .capture { margin: 0; }
.hero .capture input { border: 0; background: #ffffffee; color: #121826; }
.hero .capture .primary { background: #fff; color: #3730a3; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); box-shadow: var(--shadow); }
.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.card:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; }
.thumb { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; color: #fff; font-weight: 800; letter-spacing: .02em; background: linear-gradient(135deg, #64748b, #334155); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .play { position: absolute; width: 44px; height: 44px; border-radius: 50%; background: rgb(0 0 0 / 55%); }
.thumb .play::after { content: ""; position: absolute; inset-block-start: 13px; inset-inline-start: 17px; border-block: 9px solid transparent; border-inline-start: 14px solid #fff; }
:dir(rtl) .thumb .play::after { transform: scaleX(-1); }
.pf-bg-youtube { background: linear-gradient(135deg, #ef4444, #991b1b); }
.pf-bg-github { background: linear-gradient(135deg, #374151, #111827); }
.pf-bg-instagram { background: linear-gradient(135deg, #f59e0b, #db2777 50%, #7c3aed); }
.pf-bg-tiktok { background: linear-gradient(135deg, #111827, #0e7490); }
.pf-bg-linkedin { background: linear-gradient(135deg, #0a66c2, #004182); }
.pf-bg-x { background: linear-gradient(135deg, #1f2937, #000); }
.pf-bg-reddit { background: linear-gradient(135deg, #ff6314, #c2410c); }
.pf-bg-arxiv { background: linear-gradient(135deg, #b31b1b, #6b0f0f); }
.pf-bg-huggingface { background: linear-gradient(135deg, #fbbf24, #f97316); }
.pf-bg-web { background: linear-gradient(135deg, #6366f1, #0891b2); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { font-size: 1rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.summary { margin: 0; color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pending { margin: 0; color: var(--muted); font-size: .85rem; font-style: italic; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.idea-count { font-size: .8rem; color: var(--muted); }
.meta-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; color: var(--muted); font-size: .8rem; }
.pf { font-weight: 700; color: var(--text); }
.pf-youtube { color: #dc2626; } .pf-instagram { color: #db2777; } .pf-linkedin { color: #0a66c2; } .pf-reddit { color: #ea580c; } .pf-github { color: var(--text); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: linear-gradient(135deg, var(--brand), var(--accent)); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: thin; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: .3em .8em; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .82rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
a.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip.on { background: var(--brand); color: #fff; }
.chip small { opacity: .7; }
.chip.rising { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.filters { display: flex; gap: 10px; margin-bottom: 16px; }
.filters select { width: auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ideas */
.ideas { display: grid; gap: 12px; }
.ideas.grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.idea { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--brand); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.panel .idea { box-shadow: none; }
.idea.status-trying { border-inline-start-color: #f59e0b; }
.idea.status-adopted { border-inline-start-color: var(--ok); }
.idea.status-dismissed { opacity: .6; border-inline-start-color: var(--line); }
.idea h3 { margin: 0 0 6px; font-size: .98rem; }
.idea .how { font-size: .9rem; }
.idea .from { display: block; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.seg { display: inline-flex; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; padding: .35em .8em; font-size: .78rem; background: transparent; color: var(--muted); }
.seg button.on { background: var(--brand-soft); color: var(--brand); }

/* item */
.item { max-width: 820px; }
.item h1 { font-size: 1.8rem; margin: 8px 0 14px; }
.player, .banner { border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; background: #000; box-shadow: var(--shadow); }
.player { aspect-ratio: 16 / 9; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.banner img { display: block; width: 100%; max-height: 420px; object-fit: cover; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.spacer { flex: 1; }
.lead { font-size: 1.08rem; }
.item section h2 { font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.original { margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.original summary { cursor: pointer; font-weight: 700; }
.original h3 { margin-top: 18px; color: var(--muted); }
.ts { font: inherit; font-size: .82rem; font-weight: 700; padding: .05em .45em; border-radius: 6px; background: var(--brand-soft); color: var(--brand); border: 0; cursor: default; font-variant-numeric: tabular-nums; }
button.ts { cursor: pointer; }

/* prose */
.prose { overflow-wrap: anywhere; }
.prose p { margin: 0 0 .8em; }
.prose ul, .prose ol { margin: 0 0 .8em; padding-inline-start: 1.3em; }
.prose li { margin: .25em 0; }
.prose pre { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: .85rem; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: 0 0 .8em; padding-inline-start: 12px; border-inline-start: 3px solid var(--line); color: var(--muted); }
.prose h1 { font-size: 1.4rem; } .prose h2 { font-size: 1.15rem; margin-top: 1.2em; } .prose h3 { font-size: 1rem; margin-top: 1em; }
.clamp { max-height: 340px; overflow: hidden; mask-image: linear-gradient(#000 75%, transparent); }

/* radar */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.bars .bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bars .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--accent)); }
:dir(rtl) .bars .bar i { background: linear-gradient(270deg, var(--brand), var(--accent)); }
.rising-badge { font-size: .75rem; font-weight: 700; color: var(--accent); }

/* digests */
.digest-layout { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: start; }
.digest-list { display: grid; gap: 4px; position: sticky; top: 80px; }
.digest-list a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.digest-list a.on { background: var(--brand-soft); color: var(--brand); }

/* sources + settings */
.source-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.source-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.source-list li.paused { opacity: .6; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.settings { display: grid; gap: 16px; max-width: 560px; }
.connect h3 { margin-top: 20px; }
.code { position: relative; }
.code pre { margin: 6px 0; padding: 12px 14px; padding-inline-end: 80px; background: var(--surface-2); border-radius: 10px; overflow-x: auto; font: .82rem/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.code button { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; }
.agent-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .85rem; margin-bottom: 14px; }
.agent-bar.running span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-inline-end: 8px; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .2; } }

/* login + share */
.page-center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.narrow { width: min(420px, 100%); }
.card.narrow, .login { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); display: grid; gap: 14px; text-align: center; justify-items: center; }
.login input, .login button.primary { width: 100%; }
.share { max-width: 560px; display: grid; gap: 14px; }
.share form { display: grid; gap: 12px; }

#toast { position: fixed; inset-inline: 0; bottom: 24px; margin: auto; width: max-content; max-width: 90vw; padding: 10px 18px; border-radius: 12px; background: #111827; color: #fff; font-weight: 600; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--err); }

/* phone */
@media (max-width: 860px) {
  #shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-only { display: flex; }
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .view { padding: 16px 14px 96px; }
  .two-col, .digest-layout { grid-template-columns: 1fr; }
  .digest-list { position: static; display: flex; overflow-x: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 20px; }
  .hero h1 { font-size: 1.5rem; }
  .ideas.grid { grid-template-columns: 1fr; }
  .tabbar { display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 10; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px max(6px, env(safe-area-inset-bottom)); }
  .tabbar a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .68rem; flex: 1; }
  .tabbar a.on { color: var(--brand); }
  .source-list li { flex-direction: column; align-items: stretch; }
  #toast { bottom: 84px; }
}
.settings.wide { max-width: none; }
.settings textarea { font: .85rem/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; resize: vertical; }
.chip.discovered { background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 18%, var(--surface)), color-mix(in srgb, var(--accent) 18%, var(--surface))); }
.settings h3 { margin: 8px 0 0; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.settings textarea { font: inherit; line-height: 1.6; }

/* long tokens in release notes (ENV_VAR_NAMES) wrap instead of widening the page */
.changes li, .prose, .prose code { overflow-wrap: anywhere; }
.updates .tool-row > * { min-width: 0; }
/* a repo's social card is a thumbnail, not a hero */
.banner.thumb { max-width: 360px; }
.tabbar a { position: relative; }
.sidebar .badge-dot, :dir(rtl) .sidebar .badge-dot { position: static; transform: none; margin-inline-start: auto; }
details.dev { margin: 8px 0 4px; }
details.dev > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
