:root {
  --bg: #0b1020;
  --panel: #141b2e;
  --panel-2: #1c2540;
  --text: #e8edf6;
  --muted: #9aa6bf;
  --accent: #ed174c;
  --accent-2: #006bb6;
  --border: #28324d;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2440 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  width: min(960px, 92vw);
  margin: 0 auto;
}

/* Header */
.site-header {
  padding: 24px 0 14px;
  text-align: center;
}
.site-header h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 38px);
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Tabs */
.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 16, 32, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.tabs-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
}
.tab {
  flex-shrink: 0;
  flex-grow: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.tab:hover {
  border-color: var(--accent-2);
}
.tab.is-active {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: #fff;
}
.tab-row-spacer {
  flex: 1;
}
.refresh {
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.refresh:hover {
  border-color: var(--accent);
}
.refresh:disabled {
  opacity: 0.5;
  cursor: default;
}
.refresh-icon {
  display: inline-block;
}
.refresh.loading .refresh-icon {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.x-show-btn {
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  -webkit-touch-callout: none;
}
.x-show-btn .x-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1d9bf0;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* Status */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 12px;
  min-height: 22px;
  font-size: 14px;
  color: var(--muted);
}
.status.error {
  color: #ff6b81;
}

.updated {
  color: var(--muted);
  font-size: 12.5px;
}

/* Feed */
.feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding-bottom: 40px;
}
.card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-2);
}
.card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.35;
}
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

/* Skeleton */
.skeleton {
  height: 110px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0 30px;
  text-align: center;
  clear: both;
}
.site-footer p {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
}

/* ======================================================================
   LAYOUT: Main area + sidebar
   ====================================================================== */
.main-layout {
  display: flex;
  align-items: flex-start;
  padding-top: 0;
}

/* ======================================================================
   DESKTOP: X Feed Floating Panel (right side)
   ====================================================================== */
.x-sidebar {
  position: fixed;
  top: 56px;
  right: 16px;
  bottom: 16px;
  width: 340px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 150;
  resize: horizontal;
  min-width: 200px;
  max-width: 500px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.x-sidebar.collapsed {
  transform: translateX(calc(100% + 20px));
  pointer-events: none;
  box-shadow: none;
}
.x-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.x-sidebar-header:active {
  cursor: grabbing;
}
.x-sidebar-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.x-sidebar-title .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1d9bf0;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.x-sidebar-controls {
  display: flex;
  gap: 4px;
}
.x-sidebar-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--panel);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}
.x-sidebar-btn:hover {
  background: var(--border);
  color: var(--text);
}
.x-sidebar-btn-close:hover {
  background: var(--accent);
  color: #fff;
}
.x-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.x-sidebar-content::-webkit-scrollbar {
  width: 4px;
}
.x-sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
.x-resize-handle {
  width: 6px;
  cursor: ew-resize;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: transparent;
}
.x-resize-handle:hover,
.x-resize-handle.active {
  background: #1d9bf0;
  opacity: 0.5;
}

.x-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 140;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.x-sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ======================================================================
   MOBILE: X Feed Bottom Sheet
   ====================================================================== */

/* Mobile bottom sheet overlay */
.x-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.x-mobile-overlay.open {
  display: block;
  opacity: 1;
}

/* Mobile bottom sheet */
.x-mobile-sheet {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 310;
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.5);
}
.x-mobile-sheet.open {
  transform: translateY(0);
}
.x-mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  padding-top: calc(16px + env(safe-area-inset-top, 12px));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.x-mobile-sheet-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.x-mobile-sheet-title span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1d9bf0;
  animation: pulse 2s ease-in-out infinite;
}
.x-mobile-sheet-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.x-mobile-sheet-close:active {
  background: var(--border);
  color: var(--text);
}
.x-mobile-sheet-body {
  padding: 16px;
}
.x-mobile-sheet-body .x-profile-card {
  padding: 16px;
  border-radius: 16px;
}
.x-mobile-sheet-body .x-profile-card:active {
  background: var(--panel-2);
}
.x-mobile-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 8px auto 0;
}

/* ======================================================================
   X Profile Card Styles
   ====================================================================== */
.twitter-widgets {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.twitter-embedded-widget {
  width: 100%;
  margin: 0 auto;
}
.x-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
  cursor: pointer;
}
.x-profile-card:hover,
.x-profile-card:active {
  border-color: #1d9bf0;
  background: var(--panel-2);
}
.x-profile-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1d9bf0;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.x-profile-info {
  flex: 1;
  min-width: 0;
}
.x-profile-handle {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.x-profile-label {
  font-size: 12px;
  color: #1d9bf0;
  margin-top: 2px;
}

/* ======================================================================
   RESPONSIVE
   ====================================================================== */

/* Tablet: shrink sidebar */
@media (max-width: 1100px) {
  .x-sidebar {
    width: 320px;
    right: 8px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .x-sidebar,
  .x-resize-handle,
  .x-sidebar-overlay {
    display: none !important;
  }
  .main-layout {
    padding-right: 0 !important;
  }
  .x-show-btn {
    display: inline-flex !important;
  }
  .tabs-inner {
    padding: 8px 0;
    gap: 4px;
    flex-wrap: wrap;
  }
  .tab {
    padding: 8px 12px;
    font-size: 13px;
    flex: 1;
    text-align: center;
    min-width: 0;
  }
  .refresh {
    padding: 8px 12px;
    font-size: 13px;
  }
  .x-show-btn .x-show-label {
    display: none;
  }
  .card {
    padding: 14px 16px;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
  }
  .card h3 {
    font-size: 15px;
  }
  .x-mobile-sheet-body .x-profile-icon {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}
