/* ================================================================
   Feed page — Robinhood-inspired day/night theme
   ================================================================ */

html[data-feed-theme="light"] {
  color-scheme: light;
}

html[data-feed-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"] body.feed-body {
  --feed-bg: #f4f8f2;
  --feed-bg-strong: #edf4e8;
  --feed-panel: rgba(255, 255, 255, 0.94);
  --feed-panel-alt: #f7faf5;
  --feed-card: #ffffff;
  --feed-border: #d9e2d3;
  --feed-divider: #e6ede1;
  --feed-text: #131a15;
  --feed-muted: #667166;
  --feed-accent: #00c805;
  --feed-accent-strong: #00a83d;
  --feed-accent-soft: rgba(0, 200, 5, 0.1);
  --feed-accent-soft-strong: rgba(0, 200, 5, 0.16);
  --feed-btn: #eef4ea;
  --feed-btn-hover: #e4eedf;
  --feed-shadow: 0 20px 44px rgba(23, 33, 24, 0.08);
  --feed-card-shadow: 0 8px 18px rgba(14, 21, 15, 0.06);
  --feed-sidebar-shadow: 0 8px 20px rgba(15, 20, 16, 0.05);
}

html[data-theme="dark"] body.feed-body {
  --feed-bg: #0a0f0b;
  --feed-bg-strong: #0f1511;
  --feed-panel: rgba(18, 24, 19, 0.96);
  --feed-panel-alt: #121813;
  --feed-card: #161d17;
  --feed-border: #243026;
  --feed-divider: #1d251e;
  --feed-text: #eef5ee;
  --feed-muted: #8f9e8f;
  --feed-accent: #00c805;
  --feed-accent-strong: #3be374;
  --feed-accent-soft: rgba(0, 200, 5, 0.14);
  --feed-accent-soft-strong: rgba(0, 200, 5, 0.2);
  --feed-btn: #1a211b;
  --feed-btn-hover: #212a22;
  --feed-shadow: 0 24px 52px rgba(0, 0, 0, 0.36);
  --feed-card-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  --feed-sidebar-shadow: none;
}

html:has(body.feed-body),
body.feed-body {
  height: 100%;
  overflow: hidden;
  margin: 0;
}

body.feed-body {
  background:
    radial-gradient(circle at top, rgba(0, 200, 5, 0.08), transparent 24%),
    linear-gradient(180deg, var(--feed-bg) 0%, var(--feed-bg-strong) 100%);
  color: var(--feed-text);
}

body.feed-body,
body.feed-body button,
body.feed-body input,
body.feed-body select,
body.feed-body textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.feed-body a {
  color: var(--feed-accent-strong);
  text-decoration: none;
}

body.feed-body a:hover {
  text-decoration: underline;
}

body.feed-body .muted {
  color: var(--feed-muted);
}

body.feed-body .logo {
  background: linear-gradient(135deg, var(--feed-accent), var(--feed-accent-strong));
  color: #081007;
  box-shadow: 0 10px 22px rgba(0, 200, 5, 0.24);
}

body.feed-body .btn {
  background: var(--feed-btn);
  color: var(--feed-text);
  border: 1px solid var(--feed-border);
  box-shadow: none;
}

body.feed-body .btn:hover {
  background: var(--feed-btn-hover);
  border-color: var(--feed-accent-soft-strong);
}

body.feed-body .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

body.feed-body .btn-primary {
  background: var(--feed-accent);
  border-color: var(--feed-accent);
  color: #081007;
  font-weight: 600;
}

body.feed-body .btn-primary:hover {
  background: var(--feed-accent-strong);
  border-color: var(--feed-accent-strong);
}

.feed-theme-toggle {
  min-width: 86px;
  justify-content: center;
  font-weight: 600;
}

/* ── top nav ──────────────────────────────────────────────────── */
.feed-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 60px;
  background: var(--feed-panel);
  border-bottom: 1px solid var(--feed-border);
  box-shadow: 0 1px 0 rgba(17, 23, 21, 0.04);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
  z-index: 20;
  position: relative;
}

.feed-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feed-brand-name {
  font-weight: 700;
  font-size: 0.96rem;
  letter-spacing: -0.01em;
}

.feed-topbar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feed-email {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── two-column layout ────────────────────────────────────────── */
.feed-layout {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ── sidebar ──────────────────────────────────────────────────── */
.feed-sidebar {
  width: 300px;
  min-width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--feed-border);
  display: flex;
  flex-direction: column;
  background: var(--feed-panel);
  box-shadow: var(--feed-sidebar-shadow);
  overflow: hidden;
}

.feed-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--feed-divider);
  flex-shrink: 0;
}

.feed-sidebar-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--feed-muted);
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.feed-empty-sidebar {
  padding: 22px 18px;
  line-height: 1.6;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  cursor: pointer;
  border-left: 3px solid transparent;
  border-radius: 16px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.channel-item + .channel-item {
  margin-top: 4px;
}

.channel-item:hover {
  background: var(--feed-accent-soft);
}

.channel-item.active {
  background: linear-gradient(90deg, var(--feed-accent-soft-strong), transparent 86%);
  border-left-color: var(--feed-accent);
}

.channel-item:active {
  transform: translateY(1px);
}

.channel-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  color: #f7fff6;
  text-transform: uppercase;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.channel-info {
  flex: 1;
  min-width: 0;
}

.channel-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--feed-text);
}

.channel-meta {
  font-size: 0.73rem;
  color: var(--feed-muted);
  margin-top: 3px;
}

/* ── main message pane ────────────────────────────────────────── */
.feed-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(0, 200, 5, 0.02), transparent 22%),
    linear-gradient(180deg, var(--feed-bg) 0%, var(--feed-bg-strong) 100%);
  min-width: 0;
}

.feed-splash {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.feed-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 420px;
}

.feed-splash-logo {
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, var(--feed-accent), var(--feed-accent-strong));
  color: #081007;
  border-radius: 24px;
  font-size: 1.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  box-shadow: 0 18px 34px rgba(0, 200, 5, 0.2);
}

.feed-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.feed-content-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--feed-panel);
  border-bottom: 1px solid var(--feed-border);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
  min-height: 60px;
}

.feed-content-header-info h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--feed-text);
}

.feed-messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 92px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feed-load-older {
  text-align: center;
  padding-bottom: 18px;
  flex-shrink: 0;
}

.feed-loading-indicator,
.feed-empty-msgs {
  text-align: center;
  padding: 28px 0;
}

.msg-date-sep {
  text-align: center;
  margin: 20px 0 12px;
  font-size: 0.72rem;
  color: var(--feed-muted);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.msg-date-sep::before,
.msg-date-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--feed-divider);
}

.msg-card {
  background: linear-gradient(180deg, var(--feed-card) 0%, var(--feed-panel-alt) 100%);
  border-radius: 18px;
  padding: 12px 15px 11px;
  max-width: 780px;
  width: 100%;
  border: 1px solid var(--feed-border);
  box-shadow: var(--feed-card-shadow);
  word-break: break-word;
  margin-bottom: 6px;
}

.msg-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* Translate button — sits left of the timestamp via margin-right: auto */
.msg-translate-btn {
  margin-right: auto;
  padding: 2px 8px;
  border: 1px solid var(--feed-border);
  border-radius: 999px;
  background: transparent;
  color: var(--feed-muted);
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}

.msg-translate-btn:hover {
  color: var(--feed-accent-strong);
  border-color: var(--feed-accent-strong);
  background: var(--feed-accent-soft);
}

.msg-translate-btn:disabled {
  cursor: progress;
  opacity: 0.6;
}

/* Translated text — same style as original */
.msg-text-translated {
  border-left: 2px solid var(--feed-accent);
  padding-left: 8px;
}

/* Small attribution label below the translated paragraph */
.msg-translated-label {
  display: block;
  margin-top: 4px;
  font-size: 0.66rem;
  color: var(--feed-muted);
  opacity: 0.7;
}

/* Language selector in the topbar */
.translate-lang-select {
  padding: 4px 6px;
  border: 1px solid var(--feed-border);
  border-radius: 8px;
  background: var(--feed-btn);
  color: var(--feed-text);
  font-size: 0.78rem;
  cursor: pointer;
  max-width: 150px;
}

.translate-lang-select:hover {
  border-color: var(--feed-accent-soft-strong);
  background: var(--feed-btn-hover);
}

.msg-ts {
  font-size: 0.7rem;
  color: var(--feed-muted);
}

.msg-text {
  font-size: 0.93rem;
  line-height: 1.62;
  white-space: pre-wrap;
  margin: 0;
  color: var(--feed-text);
}

.msg-link {
  color: var(--feed-accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.msg-link-preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.link-preview {
  display: grid;
  width: min(100%, 560px);
  overflow: hidden;
  border: 1px solid var(--feed-border);
  border-radius: 8px;
  background: var(--feed-btn);
}

.link-preview-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  color: inherit;
  text-decoration: none;
}

.link-preview-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--feed-panel-alt);
  overflow: hidden;
}

.link-preview-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.link-preview-play-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.link-preview-body {
  min-width: 0;
  padding: 10px 11px;
}

.link-preview-site {
  color: var(--feed-muted);
  font-size: 0.72rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-preview-title {
  margin-top: 3px;
  color: var(--feed-text);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

.link-preview-desc {
  display: -webkit-box;
  margin-top: 4px;
  color: var(--feed-muted);
  font-size: 0.78rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.link-preview.is-loading .link-preview-title {
  color: var(--feed-muted);
  font-weight: 500;
}

.link-preview-play {
  justify-self: start;
  margin: 0 11px 10px;
  padding: 6px 10px;
  border: 1px solid var(--feed-border);
  border-radius: 999px;
  background: var(--feed-panel);
  color: var(--feed-text);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.link-preview-play:hover {
  background: var(--feed-btn-hover);
}

.link-preview-embed {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}

.msg-media-list {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.msg-media-item,
.msg-media-download,
.msg-media-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--feed-btn);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.77rem;
  color: var(--feed-muted);
  border: 1px solid var(--feed-border);
}

.msg-media-download,
.msg-media-play {
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
}

.msg-media-download:hover,
.msg-media-play:hover {
  background: var(--feed-btn-hover);
  color: var(--feed-text);
}

.msg-media-download:disabled,
.msg-media-play:disabled {
  cursor: progress;
  opacity: 0.7;
}

.msg-media-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.msg-image-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(100%, 560px);
  min-height: 160px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--feed-border);
  border-radius: 8px;
  background: var(--feed-btn);
}

.msg-image-frame::before {
  content: "Loading image";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--feed-muted);
  font-size: 0.78rem;
}

.msg-image-frame.is-error::before {
  content: "Image unavailable";
}

.msg-media-image {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  max-height: min(68vh, 680px);
  object-fit: contain;
  background: var(--feed-panel-alt);
  opacity: 0;
  transition: opacity 160ms ease;
}

.msg-media-image.is-loaded {
  opacity: 1;
}

.msg-image-frame figcaption {
  position: relative;
  z-index: 2;
  padding: 0 10px 8px;
  color: var(--feed-muted);
  font-size: 0.72rem;
}

.msg-media-player {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.msg-media-player.is-error::after,
.msg-media-download.is-error::after {
  content: attr(data-error);
  color: #ef4444;
  font-size: 0.72rem;
}

.msg-media-name {
  color: var(--feed-muted);
  font-size: 0.75rem;
}

.msg-video-element,
.msg-audio-element {
  width: min(100%, 620px);
}

.msg-video-element {
  max-height: min(68vh, 680px);
  border-radius: 8px;
  background: #000;
}

.feed-app-footer {
  color: var(--feed-muted);
}

.feed-app-footer code {
  background: var(--feed-panel);
  color: var(--feed-text);
  border: 1px solid var(--feed-border);
  border-radius: 999px;
  padding: 4px 8px;
}

/* ── mobile overrides ─────────────────────────────────────────── */
.feed-mobile-only {
  display: none;
}

@media (max-width: 700px) {
  .feed-topbar {
    height: 56px;
    padding: 0 12px;
  }

  .feed-email,
  .feed-settings-link {
    display: none;
  }

  .feed-layout {
    height: calc(100vh - 56px);
    position: relative;
    overflow: hidden;
  }

  .feed-sidebar {
    position: absolute;
    inset: 0;
    width: 100%;
    z-index: 10;
    transition: transform 0.22s ease;
  }

  .feed-sidebar.slide-out {
    transform: translateX(-100%);
  }

  .feed-main {
    position: absolute;
    inset: 0;
  }

  .feed-mobile-only {
    display: inline-flex;
  }

  .feed-messages-wrap {
    padding: 14px 12px 88px;
  }

  .msg-card {
    max-width: 100%;
  }
}
