/* ==========================================================================
   Lane E — whole-app shell restyle from the reference image
   (clean white canvas, Inter, teal accent, flat stream, 1px dividers).
   LAST-LOADED sheet: it sits on top of bundle.css + stitch sheets and
   restyles the EXISTING shell. It invents no feature, no data, no route:
   every button it adds reuses an existing data-nav / data-show-view key
   or an existing function (DCTheme.toggleTheme, composer focus).
   Dark rules live in this same file under [data-theme="dark"] so the
   dark restyle is complete, not a partial overlay.
   Account-lane note: selectors below target shell / feed / sidebar only
   (plus .restyle-* names for new nodes). They do not touch account-page
   scoped classes; if an account sheet loads after this one, its scoped
   rules win inside account views, which is the intended precedence.
   ========================================================================== */

/* ---------- Tokens / base ---------- */
body.social2-shell {
  font-family: Inter, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #ffffff;
  color: #111827;
  overflow-x: hidden;
}
body.social2-shell img, body.social2-shell video, body.social2-shell pre,
body.social2-shell table { max-width: 100%; }
body.social2-shell pre { overflow-x: auto; }

/* ---------- Desktop layout: rail / stream / right rail, no top bar ---------- */
@media (min-width: 1024px) {
  body.social2-shell .dc-topbar.social2-topbar { display: none; }
  body.social2-shell .layout.social2-layout {
    grid-template-columns: 240px minmax(0, 640px) 340px;
    gap: 0;
    max-width: 1280px;
    padding: 0 16px 32px;
  }
  body.social2-shell .social2-left-nav {
    top: 0;
    max-height: 100vh;
    padding: 16px 16px 0 0;
    border-right: 1px solid #e5e7eb;
  }
  body.social2-shell .social2-main { padding: 0 24px; }
  body.social2-shell .social2-sidebar {
    top: 0;
    max-height: 100vh;
    padding: 16px 0 0 24px;
    border-left: 1px solid #e5e7eb;
  }
}

/* ---------- Left rail: brand ---------- */
.restyle-rail-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 16px; text-decoration: none;
}
.restyle-rail-brand img { height: 32px; width: auto; }
.restyle-rail-brand .restyle-wordmark { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: #111827; }
.restyle-rail-brand .restyle-wordmark em { font-style: normal; color: #0f766e; }

/* ---------- Left rail: primary nav (image order) ---------- */
.restyle-primary { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; }
.restyle-primary .nav-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 11px 12px; border: 0; border-radius: 999px; background: transparent;
  font-size: 16px; font-weight: 600; color: #111827; cursor: pointer; text-align: left;
}
.restyle-primary .nav-btn:hover { background: #f3f4f6; }
.restyle-primary .nav-btn.is-active, .restyle-primary .nav-btn[aria-current="page"] { background: #f3f4f6; }
.restyle-primary .nav-btn .nav-icon { width: 24px; height: 24px; stroke: #111827; flex: 0 0 auto; }
.restyle-primary .nav-btn.is-active .nav-icon, .restyle-primary .nav-btn[aria-current="page"] .nav-icon { stroke: #0f766e; }
.restyle-primary .nav-btn .restyle-badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: #0f766e; color: #fff; font-size: 12px; font-weight: 700;
}
.restyle-primary .nav-btn .restyle-badge:empty { display: none; }
.restyle-primary .nav-btn .restyle-dot {
  margin-left: auto; width: 9px; height: 9px; border-radius: 50%; background: #0f766e; flex: 0 0 auto;
}
/* Hide the OLD direct-child copies of the 9 primary keys in the left rail
   only (bottom nav + More panel copies are untouched and keep working).
   Their ids (#message-badge) keep updating in the background; the rail
   mirrors them via restyle-shell.js, so no live count is lost. */
.social2-left-nav > .nav-btn[data-nav="feed"],
.social2-left-nav > .nav-btn[data-nav="explore"],
.social2-left-nav > .nav-btn[data-nav="communities"],
.social2-left-nav > .nav-btn[data-nav="projects"],
.social2-left-nav > .nav-btn[data-nav="messages"],
.social2-left-nav > .nav-btn[data-nav="notifications"],
.social2-left-nav > .nav-btn[data-nav="saved"],
.social2-left-nav > .nav-btn[data-nav="profile"],
.social2-left-nav > .nav-btn[data-nav="account"] { display: none; }
/* Remaining (secondary) views stay listed below the primary rail. */
.social2-left-nav > .nav-btn:not(.restyle-primary .nav-btn) {
  font-size: 14px; padding: 8px 12px;
}

/* ---------- Left rail: Post pill + Dark Theme pill + user card ---------- */
.restyle-rail-post {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin: 12px 0 8px; padding: 13px 16px;
  border: 0; border-radius: 999px; background: #0f766e; color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.restyle-rail-post:hover { background: #0d5f58; }
.restyle-dark-pill {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 14px; border: 1px solid #e5e7eb; border-radius: 999px;
  background: #fff; color: #111827; font-size: 14px; font-weight: 600; cursor: pointer;
}
.restyle-dark-pill .restyle-dark-state {
  margin-left: auto; padding: 2px 10px; border-radius: 999px;
  background: #f3f4f6; font-size: 12px; font-weight: 700; color: #374151;
}
.restyle-user-card {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin-top: 16px; padding: 12px; border: 0; border-radius: 999px;
  background: #fff; text-align: left; cursor: pointer;
}
.restyle-user-card:hover { background: #f3f4f6; }
.restyle-user-card .dc-avatar { flex: 0 0 auto; }
.restyle-user-card .restyle-user-meta { min-width: 0; flex: 1 1 auto; }
.restyle-user-card .restyle-user-name {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; font-weight: 700; color: #111827;
}
.restyle-user-card .restyle-user-handle {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: #6b7280;
}
.restyle-user-card .restyle-user-more { font-size: 18px; color: #6b7280; line-height: 1; }
.restyle-user-menu {
  display: flex; flex-direction: column; gap: 2px; padding: 8px;
  border: 1px solid #e5e7eb; border-radius: 16px; background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.restyle-user-menu button {
  padding: 9px 12px; border: 0; border-radius: 999px; background: transparent;
  font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; color: #111827;
}
.restyle-user-menu button:hover { background: #f3f4f6; }

/* ---------- Centre stream: flat, 1px dividers ---------- */
#view-feed > .view-head { display: none; }
.social2-layout .dc-post-card, .social2-layout .dc-social2-post {
  border: 0; border-bottom: 1px solid #e5e7eb; border-radius: 0;
  box-shadow: none; background: #fff;
}
.social2-layout .dc-post-card .dc-post-head { padding-top: 4px; }
.social2-layout .dc-post-card .dc-author-link { font-weight: 700; color: #111827; }
.social2-layout .dc-post-card .dc-handle, .social2-layout .dc-post-card .dc-time { color: #6b7280; font-weight: 400; }
/* Role badge: soft tint, reusing the existing .dc-role-badge system. */
.social2-layout .dc-role-badge {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #f0fdfa; color: #0f766e;
}
.social2-layout .dc-role-badge[data-role="investor"] { background: #fef3c7; color: #92400e; }
.social2-layout .dc-role-badge[data-role="tester"] { background: #ede9fe; color: #5b21b6; }
.social2-layout .dc-post-tags a { color: #0f766e; font-weight: 600; }
/* Attachment blocks from real post data. */
.social2-layout .dc-post-card .dc-project-card,
.social2-layout .dc-post-card .dc-project {
  background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 16px;
}
.social2-layout .dc-post-card pre, .social2-layout .dc-post-card .dc-code,
.social2-layout .dc-post-card code { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.social2-layout .dc-post-card pre, .social2-layout .dc-post-card .dc-code-block {
  background: #111827; color: #e5e7eb; border-radius: 16px;
}
/* Action bar: real counts only (the renderer already prints them). */
.social2-layout .dc-post-actions { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.social2-layout .dc-post-actions .dc-action-btn { color: #6b7280; font-size: 13px; }

/* ---------- Feed tabs: teal underline on the active tab ---------- */
/* NOTE: #view-feed prefix is required: social2-feed.css uses the ID selector
   #view-feed .dc-social2-tabs .dc-tab (1,2,0), which beats any class-only rule. */
#view-feed .social2-layout .dc-feed-tabs, .social2-layout #view-feed .dc-feed-tabs {
  display: flex; gap: 0; border-bottom: 1px solid #e5e7eb; background: #fff;
}
#view-feed .social2-layout .dc-feed-tabs .dc-tab, .social2-layout #view-feed .dc-feed-tabs .dc-tab {
  flex: 1 1 0; padding: 14px 8px; border: 0; border-bottom: 3px solid transparent;
  border-radius: 0; background: transparent; color: #6b7280;
  font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: none;
}
#view-feed .social2-layout .dc-feed-tabs .dc-tab.is-active,
#view-feed .social2-layout .dc-feed-tabs .dc-tab[aria-pressed="true"],
.social2-layout #view-feed .dc-feed-tabs .dc-tab.is-active,
.social2-layout #view-feed .dc-feed-tabs .dc-tab[aria-pressed="true"] {
  color: #111827; border-bottom: 3px solid #0f766e; background: transparent; box-shadow: none;
}

/* ---------- Story strip: ringed circles, dashed create item ---------- */
.social2-layout .dc-stories { border-bottom: 1px solid #e5e7eb; }
.social2-layout #stories-strip { display: flex; gap: 16px; overflow-x: auto; padding: 12px 4px; }
.social2-layout .dc-social2-story { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; }
.social2-layout .dc-social2-story-ring {
  width: 60px; height: 60px; border-radius: 50%;
  border: 3px solid var(--story-ring, #0f766e);
  display: flex; align-items: center; justify-content: center; background: #fff;
}
.social2-layout .dc-social2-story-ring .dc-avatar { width: 48px; height: 48px; }
.social2-layout .dc-social2-story--create .dc-social2-story-ring { border-style: dashed; border-color: #0f766e; }
.social2-layout .dc-social2-story--create .dc-social2-story-plus { font-size: 24px; color: #0f766e; font-weight: 700; }
.social2-layout .dc-story-name { font-size: 12px; color: #374151; }

/* ---------- Composer: flat, pill Post, visibility as a pill ---------- */
.social2-layout #post-form { border-bottom: 1px solid #e5e7eb; }
.social2-layout .dc-composer { border: 0; box-shadow: none; background: #fff; }
.social2-layout .dc-composer textarea {
  border: 0; font-size: 17px; color: #111827;
}
.social2-layout .dc-composer textarea::placeholder { color: #9ca3af; }
.social2-layout .dc-composer .dc-visibility-label,
.social2-layout .dc-composer .dc-composer-visibility {
  display: inline-flex; padding: 4px 12px; border: 1px solid #d1fae5;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: #0f766e;
}
.social2-layout .dc-social2-composer-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.social2-layout .dc-social2-composer-action { color: #0f766e; font-weight: 600; }
.social2-layout .dc-composer button[type="submit"].btn-primary,
.social2-layout .dc-composer .btn-primary[type="submit"] {
  border-radius: 999px; background: #0f766e; border-color: #0f766e; padding: 10px 22px;
}
.social2-layout .dc-composer button[type="submit"].btn-primary:hover { background: #0d5f58; }

/* ---------- Right rail: pill search, ordered cards, BLACK Follow pills ---------- */
@media (min-width: 1024px) {
  body.social2-shell .social2-sidebar { display: flex; flex-direction: column; gap: 0; }
  body.social2-shell .social2-sidebar .dc-sidebar-card { border: 0; border-bottom: 1px solid #e5e7eb; border-radius: 0; box-shadow: none; background: #fff; }
  body.social2-shell .social2-sidebar .social2-side-search-card { order: 1; }
  body.social2-shell .social2-sidebar .dc-sidebar-card:has(#dc-sidebar-live) { order: 2; }
  body.social2-shell .social2-sidebar .dc-sidebar-card:has(#trending-sidebar) { order: 3; }
  body.social2-shell .social2-sidebar .dc-sidebar-card:has(#dc-sidebar-trending) { order: 4; }
  body.social2-shell .social2-sidebar .dc-sidebar-card:has(#dc-sidebar-suggested) { order: 5; }
  body.social2-shell .social2-sidebar .dc-sidebar-card:has(#dc-sidebar-testing) { order: 6; }
}
.social2-sidebar .social2-side-search {
  width: 100%; padding: 11px 16px; border: 0; border-radius: 999px;
  background: #f3f4f6; color: #6b7280; font-size: 14px; text-align: left;
}
.social2-sidebar .dc-sidebar-title { font-size: 17px; font-weight: 800; color: #111827; }
.social2-sidebar .dc-live-dot { background: #0f766e; }
/* Who-to-follow Follow pills are BLACK in the reference; Post buttons and
   links stay teal. Scoped to the suggested card only. */
.social2-sidebar .dc-sidebar-card:has(#dc-sidebar-suggested) .dc-sidebar-follow,
.social2-sidebar .dc-sidebar-card:has(#dc-sidebar-suggested) .btn-primary {
  background: #111827; border-color: #111827; color: #fff; border-radius: 999px;
}
.social2-sidebar .dc-sidebar-card:has(#dc-sidebar-suggested) .dc-sidebar-follow:hover { background: #000; }
.restyle-view-all {
  padding: 8px 12px; border: 0; background: transparent;
  color: #0f766e; font-size: 14px; font-weight: 700; cursor: pointer;
}
.restyle-rail-footer { padding: 12px 4px; font-size: 13px; color: #6b7280; line-height: 1.9; order: 7; }
.restyle-rail-footer a { color: #6b7280; text-decoration: none; margin-right: 12px; }
.restyle-rail-footer a:hover { text-decoration: underline; }

/* ---------- Whole-app carry: other views keep the flat look ---------- */
.social2-layout .view .dc-card, .social2-layout .view .dc-panel {
  border-color: #e5e7eb; box-shadow: none;
}
.social2-layout .btn-primary { background: #0f766e; border-color: #0f766e; }
.social2-layout .btn-primary:hover { background: #0d5f58; }
.social2-layout a { color: #0f766e; }

/* ---------- Mobile: rail -> bottom bar, stream full width, right rail gone ---------- */
@media (max-width: 1023px) {
  body.social2-shell .social2-left-nav { display: none; }
  body.social2-shell .social2-sidebar { display: none; }
  body.social2-shell .layout.social2-layout { padding: 0 0 80px; }
  body.social2-shell .social2-main { padding: 0 12px; }
  body.social2-shell .dc-topbar.social2-topbar { display: block; }
  body.social2-shell .dc-topbar .dc-search,
  body.social2-shell .dc-topbar .dc-topbar-actions .btn-primary,
  body.social2-shell .dc-topbar .notif,
  body.social2-shell .dc-topbar #logout-btn,
  body.social2-shell .dc-topbar #current-user-display { display: none; }
  body.social2-shell #view-feed > .view-head { display: none; }
  body.social2-shell #view-feed .dc-feed-tabs .dc-tab.is-active,
  body.social2-shell #view-feed .dc-feed-tabs .dc-tab[aria-pressed="true"] { border-bottom: 3px solid #0f766e; }
}

/* ==========================================================================
   DARK MODE — complete carry of the restyle (whole app, no view left light).
   Keyed on html[data-theme="dark"], the app's existing theme attribute.
   Scheduling stays opt-in/off by default: untouched here, as in the app.
   ========================================================================== */
html[data-theme="dark"] body.social2-shell { background: #0f172a; color: #e2e8f0; }
html[data-theme="dark"] .restyle-rail-brand .restyle-wordmark { color: #f1f5f9; }
html[data-theme="dark"] .restyle-primary .nav-btn { color: #e2e8f0; }
html[data-theme="dark"] .restyle-primary .nav-btn:hover,
html[data-theme="dark"] .restyle-primary .nav-btn.is-active,
html[data-theme="dark"] .restyle-primary .nav-btn[aria-current="page"] { background: #1e293b; }
html[data-theme="dark"] .restyle-primary .nav-btn .nav-icon { stroke: #e2e8f0; }
html[data-theme="dark"] .restyle-primary .nav-btn.is-active .nav-icon,
html[data-theme="dark"] .restyle-primary .nav-btn[aria-current="page"] .nav-icon { stroke: #2dd4bf; }
html[data-theme="dark"] .restyle-primary .nav-btn .restyle-badge { background: #14b8a6; color: #062f2b; }
html[data-theme="dark"] .restyle-primary .nav-btn .restyle-dot { background: #2dd4bf; }
html[data-theme="dark"] .restyle-rail-post { background: #14b8a6; color: #062f2b; }
html[data-theme="dark"] .restyle-rail-post:hover { background: #2dd4bf; }
html[data-theme="dark"] .restyle-dark-pill { background: #0f172a; border-color: #334155; color: #e2e8f0; }
html[data-theme="dark"] .restyle-dark-pill .restyle-dark-state { background: #1e293b; color: #cbd5e1; }
html[data-theme="dark"] .restyle-user-card { background: #0f172a; }
html[data-theme="dark"] .restyle-user-card:hover { background: #1e293b; }
html[data-theme="dark"] .restyle-user-card .restyle-user-name { color: #f1f5f9; }
html[data-theme="dark"] .restyle-user-card .restyle-user-handle { color: #94a3b8; }
html[data-theme="dark"] .restyle-user-menu { background: #1e293b; border-color: #334155; }
html[data-theme="dark"] .restyle-user-menu button { color: #e2e8f0; }
html[data-theme="dark"] .restyle-user-menu button:hover { background: #334155; }
@media (min-width: 1024px) {
  html[data-theme="dark"] body.social2-shell .social2-left-nav { border-right-color: #1e293b; }
  html[data-theme="dark"] body.social2-shell .social2-sidebar { border-left-color: #1e293b; }
}
html[data-theme="dark"] .social2-layout .dc-post-card,
html[data-theme="dark"] .social2-layout .dc-social2-post { background: #0f172a; border-bottom-color: #1e293b; }
html[data-theme="dark"] .social2-layout .dc-post-card .dc-author-link { color: #f1f5f9; }
html[data-theme="dark"] .social2-layout .dc-post-card .dc-handle,
html[data-theme="dark"] .social2-layout .dc-post-card .dc-time { color: #94a3b8; }
html[data-theme="dark"] .social2-layout .dc-role-badge { background: #134e4a; color: #5eead4; }
html[data-theme="dark"] .social2-layout .dc-role-badge[data-role="investor"] { background: #451a03; color: #fcd34d; }
html[data-theme="dark"] .social2-layout .dc-role-badge[data-role="tester"] { background: #2e1065; color: #c4b5fd; }
html[data-theme="dark"] .social2-layout .dc-post-tags a { color: #2dd4bf; }
html[data-theme="dark"] .social2-layout .dc-post-card .dc-project-card,
html[data-theme="dark"] .social2-layout .dc-post-card .dc-project { background: #1e293b; border-color: #334155; }
html[data-theme="dark"] .social2-layout .dc-post-card pre,
html[data-theme="dark"] .social2-layout .dc-post-card .dc-code-block { background: #020617; color: #e2e8f0; }
html[data-theme="dark"] .social2-layout .dc-post-actions .dc-action-btn { color: #94a3b8; }
html[data-theme="dark"] #view-feed .social2-layout .dc-feed-tabs { background: #0f172a; border-bottom-color: #1e293b; }
html[data-theme="dark"] #view-feed .social2-layout .dc-feed-tabs .dc-tab { color: #94a3b8; }
html[data-theme="dark"] #view-feed .social2-layout .dc-feed-tabs .dc-tab.is-active,
html[data-theme="dark"] #view-feed .social2-layout .dc-feed-tabs .dc-tab[aria-pressed="true"] { color: #f1f5f9; border-bottom: 3px solid #2dd4bf; }
html[data-theme="dark"] .social2-layout .dc-stories { border-bottom-color: #1e293b; }
html[data-theme="dark"] .social2-layout .dc-social2-story-ring { background: #0f172a; }
html[data-theme="dark"] .social2-layout .dc-social2-story--create .dc-social2-story-ring { border-color: #2dd4bf; }
html[data-theme="dark"] .social2-layout .dc-social2-story--create .dc-social2-story-plus { color: #2dd4bf; }
html[data-theme="dark"] .social2-layout .dc-story-name { color: #cbd5e1; }
html[data-theme="dark"] .social2-layout #post-form { border-bottom-color: #1e293b; }
html[data-theme="dark"] .social2-layout .dc-composer { background: #0f172a; }
html[data-theme="dark"] .social2-layout .dc-composer textarea { color: #f1f5f9; background: #0f172a; }
html[data-theme="dark"] .social2-layout .dc-composer textarea::placeholder { color: #64748b; }
html[data-theme="dark"] .social2-layout .dc-composer .dc-visibility-label { border-color: #134e4a; color: #5eead4; }
html[data-theme="dark"] .social2-layout .dc-social2-composer-action { color: #2dd4bf; }
html[data-theme="dark"] .social2-layout .dc-composer button[type="submit"].btn-primary { background: #14b8a6; border-color: #14b8a6; color: #062f2b; }
html[data-theme="dark"] .social2-sidebar .social2-side-search { background: #1e293b; color: #94a3b8; }
html[data-theme="dark"] .social2-sidebar .dc-sidebar-title { color: #f1f5f9; }
html[data-theme="dark"] .social2-sidebar .dc-live-dot { background: #2dd4bf; }
html[data-theme="dark"] .social2-sidebar .dc-sidebar-card:has(#dc-sidebar-suggested) .dc-sidebar-follow,
html[data-theme="dark"] .social2-sidebar .dc-sidebar-card:has(#dc-sidebar-suggested) .btn-primary { background: #f1f5f9; border-color: #f1f5f9; color: #0f172a; }
html[data-theme="dark"] .restyle-view-all { color: #2dd4bf; }
html[data-theme="dark"] .restyle-rail-footer { color: #94a3b8; }
html[data-theme="dark"] .restyle-rail-footer a { color: #94a3b8; }
html[data-theme="dark"] .social2-layout .view .dc-card,
html[data-theme="dark"] .social2-layout .view .dc-panel { border-color: #334155; background: #0f172a; }
html[data-theme="dark"] .social2-layout .btn-primary { background: #14b8a6; border-color: #14b8a6; color: #062f2b; }
html[data-theme="dark"] .social2-layout a { color: #2dd4bf; }
@media (min-width: 1024px) {
  html[data-theme="dark"] body.social2-shell .social2-sidebar .dc-sidebar-card { background: #0f172a; border-bottom-color: #1e293b; }
}
@media (max-width: 1023px) {
  html[data-theme="dark"] body.social2-shell .dc-topbar.social2-topbar { background: #0f172a; }
  html[data-theme="dark"] body.social2-shell #view-feed .dc-feed-tabs .dc-tab.is-active,
  html[data-theme="dark"] body.social2-shell #view-feed .dc-feed-tabs .dc-tab[aria-pressed="true"] { border-bottom: 3px solid #2dd4bf; }
}
