@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,700;1,9..40,400&display=swap');

*{margin:0;padding:0;box-sizing:border-box}

:root {
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-soft: rgba(29,155,240,0.08);
  --accent-border: rgba(29,155,240,0.15);
  --text-primary: #0f1419;
  --text-secondary: #536471;
  --text-tertiary: #8899a6;
  --surface-bg: #f5f7f9;
  --surface-card: #ffffff;
  --surface-elevated: #ffffff;
  --border: #ebeef0;
  --border-light: #f0f2f4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--surface-bg);
  color: var(--text-primary);
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══ App Shell ═══ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ═══ Top Bar ═══ */
.top-bar {
  flex-shrink: 0;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 52px;
  z-index: 10;
}

.top-bar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-bar-brand svg {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex-shrink: 0;
}

.tab-nav {
  display: flex;
  height: 100%;
  align-items: stretch;
  gap: 2px;
}

.tab-link {
  display: flex;
  align-items: center;
  padding: 0 14px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  position: relative;
}

.tab-link:hover {
  color: var(--text-primary);
}

.tab-link.active {
  color: var(--text-primary);
  font-weight: 700;
  border-bottom-color: var(--text-primary);
}

.top-bar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text-primary);
  color: white;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
}

.btn-primary:hover { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-bg);
  color: var(--text-primary);
}

/* ═══ Badge ═══ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ═══ Avatar ═══ */
.avatar {
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

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

.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 44px; height: 44px; font-size: 18px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }

/* ═══ Search Input ═══ */
.search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 9px 16px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--surface-card);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ═══ Card (shared tweet card) ═══ */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-date {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.card-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.card-badges {
  display: flex;
  gap: 4px;
}

.card-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.card-author-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.card-author-handle {
  font-size: 13px;
  color: var(--text-secondary);
}

.card-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-media {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.card-media figure {
  margin: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-bg);
  cursor: pointer;
  transition: opacity 0.15s;
}

.card-media figure:hover { opacity: 0.8; }

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ═══ Lightbox ═══ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lightbox-in 0.15s ease;
}

@keyframes lightbox-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  cursor: zoom-out;
}

.lightbox img {
  position: relative;
  z-index: 1;
  max-width: 85vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  user-select: none;
}

.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  backdrop-filter: blur(4px);
}

.lightbox-arrow:hover { background: rgba(255,255,255,0.3); }

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.lightbox-close:hover { background: rgba(255,255,255,0.3); }

.card-video-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.card-metrics {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.card-metrics span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.card-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.card-link:hover { text-decoration: underline; }

/* ═══ Stat Card ═══ */
.stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ═══ Empty State ═══ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 14px;
  opacity: 0.7;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  max-width: 280px;
  line-height: 1.5;
}

/* ═══ Live Fetch Banner ═══ */
.live-banner {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ═══ Viewer Panel ═══ */
.viewer-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-bg);
  border: 1px solid var(--border-light);
}

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

.viewer-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.viewer-handle {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.viewer-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ═══ Loading ═══ */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Note Pills ═══ */
.note-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

/* ═══ Page Content (scrollable body for likes) ═══ */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.page-content-inner {
  max-width: 1080px;
  margin: 0 auto;
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .top-bar { padding: 0 16px; gap: 16px; height: 48px; }
  .page-content { padding: 16px; }
  .tab-link { padding: 0 10px; font-size: 12px; }
}

/* ═══ Daily crawl chart ═══ */
.daily-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.daily-chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-secondary); }
.daily-chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.daily-chart-swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.daily-chart-link { font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
.daily-chart-link:hover { color: var(--accent-hover); }
.daily-chart-area { position: relative; width: 100%; margin-top: 14px; }
.daily-chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.daily-chart-zone { cursor: crosshair; }
.daily-chart-tip {
  position: absolute; pointer-events: none; top: 8px;
  background: var(--surface-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 12px; box-shadow: var(--shadow-lg);
  font-size: 12px; min-width: 150px; z-index: 6;
}
.daily-chart-tip-day { font-weight: 800; color: var(--text-primary); margin-bottom: 6px; }
.daily-chart-tip-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; line-height: 1.7; }
.daily-chart-tip-row span { color: var(--text-tertiary); }
.daily-chart-tip-row strong { color: var(--text-primary); font-weight: 700; }
