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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #1a1a1a;
  color: #fff;
  overflow: hidden;
  height: 100vh;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px;
  gap: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

h1 {
  font-size: 24px;
  font-weight: 600;
}

.controls {
  display: flex;
  gap: 15px;
  align-items: center;
}

.page-info {
  font-size: 14px;
  color: #aaa;
}

button {
  background: #2563eb;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  font-weight: 500;
}

button:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

button:disabled {
  background: #374151;
  cursor: not-allowed;
  opacity: 0.5;
}

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 15px;
  overflow: hidden;
}

.grid-item {
  background: #262626;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid #404040;
}

.grid-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.3);
  border-color: #2563eb;
}

.grid-item-header {
  background: linear-gradient(135deg, #333 0%, #2a2a2a 100%);
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid #404040;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-indicator.loading {
  background: #f59e0b;
  animation: pulse 1.5s infinite;
}

.status-indicator.error {
  background: #ef4444;
}

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

.grid-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: capitalize;
  letter-spacing: 0.5px;
}

.open-link {
  color: #2563eb;
  font-size: 18px;
  text-decoration: none;
  opacity: 0.7;
  transition: all 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.open-link:hover {
  opacity: 1;
  background: rgba(37, 99, 235, 0.2);
}

.grid-item-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #2563eb;
  animation: spin 1s linear infinite;
  z-index: 5;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.loading-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.error-text {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
}

.open-all-btn {
  background: #7c3aed;
}

.open-all-btn:hover:not(:disabled) {
  background: #6d28d9;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.refresh-btn {
  background: #059669;
}

.refresh-btn:hover:not(:disabled) {
  background: #047857;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}