/* =====================================================================
   Trayo Newsfeed — Design system v4
   Hard rules:
   - ONE accent color per theme (indigo dark, brand purple light).
   - Per-type tinting limited to a small uppercase eyebrow label.
   - No nested boxes. The card is one surface.
   - Single anatomy: chrome / anchor / angle / footer.
   - Type scale is fixed and deliberate (no ad-hoc font sizes).
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

/* ---------- Tokens (dark default; Trayo app shell) ---------- */
:root {
  /* Spacing scale (4-based) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;

  /* Radii */
  --r-card: 14px;
  --r-pill: 9999px;
  --r-btn: 8px;
  --r-chip: 6px;

  /* Type tokens — fixed scale */
  --t-anchor:        19px;
  --t-anchor-line:   1.35;
  --t-anchor-track:  -0.018em;
  --t-anchor-weight: 600;

  --t-anchor-sub:    14px;
  --t-body:          14.5px;
  --t-body-line:     1.65;
  --t-meta:          12.5px;
  --t-eyebrow:       11px;
  --t-eyebrow-track: 0.08em;

  /* Color */
  --accent:        var(--accent-indigo);
  --accent-soft:   rgba(99, 102, 241, 0.14);
  --accent-ring:   rgba(99, 102, 241, 0.30);

  /* Per-type eyebrow tints (subtle, text-only) */
  --type-news:    #A5B4FC;
  --type-career:  #6EE7B7;
  --type-job:     #FCD34D;

  /* Layout */
  --feed-max:   720px;
  --sidebar-w:  240px;

  /* Card sizing (overridden by density) */
  --card-pad-x: var(--sp-6);
  --card-pad-y: var(--sp-6);
  --card-gap:   var(--sp-3);
}

:root[data-theme="light"] {
  --bg-shell:        #fefbf4;
  --bg-sidebar:      #fefbf4;
  --bg-card:         #fffdf8;
  --bg-card-hover:   #fbf6e8;
  --bg-well:         #fbf6e8;
  --bg-popover:      #fffdf8;
  --bg-muted:        #f5f0e0;
  --bg-secondary:    #ECE5FF;
  --bg-accent:       #f5f0e0;

  --fg-1:            #171717;
  --fg-card:         #404040;
  --fg-2:            #737373;
  --fg-muted:        #a3a3a3;

  --border:          rgb(60 40 20 / 0.10);
  --border-strong:   rgb(60 40 20 / 0.18);

  --accent:          #845cff;
  --accent-soft:     #ECE5FF;
  --accent-ring:     rgba(132, 92, 255, 0.28);

  /* Per-type eyebrow tints in light, from the marketing palette */
  --type-news:    #845cff;    /* brand purple */
  --type-career:  #c87a55;    /* warm peach */
  --type-job:     #b56eb8;    /* warm violet */

  --r-card: 16px;
}

:root[data-density="compact"] {
  --card-pad-x: var(--sp-5);
  --card-pad-y: var(--sp-4);
  --card-gap: var(--sp-2);
  --t-anchor: 17px;
  --t-anchor-line: 1.32;
  --t-body: 13.5px;
  --t-body-line: 1.55;
}
:root[data-density="comfortable"] {
  --card-pad-x: var(--sp-7);
  --card-pad-y: var(--sp-7);
  --card-gap: var(--sp-4);
  --t-anchor: 20px;
  --t-body: 15px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: transparent;
  color: var(--fg-card);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:root[data-theme="light"] body {
  font-family: 'Manrope', 'Polymath', system-ui, -apple-system, sans-serif;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg-shell);
  color: var(--fg-1);
  transition: color 200ms ease;
}

/* ===== Sidebar (unchanged from v3, simplified) ===== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  padding: var(--sp-5) var(--sp-4);
}
.sidebar-brand { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-2) var(--sp-5); }
.sidebar-brand img { width: 24px; height: 24px; }
:root[data-theme="light"] .sidebar-brand img { filter: invert(1); }
.sidebar-brand .word {
  font-family: var(--font-clash);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.04em;
  color: var(--fg-1);
}
:root[data-theme="light"] .sidebar-brand .word {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.sidebar-accounts { display: flex; flex-direction: column; gap: var(--sp-1); margin: var(--sp-1) 0 var(--sp-5); }
.account-pill {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--fg-1);
  font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--border);
}
.account-pill.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.account-pill .glyph {
  width: 18px; height: 18px;
  border-radius: var(--r-chip);
  background: var(--accent-soft);
  display: grid; place-items: center;
  color: var(--accent);
  font-size: 11px; font-weight: 700;
}

.sidebar-section-label {
  font-size: var(--t-eyebrow);
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-2);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  color: var(--fg-1);
}
.nav-item:hover { background: var(--bg-card); }
.nav-item.active {
  background: linear-gradient(to right, #FFFFFF, #EFF6FF 60%, #BFDBFE);
  color: #0F172A;
  font-weight: 600;
  box-shadow: 0 6px 14px -6px rgba(0,0,0,0.20), 0 0 0 1px #BFDBFE inset;
}
:root[data-theme="light"] .nav-item.active {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 6px 14px -6px rgba(132,92,255,0.40);
}
.nav-item .badge {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: var(--r-pill);
}
.nav-item.active .badge { background: rgba(15,23,42,0.08); color: #0F172A; }
:root[data-theme="light"] .nav-item.active .badge { background: rgba(255,255,255,0.20); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.sidebar-footer .avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--brand-gradient-from), var(--brand-gradient-to));
  color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
}
.sidebar-footer .name { font-weight: 500; font-size: 13.5px; color: var(--fg-1); }
.sidebar-footer .sub { font-size: 11px; color: var(--fg-2); }

/* ===== Main ===== */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-7);
  background: color-mix(in srgb, var(--bg-shell) 90%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--fg-1);
}
:root[data-theme="light"] .topbar .title { letter-spacing: -0.02em; }
.topbar .grow { flex: 1; }

.theme-switch {
  display: inline-flex; align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 2px;
}
.theme-switch button {
  appearance: none; border: 0; background: transparent;
  color: var(--fg-2);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: 12.5px; font-weight: 500;
}
.theme-switch button svg { width: 14px; height: 14px; }
.theme-switch button.on {
  background: var(--bg-shell);
  color: var(--fg-1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ===== Feed column ===== */
.feed-col {
  width: 100%;
  max-width: var(--feed-max);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-7) var(--sp-9);
}

/* ---- Filter bar ---- */
.filter-bar { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--fg-2);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  white-space: nowrap;
  font-family: inherit;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.filter-pill:hover { background: var(--bg-card); color: var(--fg-1); }
.filter-pill .count {
  font-size: 11.5px;
  color: var(--fg-muted);
  padding: 0 3px;
  font-variant-numeric: tabular-nums;
}
.filter-pill.on {
  background: var(--fg-1);
  color: var(--bg-shell);
  border-color: var(--fg-1);
}
.filter-pill.on .count { color: inherit; opacity: 0.6; }
:root[data-theme="light"] .filter-pill.on {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.filter-bar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 var(--sp-2); }

.filter-search {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  color: var(--fg-2);
  font-size: 13px;
  margin-left: auto;
}
.filter-search input {
  background: transparent; border: 0; outline: 0;
  color: var(--fg-1);
  width: 140px;
  font-family: inherit; font-size: 13px;
}
.filter-search svg { width: 14px; height: 14px; }

/* =====================================================================
   CARD — Single anatomy
   ===================================================================== */
.cards { display: flex; flex-direction: column; gap: var(--sp-3); }

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--card-pad-y) var(--card-pad-x);
}
:root[data-theme="dark"] .card { box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
:root[data-theme="light"] .card {
  box-shadow:
    0 8px 20px rgb(60 40 20 / 0.045),
    0 1px 4px  rgb(60 40 20 / 0.025);
}
.card:hover { background-color: var(--bg-card-hover); }

/* ----- Chrome (top eyebrow) ----- */
.chrome {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--t-meta);
  color: var(--fg-2);
  margin-bottom: var(--sp-4);
}
.account-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  color: var(--fg-1);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 0;
}
.account-chip .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.account-chip:hover { color: var(--accent); }
.account-chip .logo {
  width: 20px; height: 20px;
  border-radius: var(--r-chip);
  object-fit: cover;
  background: #fff;
}
.account-chip .logo-fallback {
  width: 20px; height: 20px;
  border-radius: var(--r-chip);
  background: linear-gradient(135deg, var(--brand-gradient-from), var(--brand-gradient-to));
  color: white;
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 800;
}

.eyebrow {
  font-size: var(--t-eyebrow);
  font-weight: 700;
  letter-spacing: var(--t-eyebrow-track);
  text-transform: uppercase;
  color: var(--type-color, var(--fg-2));
  white-space: nowrap;
  flex-shrink: 0;
}
.eyebrow .kind {
  color: var(--fg-2);
  margin-left: 6px;
  position: relative;
  padding-left: 8px;
}
.eyebrow .kind::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: var(--fg-muted);
  transform: translateY(-50%);
}

.chrome-meta {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  color: var(--fg-2);
  white-space: nowrap;
  font-size: var(--t-meta);
}
.chrome-meta .dot { color: var(--fg-muted); opacity: 0.7; }
.chrome-meta a.source { color: var(--fg-2); transition: color 120ms ease; }
.chrome-meta a.source:hover { color: var(--fg-1); text-decoration: underline; text-underline-offset: 3px; }

/* Overflow */
.overflow-menu { position: relative; margin-left: 2px; }
.overflow-menu .btn {
  appearance: none; background: transparent; border: 0;
  color: var(--fg-muted);
  width: 24px; height: 24px;
  border-radius: var(--r-chip);
  display: grid; place-items: center;
}
.overflow-menu .btn:hover { background: var(--bg-well); color: var(--fg-1); }
.overflow-menu .btn svg { width: 14px; height: 14px; }
.overflow-menu .pop {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  min-width: 210px;
  background: var(--bg-popover);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-menu, 0 25px 50px -12px rgba(0,0,0,0.20));
  padding: 4px;
  z-index: 30;
}
.overflow-menu .pop button,
.overflow-menu .pop a {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent; border: 0;
  padding: 7px 10px;
  border-radius: var(--r-chip);
  font-size: 13px;
  color: var(--fg-1);
  text-align: left;
  font-family: inherit;
  text-decoration: none;
}
.overflow-menu .pop button:hover,
.overflow-menu .pop a:hover { background: var(--bg-well); }
.overflow-menu .pop button svg,
.overflow-menu .pop a svg { width: 13px; height: 13px; color: var(--fg-2); }
.overflow-menu .pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ====================================================================
   Typed anchor — three shapes, same vertical metrics
   ==================================================================== */
.anchor {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

/* News anchor — title + optional sub */
.anchor-title {
  font-size: var(--t-anchor);
  font-weight: var(--t-anchor-weight);
  line-height: var(--t-anchor-line);
  letter-spacing: var(--t-anchor-track);
  color: var(--fg-1);
  margin: 0;
  text-wrap: pretty;
}
:root[data-theme="light"] .anchor-title { letter-spacing: -0.022em; }

.anchor-sub {
  font-size: var(--t-anchor-sub);
  color: var(--fg-2);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Person anchor (career change) — avatar + name + transition */
.anchor-avatar {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand-gradient-from), var(--brand-gradient-to));
}
.anchor-avatar.violet { background: linear-gradient(135deg, #A78BFA, #7C3AED); }
.anchor-avatar.teal { background: linear-gradient(135deg, #5EEAD4, #14B8A6); }
.anchor-avatar.amber { background: linear-gradient(135deg, #FCD34D, #F59E0B); }
.anchor-avatar.rose { background: linear-gradient(135deg, #FDA4AF, #F43F5E); }
.anchor-text { flex: 1; min-width: 0; }
.anchor-text .person-name {
  font-size: var(--t-anchor);
  font-weight: var(--t-anchor-weight);
  line-height: 1.2;
  letter-spacing: var(--t-anchor-track);
  color: var(--fg-1);
  margin: 0;
}
.anchor-text .person-transition {
  font-size: var(--t-anchor-sub);
  color: var(--fg-1);
  font-weight: 500;
  margin-top: 4px;
}
.anchor-text .person-transition strong {
  color: var(--fg-1);
}
.anchor-text .person-sub {
  font-size: 12.5px;
  color: var(--fg-2);
  margin-top: 4px;
}

/* ====================================================================
   Trayo's angle — clean prose. Two paragraphs max.
   ==================================================================== */
.angle {
  margin-bottom: var(--sp-5);
}
.angle p {
  margin: 0;
  font-size: var(--t-body);
  line-height: var(--t-body-line);
  color: var(--fg-card);
  text-wrap: pretty;
}
.angle p + p { margin-top: var(--sp-2); }
.angle em {
  font-style: normal;
  color: var(--accent);
  font-weight: 500;
}
.angle .fits {
  display: block;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--accent-soft);
  color: var(--fg-card);
}
.angle .fits strong {
  color: var(--fg-1);
  font-weight: 600;
}

/* ====================================================================
   Action footer
   ==================================================================== */
.action {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.cta {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 6px 14px 6px 6px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  border: 0;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0,0,0,0.10), 0 4px 12px -4px var(--accent-ring);
  transition: filter 120ms ease, transform 120ms ease;
}
.cta:hover { filter: brightness(1.08); }
.cta:active { transform: translateY(1px); }
.cta svg { width: 13px; height: 13px; opacity: 0.85; }
.cta-text { padding-right: 2px; }
.cta-text strong { font-weight: 700; }

.cta-avatar {
  width: 26px; height: 26px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--brand-gradient-from), var(--brand-gradient-to));
  border: 2px solid rgba(255,255,255,0.18);
}
.cta-avatar.violet { background: linear-gradient(135deg, #A78BFA, #7C3AED); }
.cta-avatar.teal { background: linear-gradient(135deg, #5EEAD4, #14B8A6); }
.cta-avatar.amber { background: linear-gradient(135deg, #FCD34D, #F59E0B); }
.cta-avatar.rose { background: linear-gradient(135deg, #FDA4AF, #F43F5E); }

.action-meta {
  font-size: var(--t-meta);
  color: var(--fg-2);
  flex: 1;
  min-width: 0;
}
.action-meta .role {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.more {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-2);
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.more:hover { color: var(--fg-1); border-color: var(--border-strong); background: var(--bg-well); }

/* Expander */
.others {
  flex-basis: 100%;
  display: flex; flex-direction: column;
  gap: 2px;
  padding-top: var(--sp-3);
  margin-top: var(--sp-2);
  border-top: 1px dashed var(--border);
}
.others .item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: 10px;
  color: var(--fg-1);
  transition: background 120ms ease;
}
.others .item:hover { background: var(--bg-well); }
.others .item .avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--brand-gradient-from), var(--brand-gradient-to));
  flex-shrink: 0;
}
.others .item .avatar.violet { background: linear-gradient(135deg, #A78BFA, #7C3AED); }
.others .item .avatar.teal { background: linear-gradient(135deg, #5EEAD4, #14B8A6); }
.others .item .avatar.amber { background: linear-gradient(135deg, #FCD34D, #F59E0B); }
.others .item .avatar.rose { background: linear-gradient(135deg, #FDA4AF, #F43F5E); }
.others .item .info { flex: 1; min-width: 0; }
.others .item .info .name { font-weight: 600; font-size: 13.5px; color: var(--fg-1); }
.others .item .info .role { font-size: 12px; color: var(--fg-2); }
.others .item .reach { color: var(--fg-2); }
.others .item:hover .reach { color: var(--accent); }

/* Featured (light only — warm sand gradient on important news) */
:root[data-theme="light"] .card[data-featured="true"] {
  background: linear-gradient(180deg, #fef0d2 0%, #fde6b0 100%);
  border-color: transparent;
}
:root[data-theme="light"] .card[data-featured="true"] .action { border-top-color: rgb(60 40 20 / 0.16); }
:root[data-theme="light"] .card[data-featured="true"] .angle .fits { border-left-color: rgb(60 40 20 / 0.20); }

/* End marker + empty */
.end { text-align: center; padding: var(--sp-6); color: var(--fg-2); font-size: 12px; }
.empty { text-align: center; padding: 60px 20px; color: var(--fg-2); }

:root[data-theme="dark"] ::-webkit-scrollbar { width: 8px; height: 8px; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-pill); }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .feed-col { padding: var(--sp-4); }
  .topbar { padding: var(--sp-3) var(--sp-4); }
}
