@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --elevated: #1c2128;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --focus: #1d9bf0;
  --focus-hover: #1a8cd8;
  --ok: #3fb950;
  --hover: rgba(255, 255, 255, 0.04);
  --card-radius: 12px;
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* === 3-COLUMN LAYOUT === */
.app {
  max-width: 1265px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 620px) 350px;
  gap: 0;
}

/* === LEFT SIDEBAR === */
.left {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 8px 12px 20px;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  font-weight: 700;
  font-size: 17px;
  border-radius: var(--card-radius);
  width: fit-content;
  cursor: pointer;
  transition: background-color .2s;
}
.brand:hover { background: var(--hover); }
.brand svg { width: 26px; height: 26px; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; flex: 1; }
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--card-radius);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  font-family: inherit;
  width: auto;
  transition: background-color .2s, color .2s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { color: var(--text); font-weight: 600; background: var(--surface); }
.nav-item svg { width: 22px; height: 22px; stroke-width: 2; }
.nav-item .icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background-color .2s;
}
.nav-item.active .icon-wrap { background: rgba(29, 155, 240, 0.15); }
.nav-item.active .icon-wrap svg { color: var(--focus); }
.nav-action {
  background: var(--focus);
  color: #fff;
  border: none;
  border-radius: var(--card-radius);
  padding: 14px 0;
  width: 90%;
  font-size: 15px;
  font-weight: 600;
  margin: 16px auto 0;
  cursor: pointer;
  font-family: inherit;
  transition: background-color .2s, transform .1s;
}
.nav-action:hover { background: var(--focus-hover); }
.nav-action:active { transform: scale(0.98); }

/* === CENTER FEED === */
.main {
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 100vh;
}
.feed-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}
.feed-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 0;
}
.feed-header-title {
  font-size: 18px;
  font-weight: 700;
}
.feed-header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: var(--ok); }

/* === SEGMENTED TABS === */
.feed-tabs {
  padding: 10px 0;
  margin: 4px 0;
}
.feed-tab {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  cursor: default;
  border: none;
  background: transparent;
  font-family: inherit;
}
.feed-meta {
  padding: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* === VIEW SYSTEM === */
.view { display: none; }
.view.active { display: block; }

/* === NEWS POSTS (CARDS) === */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}
.post {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--card-radius);
  cursor: pointer;
  transition: background-color .2s, transform .15s;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}
.post:hover { background: var(--elevated); border-color: var(--line); }
.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--elevated), var(--line));
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.post-body { flex: 1; min-width: 0; }
.post-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  line-height: 1.2;
}
.post-source { font-weight: 600; color: var(--text); }
.post-handle { color: var(--muted); font-weight: 400; font-size: 13px; }
.post-sep { color: var(--muted); font-size: 13px; }
.post-time { color: var(--muted); font-weight: 400; font-size: 13px; }
.post-title {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
}
.post-image {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  margin-top: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.post-actions {
  display: flex;
  justify-content: space-between;
  max-width: 425px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.post-action {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  transition: color .2s, background .2s;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.post-action:hover { color: var(--focus); background: rgba(29, 155, 240, 0.1); }
.post-action svg { width: 16px; height: 16px; }

/* === RIGHT SIDEBAR === */
.right {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 8px 16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.right::-webkit-scrollbar { display: none; }
.search-box {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 0;
  background: var(--bg);
}
.search-box input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 10px 14px 10px 40px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.15);
}
.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-box .search-icon svg { width: 16px; height: 16px; }

/* === TRENDING (MINI-CARDS WITH SCORE BAR) === */
.trending-panel {
  background: var(--surface);
  border-radius: var(--card-radius);
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.trending-panel h2 {
  font-size: 17px;
  font-weight: 700;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.trending-item {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background-color .2s;
  cursor: pointer;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}
.trending-item:last-child { border-bottom: none; }
.trending-item:hover { background: var(--hover); }
.trending-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.trending-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.trending-score-bar {
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 2px;
}
.trending-score-fill {
  height: 100%;
  background: var(--focus);
  border-radius: 4px;
  transition: width .4s ease;
}
.trending-count { font-size: 11px; color: var(--muted); font-weight: 500; }
.trending-show-more {
  padding: 14px 16px;
  color: var(--focus);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .2s;
}
.trending-show-more:hover { background: var(--hover); }
.footer-links {
  padding: 16px 4px;
  font-size: 12px;
  color: var(--muted);
}
.footer-links a { color: var(--muted); }
.footer-links a:hover { text-decoration: underline; color: var(--text); }

/* === BUTTONS === */
.btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background-color .2s, border-color .2s;
}
.btn:hover { background: var(--hover); border-color: var(--muted); }
.btn.primary { background: var(--focus); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--focus-hover); }
.btn.ghost { border-color: transparent; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* === PANELS (connect, apikey, settings) === */
.panel {
  padding: 20px 16px;
  border-bottom: 1px solid var(--line);
}
.panel h1 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.panel .muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.panel .mini {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.panel .mini-card {
  padding: 16px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.panel .mini-card:last-child { border-bottom: none; }
.token-card {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 16px;
}
.token-mono {
  word-break: break-all;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  margin-top: 10px;
  color: var(--muted);
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 14px; }
.setting-desc { font-size: 13px; color: var(--muted); }
.pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
}

/* === STATUS CARDS === */
.status-card {
  padding: 40px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.status-title { font-size: 15px; font-weight: 600; }
.status-help { color: var(--muted); font-size: 14px; max-width: 400px; line-height: 1.5; }

/* === SKELETON === */
.post.skeleton { pointer-events: none; background: var(--surface); border-radius: var(--card-radius); }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 10px; background: var(--line); }
.skeleton-line { height: 14px; border-radius: 6px; background: var(--line); margin-top: 8px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long { width: 100%; }
.skeleton-line.image { height: 200px; border-radius: 10px; margin-top: 12px; }

/* === FEED LOADER === */
.feed-loader {
  display: none;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.feed-loader.active { display: block; }

/* === PROGRESS BAR === */
.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  overflow: hidden;
  z-index: 20;
}
.progress-bar.active::after {
  content: '';
  display: block;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--focus), #58a6ff);
  border-radius: 4px;
  animation: progressSlide 1.2s ease-in-out infinite;
}
@keyframes progressSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(430%); }
}

/* === RESPONSIVE === */
@media (max-width: 1265px) {
  .app { grid-template-columns: 72px minmax(0, 1fr) 290px; }
  .nav-item .label { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item .icon-wrap { width: 40px; height: 40px; }
  .brand span { display: none; }
  .nav-action { width: 48px; height: 48px; padding: 0; font-size: 0; border-radius: 50%; }
  .nav-action::after { content: '\21BB'; font-size: 18px; }
}
@media (max-width: 1004px) {
  .app { grid-template-columns: 68px minmax(0, 1fr); }
  .right { display: none; }
  .nav-item .label { display: none; }
  .brand span { display: none; }
}
@media (max-width: 690px) {
  .app { grid-template-columns: 1fr; }
  .left { display: none; }
  .right { display: none; }
  .mobile-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    justify-content: space-around;
    padding: 8px 0;
    z-index: 50;
  }
  .mobile-nav button {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
  .mobile-nav button.active { color: var(--focus); }
  .mobile-nav button svg { width: 22px; height: 22px; }
  .main { border: none; padding-bottom: 70px; }
  .post-list { padding: 4px; gap: 4px; }
}
.mobile-nav { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
